[gnome-devel-docs] demos: add build and install instructions for Vala
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] demos: add build and install instructions for Vala
- Date: Tue, 18 Jun 2013 21:32:52 +0000 (UTC)
commit a3624d099ff912a6dee2588f0ed9b1d223722ecf
Author: Tiffany Ann Antopolski <tiffany antopolski gmail com>
Date: Tue Jun 18 17:30:48 2013 -0400
demos: add build and install instructions for Vala
- some reorganisation was necessary to do this.
platform-demos/C/hello-world.c.page | 18 ++--
platform-demos/C/hello-world.vala.page | 127 ++++++++++++++++++++++++-
platform-demos/C/part-1.vala.page | 2 +-
platform-demos/C/part-2.vala.page | 2 +-
platform-demos/C/part-3.vala.page | 2 +-
platform-demos/C/part-4.vala.page | 2 +-
platform-demos/C/part-5.vala.page | 2 +-
platform-demos/C/part-6.vala.page | 2 +-
platform-demos/C/samples/hello-in-vala/README | 43 +++++++++
platform-demos/Makefile.am | 7 ++
10 files changed, 187 insertions(+), 20 deletions(-)
---
diff --git a/platform-demos/C/hello-world.c.page b/platform-demos/C/hello-world.c.page
index 909c5de..20bf271 100644
--- a/platform-demos/C/hello-world.c.page
+++ b/platform-demos/C/hello-world.c.page
@@ -46,7 +46,7 @@
</section>
<section id="application"><title>Creating the main window for the application</title>
- <code mime="text/x-xcsrc"><![CDATA[static void
+ <code mime="text/x-csrc"><![CDATA[static void
activate (GtkApplication* app,
gpointer user_data)
{
@@ -59,9 +59,9 @@ activate (GtkApplication* app,
}
]]></code>
- <p>Gtk.Application 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 class called <var>MyWindow</var> and
assigning it a Gtk.ApplicationWindow.</p>
- <p>We give the window a property called <var>title</var>. The 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>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>
@@ -101,7 +101,7 @@ main (int argc,
<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>filename</var></screen>
+ <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>
@@ -111,7 +111,7 @@ main (int argc,
<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-python/hello-world.desktop.in" parse="text"><xi:fallback/></xi:include></code>
+ <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>
@@ -131,7 +131,7 @@ main (int argc,
<links type="section"/>
<section id="autogen"><title>autogen.sh</title>
- <code mime="application/x-shellscript" style="numbered"><xi:include
href="samples/hello-in-python/autogen.sh" parse="text"><xi:fallback/></xi:include></code>
+ <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>
@@ -139,12 +139,12 @@ main (int argc,
<section id="makefile"><title>Makefile.am</title>
- <code mime="application/x-shellscript" style="numbered"><xi:include
href="samples/hello-in-python/Makefile.am" parse="text"><xi:fallback/></xi:include></code>
+ <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-python/configure.ac" parse="text"><xi:fallback/></xi:include></code>
+ <code mime="application/x-shellscript" style="numbered"><xi:include
href="samples/hello-in-C/configure.ac" parse="text"><xi:fallback/></xi:include></code>
</section>
diff --git a/platform-demos/C/hello-world.vala.page b/platform-demos/C/hello-world.vala.page
index 2e3362f..5670d28 100644
--- a/platform-demos/C/hello-world.vala.page
+++ b/platform-demos/C/hello-world.vala.page
@@ -1,22 +1,139 @@
<?xml version='1.0' encoding='UTF-8'?>
<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
type="guide" style="task"
id="hello-world.vala">
<info>
- <link type="guide" xref="beginner.vala#tutorials"/>
- <revision version="0.1" date="2012-02-20" status="stub"/>
+ <title type="text">Hello World (Vala)</title>
+ <link type="guide" xref="beginner.vala#tutorials" group="#first"/>
+
+ <revision version="0.1" date="2013-06-17" status="review"/>
<credit type="author copyright">
+ <name>Susanna Huhtanen</name>
+ <email>ihmis suski gmail com</email>
+ <years>2012</years>
+ </credit>
+ <credit type="editor">
<name>Tiffany Antopolski</name>
<email>tiffany antopolski gmail com</email>
- <years>2012</years>
</credit>
- <desc></desc>
+ <desc>A basic "hello, world" application</desc>
</info>
- <title>i. Hello World</title>
+ <title>How to build, install and create a <file>tar.xz</file> of a Hello World program</title>
+ <media type="image" mime="image/png" style="floatend" src="media/hello-world.png"/>
+ <synopsis>
+ <p>This tutorial will demonstrate how to:</p>
+ <list style="numbered">
+ <item><p>create a small "Hello, World" application using GTK+</p></item>
+ <item><p>make the <file>.desktop</file> file</p></item>
+ <item><p>how to set up the build system</p></item>
+ </list>
+ </synopsis>
+
+ <links type="section" />
+
+ <section id="hello-world"><title>Create the program</title>
+
+ <links type="section" />
+
+ <section id="application"><title>Creating the main window for the application</title>
+ <code mime="text/x-csharp"><![CDATA[class MyApplication : Gtk.Application {
+ protected override void activate () {
+ var window = new Gtk.ApplicationWindow (this);
+ window.set_title ("Welcome to GNOME");
+ window.set_default_size (200, 100);
+ window.show_all ();
+ }
+}]]></code>
+
+ <p>Gtk.Application 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 new Gtk.ApplicationWindow.</p>
+ <p>We give the window a title using <code>set_title</code>. The 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>
+
+ <section id="label"><title>Label for the window</title>
+ <code mime="text/x-csharp"><![CDATA[var label = new Gtk.Label ("Hello GNOME!");
+ window.add (label);
+]]></code>
+
+ <p>Finally, we create and run the application:</p>
+
+ <code mime="text/x-csharp"><![CDATA[int main (string[] args) {
+ return new MyApplication ().run (args);
+}]]></code>
+
+ <p>Gtk.ApplicationWindow can only hold one widget at a time. To construct more elaborate programs you
need to create a holder widget like Gtk.Grid inside the window, and then add all the other widgets to it.</p>
+ </section>
+
+
+ <section id="vala"><title>hello-world.vala</title>
+ <p>The complete file:</p>
+ <code mime="text/x-csharp" style="numbered"><xi:include href="samples/hello-in-vala/hello-world.vala"
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.vala. Then open Terminal, go to the folder
where your application is stored.</p>
+ <p>Compile the program:</p>
+ <screen>valac --pkg gtk+-3.0 <file>hello-world.vala</file></screen>
+ <p>Run the program:</p>
+ <screen>./<var>hello-world</var></screen>
+ </section>
+ </section>
+
+ <section id="desktop.in"><title>The <file>.desktop.in</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-vala/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>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-vala/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-vala/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-vala/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-vala/README"
parse="text"><xi:fallback/></xi:include></code>
+ </section>
+ <!-- TODO: How to make a custom icon with autotools -->
+ </section>
</page>
diff --git a/platform-demos/C/part-1.vala.page b/platform-demos/C/part-1.vala.page
index a85edfc..f2b667c 100644
--- a/platform-demos/C/part-1.vala.page
+++ b/platform-demos/C/part-1.vala.page
@@ -3,7 +3,7 @@
type="topic" style="task"
id="part-1.vala">
<info>
- <link type="guide" xref="hello-world.vala"/>
+ <link type="guide" xref="anjuta-hello-world.vala"/>
<link type="next" xref="part-2.vala"/>
<title type="link" role="series">
Your first GTK+ application
diff --git a/platform-demos/C/part-2.vala.page b/platform-demos/C/part-2.vala.page
index 36ce231..54498f1 100644
--- a/platform-demos/C/part-2.vala.page
+++ b/platform-demos/C/part-2.vala.page
@@ -3,7 +3,7 @@
type="topic" style="task"
id="part-2.vala">
<info>
- <link type="guide" xref="hello-world.vala"/>
+ <link type="guide" xref="anjuta-hello-world.vala"/>
<link type="next" xref="part-3.vala"/>
<revision version="0.1" date="2012-02-20" status="stub"/>
diff --git a/platform-demos/C/part-3.vala.page b/platform-demos/C/part-3.vala.page
index ae00c40..9732dfe 100644
--- a/platform-demos/C/part-3.vala.page
+++ b/platform-demos/C/part-3.vala.page
@@ -3,7 +3,7 @@
type="topic" style="task"
id="part-3.vala">
<info>
- <link type="guide" xref="hello-world.vala"/>
+ <link type="guide" xref="anjuta-hello-world.vala"/>
<link type="next" xref="part-4.vala"/>
<revision version="0.1" date="2012-02-20" status="stub"/>
diff --git a/platform-demos/C/part-4.vala.page b/platform-demos/C/part-4.vala.page
index c447ac4..19cfd4a 100644
--- a/platform-demos/C/part-4.vala.page
+++ b/platform-demos/C/part-4.vala.page
@@ -3,7 +3,7 @@
type="topic" style="task"
id="part-4.vala">
<info>
- <link type="guide" xref="hello-world.vala"/>
+ <link type="guide" xref="anjuta-hello-world.vala"/>
<link type="next" xref="part-5.vala"/>
<revision version="0.1" date="2012-02-20" status="stub"/>
diff --git a/platform-demos/C/part-5.vala.page b/platform-demos/C/part-5.vala.page
index c7d74c2..754510a 100644
--- a/platform-demos/C/part-5.vala.page
+++ b/platform-demos/C/part-5.vala.page
@@ -3,7 +3,7 @@
type="topic" style="task"
id="part-5.vala">
<info>
- <link type="guide" xref="hello-world.vala"/>
+ <link type="guide" xref="anjuta-hello-world.vala"/>
<link type="next" xref="part-6.vala"/>
<revision version="0.1" date="2012-02-20" status="stub"/>
diff --git a/platform-demos/C/part-6.vala.page b/platform-demos/C/part-6.vala.page
index f67f229..4781feb 100644
--- a/platform-demos/C/part-6.vala.page
+++ b/platform-demos/C/part-6.vala.page
@@ -3,7 +3,7 @@
type="topic" style="task"
id="part-6.vala">
<info>
- <link type="guide" xref="hello-world.vala"/>
+ <link type="guide" xref="anjuta-hello-world.vala"/>
<revision version="0.1" date="2012-02-20" status="stub"/>
<credit type="author copyright">
diff --git a/platform-demos/C/samples/hello-in-vala/README b/platform-demos/C/samples/hello-in-vala/README
index e69de29..7c69201 100644
--- a/platform-demos/C/samples/hello-in-vala/README
+++ b/platform-demos/C/samples/hello-in-vala/README
@@ -0,0 +1,43 @@
+To build and install this program:
+
+./autogen.sh --prefix=/home/your_username/.local
+make
+make install
+
+-------------
+Running the first line above creates the following files:
+
+aclocal.m4
+autom4te.cache
+config.log
+config.status
+configure
+depcomp
+hello-world
+hello-world.c
+hello-world.desktop
+hello_world-hello-world.o
+hello_world_vala.stamp
+install-sh
+missing
+Makefile.in
+Makefile
+
+Running "make" links all the appropriate libraries.
+
+Running "make install", installs the application in /home/your_username/.local/bin
+and installs the hello-world.desktop file in /home/your_username/.local/share/applications
+
+You can now run the application by typing "Hello World" in the Overview.
+
+----------------
+To uninstall, type:
+
+make uninstall
+
+----------------
+To create a tarball type:
+
+make distcheck
+
+This will create hello-world-1.0.tar.xz
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index de63d32..3b88ad3 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -94,6 +94,12 @@ demo_sources = \
samples/hello-in-python/hello-world.desktop.in\
samples/hello-in-python/Makefile.am \
samples/hello-in-python/README \
+ samples/hello-in-vala/autogen.sh \
+ samples/hello-in-vala/configure.ac \
+ samples/hello-in-vala/hello-world.vala \
+ samples/hello-in-vala/hello-world.desktop.in\
+ samples/hello-in-vala/Makefile.am \
+ samples/hello-in-vala/README \
samples/image.c \
samples/image.js \
samples/image.py \
@@ -342,6 +348,7 @@ HELP_FILES = \
hello-world.c.page \
hello-world.js.page \
hello-world.py.page \
+ hello-world.vala.page \
image.c.page \
image.js.page \
image.py.page \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]