An example of traditional menus on headebars for GTK4/Adwaita apps?

Hello, anyone knows if there is an example somewhere that puts traditional (non inline) menus on headerbars in a GTK4/Adwaita app, similar to VCode? Also if anyone could provide such template please

1 Like

Check out the “application” demo in the gtk source tree.

nice, but there isn’t such with menus on headerbar, hm?

Having HeaderBar of menu items with disabled arrows in TitleBar, those text menus will be there.
Something like

  GtkWidget *bar = gtk_header_bar_new();
  g_return_val_if_fail(GTK_IS_HEADER_BAR(bar), false);
  gtk_window_set_titlebar(GTK_WINDOW(window), bar);
  GtkWidget *button = gtk_menu_button_new();
  g_return_val_if_fail(GTK_IS_MENU_BUTTON(button), NULL);
  gtk_menu_button_set_label(GTK_MENU_BUTTON(button), "Actions");
  gtk_menu_button_set_direction(GTK_MENU_BUTTON(button), GTK_ARROW_NONE);
  gtk_header_bar_pack_start(GTK_HEADER_BAR(bar), button);
  GtkWidget *popover = gtk_popover_menu_new_from_model(G_MENU_MODEL(menu));
  g_return_val_if_fail(GTK_IS_POPOVER_MENU(popover), NULL);
  gtk_menu_button_set_popover(GTK_MENU_BUTTON(button), popover);
  gtk_popover_set_has_arrow(GTK_POPOVER(popover), false);

text menu item without arrows looks like this one


Why not try packing GtkPopoverMenuBar into {Adw,Gtk}HeaderBar

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.