forked from AuroraMiddleware/gtk
gtk3-demo-application: add an example for the new api
Turn the menutoolbutton menu into one that is gmenu/gaction backed.
This commit is contained in:
parent
4240bfb74a
commit
d818bdc297
@ -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);
|
||||
|
||||
|
@ -7,18 +7,8 @@
|
||||
<property name="halign">fill</property>
|
||||
<property name="hexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkMenuToolButton" id="menu">
|
||||
<object class="GtkMenuToolButton" id="menutool">
|
||||
<property name="stock-id">gtk-open</property>
|
||||
<child type="menu">
|
||||
<object class="GtkMenu" id="m">
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="file">
|
||||
<property name="visible">True</property>
|
||||
<property name="label">File1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
@ -106,4 +96,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<menu id="toolmenu">
|
||||
<item label='File1' action='win.file1'/>
|
||||
</menu>
|
||||
</interface>
|
||||
|
Loading…
Reference in New Issue
Block a user