[gnome-devel-docs] Vala Gtk.Switch example files.



commit aa6bd9f76ad28f5ca3c2ad881435433be3fb1f80
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date:   Wed May 9 16:02:28 2012 -0400

    Vala Gtk.Switch example files.

 platform-demos/C/media/switch_off.png |  Bin 0 -> 3005 bytes
 platform-demos/C/media/switch_on.png  |  Bin 0 -> 5450 bytes
 platform-demos/C/samples/switch.vala  |   48 +++++++++++++++++++++++++++++++++
 platform-demos/C/switch.vala.page     |   35 ++++++++++++++++++++++++
 platform-demos/Makefile.am            |    4 +++
 5 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/media/switch_off.png b/platform-demos/C/media/switch_off.png
new file mode 100644
index 0000000..087c654
Binary files /dev/null and b/platform-demos/C/media/switch_off.png differ
diff --git a/platform-demos/C/media/switch_on.png b/platform-demos/C/media/switch_on.png
new file mode 100644
index 0000000..8e7cff8
Binary files /dev/null and b/platform-demos/C/media/switch_on.png differ
diff --git a/platform-demos/C/samples/switch.vala b/platform-demos/C/samples/switch.vala
new file mode 100644
index 0000000..2bca45e
--- /dev/null
+++ b/platform-demos/C/samples/switch.vala
@@ -0,0 +1,48 @@
+class MyWindow : Gtk.ApplicationWindow {
+
+	Gtk.Switch switcher;
+
+	internal MyWindow (MyApplication app) {
+		Object (application: app, title: "Switch Example");
+
+		this.set_default_size (300, 100);
+		this.border_width = 10;
+	
+		var label = new Gtk.Label ("Title");
+		switcher = new Gtk.Switch ();
+
+		switcher.set_active (true);
+
+		switcher.notify["active"].connect (switcher_cb);
+
+		var grid = new Gtk.Grid ();
+		grid.set_column_spacing (10);
+		grid.attach (label, 0, 0, 1, 1);
+		grid.attach (switcher, 1, 0, 1, 1);
+
+		this.add (grid);
+	}
+
+	void switcher_cb () {
+		if (switcher.get_active())
+			this.set_title ("Switch Example");
+		else
+			this.set_title ("");
+	}
+}
+
+class MyApplication : Gtk.Application {
+	protected override void activate () {
+		
+		var window = new MyWindow (this);
+		window.show_all (); //show all the things
+	}
+
+	internal MyApplication () {
+		Object (application_id: "org.example.checkbutton");
+	}
+}
+
+int main (string[] args) {
+	return new MyApplication ().run (args);
+}
diff --git a/platform-demos/C/switch.vala.page b/platform-demos/C/switch.vala.page
new file mode 100644
index 0000000..1ed7f78
--- /dev/null
+++ b/platform-demos/C/switch.vala.page
@@ -0,0 +1,35 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:xi="http://www.w3.org/2001/XInclude";
+      type="guide" style="task"
+      id="switch.vala">
+  <info>
+    <link type="guide" xref="beginner.vala#buttons"/>
+    <link type="seealso" xref="checkbutton.vala"/>
+    <link type="seealso" xref="label.vala"/>
+    <link type="seealso" xref="grid.vala"/>
+
+    <revision version="0.1" date="2012-05-09" status="draft"/>
+
+    <credit type="author copyright">
+      <name>Tiffany Antopolski</name>
+      <email>tiffany antopolski gmail com</email>
+      <years>2012</years>
+    </credit>
+
+    <desc>A "light switch" style toggle</desc>
+  </info>
+
+  <title>Switch</title>
+  <media type="image" mime="image/png" style="floatend" src="media/switch_off.png"/>
+  <media type="image" mime="image/png" src="media/switch_on.png"/>
+ 
+  <p>This Switch toggles the title.</p>
+
+<code mime="text/x-vala" style="numbered"><xi:include href="samples/switch.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.Switch";>Gtk.Switch</link></p></item>
+</list>
+</page>
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index d4fe3bf..2cfd76f 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -47,6 +47,7 @@ demo_sources = \
 	samples/radiobutton.vala		\
 	samples/spinner.vala			\
 	samples/statusbar.vala			\
+	samples/switch.vala			\
 	samples/togglebutton.vala		\
 	samples/toolbar.vala			\
 	samples/window.c			\
@@ -86,6 +87,8 @@ DOC_FIGURES = \
 	media/record-collection.png		\
 	media/spinner.png			\
 	media/statusbar.png			\
+	media/switch_on.png			\
+	media/switch_off.png			\
 	media/togglebutton.png			\
 	media/toolbar.png			\
 	media/toolbar2.png			\
@@ -154,6 +157,7 @@ DOC_PAGES =				\
 	record-collection.js.page	\
 	spinner.vala.page		\
 	statusbar.vala.page		\
+	switch.vala.page		\
 	togglebutton.vala.page		\
 	toolbar.js.page			\
 	toolbar.vala.page		\



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