[gnome-devel-docs] Tutorial vala codes samples: Gtk.Window



commit 84b5bdd84d21100f3172e80022d944b54f7b2355
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date:   Mon Apr 9 00:21:06 2012 -0400

    Tutorial vala codes samples: Gtk.Window

 platform-demos/C/beginner.vala.page  |   11 +++++++
 platform-demos/C/samples/window.vala |   22 +++++++++++++++
 platform-demos/C/window.vala.page    |   50 ++++++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/beginner.vala.page b/platform-demos/C/beginner.vala.page
index 232333a..f9179cf 100644
--- a/platform-demos/C/beginner.vala.page
+++ b/platform-demos/C/beginner.vala.page
@@ -38,6 +38,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>.vala</p></item>
+    <item><p>In the terminal type:</p>
+          <screen>valac --pkg gtk+-3.0 <var>filename</var>.vala</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.vala b/platform-demos/C/samples/window.vala
new file mode 100644
index 0000000..ba957b2
--- /dev/null
+++ b/platform-demos/C/samples/window.vala
@@ -0,0 +1,22 @@
+using Gtk;
+
+int main (string[] args) {
+
+	init (ref args);
+
+	var window = new Window ();
+	window.title = "Welcome to GNOME";
+
+	//window.border_width = 10;
+	//window.window_position = WindowPosition.CENTER;
+	//window.set_default_size (350, 70);
+
+	/*The destroy signal is emitted when the x
+	  in the top right of the window is clicked.*/
+	window.destroy.connect (main_quit);
+
+	window.show ();
+
+	Gtk.main ();
+	return 0;
+}
diff --git a/platform-demos/C/window.vala.page b/platform-demos/C/window.vala.page
new file mode 100644
index 0000000..c0eea80
--- /dev/null
+++ b/platform-demos/C/window.vala.page
@@ -0,0 +1,50 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      type="guide" style="task"
+      id="window.vala">
+  <info>
+    <link type="guide" xref="beginner.vala#windows"/>
+    <revision version="0.1" date="2012-04-07" status="draft"/>
+
+    <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 toplevel window with destroy signal hooked up.</p>
+  
+      <code mime="text/x-vala" style="numbered"><![CDATA[
+using Gtk;
+
+int main (string[] args) {
+
+    init (ref args);
+
+    var window = new Window ();
+    window.title = "Welcome to GNOME";
+
+    //window.border_width = 10;
+    //window.window_position = WindowPosition.CENTER;
+    //window.set_default_size (250, 50);
+
+    /*The destroy signal is emitted when the x
+      in the top right of the window is clicked. Here,
+      the signal is connected to main_quit, causing
+      the program to exit the main_loop.*/
+    window.destroy.connect (main_quit);
+
+    window.show ();
+
+    Gtk.main ();
+    return 0;
+}
+]]></code>
+<p>
+  In this sample we used the following widget: <link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Window";>Gtk.Window</link> and the following enum: <link href="http://references.valadoc.org/#!api=gtk+-3.0/Gtk.WindowPosition";>Gtk.WindowPosition</link>.
+</p>
+</page>



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