[gnome-devel-docs/wip/develguide: 16/18] Add window example to GtkApplication guide



commit e166a1d0e2d1a6f5cd2cffd84b29e58a552f891c
Author: David King <amigadave amigadave com>
Date:   Thu May 1 10:18:41 2014 +0200

    Add window example to GtkApplication guide

 devel-guide/C/examples/gtkapp-window.c   |   30 ++++++++++++++++++++
 devel-guide/C/gtkapplication-window.page |   45 ++++++++++++++++++++++++++++++
 devel-guide/Makefile.am                  |    4 ++-
 3 files changed, 78 insertions(+), 1 deletions(-)
---
diff --git a/devel-guide/C/examples/gtkapp-window.c b/devel-guide/C/examples/gtkapp-window.c
new file mode 100644
index 0000000..302c019
--- /dev/null
+++ b/devel-guide/C/examples/gtkapp-window.c
@@ -0,0 +1,30 @@
+#include <gtk/gtk.h>
+
+static void
+on_activate (GApplication *app,
+             gpointer user_data)
+{
+    GtkWidget *window;
+
+    /* Application windows are associated with a GtkApplication. */
+    window = gtk_application_window_new (GTK_APPLICATION (app));
+    gtk_widget_show (window);
+}
+
+int
+main (int argc, char **argv)
+{
+    GApplication *app;
+    int result;
+
+    /* com.example.MyApp is a unique application identifier. */
+    app = gtk_application_new ("com.example.MyApp", G_APPLICATION_FLAGS_NONE);
+
+    g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
+
+    result = g_application_run (app, argc, argv);
+
+    g_object_unref (app);
+
+    return result;
+}
diff --git a/devel-guide/C/gtkapplication-window.page b/devel-guide/C/gtkapplication-window.page
new file mode 100644
index 0000000..dab964b
--- /dev/null
+++ b/devel-guide/C/gtkapplication-window.page
@@ -0,0 +1,45 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:its="http://www.w3.org/2005/11/its";
+      type="topic" style="task"
+      id="gtkapplication-window">
+
+  <info>
+    <link type="next" xref="gtkapplication-actions"/>
+    <revision pkgversion="3.14" date="2014-04-30" status="draft"/>
+
+    <credit type="author">
+      <name>David King</name>
+      <email its:translate="no">davidk gnome org</email>
+      <years>2014</years>
+    </credit>
+
+    <include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
+
+  </info>
+
+  <title>Application windows</title>
+
+  <links type="series" style="floatend">
+    <title>GtkApplication</title>
+  </links>
+
+  <p>Add an application window.</p>
+  
+  <p>Adding application menus and actions depends on using
+  GtkApplicationWindow.</p>
+
+  <p>A simple application using GtkApplicationWindow is as follows:</p>
+  <example>
+    <listing> 
+      <title><file>gtkapp-window.c</file></title>
+<code mime="text/x-csrc">
+<include href="examples/gtkapp-window.c" parse="text" xmlns="http://www.w3.org/2001/XInclude"/>
+</code>
+    </listing>
+  </example>
+
+  <p>The example creates an application, adds an application window to it,
+  shows the window and runs the application. The application terminates as soon
+  as the last window has been closed.</p>
+ 
+</page>
diff --git a/devel-guide/Makefile.am b/devel-guide/Makefile.am
index 59d9829..5308ea7 100644
--- a/devel-guide/Makefile.am
+++ b/devel-guide/Makefile.am
@@ -20,6 +20,7 @@ HELP_FILES = \
         extension-widget.page \
        gtkapplication.page \
        gtkapplication-helloworld.page \
+       gtkapplication-window.page \
         help-appmenu.page \
         help-build.page \
         help.page \
@@ -28,7 +29,8 @@ HELP_FILES = \
        legal.xml
 
 HELP_EXTRA = \
-       examples/gtkapp-helloworld.c
+       examples/gtkapp-helloworld.c \
+       examples/gtkapp-window.c
 
 HELP_MEDIA =
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]