[gnome-devel-docs] Vala samples: Gtk.Spinner



commit 962454c1a66d677933824bab06c7f927152fc47f
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date:   Mon May 7 00:01:14 2012 -0400

    Vala samples: Gtk.Spinner

 platform-demos/C/beginner.vala.page   |    2 +-
 platform-demos/C/media/spinner.png    |  Bin 0 -> 9282 bytes
 platform-demos/C/samples/spinner.vala |   51 +++++++++++++++++++++++++++++++++
 platform-demos/C/spinner.vala.page    |   31 ++++++++++++++++++++
 platform-demos/Makefile.am            |    3 ++
 5 files changed, 86 insertions(+), 1 deletions(-)
---
diff --git a/platform-demos/C/beginner.vala.page b/platform-demos/C/beginner.vala.page
index ef0119d..9c2e80b 100644
--- a/platform-demos/C/beginner.vala.page
+++ b/platform-demos/C/beginner.vala.page
@@ -50,7 +50,7 @@
   <section id="windows" style="2column"><title>Windows</title>
     <p></p>
   </section>
-  <section id="display-widgets"><title>Display widgets</title>
+  <section id="display-widgets" style="2column"><title>Display widgets</title>
   </section>
   <section id="buttons"><title>Buttons and toggles</title>
   </section>
diff --git a/platform-demos/C/media/spinner.png b/platform-demos/C/media/spinner.png
new file mode 100644
index 0000000..26cde9c
Binary files /dev/null and b/platform-demos/C/media/spinner.png differ
diff --git a/platform-demos/C/samples/spinner.vala b/platform-demos/C/samples/spinner.vala
new file mode 100644
index 0000000..7fd727e
--- /dev/null
+++ b/platform-demos/C/samples/spinner.vala
@@ -0,0 +1,51 @@
+public class MyWindow : Gtk.ApplicationWindow {
+
+	Gtk.Widget spinner;
+
+	internal MyWindow (MyApplication app) {
+
+		Object (application: app, title: "Spinner Example");
+
+		this.set_default_size (200, 200);
+		this.border_width = 30;
+		
+		spinner = new Gtk.Spinner ();
+
+		this.add (spinner);
+		(spinner as Gtk.Spinner).active = true;
+		spinner.show ();
+	}
+
+	protected override bool key_press_event (Gdk.EventKey event) {
+
+		//print (Gdk.keyval_name(event.keyval) +"\n");
+		if (Gdk.keyval_name(event.keyval) == "space") {
+
+			if ((spinner as Gtk.Spinner).active) {
+				(spinner as Gtk.Spinner).stop ();
+				//spinner.visible = false;
+			}
+			else {
+				(spinner as Gtk.Spinner).start ();
+				//spinner.visible = true;
+			}
+		}
+		return true;
+	}
+}
+
+public class MyApplication : Gtk.Application {
+
+	protected override void activate () {
+		MyWindow window = new MyWindow (this);
+		window.show ();
+	}
+
+	internal MyApplication () {
+		Object (application_id: "org.example.spinner");
+	}
+}
+
+public int main (string[] args) {
+	return new MyApplication ().run (args);
+}
diff --git a/platform-demos/C/spinner.vala.page b/platform-demos/C/spinner.vala.page
new file mode 100644
index 0000000..b107e79
--- /dev/null
+++ b/platform-demos/C/spinner.vala.page
@@ -0,0 +1,31 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:xi="http://www.w3.org/2001/XInclude";
+      type="guide" style="task"
+      id="spinner.vala">
+  <info>
+    <link type="guide" xref="beginner.vala#display-widgets"/>
+    <revision version="0.1" date="2012-05-06" status="draft"/>
+
+    <credit type="author copyright">
+      <name>Tiffany Antopolski</name>
+      <email>tiffany antopolski gmail com</email>
+      <years>2012</years>
+    </credit>
+
+    <desc>A spinner animation</desc>
+  </info>
+
+  <title>Spinner</title>
+  <media type="image" mime="image/png" src="media/spinner.png"/>
+  <p>This Spinner is stopped and started by pressing the spacebar.</p>
+
+<code mime="text/x-vala" style="numbered"><xi:include href="samples/spinner.vala" parse="text"><xi:fallback/></xi:include></code>
+<p>
+  In this sample we used the following:
+</p>
+<list>
+  <item><p><link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Widget";>Gtk.Widget</link></p></item>
+  <item><p><link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Spinner";>Gtk.Spinner</link></p></item>
+  <item><p><link href="http://www.valadoc.org/#!api=gdk-3.0/Gdk.keyval_name";>Gdk.keyval_name</link></p></item>
+</list>
+</page>
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index bd46715..5cb2e5d 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -41,6 +41,7 @@ demo_sources = \
 	samples/label.vala			\
 	samples/messagedialog.vala		\
 	samples/progressbar.vala		\
+	samples/spinner.vala			\
 	samples/window.c			\
 	samples/window.py			\
 	samples/window.vala			\
@@ -73,6 +74,7 @@ DOC_FIGURES = \
 	media/photo-wall-focused.png		\
 	media/progressbar.ogv			\
 	media/record-collection.png		\
+	media/spinner.png			\
 	media/toolbar.png			\
 	media/ubuntu.png			\
 	media/weatherAppJs.png			\
@@ -129,6 +131,7 @@ DOC_PAGES =				\
 	magic-mirror.vala.page		\
 	message-board.c.page		\
 	messagedialog.vala.page		\
+	spinner.vala.page		\
 	toolbar.js.page			\
 	photo-wall.c.page		\
 	progressbar.vala.page		\



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