[gnome-devel-docs] Split hello-world.c.page into three tutorials.
- From: Bastian Ilsø Hougaard <bastianilso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Split hello-world.c.page into three tutorials.
- Date: Mon, 9 Feb 2015 18:48:01 +0000 (UTC)
commit a61caf50b515bddd3969cf97c2b877feff076b9f
Author: Bastian Ilsø <bastianilso src gnome org>
Date: Mon Jan 26 18:40:45 2015 +0000
Split hello-world.c.page into three tutorials.
platform-demos/C/buildsystem.page | 85 +++++++++++++++++++
platform-demos/C/dotdesktop.page | 88 ++++++++++++++++++++
platform-demos/C/hello-world.c.page | 152 +++++------------------------------
3 files changed, 195 insertions(+), 130 deletions(-)
---
diff --git a/platform-demos/C/buildsystem.page b/platform-demos/C/buildsystem.page
new file mode 100644
index 0000000..02fb2fc
--- /dev/null
+++ b/platform-demos/C/buildsystem.page
@@ -0,0 +1,85 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:its="http://www.w3.org/2005/11/its"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="buildsystem">
+
+ <info>
+ <!-- The text title is used on the help.gnome.org -->
+ <title type='link'>Setting up the build system (C)</title>
+ <link type="guide" xref="c#examples"/>
+ <revision version="0.1" date="2013-06-17" status="review"/>
+
+ <credit type="author copyright">
+ <name>Susanna Huhtanen</name>
+ <email its:translate="no">ihmis suski gmail com</email>
+ <years>2012</years>
+ </credit>
+ <credit type="editor">
+ <name>Tiffany Antopolski</name>
+ <email its:translate="no">tiffany antopolski gmail com</email>
+ </credit>
+ <credit type="editor">
+ <name>Bastian Ilsø</name>
+ <email its:translate="no">bastianilso gnome org</email>
+ </credit>
+
+ <include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
+
+ <desc>Using autotools to set up a build system for your project.</desc>
+ </info>
+
+ <title>Setting up the build system</title>
+
+ <p>To make your application truly a part of the GNOME 3 system you need
+ to install it with the help of autotools.
+ The autotools build will install all the necessary files to all the right places. </p>
+
+ <p>For this you need to have the following files in your project folder:</p>
+
+ <links type="section"/>
+
+ <section id="autogen">
+ <title>autogen.sh</title>
+
+ <code mime="application/x-shellscript" style="numbered">
+ <xi:include href="samples/hello-in-C/autogen.sh" parse="text"><xi:fallback/></xi:include>
+ </code>
+
+ <p>After the <file>autogen.sh</file> file is ready and saved, run:</p>
+ <screen><output style="prompt">$ </output><input>chmod +x autogen.sh</input></screen>
+ </section>
+
+ <section id="makefile">
+ <title>Makefile.am</title>
+
+ <code mime="application/x-shellscript" style="numbered">
+ <xi:include href="samples/hello-in-C/Makefile.am" parse="text"><xi:fallback/></xi:include>
+ </code>
+ </section>
+
+ <section id="configure">
+ <title>configure.ac</title>
+
+ <code mime="application/x-shellscript" style="numbered">
+ <xi:include href="samples/hello-in-C/configure.ac" parse="text"><xi:fallback/></xi:include>
+ </code>
+ </section>
+
+ <section id="readme">
+ <title>README</title>
+ <p>Information users should read first. This file can be blank.</p>
+
+ <p>When you have the <file>hello-world.c</file>, <file>hello-world.desktop.in</file>,
+ <file>Makefile.am</file>, <file>configure.ac</file> and <file>autogen.sh</file>
+ files with correct information and rights, the <file>README</file> file
+ can include the following instructions:</p>
+
+ <code mime="text/readme" style="numbered">
+ <xi:include href="samples/hello-in-C/README" parse="text"><xi:fallback/></xi:include>
+ </code>
+ </section>
+
+ <!-- TODO: How to make a custom icon with autotools -->
+</page>
diff --git a/platform-demos/C/dotdesktop.page b/platform-demos/C/dotdesktop.page
new file mode 100644
index 0000000..521f6a4
--- /dev/null
+++ b/platform-demos/C/dotdesktop.page
@@ -0,0 +1,88 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:its="http://www.w3.org/2005/11/its"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="dotdesktop">
+
+ <info>
+ <!-- The text title is used on the help.gnome.org -->
+ <title type="link">Make your application appear in the application overview (C)</title>
+ <link type="guide" xref="c#examples"/>
+
+ <revision version="0.1" date="2013-06-17" status="review"/>
+
+ <credit type="author copyright">
+ <name>Susanna Huhtanen</name>
+ <email its:translate="no">ihmis suski gmail com</email>
+ <years>2012</years>
+ </credit>
+ <credit type="editor">
+ <name>Tiffany Antopolski</name>
+ <email its:translate="no">tiffany antopolski gmail com</email>
+ </credit>
+ <credit type="editor">
+ <name>Bastian Ilsø</name>
+ <email its:translate="no">bastianilso gnome org</email>
+ </credit>
+
+ <include href="legal.xml" xmlns="http://www.w3.org/2001/XInclude"/>
+
+ <desc>A guide on creating <file>.desktop</file> files.</desc>
+ </info>
+
+ <title>Make your application appear in the application overview.</title>
+
+ <p>A fully working <link href=
"https://developer.gnome.org/integration-guide/stable/mime.html.en">application integration</link>
+ in GNOME 3 requires a desktop launcher. For this you need to create a
+ <file>.desktop</file> file. The <file>.desktop</file> file describes the
+ application name, the used icon and various integration bits.
+ A deeper insight into the <file>.desktop</file> file can be found
+ <link href= "http://developer.gnome.org/desktop-entry-spec/">here</link>.
+ The <file>.desktop.in</file> file will create the <file>.desktop</file>.</p>
+
+ <p>The example shows you the minimum requirements for a
+ <file>.desktop.in</file> file.</p>
+
+ <code mime="text/desktop" style="numbered">
+ <xi:include href="samples/hello-in-C/hello-world.desktop.in" parse="text"><xi:fallback/></xi:include>
+ </code>
+
+ <p>Now let's go through some parts of the <code>.desktop.in</code> file.</p>
+
+ <terms>
+ <item>
+ <title>Name</title>
+ <p>The application name.</p>
+ </item>
+ <item>
+ <title>Comment</title>
+ <p>A short description of the application.</p>
+ </item>
+ <item>
+ <title>Exec</title>
+ <p>Specifies a command to execute when you choose the application from the menu.
+ In this example exec just tells where to find the <file>hello-world</file>
+ file and the file takes care of the rest.</p>
+ </item>
+ <item>
+ <title>Terminal</title>
+ <p>Specifies whether the command in the Exec key runs
+ in a terminal window.</p>
+ </item>
+ </terms>
+
+ <p>To put your application into the appropriate category, you need to add
+ the necessary categories to the Categories line. More information on the
+ different categories can be found in the
+ <link href = "http://standards.freedesktop.org/menu-spec/latest/apa.html">menu specification</link>.
+ </p>
+
+ <p>In this example we use an existing icon. For a custom icon you need to
+ have a .svg file of your icon, stored in <file>/usr/share/icons/hicolor/scalable/apps</file>.
+ Write the name of your icon file to the .desktop.in file, on line 7.
+ More information on icons in:
+ <link href="https://live.gnome.org/GnomeGoals/AppIcon">Installing Icons for Themes</link>
+ and <link href="http://freedesktop.org/wiki/Specifications/icon-theme-spec">on freedesktop.org:
Specifications/icon-theme-spec</link>.</p>
+
+</page>
diff --git a/platform-demos/C/hello-world.c.page b/platform-demos/C/hello-world.c.page
index 06b58d5..c236dd8 100644
--- a/platform-demos/C/hello-world.c.page
+++ b/platform-demos/C/hello-world.c.page
@@ -3,13 +3,12 @@
xmlns:its="http://www.w3.org/2005/11/its"
xmlns:xi="http://www.w3.org/2001/XInclude"
type="guide" style="task"
- id="hello-world.c">
+ id="hello-world">
<info>
- <title type="text">Hello World (C)</title>
- <desc>How to create GTK+ 3 Hello World dialog in C.</desc>
+ <!-- The text title is used on the help.gnome.org -->
+ <title type="link">Hello World (C)</title>
<link type="guide" xref="c#examples"/>
-
<revision version="0.1" date="2013-06-17" status="review"/>
<credit type="author copyright">
@@ -25,136 +24,29 @@
<name>Bastian Ilsø</name>
<email its:translate="no">bastianilso gnome org</email>
</credit>
- </info>
-
- <title>Hello World</title>
- <media type="image" mime="image/png" style="floatend" src="media/hello-world.png"/>
- <p>This beginner tutorial will cover the following topics:</p>
- <links type="section" />
- <p>The tutorial will introduce you to writing a <file>helloworld.c</file>, containing the following C
code:</p>
- <code mime="text/x-csrc" style="numbered"><xi:include href="samples/hello-in-C/hello-world.c"
parse="text"><xi:fallback/></xi:include></code>
-
-
- <section id="hello-world">
- <title>Creating a small "Hello, World" application using GTK+</title>
- <media type="image" mime="image/png" src="media/hello-world-dialog-overview.png"/>
- <p>GTK+ applications are </p>
-
- <p>Start by creating an empty folder containing a file named <file>helloworld.c</file>. Open
<file>helloworld.c</file> and import the GTK+ headers to your helloworld project via the following line.</p>
-
- <code mime="text/x-csrc"><![CDATA[#include <gtk/gtk.h>]]></code>
-
- <p>Next, the main window for the application is created.</p>
- <code mime="text/x-csrc"><![CDATA[
-static void
-activate (GtkApplication* app,
- gpointer user_data)
-{
- GtkWidget *window;
-
- window = gtk_application_window_new (app);
- gtk_window_set_title (GTK_WINDOW (window), "Hello World");
- gtk_window_set_default_size (GTK_WINDOW (window), 200, 100);
- gtk_widget_show_all (window);
-}
-]]></code>
-
- <p>GtkApplication initializes GTK+. It also connects the <gui>x</gui> button that's automatically
generated along with the window to the "destroy" signal.</p>
- <p>We can start building our first window. We do this by creating a variable called <var>window</var>
and assigning it a gtk_application_window_new</p>
- <p>The window title can be any string you want it to be. To be on the safe side, it's best to stick to
UTF-8 encoding.</p>
- <p>Now we have a window which has a title and a working "close" button. Let's add the actual "Hello
World" text.</p>
-
- <section id="label"><title>Label for the window</title>
- <code mime="text/x-csrc"><![CDATA[GtkWidget *label;
-
- label = gtk_label_new ("Hello World!");
- gtk_container_add (GTK_CONTAINER (window), label);
-]]></code>
-
- <p>Finally, we create and run the application:</p>
-
- <code mime="text/x-csrc"><![CDATA[int
-main (int argc,
- char **argv)
-{
- GtkApplication *app;
- int status;
-
- app = gtk_application_new (NULL, 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>GtkApplicationWindow can only hold one widget at a time. To construct more elaborate programs you
need to create a holder widget like GtkGrid inside the window, and then add all the other widgets to it.</p>
- </section>
-
-
- <section id="c"><title>hello-world.c</title>
- <p>The complete file:</p>
- <code mime="text/x-csrc" style="numbered"><xi:include href="samples/hello-in-C/hello-world.c"
parse="text"><xi:fallback/></xi:include></code>
- </section>
-
- <section id="terminal"><title>Running the application from terminal</title>
- <p>To run this application, first save it as hello-world.c. Then open Terminal, go to the folder where
your application is stored.</p>
- <p>Compile the program:</p>
- <screen>gcc <var>hello-world</var>.c `pkg-config --cflags --libs gtk+-3.0` -o
<var>hello-world</var></screen>
- <p>Run the program:</p>
- <screen>./<var>hello-world</var></screen>
- </section>
- </section>
-
- <section id="desktop.in"><title>Making the <file>.desktop</file> file</title>
- <p>Running applications from the Terminal is useful at the beginning of the application making
process. To have fully working <link href=
"https://developer.gnome.org/integration-guide/stable/mime.html.en">application integration</link> in GNOME 3
requires a desktop launcher. For this you need to create a <file>.desktop</file> file. The
<file>.desktop</file> file describes the application name, the used icon and various integration bits. A
deeper insight into the <file>.desktop</file> file can be found <link href=
"http://developer.gnome.org/desktop-entry-spec/">here</link>. The <file>.desktop.in</file> file will create
the <file>.desktop</file>.</p>
-
- <p>The example shows you the minimum requirements for a <code>.desktop.in</code> file.</p>
- <code mime="text/desktop" style="numbered"><xi:include href="samples/hello-in-C/hello-world.desktop.in"
parse="text"><xi:fallback/></xi:include></code>
-
- <p>Now let's go through some parts of the <code>.desktop.in</code> file.</p>
- <terms>
- <item><title>Name</title><p>The application name.</p></item>
- <item><title>Comment</title><p>A short description of the application.</p></item>
- <item><title>Exec</title><p>Specifies a command to execute when you choose the application from the
menu. In this example exec just tells where to find the <file>hello-world</file> file and the file takes care
of the rest.</p></item>
- <item><title>Terminal</title><p>Specifies whether the command in the Exec key runs in a terminal
window.</p></item>
- </terms>
-
- <p>To put your application into the appropriate category, you need to add the necessary categories to
the Categories line. More information on the different categories can be found in the <link href =
"http://standards.freedesktop.org/menu-spec/latest/apa.html">menu specification</link>.</p>
- <p>In this example we use an existing icon. For a custom icon you need to have a .svg file of your icon,
stored in <file>/usr/share/icons/hicolor/scalable/apps</file>. Write the name of your icon file to the
.desktop.in file, on line 7. More information on icons in: <link
href="https://live.gnome.org/GnomeGoals/AppIcon">Installing Icons for Themes</link> and <link
href="http://freedesktop.org/wiki/Specifications/icon-theme-spec">on freedesktop.org:
Specifications/icon-theme-spec</link>.</p>
- </section>
-
- <section id="autotools"><title>Setting up the build system</title>
- <p>To make your application truly a part of the GNOME 3 system you need to install it with the help of
autotools. The autotools build will install all the necessary files to all the right places. </p>
- <p>For this you need to have the following files:</p>
- <links type="section"/>
-
- <section id="autogen"><title>autogen.sh</title>
- <code mime="application/x-shellscript" style="numbered"><xi:include
href="samples/hello-in-C/autogen.sh" parse="text"><xi:fallback/></xi:include></code>
-
- <p>After the <file>autogen.sh</file> file is ready and saved, run:</p>
- <screen><output style="prompt">$ </output><input>chmod +x autogen.sh</input></screen>
- </section>
-
-
- <section id="makefile"><title>Makefile.am</title>
- <code mime="application/x-shellscript" style="numbered"><xi:include
href="samples/hello-in-C/Makefile.am" parse="text"><xi:fallback/></xi:include></code>
- </section>
-
-
- <section id="configure"><title>configure.ac</title>
- <code mime="application/x-shellscript" style="numbered"><xi:include
href="samples/hello-in-C/configure.ac" parse="text"><xi:fallback/></xi:include></code>
- </section>
+ <desc>Creating a small "Hello, World" application using GTK+.</desc>
+ </info>
+ <title>Hello world</title>
- <section id="readme"><title>README</title>
- <p>Information users should read first. This file can be blank.</p>
+ <note>
+ <p>For a detailed walk-through of creating a GTK+ dialog in C, see
+ <link href="https://developer.gnome.org/gtk3/stable/gtk-getting-started.html">Getting Started with
GTK+</link></p>
+ </note>
- <p>When you have the <file>hello-world.c</file>, <file>hello-world.desktop.in</file>,
<file>Makefile.am</file>, <file>configure.ac</file> and <file>autogen.sh</file> files with correct
information and rights, the <file>README</file> file can include the following instructions:</p>
- <code mime="text/readme" style="numbered"><xi:include href="samples/hello-in-C/README"
parse="text"><xi:fallback/></xi:include></code>
- </section>
+ <p>Writing a hello world GTK+ dialog in C can be done as seen in the code sample below:</p>
+ <code mime="text/x-csrc" style="numbered">
+ <xi:include href="samples/hello-in-C/hello-world.c" parse="text"><xi:fallback/></xi:include>
+ </code>
- <!-- TODO: How to make a custom icon with autotools -->
+ <p>GtkApplication initializes GTK+. It also connects the <gui>x</gui> button
+ that's automatically generated along with the window to the "destroy" signal.
+ We can start building our first window.
+ We do this by creating a variable called <var>window</var> and assigning it
+ a gtk_application_window_new. The window title can be any string you want it
+ to be. To be on the safe side, it's best to stick to UTF-8 encoding.
+ The code above will create a dialog window similar to what can be seen below:</p>
- </section>
+ <media type="image" mime="image/png" src="media/hello-world.png"/>
</page>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]