From d818bdc297675a723869604f604e497ae53b6ea0 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 24 Jan 2012 22:27:28 -0500 Subject: [PATCH] gtk3-demo-application: add an example for the new api Turn the menutoolbutton menu into one that is gmenu/gaction backed. --- demos/gtk-demo/application.c | 8 ++++++++ demos/gtk-demo/application.ui | 15 ++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/demos/gtk-demo/application.c b/demos/gtk-demo/application.c index 95d4be9581..7bce9fd6c9 100644 --- a/demos/gtk-demo/application.c +++ b/demos/gtk-demo/application.c @@ -283,6 +283,7 @@ static GActionEntry win_entries[] = { { "shape", activate_radio, "s", "'oval'", change_radio_state }, { "bold", activate_toggle, NULL, "false", NULL }, { "about", activate_about, NULL, NULL, NULL }, + { "file1", activate_action, NULL, NULL, NULL }, { "logo", activate_action, NULL, NULL, NULL } }; @@ -322,6 +323,8 @@ activate (GApplication *app) GtkWidget *message; GtkWidget *button; GtkWidget *infobar; + GtkWidget *menutool; + GMenuModel *toolmenu; GtkTextBuffer *buffer; window = gtk_application_window_new (GTK_APPLICATION (app)); @@ -342,12 +345,17 @@ activate (GApplication *app) message = (GtkWidget *)gtk_builder_get_object (builder, "message"); button = (GtkWidget *)gtk_builder_get_object (builder, "button"); infobar = (GtkWidget *)gtk_builder_get_object (builder, "infobar"); + menutool = (GtkWidget *)gtk_builder_get_object (builder, "menutool"); + toolmenu = (GMenuModel *)gtk_builder_get_object (builder, "toolmenu"); g_object_set_data (G_OBJECT (window), "message", message); g_object_set_data (G_OBJECT (window), "infobar", infobar); gtk_container_add (GTK_CONTAINER (window), grid); + gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (menutool), + gtk_menu_new_from_model (toolmenu)); + gtk_widget_grab_focus (contents); g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), infobar); diff --git a/demos/gtk-demo/application.ui b/demos/gtk-demo/application.ui index af92b1c2a4..b99e5ca0d5 100644 --- a/demos/gtk-demo/application.ui +++ b/demos/gtk-demo/application.ui @@ -7,18 +7,8 @@ fill True - + gtk-open - - - - - True - File1 - - - - @@ -106,4 +96,7 @@ + + +