[gnome-devel-docs] Vala CheckButton sample.



commit 52eb3e223dec772dcbd692c44fff9737907a8a41
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date:   Wed May 9 00:47:23 2012 -0400

    Vala CheckButton sample.

 platform-demos/C/checkbutton.vala.page    |   29 +++++++++++++++++++++++
 platform-demos/C/media/checkbutton.png    |  Bin 0 -> 6085 bytes
 platform-demos/C/samples/checkbutton.vala |   36 +++++++++++++++++++++++++++++
 platform-demos/Makefile.am                |    3 ++
 4 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/checkbutton.vala.page b/platform-demos/C/checkbutton.vala.page
new file mode 100644
index 0000000..1aaade8
--- /dev/null
+++ b/platform-demos/C/checkbutton.vala.page
@@ -0,0 +1,29 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:xi="http://www.w3.org/2001/XInclude";
+      type="guide" style="task"
+      id="checkbutton.vala">
+  <info>
+    <link type="guide" xref="beginner.vala#buttons"/>
+    <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>Create widgets with a disrete toggle button</desc>
+  </info>
+
+  <title>CheckButton</title>
+  <media type="image" mime="image/png" src="media/checkbutton.png"/>
+  <p>This CheckButton toggles the title.</p>
+
+<code mime="text/x-vala" style="numbered"><xi:include href="samples/checkbutton.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.CheckButton";>Gtk.CheckButton</link></p></item>
+</list>
+</page>
diff --git a/platform-demos/C/media/checkbutton.png b/platform-demos/C/media/checkbutton.png
new file mode 100644
index 0000000..b565131
Binary files /dev/null and b/platform-demos/C/media/checkbutton.png differ
diff --git a/platform-demos/C/samples/checkbutton.vala b/platform-demos/C/samples/checkbutton.vala
new file mode 100644
index 0000000..e9c21e7
--- /dev/null
+++ b/platform-demos/C/samples/checkbutton.vala
@@ -0,0 +1,36 @@
+class MyWindow : Gtk.ApplicationWindow {
+	
+	internal MyWindow (MyApplication app) {
+		Object (application: app, title: "CheckButton Example");
+
+		this.set_default_size (300, 100);
+		this.border_width = 10;
+	
+		var checkbutton = new Gtk.CheckButton.with_label ("Show Title");
+		(checkbutton as Gtk.ToggleButton).toggled.connect (toggled_cb);
+		this.add (checkbutton);
+		checkbutton.set_active (true);
+		checkbutton.show ();
+	}
+
+	void toggled_cb (Gtk.ToggleButton checkbutton) {
+		if (checkbutton.get_active())
+			this.set_title ("CheckButton Example");
+		else
+			this.set_title ("");
+	}
+}
+
+class MyApplication : Gtk.Application {
+	protected override void activate () {
+		new MyWindow (this).show ();
+	}
+
+	internal MyApplication () {
+		Object (application_id: "org.example.checkbutton");
+	}
+}
+
+int main (string[] args) {
+	return new MyApplication ().run (args);
+}
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index 9f6b609..e5594c4 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -24,6 +24,7 @@ demo_sources = \
 	samples/aboutdialog.vala		\
 	samples/button.py			\
 	samples/button.vala			\
+	samples/checkbutton.vala		\
 	samples/combobox.vala			\
 	samples/dialog.vala			\
 	samples/entry.vala			\
@@ -54,6 +55,7 @@ demo_sources = \
 DOC_FIGURES = \
 	media/aboutdialog_GMenu.png		\
 	media/button.png			\
+	media/checkbutton.png			\
 	media/combobox.png			\
 	media/dialog.png			\
 	media/entry.png				\
@@ -98,6 +100,7 @@ DOC_PAGES =				\
 	bug-filing.page			\
 	button.py.page			\
 	button.vala.page		\
+	checkbutton.vala.page		\
 	combobox.vala.page		\
 	c.page				\
 	cpp.page			\



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