From 4d191aa0b56a713e695844bf98c7b639cde8a2a3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 7 Jun 2019 18:05:57 +0000 Subject: [PATCH] widget factory: Redo the menubar with a model No UI change intended, except for the fact that actions don't do inconsistent states for checks and radios. --- demos/widget-factory/widget-factory.c | 21 ++++ demos/widget-factory/widget-factory.ui | 138 +++++++++++++++++++++++++ 2 files changed, 159 insertions(+) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 976661b8c8..fb1ac6f153 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -1932,6 +1932,12 @@ activate (GApplication *app) model = (GMenuModel *)gtk_builder_get_object (builder, "new_style_context_menu_model"); set_up_context_popover (widget, model); + widget = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (builder, "page2frame2"))); + model = (GMenuModel *)gtk_builder_get_object (builder, "menu_bar_model"); + widget2 = gtk_popover_bar_new_from_model (model); + gtk_container_add (GTK_CONTAINER (widget), widget2); + gtk_box_reorder_child_after (GTK_BOX (widget), widget2, NULL); + gtk_widget_show (GTK_WIDGET (window)); g_object_unref (builder); @@ -2017,10 +2023,13 @@ main (int argc, char *argv[]) { "print", activate_action, NULL, NULL, NULL }, { "share", activate_action, NULL, NULL, NULL }, { "labels", activate_action, NULL, NULL, NULL }, + { "new", activate_action, NULL, NULL, NULL }, { "open", activate_action, NULL, NULL, NULL }, { "open-in", activate_action, NULL, NULL, NULL }, { "open-tab", activate_action, NULL, NULL, NULL }, { "open-window", activate_action, NULL, NULL, NULL }, + { "save", activate_action, NULL, NULL, NULL }, + { "save-as", activate_action, NULL, NULL, NULL }, { "cut", activate_action, NULL, NULL, NULL }, { "copy", activate_action, NULL, NULL, NULL }, { "paste", activate_action, NULL, NULL, NULL }, @@ -2034,6 +2043,12 @@ main (int argc, char *argv[]) { "option-b", activate_action, NULL, NULL, NULL }, { "option-c", activate_action, NULL, NULL, NULL }, { "option-d", activate_action, NULL, NULL, NULL }, + { "check-on", NULL, NULL, "true", NULL }, + { "check-off", NULL, NULL, "false", NULL }, + { "radio-x", NULL, "s", "'x'", NULL }, + { "check-on-disabled", NULL, NULL, "true", NULL }, + { "check-off-disabled", NULL, NULL, "false", NULL }, + { "radio-x-disabled", NULL, "s", "'x'", NULL }, }; gint status; @@ -2044,6 +2059,12 @@ main (int argc, char *argv[]) app); action = g_action_map_lookup_action (G_ACTION_MAP (app), "wine"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE); + action = g_action_map_lookup_action (G_ACTION_MAP (app), "check-on-disabled"); + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE); + action = g_action_map_lookup_action (G_ACTION_MAP (app), "check-off-disabled"); + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE); + action = g_action_map_lookup_action (G_ACTION_MAP (app), "radio-x-disabled"); + g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index 93ba817f3f..0e4777c995 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -3887,4 +3887,142 @@ bad things might happen. + + + File +
+ + _New + app.new + + + _Open + app.open + + + _Save + app.save + + + Save _As + app.save-as + +
+
+ + _Quit + app.quit + +
+
+ + Edit +
+ + Cu_t + app.cut + + + _Copy + app.copy + + + _Paste + app.paste + + + Delete + win.delete + + + Search + win.search + +
+
+ + Checks & Radios +
+ + Check + app.check-on + + + Check + app.check-off + + + Check + app.check-on-disabled + + + Check + app.check-off-disabled + + + Check + app.check-no-action + action-missing + +
+
+ + Radio + app.radio-x + x + + + Radio + app.radio-x + y + + + Radio + app.radio-x-disabled + x + + + Radio + app.radio-x-disabled + y + + + Radio + app.radio-no-action + action-missing + +
+
+
+
+ + View +
+ + Dark Theme + win.dark + + + Toolbar + win.toolbar + + + Statusbar + win.statusbar + + + Select Background + win.background + +
+ +
+ + Help + + About + app.about + + +