[gtk/matthiasc/for-master] Refresh the tutorial examples
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] Refresh the tutorial examples
- Date: Mon, 11 May 2020 02:03:54 +0000 (UTC)
commit 97751f4b2c15adbbe36073f89dcbaeffc258ef6a
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 10 21:26:19 2020 -0400
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
docs/reference/gtk/getting_started.xml.in | 74 ++----
docs/reference/gtk/images/getting-started-app1.png | Bin 3004 -> 4764 bytes
docs/reference/gtk/images/getting-started-app2.png | Bin 5718 -> 7246 bytes
docs/reference/gtk/images/getting-started-app3.png | Bin 37590 -> 39268 bytes
docs/reference/gtk/images/getting-started-app4.png | Bin 211105 -> 50510 bytes
docs/reference/gtk/images/getting-started-app6.png | Bin 223488 -> 153201 bytes
docs/reference/gtk/images/getting-started-app7.png | Bin 38964 -> 48914 bytes
docs/reference/gtk/images/getting-started-app8.png | Bin 58744 -> 80142 bytes
docs/reference/gtk/images/getting-started-app9.png | Bin 46932 -> 71600 bytes
examples/application1/README | 2 +
examples/application10/Makefile.example | 35 ---
examples/application10/exampleapp.c | 114 --------
examples/application10/exampleapp.gresource.xml | 9 -
examples/application10/exampleapp.h | 14 -
examples/application10/exampleappprefs.c | 59 -----
examples/application10/exampleappprefs.h | 15 --
examples/application10/exampleappwin.c | 295 ---------------------
examples/application10/exampleappwin.h | 16 --
examples/application10/gears-menu.ui | 14 -
examples/application10/main.c | 16 --
examples/application10/meson.build | 14 -
.../application10/org.gtk.exampleapp.gschema.xml | 25 --
examples/application10/prefs.ui | 67 -----
examples/application10/window.ui | 81 ------
examples/application2/README | 1 +
examples/application2/window.ui | 10 +-
examples/application3/README | 1 +
examples/application3/window.ui | 20 +-
examples/application4/README | 1 +
examples/application4/exampleapp.c | 7 -
examples/application4/exampleapp.gresource.xml | 2 +-
examples/application4/exampleappwin.c | 10 +
.../app-menu.ui => application4/gears-menu.ui} | 3 +-
examples/application4/window.ui | 25 +-
examples/application5/exampleapp.c | 7 -
examples/application5/exampleapp.gresource.xml | 2 +-
examples/application5/exampleappwin.c | 12 +-
.../app-menu.ui => application5/gears-menu.ui} | 3 +-
examples/application5/window.ui | 25 +-
examples/application6/exampleapp.c | 7 -
examples/application6/exampleapp.gresource.xml | 2 +-
examples/application6/exampleappwin.c | 11 +
.../app-menu.ui => application6/gears-menu.ui} | 3 +-
examples/application6/prefs.ui | 14 +-
examples/application6/window.ui | 25 +-
examples/application7/README | 1 +
examples/application7/app-menu.ui | 16 --
examples/application7/exampleapp.c | 7 -
examples/application7/exampleapp.gresource.xml | 2 +-
examples/application7/exampleappwin.c | 11 +
.../app-menu.ui => application7/gears-menu.ui} | 3 +-
examples/application7/prefs.ui | 14 +-
examples/application7/window.ui | 36 +--
examples/application8/README | 1 +
examples/application8/app-menu.ui | 16 --
examples/application8/exampleapp.c | 7 -
examples/application8/exampleapp.gresource.xml | 1 -
examples/application8/exampleappwin.c | 15 +-
examples/application8/gears-menu.ui | 11 +
examples/application8/prefs.ui | 14 +-
examples/application8/window.ui | 44 ++-
examples/application9/README | 1 +
examples/application9/app-menu.ui | 16 --
examples/application9/exampleapp.c | 7 -
examples/application9/exampleapp.gresource.xml | 1 -
examples/application9/exampleappwin.c | 15 +-
examples/application9/gears-menu.ui | 11 +
examples/application9/prefs.ui | 14 +-
examples/application9/window.ui | 66 +++--
examples/meson.build | 1 -
70 files changed, 284 insertions(+), 1088 deletions(-)
---
diff --git a/docs/reference/gtk/getting_started.xml.in b/docs/reference/gtk/getting_started.xml.in
index 138da8cf1c..13e3b57b03 100644
--- a/docs/reference/gtk/getting_started.xml.in
+++ b/docs/reference/gtk/getting_started.xml.in
@@ -415,9 +415,8 @@
<para>In this step, we use a GtkBuilder template to associate a
GtkBuilder ui file with our application window class.</para>
- <para>Our simple ui file puts a GtkHeaderBar on top of a GtkStack
- widget. The header bar contains a GtkStackSwitcher, which is a
- standalone widget to show a row of 'tabs' for the pages of a GtkStack.
+ <para>Our simple ui file gives the window a title, and puts a GtkStack
+ widget as the main content.
</para>
<informalexample>
@@ -572,11 +571,14 @@ example_app_window_open (ExampleAppWindow *win,
<para>(<ulink
url="https://gitlab.gnome.org/GNOME/gtk/blob/master/examples/application3/exampleappwin.c">full
source</ulink>)</para>
</informalexample>
- <para>Note that we did not have to touch the stack switcher
- at all. It gets all its information from the stack that it
- belongs to. Here, we are passing the label to show for each
- file as the last argument to the gtk_stack_add_titled()
- function.</para>
+ <para>Lastly, we add a GtkStackSwitcher to the titlebar area
+ in the ui file, and we tell it to display information about our
+ stack.</para>
+
+ <para>The stack switcher gets all its information it needs to
+ display tabs from the stack that it belongs to. Here, we are
+ passing the label to show for each file as the last argument to
+ the gtk_stack_add_titled() function.</para>
<para>Our application is beginning to take shape:</para>
@@ -590,25 +592,25 @@ example_app_window_open (ExampleAppWindow *win,
</section>
<section>
- <title>An application menu</title>
+ <title>A menu</title>
- <para>An application menu is shown by GNOME shell at the top of the
- screen. It is meant to collect infrequently used actions that affect
+ <para>The menu is shown at the right side of the headerbar.
+ It is meant to collect infrequently used actions that affect
the whole application.</para>
- <para>Just like the window template, we specify our application menu
+ <para>Just like the window template, we specify our menu
in a ui file, and add it as a resource to our binary.</para>
<informalexample>
- <programlisting><xi:include href="@SRC_DIR@/examples/application4/app-menu.ui"
parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ <programlisting><xi:include href="@SRC_DIR@/examples/application4/gears-menu.ui"
parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
</informalexample>
- <para>To associate the app menu with the application, we have to call
- gtk_application_set_app_menu(). Since app menus work by activating
- GActions, we also have to add a suitable set of actions to our
- application.</para>
+ <para>To make the menu appear, we have to load the ui file and
+ associate the resulting menu model with the menu button that we've
+ added to the headerbar. Since menus work by activating GActions,
+ we also have to add a suitable set of actions to our application.</para>
- <para>Both of these tasks are best done in the startup() vfunc,
+ <para>Adding the actions is best done in the startup() vfunc,
which is guaranteed to be called once for each primary application
instance:</para>
<informalexample>
@@ -651,11 +653,6 @@ example_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
-
- builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
- g_object_unref (builder);
}
static void
@@ -799,7 +796,7 @@ preferences_activated (GSimpleAction *action,
<title>Adding a search bar</title>
<para>We continue to flesh out the functionality of our application.
- For now, we add search. GTK supports this with #GtkSearchEntry and
+ For now, we add search. GTK supports this with GtkSearchEntry and
GtkSearchBar. The search bar is a widget that can slide in from the
top to present a search entry.</para>
@@ -1005,35 +1002,6 @@ example_app_window_init (ExampleAppWindow *win)
</mediaobject>
</informalfigure>
</section>
- <section>
- <title>Header bar</title>
-
- <para>Our application already uses a GtkHeaderBar, but so far it
- still gets a 'normal' window titlebar on top of that. This is a
- bit redundant, and we will now tell GTK to use the header bar
- as replacement for the titlebar. To do so, we move it around to
- be a direct child of the window, and set its type to be titlebar.</para>
-
- <informalexample>
- <programlisting><xi:include href="@SRC_DIR@/examples/application10/window.ui"
parse="text"><xi:fallback>MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
- </informalexample>
-
- <para>A small extra bonus of using a header bar is that we get
- a fallback application menu for free. Here is how the
- application now looks, if this fallback is used.</para>
-
- <informalfigure>
- <mediaobject>
- <imageobject>
- <imagedata fileref="getting-started-app10.png" format="PNG"/>
- </imageobject>
- </mediaobject>
- </informalfigure>
-
- <para>If we set up the window icon for our window, the menu button
- will use that instead of the generic placeholder icon you see
- here.</para>
- </section>
</section>
<section>
diff --git a/docs/reference/gtk/images/getting-started-app1.png
b/docs/reference/gtk/images/getting-started-app1.png
index bf33a44ad3..a382510bbd 100644
Binary files a/docs/reference/gtk/images/getting-started-app1.png and
b/docs/reference/gtk/images/getting-started-app1.png differ
diff --git a/docs/reference/gtk/images/getting-started-app2.png
b/docs/reference/gtk/images/getting-started-app2.png
index ca4c0e1e4c..40f71c5e3f 100644
Binary files a/docs/reference/gtk/images/getting-started-app2.png and
b/docs/reference/gtk/images/getting-started-app2.png differ
diff --git a/docs/reference/gtk/images/getting-started-app3.png
b/docs/reference/gtk/images/getting-started-app3.png
index 164ae62c80..22b5a3683c 100644
Binary files a/docs/reference/gtk/images/getting-started-app3.png and
b/docs/reference/gtk/images/getting-started-app3.png differ
diff --git a/docs/reference/gtk/images/getting-started-app4.png
b/docs/reference/gtk/images/getting-started-app4.png
index 99d05913c2..fcfc05dd78 100644
Binary files a/docs/reference/gtk/images/getting-started-app4.png and
b/docs/reference/gtk/images/getting-started-app4.png differ
diff --git a/docs/reference/gtk/images/getting-started-app6.png
b/docs/reference/gtk/images/getting-started-app6.png
index 0e89713af5..cdb20aa949 100644
Binary files a/docs/reference/gtk/images/getting-started-app6.png and
b/docs/reference/gtk/images/getting-started-app6.png differ
diff --git a/docs/reference/gtk/images/getting-started-app7.png
b/docs/reference/gtk/images/getting-started-app7.png
index 1490a1b3dc..2e3c375d76 100644
Binary files a/docs/reference/gtk/images/getting-started-app7.png and
b/docs/reference/gtk/images/getting-started-app7.png differ
diff --git a/docs/reference/gtk/images/getting-started-app8.png
b/docs/reference/gtk/images/getting-started-app8.png
index 00ff9b5554..b86771102e 100644
Binary files a/docs/reference/gtk/images/getting-started-app8.png and
b/docs/reference/gtk/images/getting-started-app8.png differ
diff --git a/docs/reference/gtk/images/getting-started-app9.png
b/docs/reference/gtk/images/getting-started-app9.png
index 472da3e081..3a39c30dbc 100644
Binary files a/docs/reference/gtk/images/getting-started-app9.png and
b/docs/reference/gtk/images/getting-started-app9.png differ
diff --git a/examples/application1/README b/examples/application1/README
index 739ecd967d..d075ef3217 100644
--- a/examples/application1/README
+++ b/examples/application1/README
@@ -1,3 +1,5 @@
+Step 1: A trivial application
+
To make gnome-shell use the desktop file and icon for this example
while running it uninstalled, do the following:
diff --git a/examples/application2/README b/examples/application2/README
new file mode 100644
index 0000000000..5b0ae68635
--- /dev/null
+++ b/examples/application2/README
@@ -0,0 +1 @@
+Step 2: Populating the window
diff --git a/examples/application2/window.ui b/examples/application2/window.ui
index 595df79ef0..5b0eb1d58e 100644
--- a/examples/application2/window.ui
+++ b/examples/application2/window.ui
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ExampleAppWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Example Application</property>
@@ -6,15 +7,6 @@
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar" id="header">
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkStack" id="stack"/>
</child>
diff --git a/examples/application3/README b/examples/application3/README
new file mode 100644
index 0000000000..5e391213ff
--- /dev/null
+++ b/examples/application3/README
@@ -0,0 +1 @@
+Step 3: Opening files, add a stack switcher
diff --git a/examples/application3/window.ui b/examples/application3/window.ui
index 595df79ef0..5d2d5a4249 100644
--- a/examples/application3/window.ui
+++ b/examples/application3/window.ui
@@ -1,20 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ExampleAppWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header">
+ <property name="show-title-buttons">1</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar" id="header">
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkStack" id="stack"/>
</child>
diff --git a/examples/application4/README b/examples/application4/README
new file mode 100644
index 0000000000..a92e45749a
--- /dev/null
+++ b/examples/application4/README
@@ -0,0 +1 @@
+Step 4: Add a menu
diff --git a/examples/application4/exampleapp.c b/examples/application4/exampleapp.c
index 0f01fb388a..6ab68aebc3 100644
--- a/examples/application4/exampleapp.c
+++ b/examples/application4/exampleapp.c
@@ -39,8 +39,6 @@ static GActionEntry app_entries[] =
static void
example_app_startup (GApplication *app)
{
- GtkBuilder *builder;
- GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
@@ -51,11 +49,6 @@ example_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
-
- builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
- g_object_unref (builder);
}
static void
diff --git a/examples/application4/exampleapp.gresource.xml b/examples/application4/exampleapp.gresource.xml
index 1c9b11821f..5a5da01ba2 100644
--- a/examples/application4/exampleapp.gresource.xml
+++ b/examples/application4/exampleapp.gresource.xml
@@ -2,6 +2,6 @@
<gresources>
<gresource prefix="/org/gtk/exampleapp">
<file preprocess="xml-stripblanks">window.ui</file>
- <file preprocess="xml-stripblanks">app-menu.ui</file>
+ <file preprocess="xml-stripblanks">gears-menu.ui</file>
</gresource>
</gresources>
diff --git a/examples/application4/exampleappwin.c b/examples/application4/exampleappwin.c
index 9ed0b88452..bcc72807af 100644
--- a/examples/application4/exampleappwin.c
+++ b/examples/application4/exampleappwin.c
@@ -8,6 +8,7 @@ struct _ExampleAppWindow
GtkApplicationWindow parent;
GtkWidget *stack;
+ GtkWidget *gears;
};
G_DEFINE_TYPE (ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -15,7 +16,15 @@ 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));
+
+ 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);
}
static void
@@ -24,6 +33,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 *
diff --git a/examples/application6/app-menu.ui b/examples/application4/gears-menu.ui
similarity index 87%
rename from examples/application6/app-menu.ui
rename to examples/application4/gears-menu.ui
index 13bf8fd342..30e292ef9a 100644
--- a/examples/application6/app-menu.ui
+++ b/examples/application4/gears-menu.ui
@@ -1,5 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <menu id="appmenu">
+ <menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
diff --git a/examples/application4/window.ui b/examples/application4/window.ui
index 595df79ef0..eee9127573 100644
--- a/examples/application4/window.ui
+++ b/examples/application4/window.ui
@@ -1,20 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ExampleAppWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header">
+ <property name="show-title-buttons">1</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="gears">
+ <property name="direction">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar" id="header">
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkStack" id="stack"/>
</child>
diff --git a/examples/application5/exampleapp.c b/examples/application5/exampleapp.c
index 0f01fb388a..6ab68aebc3 100644
--- a/examples/application5/exampleapp.c
+++ b/examples/application5/exampleapp.c
@@ -39,8 +39,6 @@ static GActionEntry app_entries[] =
static void
example_app_startup (GApplication *app)
{
- GtkBuilder *builder;
- GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
@@ -51,11 +49,6 @@ example_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
-
- builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
- g_object_unref (builder);
}
static void
diff --git a/examples/application5/exampleapp.gresource.xml b/examples/application5/exampleapp.gresource.xml
index 1c9b11821f..5a5da01ba2 100644
--- a/examples/application5/exampleapp.gresource.xml
+++ b/examples/application5/exampleapp.gresource.xml
@@ -2,6 +2,6 @@
<gresources>
<gresource prefix="/org/gtk/exampleapp">
<file preprocess="xml-stripblanks">window.ui</file>
- <file preprocess="xml-stripblanks">app-menu.ui</file>
+ <file preprocess="xml-stripblanks">gears-menu.ui</file>
</gresource>
</gresources>
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 *
diff --git a/examples/application10/app-menu.ui b/examples/application5/gears-menu.ui
similarity index 87%
rename from examples/application10/app-menu.ui
rename to examples/application5/gears-menu.ui
index 13bf8fd342..30e292ef9a 100644
--- a/examples/application10/app-menu.ui
+++ b/examples/application5/gears-menu.ui
@@ -1,5 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <menu id="appmenu">
+ <menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
diff --git a/examples/application5/window.ui b/examples/application5/window.ui
index 595df79ef0..eee9127573 100644
--- a/examples/application5/window.ui
+++ b/examples/application5/window.ui
@@ -1,20 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ExampleAppWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header">
+ <property name="show-title-buttons">1</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="gears">
+ <property name="direction">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar" id="header">
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkStack" id="stack"/>
</child>
diff --git a/examples/application6/exampleapp.c b/examples/application6/exampleapp.c
index 64a3ceb100..8ac0ebd529 100644
--- a/examples/application6/exampleapp.c
+++ b/examples/application6/exampleapp.c
@@ -46,8 +46,6 @@ static GActionEntry app_entries[] =
static void
example_app_startup (GApplication *app)
{
- GtkBuilder *builder;
- GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
@@ -58,11 +56,6 @@ example_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
-
- builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
- g_object_unref (builder);
}
static void
diff --git a/examples/application6/exampleapp.gresource.xml b/examples/application6/exampleapp.gresource.xml
index 797688586b..c40f6419b7 100644
--- a/examples/application6/exampleapp.gresource.xml
+++ b/examples/application6/exampleapp.gresource.xml
@@ -2,7 +2,7 @@
<gresources>
<gresource prefix="/org/gtk/exampleapp">
<file preprocess="xml-stripblanks">window.ui</file>
- <file preprocess="xml-stripblanks">app-menu.ui</file>
+ <file preprocess="xml-stripblanks">gears-menu.ui</file>
<file preprocess="xml-stripblanks">prefs.ui</file>
</gresource>
</gresources>
diff --git a/examples/application6/exampleappwin.c b/examples/application6/exampleappwin.c
index 16d11f4c70..7f332181ea 100644
--- a/examples/application6/exampleappwin.c
+++ b/examples/application6/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,7 +17,16 @@ 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));
+
+ 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",
@@ -44,6 +54,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 *
diff --git a/examples/application4/app-menu.ui b/examples/application6/gears-menu.ui
similarity index 87%
rename from examples/application4/app-menu.ui
rename to examples/application6/gears-menu.ui
index 13bf8fd342..30e292ef9a 100644
--- a/examples/application4/app-menu.ui
+++ b/examples/application6/gears-menu.ui
@@ -1,5 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <menu id="appmenu">
+ <menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
diff --git a/examples/application6/prefs.ui b/examples/application6/prefs.ui
index 9551758c8f..c4cfcb621a 100644
--- a/examples/application6/prefs.ui
+++ b/examples/application6/prefs.ui
@@ -4,16 +4,16 @@
<property name="title" translatable="yes">Preferences</property>
<property name="resizable">0</property>
<property name="modal">1</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="vbox">
+ <child internal-child="content_area">
+ <object class="GtkBox" id="content_area">
<child>
<object class="GtkGrid" id="grid">
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <property name="margin-top">12</property>
+ <property name="margin-bottom">12</property>
<property name="row-spacing">12</property>
- <property name="column-spacing">6</property>
+ <property name="column-spacing">12</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="label">_Font:</property>
diff --git a/examples/application6/window.ui b/examples/application6/window.ui
index 595df79ef0..eee9127573 100644
--- a/examples/application6/window.ui
+++ b/examples/application6/window.ui
@@ -1,20 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ExampleAppWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header">
+ <property name="show-title-buttons">1</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="gears">
+ <property name="direction">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar" id="header">
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkStack" id="stack"/>
</child>
diff --git a/examples/application7/README b/examples/application7/README
new file mode 100644
index 0000000000..b5232e3017
--- /dev/null
+++ b/examples/application7/README
@@ -0,0 +1 @@
+Step 7: A search bar
diff --git a/examples/application7/exampleapp.c b/examples/application7/exampleapp.c
index 64a3ceb100..8ac0ebd529 100644
--- a/examples/application7/exampleapp.c
+++ b/examples/application7/exampleapp.c
@@ -46,8 +46,6 @@ static GActionEntry app_entries[] =
static void
example_app_startup (GApplication *app)
{
- GtkBuilder *builder;
- GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
@@ -58,11 +56,6 @@ example_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
-
- builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
- g_object_unref (builder);
}
static void
diff --git a/examples/application7/exampleapp.gresource.xml b/examples/application7/exampleapp.gresource.xml
index 797688586b..c40f6419b7 100644
--- a/examples/application7/exampleapp.gresource.xml
+++ b/examples/application7/exampleapp.gresource.xml
@@ -2,7 +2,7 @@
<gresources>
<gresource prefix="/org/gtk/exampleapp">
<file preprocess="xml-stripblanks">window.ui</file>
- <file preprocess="xml-stripblanks">app-menu.ui</file>
+ <file preprocess="xml-stripblanks">gears-menu.ui</file>
<file preprocess="xml-stripblanks">prefs.ui</file>
</gresource>
</gresources>
diff --git a/examples/application7/exampleappwin.c b/examples/application7/exampleappwin.c
index f15cf3ba42..cea8941dbc 100644
--- a/examples/application7/exampleappwin.c
+++ b/examples/application7/exampleappwin.c
@@ -9,6 +9,7 @@ struct _ExampleAppWindow
GSettings *settings;
GtkWidget *stack;
+ GtkWidget *gears;
GtkWidget *search;
GtkWidget *searchbar;
};
@@ -59,7 +60,16 @@ visible_child_changed (GObject *stack,
static void
example_app_window_init (ExampleAppWindow *win)
{
+ GtkBuilder *builder;
+ GMenuModel *menu;
+
gtk_widget_init_template (GTK_WIDGET (win));
+
+ 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",
@@ -92,6 +102,7 @@ example_app_window_class_init (ExampleAppWindowClass *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);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
diff --git a/examples/application5/app-menu.ui b/examples/application7/gears-menu.ui
similarity index 87%
rename from examples/application5/app-menu.ui
rename to examples/application7/gears-menu.ui
index 13bf8fd342..30e292ef9a 100644
--- a/examples/application5/app-menu.ui
+++ b/examples/application7/gears-menu.ui
@@ -1,5 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <menu id="appmenu">
+ <menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
diff --git a/examples/application7/prefs.ui b/examples/application7/prefs.ui
index 9551758c8f..c4cfcb621a 100644
--- a/examples/application7/prefs.ui
+++ b/examples/application7/prefs.ui
@@ -4,16 +4,16 @@
<property name="title" translatable="yes">Preferences</property>
<property name="resizable">0</property>
<property name="modal">1</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="vbox">
+ <child internal-child="content_area">
+ <object class="GtkBox" id="content_area">
<child>
<object class="GtkGrid" id="grid">
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <property name="margin-top">12</property>
+ <property name="margin-bottom">12</property>
<property name="row-spacing">12</property>
- <property name="column-spacing">6</property>
+ <property name="column-spacing">12</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="label">_Font:</property>
diff --git a/examples/application7/window.ui b/examples/application7/window.ui
index 761daef776..d4280f6354 100644
--- a/examples/application7/window.ui
+++ b/examples/application7/window.ui
@@ -4,24 +4,30 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header">
+ <property name="show-title-buttons">1</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="gears">
+ <property name="direction">none</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkToggleButton" id="search">
+ <property name="sensitive">0</property>
+ <property name="icon-name">edit-find-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar" id="header">
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkToggleButton" id="search">
- <property name="sensitive">0</property>
- <property name="icon-name">edit-find-symbolic</property>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkSearchBar" id="searchbar">
<child>
diff --git a/examples/application8/README b/examples/application8/README
new file mode 100644
index 0000000000..03788221b2
--- /dev/null
+++ b/examples/application8/README
@@ -0,0 +1 @@
+Step 8: Adding a sidebar
diff --git a/examples/application8/exampleapp.c b/examples/application8/exampleapp.c
index 64a3ceb100..8ac0ebd529 100644
--- a/examples/application8/exampleapp.c
+++ b/examples/application8/exampleapp.c
@@ -46,8 +46,6 @@ static GActionEntry app_entries[] =
static void
example_app_startup (GApplication *app)
{
- GtkBuilder *builder;
- GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
@@ -58,11 +56,6 @@ example_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
-
- builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
- g_object_unref (builder);
}
static void
diff --git a/examples/application8/exampleapp.gresource.xml b/examples/application8/exampleapp.gresource.xml
index ace59c8bb7..c40f6419b7 100644
--- a/examples/application8/exampleapp.gresource.xml
+++ b/examples/application8/exampleapp.gresource.xml
@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gtk/exampleapp">
<file preprocess="xml-stripblanks">window.ui</file>
- <file preprocess="xml-stripblanks">app-menu.ui</file>
<file preprocess="xml-stripblanks">gears-menu.ui</file>
<file preprocess="xml-stripblanks">prefs.ui</file>
</gresource>
diff --git a/examples/application8/exampleappwin.c b/examples/application8/exampleappwin.c
index f21eeec5cc..1ae4756d02 100644
--- a/examples/application8/exampleappwin.c
+++ b/examples/application8/exampleappwin.c
@@ -9,10 +9,10 @@ struct _ExampleAppWindow
GSettings *settings;
GtkWidget *stack;
+ GtkWidget *gears;
GtkWidget *search;
GtkWidget *searchbar;
GtkWidget *searchentry;
- GtkWidget *gears;
GtkWidget *sidebar;
GtkWidget *words;
};
@@ -143,6 +143,12 @@ example_app_window_init (ExampleAppWindow *win)
GAction *action;
gtk_widget_init_template (GTK_WIDGET (win));
+
+ 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",
@@ -160,11 +166,6 @@ example_app_window_init (ExampleAppWindow *win)
g_signal_connect (win->sidebar, "notify::reveal-child",
G_CALLBACK (words_changed), win);
- 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);
-
action = g_settings_create_action (win->settings, "show-words");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
@@ -191,10 +192,10 @@ example_app_window_class_init (ExampleAppWindowClass *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);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
- gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
diff --git a/examples/application8/gears-menu.ui b/examples/application8/gears-menu.ui
index 32cec0b28d..735a699af4 100644
--- a/examples/application8/gears-menu.ui
+++ b/examples/application8/gears-menu.ui
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="menu">
<section>
@@ -5,6 +6,16 @@
<attribute name="label" translatable="yes">_Words</attribute>
<attribute name="action">win.show-words</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ </item>
</section>
</menu>
</interface>
diff --git a/examples/application8/prefs.ui b/examples/application8/prefs.ui
index 9551758c8f..c4cfcb621a 100644
--- a/examples/application8/prefs.ui
+++ b/examples/application8/prefs.ui
@@ -4,16 +4,16 @@
<property name="title" translatable="yes">Preferences</property>
<property name="resizable">0</property>
<property name="modal">1</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="vbox">
+ <child internal-child="content_area">
+ <object class="GtkBox" id="content_area">
<child>
<object class="GtkGrid" id="grid">
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <property name="margin-top">12</property>
+ <property name="margin-bottom">12</property>
<property name="row-spacing">12</property>
- <property name="column-spacing">6</property>
+ <property name="column-spacing">12</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="label">_Font:</property>
diff --git a/examples/application8/window.ui b/examples/application8/window.ui
index e7935e55e2..165ebacbcb 100644
--- a/examples/application8/window.ui
+++ b/examples/application8/window.ui
@@ -4,32 +4,30 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header">
+ <property name="show-title-buttons">1</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkToggleButton" id="search">
+ <property name="sensitive">0</property>
+ <property name="icon-name">edit-find-symbolic</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="gears">
+ <property name="direction">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="content_box">
<property name="orientation">vertical</property>
- <child>
- <object class="GtkHeaderBar" id="header">
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkToggleButton" id="search">
- <property name="sensitive">0</property>
- <property name="icon-name">edit-find-symbolic</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkMenuButton" id="gears">
- <property name="direction">none</property>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- </child>
- </object>
- </child>
<child>
<object class="GtkSearchBar" id="searchbar">
<child>
diff --git a/examples/application9/README b/examples/application9/README
new file mode 100644
index 0000000000..4b43848ff7
--- /dev/null
+++ b/examples/application9/README
@@ -0,0 +1 @@
+Step 9: Using properties
diff --git a/examples/application9/exampleapp.c b/examples/application9/exampleapp.c
index 64a3ceb100..8ac0ebd529 100644
--- a/examples/application9/exampleapp.c
+++ b/examples/application9/exampleapp.c
@@ -46,8 +46,6 @@ static GActionEntry app_entries[] =
static void
example_app_startup (GApplication *app)
{
- GtkBuilder *builder;
- GMenuModel *app_menu;
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
@@ -58,11 +56,6 @@ example_app_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app),
"app.quit",
quit_accels);
-
- builder = gtk_builder_new_from_resource ("/org/gtk/exampleapp/app-menu.ui");
- app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
- g_object_unref (builder);
}
static void
diff --git a/examples/application9/exampleapp.gresource.xml b/examples/application9/exampleapp.gresource.xml
index ace59c8bb7..c40f6419b7 100644
--- a/examples/application9/exampleapp.gresource.xml
+++ b/examples/application9/exampleapp.gresource.xml
@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gtk/exampleapp">
<file preprocess="xml-stripblanks">window.ui</file>
- <file preprocess="xml-stripblanks">app-menu.ui</file>
<file preprocess="xml-stripblanks">gears-menu.ui</file>
<file preprocess="xml-stripblanks">prefs.ui</file>
</gresource>
diff --git a/examples/application9/exampleappwin.c b/examples/application9/exampleappwin.c
index 725ee67df1..c585094f4c 100644
--- a/examples/application9/exampleappwin.c
+++ b/examples/application9/exampleappwin.c
@@ -9,10 +9,10 @@ struct _ExampleAppWindow
GSettings *settings;
GtkWidget *stack;
+ GtkWidget *gears;
GtkWidget *search;
GtkWidget *searchbar;
GtkWidget *searchentry;
- GtkWidget *gears;
GtkWidget *sidebar;
GtkWidget *words;
GtkWidget *lines;
@@ -168,6 +168,12 @@ example_app_window_init (ExampleAppWindow *win)
GAction *action;
gtk_widget_init_template (GTK_WIDGET (win));
+
+ 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",
@@ -185,11 +191,6 @@ example_app_window_init (ExampleAppWindow *win)
g_signal_connect (win->sidebar, "notify::reveal-child",
G_CALLBACK (words_changed), win);
- 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);
-
action = g_settings_create_action (win->settings, "show-words");
g_action_map_add_action (G_ACTION_MAP (win), action);
g_object_unref (action);
@@ -224,10 +225,10 @@ example_app_window_class_init (ExampleAppWindowClass *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);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, search);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchbar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, searchentry);
- gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, gears);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, words);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, sidebar);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppWindow, lines);
diff --git a/examples/application9/gears-menu.ui b/examples/application9/gears-menu.ui
index 0b3d15e1be..d16d93a8ab 100644
--- a/examples/application9/gears-menu.ui
+++ b/examples/application9/gears-menu.ui
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="menu">
<section>
@@ -9,6 +10,16 @@
<attribute name="label" translatable="yes">_Lines</attribute>
<attribute name="action">win.show-lines</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Quit</attribute>
+ <attribute name="action">app.quit</attribute>
+ </item>
</section>
</menu>
</interface>
diff --git a/examples/application9/prefs.ui b/examples/application9/prefs.ui
index 9551758c8f..c4cfcb621a 100644
--- a/examples/application9/prefs.ui
+++ b/examples/application9/prefs.ui
@@ -4,16 +4,16 @@
<property name="title" translatable="yes">Preferences</property>
<property name="resizable">0</property>
<property name="modal">1</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="vbox">
+ <child internal-child="content_area">
+ <object class="GtkBox" id="content_area">
<child>
<object class="GtkGrid" id="grid">
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ <property name="margin-top">12</property>
+ <property name="margin-bottom">12</property>
<property name="row-spacing">12</property>
- <property name="column-spacing">6</property>
+ <property name="column-spacing">12</property>
<child>
<object class="GtkLabel" id="fontlabel">
<property name="label">_Font:</property>
diff --git a/examples/application9/window.ui b/examples/application9/window.ui
index 59f6e8c71a..29af168d26 100644
--- a/examples/application9/window.ui
+++ b/examples/application9/window.ui
@@ -4,43 +4,41 @@
<property name="title" translatable="yes">Example Application</property>
<property name="default-width">600</property>
<property name="default-height">400</property>
- <child>
- <object class="GtkBox" id="content_box">
- <property name="orientation">vertical</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="header">
+ <property name="show-title-buttons">1</property>
<child>
- <object class="GtkHeaderBar" id="header">
- <child>
- <object class="GtkLabel" id="lines_label">
- <property name="visible">0</property>
- <property name="label" translatable="yes">Lines:</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="lines">
- <property name="visible">0</property>
- </object>
- </child>
- <child type="title">
- <object class="GtkStackSwitcher" id="tabs">
- <property name="stack">stack</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkToggleButton" id="search">
- <property name="sensitive">0</property>
- <property name="icon-name">edit-find-symbolic</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkMenuButton" id="gears">
- <property name="direction">none</property>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- </child>
+ <object class="GtkLabel" id="lines_label">
+ <property name="visible">0</property>
+ <property name="label" translatable="yes">Lines:</property>
</object>
</child>
+ <child>
+ <object class="GtkLabel" id="lines">
+ <property name="visible">0</property>
+ </object>
+ </child>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkToggleButton" id="search">
+ <property name="sensitive">0</property>
+ <property name="icon-name">edit-find-symbolic</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="gears">
+ <property name="direction">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="content_box">
+ <property name="orientation">vertical</property>
<child>
<object class="GtkSearchBar" id="searchbar">
<child>
diff --git a/examples/meson.build b/examples/meson.build
index 8fcc04d547..22e74f34d4 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -31,4 +31,3 @@ subdir('application6')
subdir('application7')
subdir('application8')
subdir('application9')
-subdir('application10')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]