summaryrefslogtreecommitdiff
path: root/examples/application5/exampleappwin.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-05-10 21:26:19 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-05-11 08:15:56 -0400
commitd2430c70bd2166f086214880043258cf19bb3e8f (patch)
treeefc20eec503846fa269780f4df2e4f1bf5932f22 /examples/application5/exampleappwin.c
parent4de4957aa34b39b313cceff760d390003795b325 (diff)
downloadgtk+-d2430c70bd2166f086214880043258cf19bb3e8f.tar.gz
Refresh the tutorial examples
Redo this series of examples from 2013, and adapt it to modern way of doing things. The biggest differences are that we use a headerbar right from the start, and don't mention the app menu. Fixes: #2730
Diffstat (limited to 'examples/application5/exampleappwin.c')
-rw-r--r--examples/application5/exampleappwin.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/application5/exampleappwin.c b/examples/application5/exampleappwin.c
index 16d11f4c70..5425b44a4d 100644
--- a/examples/application5/exampleappwin.c
+++ b/examples/application5/exampleappwin.c
@@ -9,6 +9,7 @@ struct _ExampleAppWindow
GSettings *settings;
GtkWidget *stack;
+ GtkWidget *gears;
};
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -16,9 +17,17 @@ G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW
static void
example_app_window_init (ExampleAppWindow *win)
{
+ GtkBuilder *builder;
+ GMenuModel *menu;
+
gtk_widget_init_template (GTK_WIDGET (win));
- win->settings = g_settings_new ("org.gtk.exampleapp");
+ builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/gears-menu.ui");
+ menu = G_MENU_MODEL (gtk_builder_get_object (builder, "menu"));
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (win->gears), menu);
+ g_object_unref (builder);
+
+ win->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (win->settings, "transition",
win->stack, "transition-type",
G_SETTINGS_BIND_DEFAULT);
@@ -44,6 +53,7 @@ example_app_window_class_init (ExampleAppWindowClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/window.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, stack);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
}
ExampleAppWindow *