[gnome-devel-docs/wip/develguide-gtkapp: 1/4] Add a skeleton GtkApplication example
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs/wip/develguide-gtkapp: 1/4] Add a skeleton GtkApplication example
- Date: Fri, 2 May 2014 09:32:50 +0000 (UTC)
commit 43ef7703bbb4811edbc4e4952f4e5041a3515c1c
Author: David King <amigadave amigadave com>
Date: Wed Apr 30 18:06:29 2014 +0200
Add a skeleton GtkApplication example
devel-guide/C/examples/gtkapp-helloworld.c | 19 ++++++++++
devel-guide/C/gtkapplication-helloworld.page | 48 ++++++++++++++++++++++++++
devel-guide/Makefile.am | 4 ++
3 files changed, 71 insertions(+), 0 deletions(-)
---
diff --git a/devel-guide/C/examples/gtkapp-helloworld.c b/devel-guide/C/examples/gtkapp-helloworld.c
new file mode 100644
index 0000000..12e54d8
--- /dev/null
+++ b/devel-guide/C/examples/gtkapp-helloworld.c
@@ -0,0 +1,19 @@
+/* gtkapp-helloworld.c: Build with:
+ * gcc `pkg-config --cflags gtk+-3.0` -o gtkapp-helloworld gtkapp-helloworld.c `pkg-config --libs gtk+-3.0`
+ */
+#include <gtk/gtk.h>
+
+int
+main (int argc, char **argv)
+{
+ GtkApplication *app;
+ int result;
+
+ /* com.example.MyApp is a unique application identifier. */
+ app = gtk_application_new ("com.example.MyApp", G_APPLICATION_FLAGS_NONE);
+ result = g_application_run (G_APPLICATION (app), argc, argv);
+
+ g_object_unref (app);
+
+ return result;
+}
diff --git a/devel-guide/C/gtkapplication-helloworld.page b/devel-guide/C/gtkapplication-helloworld.page
new file mode 100644
index 0000000..7327389
--- /dev/null
+++ b/devel-guide/C/gtkapplication-helloworld.page
@@ -0,0 +1,48 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:its="http://www.w3.org/2005/11/its"
+ type="topic" style="task"
+ id="gtkapplication-helloworld">
+
+ <info>
+ <link type="next" xref="gtkapplication-window"/>
+ <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>Hello world!</title>
+
+ <links type="series" style="floatend">
+ <title>GtkApplication</title>
+ </links>
+
+ <p>Use GtkApplication to make managing the lifecycle of your application
+ easier.</p>
+
+ <p>An application written with GTK+ has many complexities, such as a main
+ loop to handle events, a connection to the display server and showing an
+ application menu in the desktop shell. GtkApplication encapsulates all these
+ concepts (and more) into one easy-to-use object.</p>
+
+ <p>A simple GTK+ application using GtkApplication is as follows:</p>
+ <example>
+ <listing>
+ <title><file>gtkapp-helloworld.c</file></title>
+<code mime="text/x-csrc">
+<include href="examples/gtkapp-helloworld.c" parse="text" xmlns="http://www.w3.org/2001/XInclude"/>
+</code>
+ </listing>
+ </example>
+
+ <p>The example creates an application, runs it and then returns the result to
+ the system. Internally, it registers the application with the session, starts
+ a main loop and connects to the display server.</p>
+
+</page>
diff --git a/devel-guide/Makefile.am b/devel-guide/Makefile.am
index ef41c7e..59d9829 100644
--- a/devel-guide/Makefile.am
+++ b/devel-guide/Makefile.am
@@ -19,6 +19,7 @@ HELP_FILES = \
extension-twitter.page \
extension-widget.page \
gtkapplication.page \
+ gtkapplication-helloworld.page \
help-appmenu.page \
help-build.page \
help.page \
@@ -26,6 +27,9 @@ HELP_FILES = \
index.page \
legal.xml
+HELP_EXTRA = \
+ examples/gtkapp-helloworld.c
+
HELP_MEDIA =
HELP_LINGUAS =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]