[gtk+] Add a new example app
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add a new example app
- Date: Sun, 21 Jul 2013 03:04:53 +0000 (UTC)
commit 8087bb7a22303064fef947fc72639fcf70ce1515
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 20 00:21:48 2013 -0400
Add a new example app
Add a new example to the getting started part of the docs. The focus
of this example is on 'new stuff': GtkApplication, templates, settings,
gmenu, gaction, GtkStack, GtkHeaderBar, GtkSearchBar, GtkRevealer,
GtkListBox, GtkMenuButton, etc.
It is being developed in several steps. Each step is put in a separate
directory below examples/: application1, ..., application8. This is a
little repetitive, but lets us use the code of all examples in the
documentation.
configure.ac | 8 +
docs/reference/gtk/Makefile.am | 9 +-
docs/reference/gtk/getting_started.xml | 598 ++++++++++++++++-
docs/reference/gtk/images/getting-started-app1.png | Bin 0 -> 3649 bytes
docs/reference/gtk/images/getting-started-app2.png | Bin 0 -> 6328 bytes
docs/reference/gtk/images/getting-started-app3.png | Bin 0 -> 45156 bytes
docs/reference/gtk/images/getting-started-app4.png | Bin 0 -> 227899 bytes
docs/reference/gtk/images/getting-started-app6.png | Bin 0 -> 168786 bytes
docs/reference/gtk/images/getting-started-app7.png | Bin 0 -> 36853 bytes
docs/reference/gtk/images/getting-started-app8.png | Bin 0 -> 174668 bytes
examples/Makefile.am | 40 +-
examples/application1/Makefile | 737 ++++++++++++++++++++
examples/application1/Makefile.am | 19 +
examples/application1/exampleapp.c | 66 ++
examples/application1/exampleapp.h | 19 +
examples/application1/exampleappwin.c | 35 +
examples/application1/exampleappwin.h | 22 +
examples/application1/main.c | 8 +
examples/application2/Makefile.am | 30 +
examples/application2/exampleapp.c | 66 ++
examples/application2/exampleapp.gresource.xml | 6 +
examples/application2/exampleapp.h | 19 +
examples/application2/exampleappwin.c | 38 +
examples/application2/exampleappwin.h | 22 +
examples/application2/main.c | 8 +
examples/application2/window.ui | 31 +
examples/application3/Makefile.am | 30 +
examples/application3/exampleapp.c | 66 ++
examples/application3/exampleapp.gresource.xml | 6 +
examples/application3/exampleapp.h | 19 +
examples/application3/exampleappwin.c | 73 ++
examples/application3/exampleappwin.h | 22 +
examples/application3/main.c | 8 +
examples/application3/window.ui | 31 +
examples/application4/Makefile.am | 31 +
examples/application4/app-menu.ui | 19 +
examples/application4/exampleapp.c | 105 +++
examples/application4/exampleapp.gresource.xml | 7 +
examples/application4/exampleapp.h | 19 +
examples/application4/exampleappwin.c | 73 ++
examples/application4/exampleappwin.h | 22 +
examples/application4/main.c | 8 +
examples/application4/window.ui | 31 +
examples/application5/Makefile.am | 45 ++
examples/application5/app-menu.ui | 19 +
examples/application5/exampleapp.c | 105 +++
examples/application5/exampleapp.gresource.xml | 7 +
examples/application5/exampleapp.h | 19 +
examples/application5/exampleappwin.c | 108 +++
examples/application5/exampleappwin.h | 22 +
examples/application5/main.c | 15 +
.../application5/org.gtk.exampleapp.gschema.xml | 20 +
examples/application5/window.ui | 31 +
examples/application6/Makefile.am | 47 ++
examples/application6/app-menu.ui | 19 +
examples/application6/exampleapp.c | 112 +++
examples/application6/exampleapp.gresource.xml | 8 +
examples/application6/exampleapp.h | 19 +
examples/application6/exampleappprefs.c | 71 ++
examples/application6/exampleappprefs.h | 20 +
examples/application6/exampleappwin.c | 108 +++
examples/application6/exampleappwin.h | 22 +
examples/application6/main.c | 15 +
.../application6/org.gtk.exampleapp.gschema.xml | 20 +
examples/application6/prefs.ui | 82 +++
examples/application6/window.ui | 31 +
examples/application7/Makefile.am | 47 ++
examples/application7/app-menu.ui | 19 +
examples/application7/exampleapp.c | 112 +++
examples/application7/exampleapp.gresource.xml | 8 +
examples/application7/exampleapp.h | 19 +
examples/application7/exampleappprefs.c | 71 ++
examples/application7/exampleappprefs.h | 20 +
examples/application7/exampleappwin.c | 180 +++++
examples/application7/exampleappwin.h | 22 +
examples/application7/main.c | 15 +
.../application7/org.gtk.exampleapp.gschema.xml | 20 +
examples/application7/prefs.ui | 82 +++
examples/application7/window.ui | 57 ++
examples/application8/Makefile.am | 48 ++
examples/application8/app-menu.ui | 19 +
examples/application8/exampleapp.c | 112 +++
examples/application8/exampleapp.gresource.xml | 9 +
examples/application8/exampleapp.h | 19 +
examples/application8/exampleappprefs.c | 71 ++
examples/application8/exampleappprefs.h | 20 +
examples/application8/exampleappwin.c | 288 ++++++++
examples/application8/exampleappwin.h | 22 +
examples/application8/gears-menu.ui | 12 +
examples/application8/main.c | 15 +
.../application8/org.gtk.exampleapp.gschema.xml | 25 +
examples/application8/prefs.ui | 82 +++
examples/application8/window.ui | 96 +++
93 files changed, 4780 insertions(+), 46 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 54b0ee6..133da31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1796,6 +1796,14 @@ demos/gtk-demo/geninclude.pl
demos/pixbuf-demo/Makefile
demos/widget-factory/Makefile
examples/Makefile
+examples/application1/Makefile
+examples/application2/Makefile
+examples/application3/Makefile
+examples/application4/Makefile
+examples/application5/Makefile
+examples/application6/Makefile
+examples/application7/Makefile
+examples/application8/Makefile
tests/Makefile
tests/visuals/Makefile
testsuite/Makefile
diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am
index e10f9f1..e2fff14 100644
--- a/docs/reference/gtk/Makefile.am
+++ b/docs/reference/gtk/Makefile.am
@@ -412,7 +412,14 @@ HTML_IMAGES = \
$(srcdir)/images/up-center.png \
$(srcdir)/images/up-end.png \
$(srcdir)/images/up-start.png \
- $(srcdir)/images/list-box.png
+ $(srcdir)/images/list-box.png \
+ $(srcdir)/images/getting-started-app1.png \
+ $(srcdir)/images/getting-started-app2.png \
+ $(srcdir)/images/getting-started-app3.png \
+ $(srcdir)/images/getting-started-app4.png \
+ $(srcdir)/images/getting-started-app6.png \
+ $(srcdir)/images/getting-started-app7.png \
+ $(srcdir)/images/getting-started-app8.png
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=--extra-dir=../gdk/html \
diff --git a/docs/reference/gtk/getting_started.xml b/docs/reference/gtk/getting_started.xml
index 5df456d..e346f20 100644
--- a/docs/reference/gtk/getting_started.xml
+++ b/docs/reference/gtk/getting_started.xml
@@ -12,7 +12,7 @@
<link linkend="gtk-compiling">Compiling the GTK+ libraries</link>
section in this reference.</para>
- <simplesect>
+ <section>
<title>Basics</title>
<para>To begin our introduction to GTK, we'll start with the simplest
@@ -127,9 +127,9 @@
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-1 example-1.c `pkg-config --libs
gtk+-3.0`</literal>
</literallayout>
</para>
- </simplesect>
+ </section>
- <simplesect>
+ <section>
<title>Packing</title>
<para>When creating an application, you'll want to put more than one widget
@@ -165,9 +165,9 @@
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-2 example-2.c `pkg-config --libs
gtk+-3.0`</literal>
</literallayout>
</para>
- </simplesect>
+ </section>
- <simplesect>
+ <section>
<title>Drawing</title>
<para>Many widgets, like buttons, do all their drawing themselves. You
@@ -210,10 +210,10 @@
<literal>gcc `pkg-config --cflags gtk+-3.0` -o example-3 example-3.c `pkg-config --libs
gtk+-3.0`</literal>
</literallayout>
</para>
- </simplesect>
+ </section>
- <simplesect>
- <title>Building interfaces</title>
+ <section>
+ <title>Building user interfaces</title>
<para>When construcing a more complicated user interface, with dozens
or hundreds of widgets, doing all the setup work in C code is
@@ -258,6 +258,586 @@
UI editors such as <ulink url="http://glade.gnome.org">glade</ulink>
can load the file and allow you to create and modify your UI by
point-and-click.</para>
+ </section>
+
+ <section>
+ <title>Building applications</title>
+
+ <para>GTK+ includes application support that is built on top of
+ #GApplication. In this tutorial we'll build a simple application by
+ starting from scratch, adding more and more pieces over time. Along
+ the way, we'll learn about #GtkApplication, templates, resources,
+ application menus, settings, #GtkHeaderBar, #GtkStack, #GtkSearchBar,
+ #GtkListBox, and more.</para>
+
+ <para>The full, buildable sources for these examples can be find
+ in the examples/ directory of the GTK+ source distribution, or
+ <ulink url="https://git.gnome.org/browse/gtk+/tree/examples">online</ulink> in the GTK+ git
repository.</para>
+
+ <section>
+ <title>A trivial application</title>
+
+ <para>When using #GtkApplication, the main() function can be very
+ simple. We just call g_application_run() and give it an instance
+ of our application class.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application1/main.c"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>All the application logic is in the application class, which
+ is a subclass of #GtkApplication. Our example does not yet have any
+ interesting functionality. All it does is open a window when it is
+ activated without arguments, and open the files it is given, if it
+ is started with arguments.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application1/exampleapp.c"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>Another important class that is part of the application support
+ in GTK+ is #GtkApplicationWindow. It is typically subclassed as well.
+ Our subclass does not do anything yet, so we will just get an empty
+ window.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application1/exampleappwin.c"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>Here is what we've achieved so far:</para>
+
+ <informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="getting-started-app1.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+ </informalfigure>
+
+ <para>This does not look very impressive yet, but our application
+ is already presenting itself on the session bus, it has single-instance
+ semantics, and it accepts files as commandline arguments.</para>
+ </section>
+
+ <section>
+ <title>Populating the window</title>
+
+ <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>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application2/window.ui"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>To make use of this file in our application, we revisit
+ our #GtkApplicationWindow subclass, and call
+ gtk_widget_class_set_template_from_resource() from the class init
+ function to set the ui file as template for this class. We also
+ add a call to gtk_widget_init_template() in the instance init
+ function to instantiate the template for each instance of our
+ class.</para>
+
+ <informalexample>
+ <programlisting><![CDATA[
+ ...
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ gtk_widget_init_template (GTK_WIDGET (win));
+}
+
+static void
+example_app_window_class_init (ExampleAppWindowClass *class)
+{
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/window.ui");
+}
+
+ ...
+ ]]></programlisting>
+ <para>(<ulink
url="https://git.gnome.org/browse/gtk+/tree/examples/application2/exampleappwin.c">full source</ulink>)</para>
+ </informalexample>
+
+ <para>You may have noticed that we used the _from_resource() variant
+ of the function that sets a template. Now we need to use GLib's resource
+ functionality to include the ui file in the binary. This is commonly
+ done by listing all resources in a .gresource.xml file, such as this:
+ </para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application2/exampleapp.gresource.xml"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>This file has to be converted into a C source file that will be
+ compiled and linked into the application together with the other source
+ files. To do so, we use the glib-compile-resources utility:</para>
+
+ <screen>
+ glib-compile-resources exampleapp.gresource.xml --target=resources.c --generate-source
+ </screen>
+
+ <para>Our application now looks like this:</para>
+
+ <informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="getting-started-app2.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+ </informalfigure>
+ </section>
+
+ <section>
+ <title>Opening files</title>
+
+ <para>In this step, we make our application show the content of
+ all the files that it is given on the commandline.</para>
+
+ <para>To this end, we add a private struct to our application
+ window subclass and keep a reference to the #GtkStack there.
+ The gtk_widget_class_bind_child() function arranges things so
+ that after instantiating the template, the @stack member of
+ the private struct will point to the widget of the same name
+ from the template.</para>
+
+ <informalexample>
+ <programlisting><![CDATA[
+...
+
+struct ExampleAppWindowPrivate {
+ GtkWidget *stack;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+...
+
+static void
+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_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack);
+}
+
+...
+ ]]></programlisting>
+ <para>(<ulink
url="https://git.gnome.org/browse/gtk+/tree/examples/application3/exampleappwin.c">full source</ulink>)</para>
+ </informalexample>
+
+ <para>Now we revisit the example_app_window_open() function that
+ is called for each commandline argument, and construct a GtkTextView
+ that we then add as a page to the stack:</para>
+
+ <informalexample>
+ <programlisting><![CDATA[
+...
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+ ExampleAppWindowPrivate *priv = example_app_window_get_instance_private (win);
+ gchar *basename;
+ GtkWidget *scrolled, *view;
+ gchar *contents;
+ gsize length;
+
+ basename = g_file_get_basename (file);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolled);
+ gtk_widget_set_hexpand (scrolled, TRUE);
+ gtk_widget_set_vexpand (scrolled, TRUE);
+ view = gtk_text_view_new ();
+ gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled), view);
+ gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_text_buffer_set_text (buffer, contents, length);
+ g_free (contents);
+ }
+
+ g_free (basename);
+}
+
+...
+ ]]></programlisting>
+ <para>(<ulink
url="https://git.gnome.org/browse/gtk+/tree/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 third argument to the gtk_stack_add_titled()
+ function.</para>
+
+ <para>Our application is beginning to take shape:</para>
+
+ <informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="getting-started-app3.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+ </informalfigure>
+ </section>
+
+ <section>
+ <title>An application 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
+ the whole application.</para>
+
+ <para>Just like the window template, we specify our application menu
+ in a ui file, and add it as a resource to our binary.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application4/app-menu.ui"
parse="text"><xi:fallback>FIXME: 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>Both of these tasks are best done in the startup() vfunc,
+ which is guaranteed to be called once for each primary application
+ instance:</para>
+ <informalexample>
+ <programlisting>
+...
+
+static void
+preferences_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+}
+
+static void
+quit_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ g_application_quit (G_APPLICATION (app));
+}
+
+static GActionEntry app_entries[] = {
+ { "preferences", preferences_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL }
+};
+
+static void
+example_app_startup (GApplication *app)
+{
+ GtkBuilder *builder;
+ GMenuModel *app_menu;
+
+ G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+
+ 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
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->startup = example_app_startup;
+ ...
+}
+
+...
+ </programlisting>
+ <para>(<ulink
url="https://git.gnome.org/browse/gtk+/tree/examples/application4/exampleappwin.c">full source</ulink>)</para>
+ </informalexample>
+
+ <para>Our preferences menu item does not do anything yet,
+ but the Quit menu item is fully functional. Note that it
+ can also be activated by the usual Ctrl-Q shortcut. The
+ shortcut was specified in the ui file.
+ </para>
+
+ <para>The application menu looks like this:</para>
+
+ <informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="getting-started-app4.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+ </informalfigure>
+ </section>
+
+ <section>
+ <title>A preference dialog</title>
+
+ <para>A typical application will have a some preferences that
+ should be remembered from one run to the next. Even for our
+ simple example application, we may want to change the font
+ that is used for the content.</para>
+
+ <para>We are going to use GSettings to store our preferences.
+ GSettings requires a schema that describes our settings:</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application5/org.gtk.exampleapp.gschema.xml"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>Before we can make use of this schema in our application,
+ we need to compile it into the binary form that GSettings
+ expects. GIO provides <ulink url="https://developer.gnome.org/gio/2.36/ch31s06.html">macros</ulink>
+ to do this in autotools-based projects.</para>
+
+ <para>Next, we need to connect our settings to the widgets
+ that they are supposed to control. One convenient way to do
+ this is to use GSettings bind functionality to bind settings
+ keys to object properties, as we do here for the transition
+ setting.</para>
+
+ <informalexample>
+ <programlisting><![CDATA[
+...
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+
+ priv = example_app_window_get_instance_private (win);
+ gtk_widget_init_template (GTK_WIDGET (win));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "transition",
+ priv->stack, "transition-type",
+ G_SETTINGS_BIND_DEFAULT);
+}
+
+...
+ ]]></programlisting>
+ <para>(<ulink
url="https://git.gnome.org/browse/gtk+/tree/examples/application5/exampleappwin.c">full source</ulink>)</para>
+ </informalexample>
+
+ <para>The code to connect the font setting is a little more involved,
+ since there is no simple object property that it corresponds to, so
+ we are not going to go into that here.</para>
+
+ <para>At this point, the application will already react if you
+ change one of the settings, e.g. using the gsettings commandline
+ tool. Of course, we expect the application to provide a preference
+ dialog for these. So lets do that now. Our preference dialog will
+ be a subclass of GtkDialog, and we'll use the same techniques that
+ we've already seen: templates, private structs, settings
+ bindings.</para>
+
+ <para>Lets start with the template.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application6/prefs.ui"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>Next comes the dialog subclass.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application6/exampleappprefs.c"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>Now we revisit the preferences_activated() function in our
+ application class, and make it open a new preference dialog.</para>
+
+ <informalexample>
+ <programlisting><![CDATA[
+...
+
+static void
+preferences_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ ExampleAppPrefs *prefs;
+ GtkWindow *win;
+
+ win = gtk_application_get_active_window (GTK_APPLICATION (app));
+ prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win));
+ gtk_window_present (GTK_WINDOW (prefs));
+}
+
+...
+ ]]></programlisting>
+ <para>(<ulink url="https://git.gnome.org/browse/gtk+/tree/examples/application6/exampleapp.c">full
source</ulink>)</para>
+ </informalexample>
+
+ <para>After all this work, our application can now show
+ a preference dialog like this:</para>
+
+ <informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="getting-started-app6.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+ </informalfigure>
+ </section>
+
+ <section>
+ <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
+ #GtkSearchBar. The search bar is a widget that can slide in from the
+ top to present a search entry.</para>
+
+ <para>We add a toggle button to the header bar, which can be used
+ to slide out the search bar below the header bar.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application7/window.ui"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>Implementing the search needs quite a few code changes that
+ we are not going to completely go over here. The central piece of
+ the search implementation is a signal handler that listens for
+ text changes in the search entry.</para>
+
+ <informalexample>
+ <programlisting><![CDATA[
+...
+
+static void
+search_text_changed (GtkEntry *entry,
+ ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+ const gchar *text;
+ GtkWidget *tab;
+ GtkWidget *view;
+ GtkTextBuffer *buffer;
+ GtkTextIter start, match_start, match_end;
+
+ text = gtk_entry_get_text (entry);
+
+ if (text[0] == '\0')
+ return;
+
+ priv = example_app_window_get_instance_private (win);
+
+ tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
+ view = gtk_bin_get_child (GTK_BIN (tab));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ /* Very simple-minded search implementation */
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ if (gtk_text_iter_forward_search (&start, text, GTK_TEXT_SEARCH_CASE_INSENSITIVE,
+ &match_start, &match_end, NULL)) {
+ gtk_text_buffer_select_range (buffer, &match_start, &match_end);
+ gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match_start,
+ 0.0, FALSE, 0.0, 0.0);
+ }
+}
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+
+...
+
+ priv->text_changed_handler = g_signal_connect (priv->searchentry, "changed",
+ G_CALLBACK (search_text_changed), win);
+
+...
+
+}
+
+...
+ ]]></programlisting>
+ <para>(<ulink
url="https://git.gnome.org/browse/gtk+/tree/examples/application7/exampleappwin.c">full source</ulink>)</para>
+ </informalexample>
+
+ <para>With the search bar, our application now looks like this:</para>
+
+ <informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="getting-started-app7.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+ </informalfigure>
+ </section>
+
+ <section>
+ <title>Adding a side bar</title>
+
+ <para>As a last piece of functionality, we are adding a sidebar,
+ which demonstrates #GtkRevealer and #GtkListBox.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application8/window.ui"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>The code to populate the sidebar with buttons for the words
+ found in each file is a little too involved to go into here. But we'll
+ look at the code to add the gears menu.</para>
+
+ <para>As expected by now, the gears menu is specified in a GtkBuilder
+ ui file.</para>
+
+ <informalexample>
+ <programlisting><xi:include href="../../../../examples/application8/gears-menu.ui"
parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting>
+ </informalexample>
+
+ <para>To connect the menuitem to the show-words setting,
+ we use a #GSettingsAction.</para>
+
+ <informalexample>
+ <programlisting><![CDATA[
+...
+
+static void
+example_app_window_init (ExampleAppWindow *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 (priv->gears), menu);
+ g_object_unref (builder);
+
+ action = g_settings_create_action (priv->settings, "show-words");
+ g_action_map_add_action (G_ACTION_MAP (win), action);
+ g_object_unref (action);
+}
+
+...
+ ]]></programlisting>
+ <para>(<ulink
url="https://git.gnome.org/browse/gtk+/tree/examples/application8/exampleappwin.c">full source</ulink>)</para>
+ </informalexample>
+
+ <para>What our application looks like now:</para>
- </simplesect>
+ <informalfigure>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="getting-started-app8.png" format="PNG"/>
+ </imageobject>
+ </mediaobject>
+ </informalfigure>
+ </section>
+ </section>
</chapter>
diff --git a/docs/reference/gtk/images/getting-started-app1.png
b/docs/reference/gtk/images/getting-started-app1.png
new file mode 100644
index 0000000..0897f43
Binary files /dev/null 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
new file mode 100644
index 0000000..db81177
Binary files /dev/null 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
new file mode 100644
index 0000000..e411d01
Binary files /dev/null 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
new file mode 100644
index 0000000..a02c974
Binary files /dev/null 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
new file mode 100644
index 0000000..7b7109d
Binary files /dev/null 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
new file mode 100644
index 0000000..330864a
Binary files /dev/null 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
new file mode 100644
index 0000000..8def204
Binary files /dev/null and b/docs/reference/gtk/images/getting-started-app8.png differ
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c55a6a8..f2fc8c4 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,39 +1,7 @@
-
-# these have a handrolled Makefile that gets in the way of distchecking
-# so they will not be included in tarballs until they get integrated
-# in the new 'getting started' section of the docs
-OLD_EXAMPLES = \
- arrow \
- aspectframe \
- base \
- buttonbox \
- buttons \
- calendar \
- entry \
- eventbox \
- fixed \
- frame \
- gtkdial \
- helloworld \
- helloworld2 \
- label \
- menu \
- notebook \
- packbox \
- paned \
- progressbar \
- radiobuttons \
- rangewidgets \
- rulers \
- scribble-simple \
- scribble-xinput \
- scrolledwin \
- selection \
- spinbutton \
- statusbar \
- table \
- tictactoe \
- wheelbarrow
+SUBDIRS = \
+ application1 application2 application3 \
+ application4 application5 application6 \
+ application7 application8
AM_CPPFLAGS = \
-I$(top_srcdir) \
diff --git a/examples/application1/Makefile b/examples/application1/Makefile
new file mode 100644
index 0000000..4c309be
--- /dev/null
+++ b/examples/application1/Makefile
@@ -0,0 +1,737 @@
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# examples/application1/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/gtk+
+pkgincludedir = $(includedir)/gtk+
+pkglibdir = $(libdir)/gtk+
+pkglibexecdir = $(libexecdir)/gtk+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
+noinst_PROGRAMS = exampleapp$(EXEEXT)
+subdir = examples/application1
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/build-aux/depcomp
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \
+ $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg_config_for_build.m4 \
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_exampleapp_OBJECTS = main.$(OBJEXT) exampleapp.$(OBJEXT) \
+ exampleappwin.$(OBJEXT)
+exampleapp_OBJECTS = $(am_exampleapp_OBJECTS)
+exampleapp_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+exampleapp_DEPENDENCIES = $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la $(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am__v_lt_1 =
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I. -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(exampleapp_SOURCES)
+DIST_SOURCES = $(exampleapp_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /home/mclasen/Sources/gtk+/build-aux/missing aclocal-1.13
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 0
+AR = ar
+AS = as
+ATK_CFLAGS = -I/home/mclasen/gnome/include/atk-1.0 -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include -I/home/mclasen/gnome/include/at-spi2-atk/2.0
+ATK_LIBS = -L/home/mclasen/gnome/lib64 -latk-1.0 -lgobject-2.0 -lglib-2.0 -latk-bridge-2.0
+ATK_PREFIX = /home/mclasen/gnome
+ATK_REQUIRED_VERSION = 2.7.5
+AUTOCONF = ${SHELL} /home/mclasen/Sources/gtk+/build-aux/missing autoconf
+AUTOHEADER = ${SHELL} /home/mclasen/Sources/gtk+/build-aux/missing autoheader
+AUTOMAKE = ${SHELL} /home/mclasen/Sources/gtk+/build-aux/missing automake-1.13
+AWK = gawk
+BASE_DEPENDENCIES_CFLAGS = -pthread -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include -I/home/mclasen/gnome/include/atk-1.0
-I/home/mclasen/gnome/include/pango-1.0 -I/home/mclasen/gnome/include/cairo
-I/home/mclasen/gnome/include/pixman-1 -I/home/mclasen/gnome/include/gdk-pixbuf-2.0 -I/usr/include/freetype2
-I/usr/include/libpng15
+BASE_DEPENDENCIES_LIBS = -L/home/mclasen/gnome/lib64 -latk-1.0 -lpango-1.0 -lcairo-gobject -lcairo
-lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0
+BUILD_EXEEXT =
+BUILD_OBJEXT =
+CAIRO_BACKEND_CFLAGS = -I/home/mclasen/gnome/include/cairo -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include -I/home/mclasen/gnome/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng15
+CAIRO_BACKEND_LIBS = -L/home/mclasen/gnome/lib64 -lX11 -lXext -lcairo
+CAIRO_PREFIX = /home/mclasen/gnome
+CAIRO_REQUIRED_VERSION = 1.10.0
+CATALOGS = af.gmo am.gmo an.gmo ang.gmo ar.gmo as.gmo ast.gmo az.gmo az_IR.gmo be.gmo be latin gmo bg.gmo
bn.gmo bn_IN.gmo br.gmo bs.gmo ca.gmo ca valencia gmo crh.gmo cs.gmo cy.gmo da.gmo de.gmo dz.gmo el.gmo
en.gmo en_CA.gmo en_GB.gmo en shaw gmo eo.gmo es.gmo et.gmo eu.gmo fa.gmo fi.gmo fr.gmo ga.gmo gl.gmo gu.gmo
he.gmo hi.gmo hr.gmo hu.gmo hy.gmo ia.gmo id.gmo io.gmo is.gmo it.gmo ja.gmo ka.gmo kg.gmo kk.gmo km.gmo
kn.gmo ko.gmo ku.gmo ky.gmo lg.gmo li.gmo lt.gmo lv.gmo mai.gmo mi.gmo mk.gmo ml.gmo mn.gmo mr.gmo ms.gmo
my.gmo nb.gmo nds.gmo ne.gmo nl.gmo nn.gmo nso.gmo oc.gmo or.gmo pa.gmo pl.gmo ps.gmo pt.gmo pt_BR.gmo ro.gmo
ru.gmo rw.gmo si.gmo sk.gmo sl.gmo sq.gmo sr.gmo sr ije gmo sr latin gmo sv.gmo ta.gmo te.gmo tg.gmo th.gmo
tk.gmo tr.gmo tt.gmo ug.gmo uk.gmo ur.gmo uz.gmo uz cyrillic gmo vi.gmo wa.gmo xh.gmo yi.gmo zh_CN.gmo
zh_HK.gmo zh_TW.gmo
+CATOBJEXT = .gmo
+CC = gcc
+CCAS = gcc
+CCASDEPMODE = depmode=gcc3
+CCASFLAGS = -g -O2
+CCDEPMODE = depmode=gcc3
+CC_FOR_BUILD = gcc
+CFLAGS = -g -O2 -g -Wall
+CFLAGS_FOR_BUILD = -g -O2
+COLORD_CFLAGS = -pthread -I/home/mclasen/gnome/include/colord-1 -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include
+COLORD_LIBS = -L/home/mclasen/gnome/lib64 -lcolord -lcolordprivate -lgio-2.0 -lgobject-2.0 -lglib-2.0
+CPP = gcc -E
+CPPFLAGS =
+CPPFLAGS_FOR_BUILD =
+CPP_FOR_BUILD = gcc -E
+CUPS_API_MAJOR = 1
+CUPS_API_MINOR = 6
+CUPS_CFLAGS =
+CUPS_CONFIG = /usr/bin/cups-config
+CUPS_LIBS = -lcups -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lz -lpthread -lm -lcrypt -lz
+CXX = c++
+CXXCPP = c++ -E
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DATADIRNAME = share
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+DISABLE_ON_QUARTZ =
+DISABLE_ON_W32 =
+DISABLE_ON_WAYLAND = %
+DLLTOOL = false
+DSYMUTIL =
+DUMPBIN =
+ECHO_C =
+ECHO_N = -n
+ECHO_T =
+EGREP = /usr/bin/grep -E
+EXEEXT =
+EXE_MANIFEST_ARCHITECTURE = X86
+FGREP = /usr/bin/grep -F
+GAIL_INET_LIBS =
+GAIL_LT_CURRENT_MINUS_AGE = 0
+GAIL_LT_VERSION_INFO = 0:0:0
+GDK_BACKENDS = x11 wayland
+GDK_DEP_CFLAGS = -pthread -I/home/mclasen/gnome/include/pango-1.0 -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include -I/home/mclasen/gnome/include/cairo
-I/home/mclasen/gnome/include/pixman-1 -I/home/mclasen/gnome/include/gdk-pixbuf-2.0
-I/home/mclasen/gnome/include/gio-unix-2.0/ -I/home/mclasen/gnome/include/harfbuzz -I/usr/include/freetype2
-I/usr/include/libpng15
+GDK_DEP_LIBS = -L/home/mclasen/gnome/lib64 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lgio-2.0
-lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage -lXfixes -lwayland-client -lxkbcommon
-lwayland-cursor -lX11 -lXext -lcairo -lpangoft2-1.0 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0
-lglib-2.0 -lm
+GDK_EXTRA_CFLAGS =
+GDK_EXTRA_LIBS =
+GDK_HIDDEN_VISIBILITY_CFLAGS = -fvisibility=hidden
+GDK_PACKAGES = pango pangocairo gdk-pixbuf-2.0 cairo cairo-gobject
+GDK_PIXBUF_CSOURCE = /home/mclasen/gnome/bin/gdk-pixbuf-csource
+GDK_PIXBUF_LIBS = -L/home/mclasen/gnome/lib64 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0
+GDK_PIXBUF_REQUIRED_VERSION = 2.27.1
+GDK_PRIVATE_PACKAGES = gio-unix-2.0 fontconfig x11 xext xinerama xi xrandr xcursor xfixes xcomposite xdamage
wayland-client >= 1.1.90 xkbcommon >= 0.2.0 wayland-cursor cairo-xlib cairo pangoft2
+GETTEXT_PACKAGE = gtk30
+GLIB_CFLAGS = -pthread -I/home/mclasen/gnome/include/glib-2.0 -I/home/mclasen/gnome/lib64/glib-2.0/include
+GLIB_CFLAGS_FOR_BUILD = -pthread -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include
+GLIB_COMPILE_RESOURCES = glib-compile-resources
+GLIB_COMPILE_SCHEMAS = glib-compile-schemas
+GLIB_GENMARSHAL = glib-genmarshal
+GLIB_LIBS = -pthread -L/home/mclasen/gnome/lib64 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0
+GLIB_LIBS_FOR_BUILD = -pthread -L/home/mclasen/gnome/lib64 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0
+GLIB_MKENUMS = glib-mkenums
+GLIB_PREFIX = /home/mclasen/gnome
+GLIB_REQUIRED_VERSION = 2.37.3
+GMODULE_CFLAGS = -pthread -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include
+GMODULE_LIBS = -Wl,--export-dynamic -pthread -L/home/mclasen/gnome/lib64 -lgmodule-2.0 -lglib-2.0
+GMOFILES = af.gmo am.gmo an.gmo ang.gmo ar.gmo as.gmo ast.gmo az.gmo az_IR.gmo be.gmo be latin gmo bg.gmo
bn.gmo bn_IN.gmo br.gmo bs.gmo ca.gmo ca valencia gmo crh.gmo cs.gmo cy.gmo da.gmo de.gmo dz.gmo el.gmo
en.gmo en_CA.gmo en_GB.gmo en shaw gmo eo.gmo es.gmo et.gmo eu.gmo fa.gmo fi.gmo fr.gmo ga.gmo gl.gmo gu.gmo
he.gmo hi.gmo hr.gmo hu.gmo hy.gmo ia.gmo id.gmo io.gmo is.gmo it.gmo ja.gmo ka.gmo kg.gmo kk.gmo km.gmo
kn.gmo ko.gmo ku.gmo ky.gmo lg.gmo li.gmo lt.gmo lv.gmo mai.gmo mi.gmo mk.gmo ml.gmo mn.gmo mr.gmo ms.gmo
my.gmo nb.gmo nds.gmo ne.gmo nl.gmo nn.gmo nso.gmo oc.gmo or.gmo pa.gmo pl.gmo ps.gmo pt.gmo pt_BR.gmo ro.gmo
ru.gmo rw.gmo si.gmo sk.gmo sl.gmo sq.gmo sr.gmo sr ije gmo sr latin gmo sv.gmo ta.gmo te.gmo tg.gmo th.gmo
tk.gmo tr.gmo tt.gmo ug.gmo uk.gmo ur.gmo uz.gmo uz cyrillic gmo vi.gmo wa.gmo xh.gmo yi.gmo zh_CN.gmo
zh_HK.gmo zh_TW.gmo
+GMSGFMT = /usr/bin/msgfmt
+GOBJECT_QUERY = gobject-query
+GREP = /usr/bin/grep
+GSETTINGS_DISABLE_SCHEMAS_COMPILE =
+GTKDOC_CHECK = /home/mclasen/gnome/bin/gtkdoc-check
+GTKDOC_DEPS_CFLAGS = -I/home/mclasen/gnome/include/glib-2.0 -I/home/mclasen/gnome/lib64/glib-2.0/include
+GTKDOC_DEPS_LIBS = -L/home/mclasen/gnome/lib64 -lgobject-2.0 -lglib-2.0
+GTKDOC_MKPDF = /home/mclasen/gnome/bin/gtkdoc-mkpdf
+GTKDOC_REBASE = /home/mclasen/gnome/bin/gtkdoc-rebase
+GTK_API_VERSION = 3.0
+GTK_BINARY_AGE = 909
+GTK_BINARY_VERSION = 3.0.0
+GTK_DEBUG_FLAGS = -DG_ENABLE_DEBUG
+GTK_DEP_CFLAGS = -pthread -I/home/mclasen/gnome/include/pango-1.0 -I/home/mclasen/gnome/include/glib-2.0
-I/home/mclasen/gnome/lib64/glib-2.0/include -I/home/mclasen/gnome/include/cairo
-I/home/mclasen/gnome/include/pixman-1 -I/home/mclasen/gnome/include/atk-1.0
-I/home/mclasen/gnome/include/gdk-pixbuf-2.0 -I/home/mclasen/gnome/include/at-spi2-atk/2.0
-I/home/mclasen/gnome/include/harfbuzz -I/home/mclasen/gnome/include/gio-unix-2.0/ -I/usr/include/freetype2
-I/usr/include/libpng15
+GTK_DEP_LIBS = -L/home/mclasen/gnome/lib64 -lpangocairo-1.0 -lX11 -lXi -lXcomposite -lXdamage -lXfixes
-lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -latk-1.0 -latk-bridge-2.0 -lpangoft2-1.0 -lpango-1.0 -lfreetype
-lfontconfig -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lm
+GTK_EXTRA_CFLAGS =
+GTK_EXTRA_LIBS =
+GTK_INTERFACE_AGE = 0
+GTK_LINK_FLAGS = -Wl,-Bsymbolic-functions
+GTK_MAJOR_VERSION = 3
+GTK_MICRO_VERSION = 9
+GTK_MINOR_VERSION = 9
+GTK_PACKAGES = atk cairo cairo-gobject gdk-pixbuf-2.0 gio-2.0
+GTK_PRIVATE_PACKAGES = atk atk-bridge-2.0 pangoft2 gio-unix-2.0
+GTK_UPDATE_ICON_CACHE =
+GTK_VERSION = 3.9.9
+GTK_XIM_FLAGS =
+HAVE_HTTP_AUTHSTRING =
+HTML_DIR = ${datadir}/gtk-doc/html
+INCLUDED_IMMODULE_DEFINE =
+INCLUDED_IMMODULE_OBJ =
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+INSTOBJEXT = .mo
+INTLLIBS =
+INTROSPECTION_CFLAGS = -pthread -I/home/mclasen/gnome/include/gobject-introspection-1.0
-I/home/mclasen/gnome/include/glib-2.0 -I/home/mclasen/gnome/lib64/glib-2.0/include
+INTROSPECTION_COMPILER = /home/mclasen/gnome/bin/g-ir-compiler
+INTROSPECTION_GENERATE = /home/mclasen/gnome/bin/g-ir-generate
+INTROSPECTION_GIRDIR = /home/mclasen/gnome/share/gir-1.0
+INTROSPECTION_LIBS = -L/home/mclasen/gnome/lib64 -lgirepository-1.0 -lgobject-2.0 -lglib-2.0
+INTROSPECTION_MAKEFILE = /home/mclasen/gnome/share/gobject-introspection-1.0/Makefile.introspection
+INTROSPECTION_REQUIRED_VERSION = 1.32.0
+INTROSPECTION_SCANNER = /home/mclasen/gnome/bin/g-ir-scanner
+INTROSPECTION_TYPELIBDIR = /home/mclasen/gnome/lib64/girepository-1.0
+LD = /usr/bin/ld -m elf_x86_64
+LDFLAGS = -L/home/mclasen/gnome/lib64
+LDFLAGS_FOR_BUILD =
+LIBOBJS =
+LIBS =
+LIBTOOL = $(SHELL) $(top_builddir)/libtool
+LIB_EXE_MACHINE_FLAG = X86
+LIPO =
+LN_S = ln -s
+LTLIBOBJS =
+LT_CURRENT_MINUS_AGE = 0
+LT_VERSION_INFO = 909:0:909
+MAINT =
+MAKEINFO = ${SHELL} /home/mclasen/Sources/gtk+/build-aux/missing makeinfo
+MANIFEST_TOOL = :
+MATH_LIB = -lm
+MKDIR_P = /usr/bin/mkdir -p
+MKINSTALLDIRS = build-aux/mkinstalldirs
+MSGFMT = /usr/bin/msgfmt
+MSGFMT_OPTS = -c
+NATIVE_GDKPIXBUF_CFLAGS =
+NATIVE_GDKPIXBUF_LIBS =
+NM = /usr/bin/nm -B
+NMEDIT =
+OBJDUMP = objdump
+OBJEXT = o
+OTOOL =
+OTOOL64 =
+PACKAGE = gtk+
+PACKAGE_BUGREPORT = http://bugzilla.gnome.org/enter_bug.cgi?product=gtk%2B
+PACKAGE_NAME = gtk+
+PACKAGE_STRING = gtk+ 3.9.9
+PACKAGE_TARNAME = gtk+
+PACKAGE_URL =
+PACKAGE_VERSION = 3.9.9
+PANGO_PREFIX = /home/mclasen/gnome
+PANGO_REQUIRED_VERSION = 1.32.4
+PATH_SEPARATOR = :
+PERL = /usr/bin/perl
+PKG_CONFIG = /usr/bin/pkg-config
+PKG_CONFIG_FOR_BUILD = /usr/bin/pkg-config
+PKG_CONFIG_LIBDIR =
+PKG_CONFIG_PATH =
/home/mclasen/gnome/lib64/pkgconfig:/home/mclasen/gnome/share/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
+POFILES = af.po am.po an.po ang.po ar.po as.po ast.po az.po az_IR.po be.po be latin po bg.po bn.po bn_IN.po
br.po bs.po ca.po ca valencia po crh.po cs.po cy.po da.po de.po dz.po el.po en.po en_CA.po en_GB.po en shaw
po eo.po es.po et.po eu.po fa.po fi.po fr.po ga.po gl.po gu.po he.po hi.po hr.po hu.po hy.po ia.po id.po
io.po is.po it.po ja.po ka.po kg.po kk.po km.po kn.po ko.po ku.po ky.po lg.po li.po lt.po lv.po mai.po mi.po
mk.po ml.po mn.po mr.po ms.po my.po nb.po nds.po ne.po nl.po nn.po nso.po oc.po or.po pa.po pl.po ps.po pt.po
pt_BR.po ro.po ru.po rw.po si.po sk.po sl.po sq.po sr.po sr ije po sr latin po sv.po ta.po te.po tg.po th.po
tk.po tr.po tt.po ug.po uk.po ur.po uz.po uz cyrillic po vi.po wa.po xh.po yi.po zh_CN.po zh_HK.po zh_TW.po
+POSUB = po
+PO_IN_DATADIR_FALSE =
+PO_IN_DATADIR_TRUE =
+RANLIB = ranlib
+SED = /usr/bin/sed
+SET_MAKE =
+SHELL = /bin/sh
+STRIP = strip
+USE_NLS = yes
+VERSION = 3.9.9
+WINDRES =
+XGETTEXT = /usr/bin/xgettext
+XMKMF =
+XMLCATALOG = /usr/bin/xmlcatalog
+XML_CATALOG_FILE = /etc/xml/catalog
+XSLTPROC = /usr/bin/xsltproc
+X_CFLAGS =
+X_EXTRA_LIBS =
+X_LIBS =
+X_PRE_LIBS =
+abs_builddir = /home/mclasen/Sources/gtk+/examples/application1
+abs_srcdir = /home/mclasen/Sources/gtk+/examples/application1
+abs_top_builddir = /home/mclasen/Sources/gtk+
+abs_top_srcdir = /home/mclasen/Sources/gtk+
+ac_ct_AR = ar
+ac_ct_CC = gcc
+ac_ct_CC_FOR_BUILD = gcc
+ac_ct_CXX = c++
+ac_ct_DUMPBIN =
+am__include = include
+am__leading_dot = .
+am__quote =
+am__tar = tar --format=ustar -chf - "$$tardir"
+am__untar = tar -xf -
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-linux-gnu
+build_alias =
+build_cpu = x86_64
+build_os = linux-gnu
+build_vendor = unknown
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+gsettingsschemadir = ${datarootdir}/glib-2.0/schemas
+host = x86_64-unknown-linux-gnu
+host_alias =
+host_cpu = x86_64
+host_os = linux-gnu
+host_vendor = unknown
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /home/mclasen/Sources/gtk+/build-aux/install-sh
+libdir = /home/mclasen/gnome/lib64
+libexecdir = ${exec_prefix}/libexec
+localedir = /home/mclasen/gnome/share/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+ms_librarian =
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /home/mclasen/gnome
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias =
+top_build_prefix = ../../
+top_builddir = ../..
+top_srcdir = ../..
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/application1/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu examples/application1/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+exampleapp$(EXEEXT): $(exampleapp_OBJECTS) $(exampleapp_DEPENDENCIES) $(EXTRA_exampleapp_DEPENDENCIES)
+ @rm -f exampleapp$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(exampleapp_OBJECTS) $(exampleapp_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+include ./$(DEPDIR)/exampleapp.Po
+include ./$(DEPDIR)/exampleappwin.Po
+include ./$(DEPDIR)/main.Po
+
+.c.o:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c $<
+
+.c.obj:
+ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+# $(AM_V_CC)source='$<' object='$@' libtool=no \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+# $(AM_V_CC)source='$<' object='$@' libtool=yes \
+# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+# $(AM_V_CC_no)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
+ ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/examples/application1/Makefile.am b/examples/application1/Makefile.am
new file mode 100644
index 0000000..27865c8
--- /dev/null
+++ b/examples/application1/Makefile.am
@@ -0,0 +1,19 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h
diff --git a/examples/application1/exampleapp.c b/examples/application1/exampleapp.c
new file mode 100644
index 0000000..bdd6a77
--- /dev/null
+++ b/examples/application1/exampleapp.c
@@ -0,0 +1,66 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application1/exampleapp.h b/examples/application1/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application1/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application1/exampleappwin.c b/examples/application1/exampleappwin.c
new file mode 100644
index 0000000..9fc326a
--- /dev/null
+++ b/examples/application1/exampleappwin.c
@@ -0,0 +1,35 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+example_app_window_init (ExampleAppWindow *app)
+{
+}
+
+static void
+example_app_window_class_init (ExampleAppWindowClass *class)
+{
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+}
diff --git a/examples/application1/exampleappwin.h b/examples/application1/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application1/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application1/main.c b/examples/application1/main.c
new file mode 100644
index 0000000..7c24d8b
--- /dev/null
+++ b/examples/application1/main.c
@@ -0,0 +1,8 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application2/Makefile.am b/examples/application2/Makefile.am
new file mode 100644
index 0000000..91e3c19
--- /dev/null
+++ b/examples/application2/Makefile.am
@@ -0,0 +1,30 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h \
+ resources.c
+
+BUILT_SOURCES = resources.c
+
+resources.c: exampleapp.gresource.xml window.ui
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/exampleapp.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --generate-source
+
+EXTRA_DIST = \
+ window.ui \
+ exampleapp.gresource.xml
diff --git a/examples/application2/exampleapp.c b/examples/application2/exampleapp.c
new file mode 100644
index 0000000..bdd6a77
--- /dev/null
+++ b/examples/application2/exampleapp.c
@@ -0,0 +1,66 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application2/exampleapp.gresource.xml b/examples/application2/exampleapp.gresource.xml
new file mode 100644
index 0000000..175264c
--- /dev/null
+++ b/examples/application2/exampleapp.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gtk/exampleapp">
+ <file preprocess="xml-stripblanks">window.ui</file>
+ </gresource>
+</gresources>
diff --git a/examples/application2/exampleapp.h b/examples/application2/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application2/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application2/exampleappwin.c b/examples/application2/exampleappwin.c
new file mode 100644
index 0000000..7adf218
--- /dev/null
+++ b/examples/application2/exampleappwin.c
@@ -0,0 +1,38 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ gtk_widget_init_template (GTK_WIDGET (win));
+}
+
+static void
+example_app_window_class_init (ExampleAppWindowClass *class)
+{
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/window.ui");
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+}
diff --git a/examples/application2/exampleappwin.h b/examples/application2/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application2/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application2/main.c b/examples/application2/main.c
new file mode 100644
index 0000000..7c24d8b
--- /dev/null
+++ b/examples/application2/main.c
@@ -0,0 +1,8 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application2/window.ui b/examples/application2/window.ui
new file mode 100644
index 0000000..d90c3f6
--- /dev/null
+++ b/examples/application2/window.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <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>
+ <object class="GtkBox" id="content_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header">
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="visible">True</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application3/Makefile.am b/examples/application3/Makefile.am
new file mode 100644
index 0000000..91e3c19
--- /dev/null
+++ b/examples/application3/Makefile.am
@@ -0,0 +1,30 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h \
+ resources.c
+
+BUILT_SOURCES = resources.c
+
+resources.c: exampleapp.gresource.xml window.ui
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/exampleapp.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --generate-source
+
+EXTRA_DIST = \
+ window.ui \
+ exampleapp.gresource.xml
diff --git a/examples/application3/exampleapp.c b/examples/application3/exampleapp.c
new file mode 100644
index 0000000..bdd6a77
--- /dev/null
+++ b/examples/application3/exampleapp.c
@@ -0,0 +1,66 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application3/exampleapp.gresource.xml b/examples/application3/exampleapp.gresource.xml
new file mode 100644
index 0000000..175264c
--- /dev/null
+++ b/examples/application3/exampleapp.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gtk/exampleapp">
+ <file preprocess="xml-stripblanks">window.ui</file>
+ </gresource>
+</gresources>
diff --git a/examples/application3/exampleapp.h b/examples/application3/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application3/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application3/exampleappwin.c b/examples/application3/exampleappwin.c
new file mode 100644
index 0000000..52306e1
--- /dev/null
+++ b/examples/application3/exampleappwin.c
@@ -0,0 +1,73 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
+
+struct ExampleAppWindowPrivate {
+ GtkWidget *stack;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ gtk_widget_init_template (GTK_WIDGET (win));
+}
+
+static void
+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_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack);
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+ ExampleAppWindowPrivate *priv = example_app_window_get_instance_private (win);
+ gchar *basename;
+ GtkWidget *scrolled, *view;
+ gchar *contents;
+ gsize length;
+
+ basename = g_file_get_basename (file);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolled);
+ gtk_widget_set_hexpand (scrolled, TRUE);
+ gtk_widget_set_vexpand (scrolled, TRUE);
+ view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+ gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled), view);
+ gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_text_buffer_set_text (buffer, contents, length);
+ g_free (contents);
+ }
+
+ g_free (basename);
+}
diff --git a/examples/application3/exampleappwin.h b/examples/application3/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application3/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application3/main.c b/examples/application3/main.c
new file mode 100644
index 0000000..7c24d8b
--- /dev/null
+++ b/examples/application3/main.c
@@ -0,0 +1,8 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application3/window.ui b/examples/application3/window.ui
new file mode 100644
index 0000000..d90c3f6
--- /dev/null
+++ b/examples/application3/window.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <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>
+ <object class="GtkBox" id="content_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header">
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="visible">True</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application4/Makefile.am b/examples/application4/Makefile.am
new file mode 100644
index 0000000..d20ca0e
--- /dev/null
+++ b/examples/application4/Makefile.am
@@ -0,0 +1,31 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h \
+ resources.c
+
+BUILT_SOURCES = resources.c
+
+resources.c: exampleapp.gresource.xml window.ui app-menu.ui
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/exampleapp.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --generate-source
+
+EXTRA_DIST = \
+ window.ui \
+ app-menu.ui \
+ exampleapp.gresource.xml
diff --git a/examples/application4/app-menu.ui b/examples/application4/app-menu.ui
new file mode 100644
index 0000000..b0eddb6
--- /dev/null
+++ b/examples/application4/app-menu.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="appmenu">
+ <section>
+ <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>
+ <attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/examples/application4/exampleapp.c b/examples/application4/exampleapp.c
new file mode 100644
index 0000000..77ced6b
--- /dev/null
+++ b/examples/application4/exampleapp.c
@@ -0,0 +1,105 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+preferences_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+}
+
+static void
+quit_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ g_application_quit (G_APPLICATION (app));
+}
+
+static GActionEntry app_entries[] = {
+ { "preferences", preferences_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL }
+};
+
+static void
+example_app_startup (GApplication *app)
+{
+ GtkBuilder *builder;
+ GMenuModel *app_menu;
+
+ G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+
+ 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
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->startup = example_app_startup;
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application4/exampleapp.gresource.xml b/examples/application4/exampleapp.gresource.xml
new file mode 100644
index 0000000..1c9b118
--- /dev/null
+++ b/examples/application4/exampleapp.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gtk/exampleapp">
+ <file preprocess="xml-stripblanks">window.ui</file>
+ <file preprocess="xml-stripblanks">app-menu.ui</file>
+ </gresource>
+</gresources>
diff --git a/examples/application4/exampleapp.h b/examples/application4/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application4/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application4/exampleappwin.c b/examples/application4/exampleappwin.c
new file mode 100644
index 0000000..52306e1
--- /dev/null
+++ b/examples/application4/exampleappwin.c
@@ -0,0 +1,73 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
+
+struct ExampleAppWindowPrivate {
+ GtkWidget *stack;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ gtk_widget_init_template (GTK_WIDGET (win));
+}
+
+static void
+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_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack);
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+ ExampleAppWindowPrivate *priv = example_app_window_get_instance_private (win);
+ gchar *basename;
+ GtkWidget *scrolled, *view;
+ gchar *contents;
+ gsize length;
+
+ basename = g_file_get_basename (file);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolled);
+ gtk_widget_set_hexpand (scrolled, TRUE);
+ gtk_widget_set_vexpand (scrolled, TRUE);
+ view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+ gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled), view);
+ gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_text_buffer_set_text (buffer, contents, length);
+ g_free (contents);
+ }
+
+ g_free (basename);
+}
diff --git a/examples/application4/exampleappwin.h b/examples/application4/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application4/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application4/main.c b/examples/application4/main.c
new file mode 100644
index 0000000..7c24d8b
--- /dev/null
+++ b/examples/application4/main.c
@@ -0,0 +1,8 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application4/window.ui b/examples/application4/window.ui
new file mode 100644
index 0000000..d90c3f6
--- /dev/null
+++ b/examples/application4/window.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <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>
+ <object class="GtkBox" id="content_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header">
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="visible">True</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application5/Makefile.am b/examples/application5/Makefile.am
new file mode 100644
index 0000000..83c65e7
--- /dev/null
+++ b/examples/application5/Makefile.am
@@ -0,0 +1,45 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h \
+ resources.c
+
+BUILT_SOURCES = \
+ resources.c \
+ gschemas.compiled
+
+resources.c: exampleapp.gresource.xml window.ui app-menu.ui
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/exampleapp.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --generate-source
+
+gsettings_SCHEMAS = \
+ org.gtk.exampleapp.gschema.xml
+
+ GSETTINGS_RULES@
+
+gschemas.compiled: org.gtk.exampleapp.gschema.xml
+ $(GLIB_COMPILE_SCHEMAS) .
+
+EXTRA_DIST = \
+ window.ui \
+ app-menu.ui \
+ exampleapp.gresource.xml \
+ org.gtk.exampleapp.gschema.xml
+
+CLEANFILES = \
+ gschemas.compiled
diff --git a/examples/application5/app-menu.ui b/examples/application5/app-menu.ui
new file mode 100644
index 0000000..b0eddb6
--- /dev/null
+++ b/examples/application5/app-menu.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="appmenu">
+ <section>
+ <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>
+ <attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/examples/application5/exampleapp.c b/examples/application5/exampleapp.c
new file mode 100644
index 0000000..77ced6b
--- /dev/null
+++ b/examples/application5/exampleapp.c
@@ -0,0 +1,105 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+preferences_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+}
+
+static void
+quit_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ g_application_quit (G_APPLICATION (app));
+}
+
+static GActionEntry app_entries[] = {
+ { "preferences", preferences_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL }
+};
+
+static void
+example_app_startup (GApplication *app)
+{
+ GtkBuilder *builder;
+ GMenuModel *app_menu;
+
+ G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+
+ 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
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->startup = example_app_startup;
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application5/exampleapp.gresource.xml b/examples/application5/exampleapp.gresource.xml
new file mode 100644
index 0000000..1c9b118
--- /dev/null
+++ b/examples/application5/exampleapp.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gtk/exampleapp">
+ <file preprocess="xml-stripblanks">window.ui</file>
+ <file preprocess="xml-stripblanks">app-menu.ui</file>
+ </gresource>
+</gresources>
diff --git a/examples/application5/exampleapp.h b/examples/application5/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application5/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application5/exampleappwin.c b/examples/application5/exampleappwin.c
new file mode 100644
index 0000000..26790f0
--- /dev/null
+++ b/examples/application5/exampleappwin.c
@@ -0,0 +1,108 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
+
+struct ExampleAppWindowPrivate {
+ GSettings *settings;
+ GtkWidget *stack;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+
+ priv = example_app_window_get_instance_private (win);
+ gtk_widget_init_template (GTK_WIDGET (win));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "transition",
+ priv->stack, "transition-type",
+ G_SETTINGS_BIND_DEFAULT);
+}
+
+static void
+example_app_window_dispose (GObject *object)
+{
+ ExampleAppWindow *win;
+ ExampleAppWindowPrivate *priv;
+
+ win = EXAMPLE_APP_WINDOW (object);
+ priv = example_app_window_get_instance_private (win);
+
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
+}
+
+static void
+example_app_window_class_init (ExampleAppWindowClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = example_app_window_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/window.ui");
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack);
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+ ExampleAppWindowPrivate *priv;
+ gchar *basename;
+ GtkWidget *scrolled, *view;
+ gchar *contents;
+ gsize length;
+ GtkTextBuffer *buffer;
+ GtkTextTag *tag;
+ GtkTextIter start_iter, end_iter;
+
+ priv = example_app_window_get_instance_private (win);
+ basename = g_file_get_basename (file);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolled);
+ gtk_widget_set_hexpand (scrolled, TRUE);
+ gtk_widget_set_vexpand (scrolled, TRUE);
+ view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+ gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled), view);
+ gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
+ gtk_text_buffer_set_text (buffer, contents, length);
+ g_free (contents);
+ }
+
+ tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
+ g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
+
+ gtk_text_buffer_get_start_iter (buffer, &start_iter);
+ gtk_text_buffer_get_end_iter (buffer, &end_iter);
+ gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
+
+ g_free (basename);
+}
diff --git a/examples/application5/exampleappwin.h b/examples/application5/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application5/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application5/main.c b/examples/application5/main.c
new file mode 100644
index 0000000..7ce327a
--- /dev/null
+++ b/examples/application5/main.c
@@ -0,0 +1,15 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ /* Since this example is running uninstalled,
+ * we have to help it find its schema. This
+ * is *not* necessary in properly installed
+ * application.
+ */
+ g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE);
+
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application5/org.gtk.exampleapp.gschema.xml
b/examples/application5/org.gtk.exampleapp.gschema.xml
new file mode 100644
index 0000000..89718c4
--- /dev/null
+++ b/examples/application5/org.gtk.exampleapp.gschema.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <enum id="org.gtk.exampleapp.Transition">
+ <value value="0" nick="none"/>
+ <value value="1" nick="crossfade"/>
+ <value value="6" nick="slide-left-right"/>
+ </enum>
+ <schema path="/org/gtk/exampleapp/" id="org.gtk.exampleapp">
+ <key name="font" type="s">
+ <default>'Monospace 12'</default>
+ <summary>Font</summary>
+ <description>The font to be used for content.</description>
+ </key>
+ <key name="transition" enum="org.gtk.exampleapp.Transition">
+ <default>'none'</default>
+ <summary>Transition</summary>
+ <description>The transition to use when switching tabs.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/examples/application5/window.ui b/examples/application5/window.ui
new file mode 100644
index 0000000..d90c3f6
--- /dev/null
+++ b/examples/application5/window.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <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>
+ <object class="GtkBox" id="content_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header">
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="visible">True</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application6/Makefile.am b/examples/application6/Makefile.am
new file mode 100644
index 0000000..b4583fe
--- /dev/null
+++ b/examples/application6/Makefile.am
@@ -0,0 +1,47 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h \
+ exampleappprefs.c exampleappprefs.h \
+ resources.c
+
+BUILT_SOURCES = \
+ resources.c \
+ gschemas.compiled
+
+resources.c: exampleapp.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)
--generate-dependencies $(srcdir)/exampleapp.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/exampleapp.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --generate-source
+
+gsettings_SCHEMAS = \
+ org.gtk.exampleapp.gschema.xml
+
+ GSETTINGS_RULES@
+
+gschemas.compiled: org.gtk.exampleapp.gschema.xml
+ $(GLIB_COMPILE_SCHEMAS) .
+
+EXTRA_DIST = \
+ window.ui \
+ app-menu.ui \
+ prefs.ui \
+ exampleapp.gresource.xml \
+ org.gtk.exampleapp.gschema.xml
+
+CLEANFILES = \
+ gschemas.compiled
diff --git a/examples/application6/app-menu.ui b/examples/application6/app-menu.ui
new file mode 100644
index 0000000..b0eddb6
--- /dev/null
+++ b/examples/application6/app-menu.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="appmenu">
+ <section>
+ <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>
+ <attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/examples/application6/exampleapp.c b/examples/application6/exampleapp.c
new file mode 100644
index 0000000..633216c
--- /dev/null
+++ b/examples/application6/exampleapp.c
@@ -0,0 +1,112 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include "exampleappprefs.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+preferences_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ ExampleAppPrefs *prefs;
+ GtkWindow *win;
+
+ win = gtk_application_get_active_window (GTK_APPLICATION (app));
+ prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win));
+ gtk_window_present (GTK_WINDOW (prefs));
+}
+
+static void
+quit_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ g_application_quit (G_APPLICATION (app));
+}
+
+static GActionEntry app_entries[] = {
+ { "preferences", preferences_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL }
+};
+
+static void
+example_app_startup (GApplication *app)
+{
+ GtkBuilder *builder;
+ GMenuModel *app_menu;
+
+ G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+
+ 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
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->startup = example_app_startup;
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application6/exampleapp.gresource.xml b/examples/application6/exampleapp.gresource.xml
new file mode 100644
index 0000000..7976885
--- /dev/null
+++ b/examples/application6/exampleapp.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">prefs.ui</file>
+ </gresource>
+</gresources>
diff --git a/examples/application6/exampleapp.h b/examples/application6/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application6/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application6/exampleappprefs.c b/examples/application6/exampleappprefs.c
new file mode 100644
index 0000000..75f2ccb
--- /dev/null
+++ b/examples/application6/exampleappprefs.c
@@ -0,0 +1,71 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include "exampleappprefs.h"
+
+struct ExampleAppPrefs {
+ GtkDialog parent;
+};
+
+struct ExampleAppPrefsClass {
+ GtkDialogClass parent_class;
+};
+
+typedef struct ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
+struct ExampleAppPrefsPrivate {
+ GSettings *settings;
+ GtkWidget *font;
+ GtkWidget *transition;
+ GtkWidget *close;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
+
+static void
+example_app_prefs_init (ExampleAppPrefs *prefs)
+{
+ ExampleAppPrefsPrivate *priv;
+
+ priv = example_app_prefs_get_instance_private (prefs);
+ gtk_widget_init_template (GTK_WIDGET (prefs));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "font",
+ priv->font, "font",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->settings, "transition",
+ priv->transition, "active-id",
+ G_SETTINGS_BIND_DEFAULT);
+ g_signal_connect_swapped (priv->close, "clicked",
+ G_CALLBACK (gtk_widget_destroy), prefs);
+}
+
+static void
+example_app_prefs_dispose (GObject *object)
+{
+ ExampleAppPrefsPrivate *priv;
+
+ priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
+}
+
+static void
+example_app_prefs_class_init (ExampleAppPrefsClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/prefs.ui");
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, font);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, transition);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, close);
+}
+
+ExampleAppPrefs *
+example_app_prefs_new (ExampleAppWindow *win)
+{
+ return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
+}
diff --git a/examples/application6/exampleappprefs.h b/examples/application6/exampleappprefs.h
new file mode 100644
index 0000000..fe32a67
--- /dev/null
+++ b/examples/application6/exampleappprefs.h
@@ -0,0 +1,20 @@
+#ifndef __EXAMPLEAPPPREFS_H
+#define __EXAMPLEAPPPREFS_H
+
+#include <gtk/gtk.h>
+#include "exampleappwin.h"
+
+
+#define EXAMPLE_APP_PREFS_TYPE (example_app_prefs_get_type ())
+#define EXAMPLE_APP_PREFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_PREFS_TYPE, ExampleAppPrefs))
+
+
+typedef struct ExampleAppPrefs ExampleAppPrefs;
+typedef struct ExampleAppPrefsClass ExampleAppPrefsClass;
+
+
+GType example_app_prefs_get_type (void);
+ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
+
+
+#endif /* __EXAMPLEAPPPREFS_H */
diff --git a/examples/application6/exampleappwin.c b/examples/application6/exampleappwin.c
new file mode 100644
index 0000000..26790f0
--- /dev/null
+++ b/examples/application6/exampleappwin.c
@@ -0,0 +1,108 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
+
+struct ExampleAppWindowPrivate {
+ GSettings *settings;
+ GtkWidget *stack;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+
+ priv = example_app_window_get_instance_private (win);
+ gtk_widget_init_template (GTK_WIDGET (win));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "transition",
+ priv->stack, "transition-type",
+ G_SETTINGS_BIND_DEFAULT);
+}
+
+static void
+example_app_window_dispose (GObject *object)
+{
+ ExampleAppWindow *win;
+ ExampleAppWindowPrivate *priv;
+
+ win = EXAMPLE_APP_WINDOW (object);
+ priv = example_app_window_get_instance_private (win);
+
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
+}
+
+static void
+example_app_window_class_init (ExampleAppWindowClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = example_app_window_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/window.ui");
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack);
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+ ExampleAppWindowPrivate *priv;
+ gchar *basename;
+ GtkWidget *scrolled, *view;
+ gchar *contents;
+ gsize length;
+ GtkTextBuffer *buffer;
+ GtkTextTag *tag;
+ GtkTextIter start_iter, end_iter;
+
+ priv = example_app_window_get_instance_private (win);
+ basename = g_file_get_basename (file);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolled);
+ gtk_widget_set_hexpand (scrolled, TRUE);
+ gtk_widget_set_vexpand (scrolled, TRUE);
+ view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+ gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled), view);
+ gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
+ gtk_text_buffer_set_text (buffer, contents, length);
+ g_free (contents);
+ }
+
+ tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
+ g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
+
+ gtk_text_buffer_get_start_iter (buffer, &start_iter);
+ gtk_text_buffer_get_end_iter (buffer, &end_iter);
+ gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
+
+ g_free (basename);
+}
diff --git a/examples/application6/exampleappwin.h b/examples/application6/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application6/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application6/main.c b/examples/application6/main.c
new file mode 100644
index 0000000..7ce327a
--- /dev/null
+++ b/examples/application6/main.c
@@ -0,0 +1,15 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ /* Since this example is running uninstalled,
+ * we have to help it find its schema. This
+ * is *not* necessary in properly installed
+ * application.
+ */
+ g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE);
+
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application6/org.gtk.exampleapp.gschema.xml
b/examples/application6/org.gtk.exampleapp.gschema.xml
new file mode 100644
index 0000000..89718c4
--- /dev/null
+++ b/examples/application6/org.gtk.exampleapp.gschema.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <enum id="org.gtk.exampleapp.Transition">
+ <value value="0" nick="none"/>
+ <value value="1" nick="crossfade"/>
+ <value value="6" nick="slide-left-right"/>
+ </enum>
+ <schema path="/org/gtk/exampleapp/" id="org.gtk.exampleapp">
+ <key name="font" type="s">
+ <default>'Monospace 12'</default>
+ <summary>Font</summary>
+ <description>The font to be used for content.</description>
+ </key>
+ <key name="transition" enum="org.gtk.exampleapp.Transition">
+ <default>'none'</default>
+ <summary>Transition</summary>
+ <description>The transition to use when switching tabs.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/examples/application6/prefs.ui b/examples/application6/prefs.ui
new file mode 100644
index 0000000..4e846b8
--- /dev/null
+++ b/examples/application6/prefs.ui
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="ExampleAppPrefs" parent="GtkDialog">
+ <property name="title" translatable="yes">Preferences</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox">
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="margin">6</property>
+ <property name="row-spacing">12</property>
+ <property name="column-spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="fontlabel">
+ <property name="visible">True</property>
+ <property name="label">_Font:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">font</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFontButton" id="font">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="transitionlabel">
+ <property name="visible">True</property>
+ <property name="label">_Transition:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">transition</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="transition">
+ <property name="visible">True</property>
+ <items>
+ <item translatable="yes" id="none">None</item>
+ <item translatable="yes" id="crossfade">Fade</item>
+ <item translatable="yes" id="slide-left-right">Slide</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="action_area">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="close">
+ <property name="visible">True</property>
+ <property name="label">_Close</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application6/window.ui b/examples/application6/window.ui
new file mode 100644
index 0000000..d90c3f6
--- /dev/null
+++ b/examples/application6/window.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <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>
+ <object class="GtkBox" id="content_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header">
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="visible">True</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application7/Makefile.am b/examples/application7/Makefile.am
new file mode 100644
index 0000000..b4583fe
--- /dev/null
+++ b/examples/application7/Makefile.am
@@ -0,0 +1,47 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h \
+ exampleappprefs.c exampleappprefs.h \
+ resources.c
+
+BUILT_SOURCES = \
+ resources.c \
+ gschemas.compiled
+
+resources.c: exampleapp.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)
--generate-dependencies $(srcdir)/exampleapp.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/exampleapp.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --generate-source
+
+gsettings_SCHEMAS = \
+ org.gtk.exampleapp.gschema.xml
+
+ GSETTINGS_RULES@
+
+gschemas.compiled: org.gtk.exampleapp.gschema.xml
+ $(GLIB_COMPILE_SCHEMAS) .
+
+EXTRA_DIST = \
+ window.ui \
+ app-menu.ui \
+ prefs.ui \
+ exampleapp.gresource.xml \
+ org.gtk.exampleapp.gschema.xml
+
+CLEANFILES = \
+ gschemas.compiled
diff --git a/examples/application7/app-menu.ui b/examples/application7/app-menu.ui
new file mode 100644
index 0000000..b0eddb6
--- /dev/null
+++ b/examples/application7/app-menu.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="appmenu">
+ <section>
+ <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>
+ <attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/examples/application7/exampleapp.c b/examples/application7/exampleapp.c
new file mode 100644
index 0000000..633216c
--- /dev/null
+++ b/examples/application7/exampleapp.c
@@ -0,0 +1,112 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include "exampleappprefs.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+preferences_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ ExampleAppPrefs *prefs;
+ GtkWindow *win;
+
+ win = gtk_application_get_active_window (GTK_APPLICATION (app));
+ prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win));
+ gtk_window_present (GTK_WINDOW (prefs));
+}
+
+static void
+quit_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ g_application_quit (G_APPLICATION (app));
+}
+
+static GActionEntry app_entries[] = {
+ { "preferences", preferences_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL }
+};
+
+static void
+example_app_startup (GApplication *app)
+{
+ GtkBuilder *builder;
+ GMenuModel *app_menu;
+
+ G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+
+ 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
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->startup = example_app_startup;
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application7/exampleapp.gresource.xml b/examples/application7/exampleapp.gresource.xml
new file mode 100644
index 0000000..7976885
--- /dev/null
+++ b/examples/application7/exampleapp.gresource.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">prefs.ui</file>
+ </gresource>
+</gresources>
diff --git a/examples/application7/exampleapp.h b/examples/application7/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application7/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application7/exampleappprefs.c b/examples/application7/exampleappprefs.c
new file mode 100644
index 0000000..75f2ccb
--- /dev/null
+++ b/examples/application7/exampleappprefs.c
@@ -0,0 +1,71 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include "exampleappprefs.h"
+
+struct ExampleAppPrefs {
+ GtkDialog parent;
+};
+
+struct ExampleAppPrefsClass {
+ GtkDialogClass parent_class;
+};
+
+typedef struct ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
+struct ExampleAppPrefsPrivate {
+ GSettings *settings;
+ GtkWidget *font;
+ GtkWidget *transition;
+ GtkWidget *close;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
+
+static void
+example_app_prefs_init (ExampleAppPrefs *prefs)
+{
+ ExampleAppPrefsPrivate *priv;
+
+ priv = example_app_prefs_get_instance_private (prefs);
+ gtk_widget_init_template (GTK_WIDGET (prefs));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "font",
+ priv->font, "font",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->settings, "transition",
+ priv->transition, "active-id",
+ G_SETTINGS_BIND_DEFAULT);
+ g_signal_connect_swapped (priv->close, "clicked",
+ G_CALLBACK (gtk_widget_destroy), prefs);
+}
+
+static void
+example_app_prefs_dispose (GObject *object)
+{
+ ExampleAppPrefsPrivate *priv;
+
+ priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
+}
+
+static void
+example_app_prefs_class_init (ExampleAppPrefsClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/prefs.ui");
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, font);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, transition);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, close);
+}
+
+ExampleAppPrefs *
+example_app_prefs_new (ExampleAppWindow *win)
+{
+ return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
+}
diff --git a/examples/application7/exampleappprefs.h b/examples/application7/exampleappprefs.h
new file mode 100644
index 0000000..fe32a67
--- /dev/null
+++ b/examples/application7/exampleappprefs.h
@@ -0,0 +1,20 @@
+#ifndef __EXAMPLEAPPPREFS_H
+#define __EXAMPLEAPPPREFS_H
+
+#include <gtk/gtk.h>
+#include "exampleappwin.h"
+
+
+#define EXAMPLE_APP_PREFS_TYPE (example_app_prefs_get_type ())
+#define EXAMPLE_APP_PREFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_PREFS_TYPE, ExampleAppPrefs))
+
+
+typedef struct ExampleAppPrefs ExampleAppPrefs;
+typedef struct ExampleAppPrefsClass ExampleAppPrefsClass;
+
+
+GType example_app_prefs_get_type (void);
+ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
+
+
+#endif /* __EXAMPLEAPPPREFS_H */
diff --git a/examples/application7/exampleappwin.c b/examples/application7/exampleappwin.c
new file mode 100644
index 0000000..05a8d30
--- /dev/null
+++ b/examples/application7/exampleappwin.c
@@ -0,0 +1,180 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
+
+struct ExampleAppWindowPrivate {
+ GSettings *settings;
+ GtkWidget *stack;
+ GtkWidget *search;
+ GtkWidget *searchbar;
+ GtkWidget *searchentry;
+ gulong text_changed_handler;
+ gulong tab_changed_handler;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+search_text_changed (GtkEntry *entry,
+ ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+ const gchar *text;
+ GtkWidget *tab;
+ GtkWidget *view;
+ GtkTextBuffer *buffer;
+ GtkTextIter start, match_start, match_end;
+
+ text = gtk_entry_get_text (entry);
+
+ if (text[0] == '\0')
+ return;
+
+ priv = example_app_window_get_instance_private (win);
+
+ tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
+ view = gtk_bin_get_child (GTK_BIN (tab));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ /* Very simple-minded search implementation */
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ if (gtk_text_iter_forward_search (&start, text, GTK_TEXT_SEARCH_CASE_INSENSITIVE,
+ &match_start, &match_end, NULL)) {
+ gtk_text_buffer_select_range (buffer, &match_start, &match_end);
+ gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match_start,
+ 0.0, FALSE, 0.0, 0.0);
+ }
+}
+
+static void
+visible_child_changed (GObject *stack,
+ GParamSpec *pspec,
+ ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+
+ priv = example_app_window_get_instance_private (win);
+ gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
+}
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+
+ priv = example_app_window_get_instance_private (win);
+ gtk_widget_init_template (GTK_WIDGET (win));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "transition",
+ priv->stack, "transition-type",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_object_bind_property (priv->search, "active",
+ priv->searchbar, "search-mode-enabled",
+ G_BINDING_BIDIRECTIONAL);
+
+ priv->text_changed_handler = g_signal_connect (priv->searchentry, "changed",
+ G_CALLBACK (search_text_changed), win);
+ priv->tab_changed_handler = g_signal_connect (priv->stack, "notify::visible-child",
+ G_CALLBACK (visible_child_changed), win);
+}
+
+static void
+example_app_window_dispose (GObject *object)
+{
+ ExampleAppWindow *win;
+ ExampleAppWindowPrivate *priv;
+
+ win = EXAMPLE_APP_WINDOW (object);
+ priv = example_app_window_get_instance_private (win);
+
+ if (priv->text_changed_handler != 0) {
+ g_signal_handler_disconnect (priv->searchentry, priv->text_changed_handler);
+ priv->text_changed_handler = 0;
+ }
+
+ if (priv->tab_changed_handler != 0) {
+ g_signal_handler_disconnect (priv->stack, priv->tab_changed_handler);
+ priv->tab_changed_handler = 0;
+ }
+
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
+}
+
+static void
+example_app_window_class_init (ExampleAppWindowClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = example_app_window_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/window.ui");
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, search);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, searchbar);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, searchentry);
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+ ExampleAppWindowPrivate *priv;
+ gchar *basename;
+ GtkWidget *scrolled, *view;
+ gchar *contents;
+ gsize length;
+ GtkTextBuffer *buffer;
+ GtkTextTag *tag;
+ GtkTextIter start_iter, end_iter;
+
+ priv = example_app_window_get_instance_private (win);
+ basename = g_file_get_basename (file);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolled);
+ gtk_widget_set_hexpand (scrolled, TRUE);
+ gtk_widget_set_vexpand (scrolled, TRUE);
+ view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+ gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled), view);
+ gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
+ gtk_text_buffer_set_text (buffer, contents, length);
+ g_free (contents);
+ }
+
+ tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
+ g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
+
+ gtk_text_buffer_get_start_iter (buffer, &start_iter);
+ gtk_text_buffer_get_end_iter (buffer, &end_iter);
+ gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
+
+ g_free (basename);
+
+ gtk_widget_set_sensitive (priv->search, TRUE);
+}
diff --git a/examples/application7/exampleappwin.h b/examples/application7/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application7/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application7/main.c b/examples/application7/main.c
new file mode 100644
index 0000000..7ce327a
--- /dev/null
+++ b/examples/application7/main.c
@@ -0,0 +1,15 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ /* Since this example is running uninstalled,
+ * we have to help it find its schema. This
+ * is *not* necessary in properly installed
+ * application.
+ */
+ g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE);
+
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application7/org.gtk.exampleapp.gschema.xml
b/examples/application7/org.gtk.exampleapp.gschema.xml
new file mode 100644
index 0000000..89718c4
--- /dev/null
+++ b/examples/application7/org.gtk.exampleapp.gschema.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <enum id="org.gtk.exampleapp.Transition">
+ <value value="0" nick="none"/>
+ <value value="1" nick="crossfade"/>
+ <value value="6" nick="slide-left-right"/>
+ </enum>
+ <schema path="/org/gtk/exampleapp/" id="org.gtk.exampleapp">
+ <key name="font" type="s">
+ <default>'Monospace 12'</default>
+ <summary>Font</summary>
+ <description>The font to be used for content.</description>
+ </key>
+ <key name="transition" enum="org.gtk.exampleapp.Transition">
+ <default>'none'</default>
+ <summary>Transition</summary>
+ <description>The transition to use when switching tabs.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/examples/application7/prefs.ui b/examples/application7/prefs.ui
new file mode 100644
index 0000000..4e846b8
--- /dev/null
+++ b/examples/application7/prefs.ui
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="ExampleAppPrefs" parent="GtkDialog">
+ <property name="title" translatable="yes">Preferences</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox">
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="margin">6</property>
+ <property name="row-spacing">12</property>
+ <property name="column-spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="fontlabel">
+ <property name="visible">True</property>
+ <property name="label">_Font:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">font</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFontButton" id="font">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="transitionlabel">
+ <property name="visible">True</property>
+ <property name="label">_Transition:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">transition</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="transition">
+ <property name="visible">True</property>
+ <items>
+ <item translatable="yes" id="none">None</item>
+ <item translatable="yes" id="crossfade">Fade</item>
+ <item translatable="yes" id="slide-left-right">Slide</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="action_area">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="close">
+ <property name="visible">True</property>
+ <property name="label">_Close</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application7/window.ui b/examples/application7/window.ui
new file mode 100644
index 0000000..4ddd22e
--- /dev/null
+++ b/examples/application7/window.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <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>
+ <object class="GtkBox" id="content_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header">
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="visible">True</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="search">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <child>
+ <object class="GtkImage" id="search-icon">
+ <property name="visible">True</property>
+ <property name="icon-name">edit-find-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSearchBar" id="searchbar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkSearchEntry" id="searchentry">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application8/Makefile.am b/examples/application8/Makefile.am
new file mode 100644
index 0000000..a7d82f6
--- /dev/null
+++ b/examples/application8/Makefile.am
@@ -0,0 +1,48 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gdk \
+ -I$(top_builddir)/gdk \
+ $(GTK_DEBUG_FLAGS) \
+ $(GTK_DEP_CFLAGS)
+
+LDADD = \
+ $(top_builddir)/gtk/libgtk-3.la \
+ $(top_builddir)/gdk/libgdk-3.la \
+ $(GTK_DEP_LIBS)
+
+
+noinst_PROGRAMS = exampleapp
+
+exampleapp_SOURCES = \
+ main.c \
+ exampleapp.c exampleapp.h \
+ exampleappwin.c exampleappwin.h \
+ exampleappprefs.c exampleappprefs.h \
+ resources.c
+
+BUILT_SOURCES = \
+ resources.c \
+ gschemas.compiled
+
+resources.c: exampleapp.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)
--generate-dependencies $(srcdir)/exampleapp.gresource.xml)
+ $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/exampleapp.gresource.xml \
+ --target=$@ --sourcedir=$(srcdir) --generate-source
+
+gsettings_SCHEMAS = \
+ org.gtk.exampleapp.gschema.xml
+
+ GSETTINGS_RULES@
+
+gschemas.compiled: org.gtk.exampleapp.gschema.xml
+ $(GLIB_COMPILE_SCHEMAS) .
+
+EXTRA_DIST = \
+ window.ui \
+ app-menu.ui \
+ prefs.ui \
+ gears-menu.ui \
+ exampleapp.gresource.xml \
+ org.gtk.exampleapp.gschema.xml
+
+CLEANFILES = \
+ gschemas.compiled
diff --git a/examples/application8/app-menu.ui b/examples/application8/app-menu.ui
new file mode 100644
index 0000000..b0eddb6
--- /dev/null
+++ b/examples/application8/app-menu.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="appmenu">
+ <section>
+ <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>
+ <attribute name="accel"><![CDATA[<Ctrl>Q]]></attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/examples/application8/exampleapp.c b/examples/application8/exampleapp.c
new file mode 100644
index 0000000..633216c
--- /dev/null
+++ b/examples/application8/exampleapp.c
@@ -0,0 +1,112 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include "exampleappprefs.h"
+
+struct ExampleApp {
+ GtkApplication parent;
+};
+
+struct ExampleAppClass {
+ GtkApplicationClass parent_class;
+};
+
+G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);
+
+static void
+example_app_init (ExampleApp *app)
+{
+}
+
+static void
+preferences_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ ExampleAppPrefs *prefs;
+ GtkWindow *win;
+
+ win = gtk_application_get_active_window (GTK_APPLICATION (app));
+ prefs = example_app_prefs_new (EXAMPLE_APP_WINDOW (win));
+ gtk_window_present (GTK_WINDOW (prefs));
+}
+
+static void
+quit_activated (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer app)
+{
+ g_application_quit (G_APPLICATION (app));
+}
+
+static GActionEntry app_entries[] = {
+ { "preferences", preferences_activated, NULL, NULL, NULL },
+ { "quit", quit_activated, NULL, NULL, NULL }
+};
+
+static void
+example_app_startup (GApplication *app)
+{
+ GtkBuilder *builder;
+ GMenuModel *app_menu;
+
+ G_APPLICATION_CLASS (example_app_parent_class)->startup (app);
+
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ app_entries, G_N_ELEMENTS (app_entries),
+ app);
+
+ 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
+example_app_activate (GApplication *app)
+{
+ ExampleAppWindow *win;
+
+ win = example_app_window_new (EXAMPLE_APP (app));
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_open (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ GList *windows;
+ ExampleAppWindow *win;
+ int i;
+
+ windows = gtk_application_get_windows (GTK_APPLICATION (app));
+ if (windows)
+ win = EXAMPLE_APP_WINDOW (windows->data);
+ else
+ win = example_app_window_new (EXAMPLE_APP (app));
+
+ for (i = 0; i < n_files; i++)
+ example_app_window_open (win, files[i]);
+
+ gtk_window_present (GTK_WINDOW (win));
+}
+
+static void
+example_app_class_init (ExampleAppClass *class)
+{
+ G_APPLICATION_CLASS (class)->startup = example_app_startup;
+ G_APPLICATION_CLASS (class)->activate = example_app_activate;
+ G_APPLICATION_CLASS (class)->open = example_app_open;
+}
+
+ExampleApp *
+example_app_new (void)
+{
+ return g_object_new (EXAMPLE_APP_TYPE,
+ "application-id", "org.gtk.exampleapp",
+ "flags", G_APPLICATION_HANDLES_OPEN,
+ NULL);
+}
diff --git a/examples/application8/exampleapp.gresource.xml b/examples/application8/exampleapp.gresource.xml
new file mode 100644
index 0000000..ace59c8
--- /dev/null
+++ b/examples/application8/exampleapp.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/application8/exampleapp.h b/examples/application8/exampleapp.h
new file mode 100644
index 0000000..8b51c59
--- /dev/null
+++ b/examples/application8/exampleapp.h
@@ -0,0 +1,19 @@
+#ifndef __EXAMPLEAPP_H
+#define __EXAMPLEAPP_H
+
+#include <gtk/gtk.h>
+
+
+#define EXAMPLE_APP_TYPE (example_app_get_type ())
+#define EXAMPLE_APP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_TYPE, ExampleApp))
+
+
+typedef struct ExampleApp ExampleApp;
+typedef struct ExampleAppClass ExampleAppClass;
+
+
+GType example_app_get_type (void);
+ExampleApp *example_app_new (void);
+
+
+#endif /* __EXAMPLEAPP_H */
diff --git a/examples/application8/exampleappprefs.c b/examples/application8/exampleappprefs.c
new file mode 100644
index 0000000..75f2ccb
--- /dev/null
+++ b/examples/application8/exampleappprefs.c
@@ -0,0 +1,71 @@
+#include <gtk/gtk.h>
+
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include "exampleappprefs.h"
+
+struct ExampleAppPrefs {
+ GtkDialog parent;
+};
+
+struct ExampleAppPrefsClass {
+ GtkDialogClass parent_class;
+};
+
+typedef struct ExampleAppPrefsPrivate ExampleAppPrefsPrivate;
+struct ExampleAppPrefsPrivate {
+ GSettings *settings;
+ GtkWidget *font;
+ GtkWidget *transition;
+ GtkWidget *close;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
+
+static void
+example_app_prefs_init (ExampleAppPrefs *prefs)
+{
+ ExampleAppPrefsPrivate *priv;
+
+ priv = example_app_prefs_get_instance_private (prefs);
+ gtk_widget_init_template (GTK_WIDGET (prefs));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "font",
+ priv->font, "font",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (priv->settings, "transition",
+ priv->transition, "active-id",
+ G_SETTINGS_BIND_DEFAULT);
+ g_signal_connect_swapped (priv->close, "clicked",
+ G_CALLBACK (gtk_widget_destroy), prefs);
+}
+
+static void
+example_app_prefs_dispose (GObject *object)
+{
+ ExampleAppPrefsPrivate *priv;
+
+ priv = example_app_prefs_get_instance_private (EXAMPLE_APP_PREFS (object));
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
+}
+
+static void
+example_app_prefs_class_init (ExampleAppPrefsClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/prefs.ui");
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, font);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, transition);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppPrefsPrivate, close);
+}
+
+ExampleAppPrefs *
+example_app_prefs_new (ExampleAppWindow *win)
+{
+ return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, NULL);
+}
diff --git a/examples/application8/exampleappprefs.h b/examples/application8/exampleappprefs.h
new file mode 100644
index 0000000..fe32a67
--- /dev/null
+++ b/examples/application8/exampleappprefs.h
@@ -0,0 +1,20 @@
+#ifndef __EXAMPLEAPPPREFS_H
+#define __EXAMPLEAPPPREFS_H
+
+#include <gtk/gtk.h>
+#include "exampleappwin.h"
+
+
+#define EXAMPLE_APP_PREFS_TYPE (example_app_prefs_get_type ())
+#define EXAMPLE_APP_PREFS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_PREFS_TYPE, ExampleAppPrefs))
+
+
+typedef struct ExampleAppPrefs ExampleAppPrefs;
+typedef struct ExampleAppPrefsClass ExampleAppPrefsClass;
+
+
+GType example_app_prefs_get_type (void);
+ExampleAppPrefs *example_app_prefs_new (ExampleAppWindow *win);
+
+
+#endif /* __EXAMPLEAPPPREFS_H */
diff --git a/examples/application8/exampleappwin.c b/examples/application8/exampleappwin.c
new file mode 100644
index 0000000..baa3db1
--- /dev/null
+++ b/examples/application8/exampleappwin.c
@@ -0,0 +1,288 @@
+#include "exampleapp.h"
+#include "exampleappwin.h"
+#include <gtk/gtk.h>
+
+struct ExampleAppWindow {
+ GtkApplicationWindow parent;
+};
+
+struct ExampleAppWindowClass {
+ GtkApplicationWindowClass parent_class;
+};
+
+typedef struct ExampleAppWindowPrivate ExampleAppWindowPrivate;
+
+struct ExampleAppWindowPrivate {
+ GSettings *settings;
+ GtkWidget *stack;
+ GtkWidget *search;
+ GtkWidget *searchbar;
+ GtkWidget *searchentry;
+ GtkWidget *gears;
+ GtkWidget *sidebar;
+ GtkWidget *words;
+ gulong text_changed_handler;
+ gulong tab_changed_handler;
+ gulong words_changed_handler;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE(ExampleAppWindow, example_app_window, GTK_TYPE_APPLICATION_WINDOW);
+
+static void
+search_text_changed (GtkEntry *entry,
+ ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+ const gchar *text;
+ GtkWidget *tab;
+ GtkWidget *view;
+ GtkTextBuffer *buffer;
+ GtkTextIter start, match_start, match_end;
+
+ text = gtk_entry_get_text (entry);
+
+ if (text[0] == '\0')
+ return;
+
+ priv = example_app_window_get_instance_private (win);
+
+ tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
+ view = gtk_bin_get_child (GTK_BIN (tab));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ /* Very simple-minded search implementation */
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ if (gtk_text_iter_forward_search (&start, text, GTK_TEXT_SEARCH_CASE_INSENSITIVE,
+ &match_start, &match_end, NULL)) {
+ gtk_text_buffer_select_range (buffer, &match_start, &match_end);
+ gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (view), &match_start,
+ 0.0, FALSE, 0.0, 0.0);
+ }
+}
+
+static void
+find_word (GtkButton *button,
+ ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+ const gchar *word;
+
+ priv = example_app_window_get_instance_private (win);
+
+ word = gtk_button_get_label (button);
+ gtk_entry_set_text (GTK_ENTRY (priv->searchentry), word);
+}
+
+static void
+update_words (ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+ GHashTable *strings;
+ GHashTableIter iter;
+ GtkWidget *tab, *view, *row;
+ GtkTextBuffer *buffer;
+ GtkTextIter start, end;
+ GList *children, *l;
+ gchar *word, *key;
+
+ priv = example_app_window_get_instance_private (win);
+
+ tab = gtk_stack_get_visible_child (GTK_STACK (priv->stack));
+ view = gtk_bin_get_child (GTK_BIN (tab));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ strings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ gtk_text_buffer_get_start_iter (buffer, &start);
+ while (!gtk_text_iter_is_end (&start)) {
+ while (!gtk_text_iter_starts_word (&start)) {
+ if (!gtk_text_iter_forward_char (&start))
+ goto done;
+ }
+ end = start;
+ if (!gtk_text_iter_forward_word_end (&end))
+ goto done;
+ word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+ g_hash_table_add (strings, g_utf8_strdown (word, -1));
+ g_free (word);
+ start = end;
+ }
+
+done:
+ children = gtk_container_get_children (GTK_CONTAINER (priv->words));
+ for (l = children; l; l = l->next) {
+ gtk_container_remove (GTK_CONTAINER (priv->words), GTK_WIDGET (l->data));
+ }
+ g_list_free (children);
+
+ g_hash_table_iter_init (&iter, strings);
+ while (g_hash_table_iter_next (&iter, (gpointer *)&key, NULL)) {
+ row = gtk_button_new_with_label (key);
+ g_signal_connect (row, "clicked",
+ G_CALLBACK (find_word), win);
+ gtk_widget_show (row);
+ gtk_container_add (GTK_CONTAINER (priv->words), row);
+ }
+
+ g_hash_table_unref (strings);
+}
+
+static void
+visible_child_changed (GObject *stack,
+ GParamSpec *pspec,
+ ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+
+ priv = example_app_window_get_instance_private (win);
+ gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (priv->searchbar), FALSE);
+ update_words (win);
+}
+
+static void
+words_changed (GObject *sidebar,
+ GParamSpec *pspec,
+ ExampleAppWindow *win)
+{
+ update_words (win);
+}
+
+static void
+example_app_window_init (ExampleAppWindow *win)
+{
+ ExampleAppWindowPrivate *priv;
+ GtkBuilder *builder;
+ GMenuModel *menu;
+ GAction *action;
+
+ priv = example_app_window_get_instance_private (win);
+ gtk_widget_init_template (GTK_WIDGET (win));
+ priv->settings = g_settings_new ("org.gtk.exampleapp");
+
+ g_settings_bind (priv->settings, "transition",
+ priv->stack, "transition-type",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (priv->settings, "show-words",
+ priv->sidebar, "reveal-child",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_object_bind_property (priv->search, "active",
+ priv->searchbar, "search-mode-enabled",
+ G_BINDING_BIDIRECTIONAL);
+
+ priv->text_changed_handler = g_signal_connect (priv->searchentry, "changed",
+ G_CALLBACK (search_text_changed), win);
+ priv->tab_changed_handler = g_signal_connect (priv->stack, "notify::visible-child",
+ G_CALLBACK (visible_child_changed), win);
+ priv->words_changed_handler = g_signal_connect (priv->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 (priv->gears), menu);
+ g_object_unref (builder);
+
+ action = g_settings_create_action (priv->settings, "show-words");
+ g_action_map_add_action (G_ACTION_MAP (win), action);
+ g_object_unref (action);
+}
+
+static void
+example_app_window_dispose (GObject *object)
+{
+ ExampleAppWindow *win;
+ ExampleAppWindowPrivate *priv;
+
+ win = EXAMPLE_APP_WINDOW (object);
+ priv = example_app_window_get_instance_private (win);
+
+ if (priv->text_changed_handler != 0) {
+ g_signal_handler_disconnect (priv->searchentry, priv->text_changed_handler);
+ priv->text_changed_handler = 0;
+ }
+
+ if (priv->tab_changed_handler != 0) {
+ g_signal_handler_disconnect (priv->stack, priv->tab_changed_handler);
+ priv->tab_changed_handler = 0;
+ }
+
+ if (priv->words_changed_handler != 0) {
+ g_signal_handler_disconnect (priv->sidebar, priv->words_changed_handler);
+ priv->words_changed_handler = 0;
+ }
+
+ g_clear_object (&priv->settings);
+
+ G_OBJECT_CLASS (example_app_window_parent_class)->dispose (object);
+}
+
+static void
+example_app_window_class_init (ExampleAppWindowClass *class)
+{
+ G_OBJECT_CLASS (class)->dispose = example_app_window_dispose;
+
+ gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
+ "/org/gtk/exampleapp/window.ui");
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, stack);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, search);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, searchbar);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, searchentry);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, gears);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, words);
+ gtk_widget_class_bind_child (GTK_WIDGET_CLASS (class), ExampleAppWindowPrivate, sidebar);
+}
+
+ExampleAppWindow *
+example_app_window_new (ExampleApp *app)
+{
+ return g_object_new (EXAMPLE_APP_WINDOW_TYPE, "application", app, NULL);
+}
+
+void
+example_app_window_open (ExampleAppWindow *win,
+ GFile *file)
+{
+ ExampleAppWindowPrivate *priv;
+ gchar *basename;
+ GtkWidget *scrolled, *view;
+ gchar *contents;
+ gsize length;
+ GtkTextBuffer *buffer;
+ GtkTextTag *tag;
+ GtkTextIter start_iter, end_iter;
+
+ priv = example_app_window_get_instance_private (win);
+ basename = g_file_get_basename (file);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolled);
+ gtk_widget_set_hexpand (scrolled, TRUE);
+ gtk_widget_set_vexpand (scrolled, TRUE);
+ view = gtk_text_view_new ();
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+ gtk_widget_show (view);
+ gtk_container_add (GTK_CONTAINER (scrolled), view);
+ gtk_stack_add_titled (GTK_STACK (priv->stack), scrolled, basename, basename);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL)) {
+ gtk_text_buffer_set_text (buffer, contents, length);
+ g_free (contents);
+ }
+
+ tag = gtk_text_buffer_create_tag (buffer, NULL, NULL);
+ g_settings_bind (priv->settings, "font", tag, "font", G_SETTINGS_BIND_DEFAULT);
+
+ gtk_text_buffer_get_start_iter (buffer, &start_iter);
+ gtk_text_buffer_get_end_iter (buffer, &end_iter);
+ gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
+
+ g_free (basename);
+
+ gtk_widget_set_sensitive (priv->search, TRUE);
+
+ update_words (win);
+}
diff --git a/examples/application8/exampleappwin.h b/examples/application8/exampleappwin.h
new file mode 100644
index 0000000..11ff3c2
--- /dev/null
+++ b/examples/application8/exampleappwin.h
@@ -0,0 +1,22 @@
+#ifndef __EXAMPLEAPPWIN_H
+#define __EXAMPLEAPPWIN_H
+
+#include <gtk/gtk.h>
+#include "exampleapp.h"
+
+
+#define EXAMPLE_APP_WINDOW_TYPE (example_app_window_get_type ())
+#define EXAMPLE_APP_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXAMPLE_APP_WINDOW_TYPE,
ExampleAppWindow))
+
+
+typedef struct ExampleAppWindow ExampleAppWindow;
+typedef struct ExampleAppWindowClass ExampleAppWindowClass;
+
+
+GType example_app_window_get_type (void);
+ExampleAppWindow *example_app_window_new (ExampleApp *app);
+void example_app_window_open (ExampleAppWindow *win,
+ GFile *file);
+
+
+#endif /* __EXAMPLEAPPWIN_H */
diff --git a/examples/application8/gears-menu.ui b/examples/application8/gears-menu.ui
new file mode 100644
index 0000000..7e5df31
--- /dev/null
+++ b/examples/application8/gears-menu.ui
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Words</attribute>
+ <attribute name="action">win.show-words</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/examples/application8/main.c b/examples/application8/main.c
new file mode 100644
index 0000000..7ce327a
--- /dev/null
+++ b/examples/application8/main.c
@@ -0,0 +1,15 @@
+#include <gtk/gtk.h>
+#include <exampleapp.h>
+
+int
+main (int argc, char *argv[])
+{
+ /* Since this example is running uninstalled,
+ * we have to help it find its schema. This
+ * is *not* necessary in properly installed
+ * application.
+ */
+ g_setenv ("GSETTINGS_SCHEMA_DIR", ".", FALSE);
+
+ return g_application_run (G_APPLICATION (example_app_new ()), argc, argv);
+}
diff --git a/examples/application8/org.gtk.exampleapp.gschema.xml
b/examples/application8/org.gtk.exampleapp.gschema.xml
new file mode 100644
index 0000000..218ae80
--- /dev/null
+++ b/examples/application8/org.gtk.exampleapp.gschema.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <enum id="org.gtk.exampleapp.Transition">
+ <value value="0" nick="none"/>
+ <value value="1" nick="crossfade"/>
+ <value value="6" nick="slide-left-right"/>
+ </enum>
+ <schema path="/org/gtk/exampleapp/" id="org.gtk.exampleapp">
+ <key name="font" type="s">
+ <default>'Monospace 12'</default>
+ <summary>Font</summary>
+ <description>The font to be used for content.</description>
+ </key>
+ <key name="transition" enum="org.gtk.exampleapp.Transition">
+ <default>'none'</default>
+ <summary>Transition</summary>
+ <description>The transition to use when switching tabs.</description>
+ </key>
+ <key name="show-words" type="b">
+ <default>false</default>
+ <summary>Show words</summary>
+ <description>Whether to show a word list in the sidebar</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/examples/application8/prefs.ui b/examples/application8/prefs.ui
new file mode 100644
index 0000000..4e846b8
--- /dev/null
+++ b/examples/application8/prefs.ui
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <template class="ExampleAppPrefs" parent="GtkDialog">
+ <property name="title" translatable="yes">Preferences</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox">
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="margin">6</property>
+ <property name="row-spacing">12</property>
+ <property name="column-spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="fontlabel">
+ <property name="visible">True</property>
+ <property name="label">_Font:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">font</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFontButton" id="font">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="transitionlabel">
+ <property name="visible">True</property>
+ <property name="label">_Transition:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">transition</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="transition">
+ <property name="visible">True</property>
+ <items>
+ <item translatable="yes" id="none">None</item>
+ <item translatable="yes" id="crossfade">Fade</item>
+ <item translatable="yes" id="slide-left-right">Slide</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="action_area">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="close">
+ <property name="visible">True</property>
+ <property name="label">_Close</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/examples/application8/window.ui b/examples/application8/window.ui
new file mode 100644
index 0000000..7463cc1
--- /dev/null
+++ b/examples/application8/window.ui
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.8 -->
+ <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>
+ <object class="GtkBox" id="content_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHeaderBar" id="header">
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="GtkStackSwitcher" id="tabs">
+ <property name="visible">True</property>
+ <property name="stack">stack</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="search">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <child>
+ <object class="GtkImage" id="search-icon">
+ <property name="visible">True</property>
+ <property name="icon-name">edit-find-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="gears">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImage" id="gears-icon">
+ <property name="visible">True</property>
+ <property name="icon-name">emblem-system-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSearchBar" id="searchbar">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkSearchEntry" id="searchentry">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox" id="hbox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkRevealer" id="sidebar">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-right</property>
+ <child>
+ <object class="GtkScrolledWindow" id="sidebar-sw">
+ <property name="visible">True</property>
+ <property name="hscrollbar-policy">never</property>
+ <property name="vscrollbar-policy">automatic</property>
+ <child>
+ <object class="GtkListBox" id="words">
+ <property name="visible">True</property>
+ <property name="selection-mode">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]