[gnome-devel-docs] samples c: GtkApplication with GtkWindow example.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] samples c: GtkApplication with GtkWindow example.
- Date: Mon, 23 Apr 2012 13:30:49 +0000 (UTC)
commit 20a932781d41864deaaf3cb6101ede57e3d5a48a
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Mon Apr 23 09:29:04 2012 -0400
samples c: GtkApplication with GtkWindow example.
Also:
- included compilation instructions for c programs in beginner.c.page
- updated Makefile.
platform-demos/C/beginner.c.page | 11 +++++++
platform-demos/C/samples/window.c | 28 +++++++++++++++++
platform-demos/C/window.c.page | 59 +++++++++++++++++++++++++++++++++++++
platform-demos/Makefile.am | 1 +
4 files changed, 99 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/beginner.c.page b/platform-demos/C/beginner.c.page
index 6871704..8daed97 100644
--- a/platform-demos/C/beginner.c.page
+++ b/platform-demos/C/beginner.c.page
@@ -32,6 +32,17 @@
<section id="samples">
<title>Code samples</title>
+ <p>
+ To run the code samples:
+ </p>
+ <steps>
+ <item><p>Copy and paste the code into <var>filename</var>.c</p></item>
+ <item><p>In the terminal type:</p>
+ <screen>gcc <var>filename</var>.c `pkg-config --cflags --libs gtk+-3.0` -o <var>filename</var>
+</screen>
+ <screen>./<var>filename</var></screen>
+ </item>
+ </steps>
<section id="windows"><title>Windows</title>
<p></p>
</section>
diff --git a/platform-demos/C/samples/window.c b/platform-demos/C/samples/window.c
new file mode 100644
index 0000000..309521e
--- /dev/null
+++ b/platform-demos/C/samples/window.c
@@ -0,0 +1,28 @@
+#include <gtk/gtk.h>
+
+static void
+activate (GtkApplication *app,
+ gpointer user_data)
+{
+ GtkWidget *window;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app));
+ gtk_window_set_title (GTK_WINDOW (window), "Hello GNOME");
+
+ gtk_widget_show_all (GTK_WIDGET (window));
+}
+
+int
+main (int argc, char **argv)
+{
+ GtkApplication *app;
+ int status;
+
+ app = gtk_application_new ("org.gtk.example",G_APPLICATION_FLAGS_NONE);
+ g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+ status = g_application_run (G_APPLICATION (app), argc, argv);
+ g_object_unref (app);
+ return status;
+}
diff --git a/platform-demos/C/window.c.page b/platform-demos/C/window.c.page
new file mode 100644
index 0000000..6bf1d4b
--- /dev/null
+++ b/platform-demos/C/window.c.page
@@ -0,0 +1,59 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ type="guide" style="task"
+ id="window.c">
+ <info>
+ <link type="guide" xref="beginner.c#windows"/>
+ <revision version="0.1" date="2012-04-07" status="stub"/>
+
+ <credit type="author copyright">
+ <name>Tiffany Antopolski</name>
+ <email>tiffany antopolski gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A toplevel window which can contain other widgets</desc>
+ </info>
+
+ <title>Window</title>
+ <media type="image" mime="image/png" src="media/window.png"/>
+ <p>A minimal GtkApplication.</p>
+
+ <code mime="text/x-csrc" style="numbered"><![CDATA[
+#include <gtk/gtk.h>
+
+static void
+activate (GtkApplication *app,
+ gpointer user_data)
+{
+ GtkWidget *window;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app));
+ gtk_window_set_title (GTK_WINDOW (window), "Hello GNOME");
+
+ gtk_widget_show_all (GTK_WIDGET (window));
+}
+
+int
+main (int argc, char **argv)
+{
+ GtkApplication *app;
+ int status;
+
+ app = gtk_application_new ("org.gtk.example",G_APPLICATION_FLAGS_NONE);
+ g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+ status = g_application_run (G_APPLICATION (app), argc, argv);
+ g_object_unref (app);
+ return status;
+}
+]]></code>
+<p>
+ In this sample we used the following:
+</p>
+<list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplication.html">GtkApplication</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html">GtkWindow</link></p></item>
+
+</list>
+</page>
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index b81a87b..5a92ac7 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -91,6 +91,7 @@ DOC_PAGES = \
weatherAppMain.js.page \
weatherAutotools.js.page \
weatherGeonames.js.page \
+ window.c.page \
window.js.page \
window.py.page \
window.vala.page
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]