[gnome-devel-docs] vala tutorial: more rough work in beginner tutorials.



commit 7e1cfcfc329a9d9e198fbd63dae9937b037c8d45
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date:   Tue Feb 21 01:55:52 2012 +0100

    vala tutorial: more rough work in beginner tutorials.

 platform-demos/C/getting-started.vala.page         |   31 -------
 platform-demos/C/hello-world.vala.page             |    2 +-
 platform-demos/C/part-1.vala.page                  |   96 +++++++++++++++++++-
 .../C/signals-and-callbacks.vala.page.stub         |   32 -------
 platform-demos/C/toolbars.vala.page                |    2 +-
 5 files changed, 96 insertions(+), 67 deletions(-)
---
diff --git a/platform-demos/C/hello-world.vala.page b/platform-demos/C/hello-world.vala.page
index c9840f3..56f049f 100644
--- a/platform-demos/C/hello-world.vala.page
+++ b/platform-demos/C/hello-world.vala.page
@@ -15,7 +15,7 @@
     <desc></desc>
   </info>
 
-  <title>ii. Hello World</title>
+  <title>i. Hello World</title>
 
 
 </page>
diff --git a/platform-demos/C/part-1.vala.page b/platform-demos/C/part-1.vala.page
index 23d0148..b057514 100644
--- a/platform-demos/C/part-1.vala.page
+++ b/platform-demos/C/part-1.vala.page
@@ -15,10 +15,102 @@
       <years>2012</years>
     </credit>
 
-    <desc></desc>
+    <desc>An intro to Anjuta's interface builder</desc>
   </info>
 
   <title>Part 1: Your first Gtk+ application</title>
-  <links type="series" style="floatright"/>
+  <links type="series" style="floatend"/>
+
+<synopsis>
+  <p>This tutorial is a brief introduction to Anjuta's interface builder.</p>
+  <p>In this tutorial you will create a very simple application.</p>
+  <p>You'll need an installed copy of <app>Anjuta</app> to be able to follow this tutorial.</p>
+</synopsis>
+
+<media type="image" mime="image/png" src="media/hello-world-label.png" width="300"/>
+
+<section id="anjuta">
+  <title>Create a project in Anjuta</title>
+  <p>Anjuta will create all of the files you need to build and run your application.
+  It's also a very useful tool for keeping everything together.</p>
+  <steps>
+    <item>
+      <p>Start <app>Anjuta</app> and click <gui>Create a new project</gui> or <guiseq><gui>File</gui><gui>New</gui><gui>Project</gui></guiseq> to open the project wizard.</p>
+    </item>
+    <item>
+      <p>Choose <gui>Gtk+ (Simple)</gui> from the <gui>Vala</gui> tab, click <gui>Forward</gui>, and fill out your details on the next few pages.
+      Use <file>hello-world</file> as the project name and directory. Click <gui>Continue</gui>.</p>
+   	</item>
+    <item>
+      <p>Click <gui>Apply</gui> and the project will be created for you.</p>
+    </item>
+  </steps>
+
+<p>From the <gui>Project</gui> or <gui>Files</gui> tab, open <file>src/hello_world.vala</file> by double-clicking on it. You should see some code:</p>
+    <code mime="text/x-valasrc"><![CDATA[
+using GLib;
+using Gtk;
+
+public class Main : Object 
+{
+	const string UI_FILE = "src/hello_world.ui";
+
+	public Main ()
+	{
+		try 
+		{
+			var builder = new Builder ();
+			builder.add_from_file (UI_FILE);
+			builder.connect_signals (this);
+
+			var window = builder.get_object ("window") as Window;
+			window.show_all ();
+		} 
+		catch (Error e) {
+			stderr.printf ("Could not load UI: %s\n", e.message);
+		} 
+	}
+
+	public void on_destroy (Widget window) 
+	{
+		Gtk.main_quit();
+	}
+
+	static int main (string[] args) 
+	{
+		Gtk.init (ref args);
+		var app = new Main ();
+
+		Gtk.main ();
+		
+		return 0;
+	}
+}]]></code>
+
+</section>
+
+<section id="build">
+  <title>Build the code for the first time</title>
+  <p>The code loads an (empty) window from the user interface description file and displays it.</p>
+
+  <list>
+  <item>
+    <p>The two <code>using</code> lines import namespaces so we don't have to name them explicitly.</p>
+   </item>
+   <item>
+    <p>The constructor of the <code>Main</code> class creates a new window by opening a GtkBuilder file (<file>src/hello_world.ui</file>, defined a few lines above), connecting its signals and then displaying it in a window. This GtkBuilder file contains a description of a user interface and all of its elements. You can use Anjuta's editor to design GtkBuilder user interfaces.</p>
+    <note>
+    <p>Connecting signals is how you define what happens when you push a button, or when some other event happens. Here, the <code>on_destroy</code> function is called (and quits the app) when you close the window.</p>
+    </note>
+   </item>
+   <item>
+    <p>The static <code>main</code> function is run by default when you start a Vala application. It calls a few functions which create the Main class, set up and then run the application. The <code>Gtk.main</code> function starts the GTK main loop, which runs the user interface and starts listening for events (like clicks and key presses).</p>
+   </item>
+  </list>
+
+  <p>This code is ready to be used, so you can compile it by clicking <guiseq><gui>Build</gui><gui>Build Project</gui></guiseq> (or press <keyseq><key>Shift</key><key>F7</key></keyseq>). When you do this, a dialog. Change the <gui>Configuration</gui> to <gui>Default</gui> and then click <gui>Execute</gui> to configure the build directory. You only need to do this once, for the first build.</p>
+
+
+</section>
 
 </page>
diff --git a/platform-demos/C/toolbars.vala.page b/platform-demos/C/toolbars.vala.page
index 0c8d8c1..44bfede 100644
--- a/platform-demos/C/toolbars.vala.page
+++ b/platform-demos/C/toolbars.vala.page
@@ -14,7 +14,7 @@
     <desc></desc>
   </info>
 
-  <title>v. Toolbars</title>
+  <title>iv. Toolbars</title>
 
   <comment>
     <cite date="2012-02-20" href="mailto:tiffany antopolski gmail com">Tiffany Antopolski</cite>



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