[gnome-devel-docs] tutorial samples vala: added button sample.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorial samples vala: added button sample.
- Date: Tue, 10 Apr 2012 22:23:22 +0000 (UTC)
commit ed67ec99a78df27a5ff46edc7ee0419b4f1f6d4e
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Tue Apr 10 18:22:31 2012 -0400
tutorial samples vala: added button sample.
platform-demos/C/button.js.page | 2 +-
platform-demos/C/button.vala.page | 48 ++++++++++++++++++++++++++++++++-
platform-demos/C/samples/button.vala | 38 ++++++++++++++++++++++++++
platform-demos/Makefile.am | 2 +-
4 files changed, 86 insertions(+), 4 deletions(-)
---
diff --git a/platform-demos/C/button.js.page b/platform-demos/C/button.js.page
index 93afe3e..95f6294 100644
--- a/platform-demos/C/button.js.page
+++ b/platform-demos/C/button.js.page
@@ -16,7 +16,7 @@
<title>Button widget</title>
- <media type="image" mime="image/png" src="media/button.png"/>
+ <media type="image" mime="image/png" src="media/button_with_progress_bar.png"/>
<p>A button widget connected to a progress bar.</p>
<code mime="text/javascript" style="numbered"><![CDATA[
diff --git a/platform-demos/C/button.vala.page b/platform-demos/C/button.vala.page
index d8828cc..6db1c6d 100644
--- a/platform-demos/C/button.vala.page
+++ b/platform-demos/C/button.vala.page
@@ -11,14 +11,58 @@
<years>2012</years>
</credit>
- <desc>A widget that emits a signal when clicked</desc>
+ <desc>A button widget which can be connected to other widgets.</desc>
</info>
<title>Button widget</title>
<media type="image" mime="image/png" src="media/button.png"/>
- <p>A button widget connected to a progress bar.</p>
+ <p>A button widget connected to stdout.printf (), and a modal window.</p>
<code mime="text/x-vala" style="numbered"><![CDATA[
+using Gtk;
+
+/*callback for the "clicked" signal.*/
+void button_clicked_cb () {
+ stdout.printf ("You clicked the button!\n");
+ //TODO: add a modal window
+}
+
+int main (string[] args) {
+
+ init (ref args);
+
+ var window = new Window ();
+ window.title = "GNOME Button";
+ window.set_default_size (250,50);
+
+ var button = new Button.with_label ("Click Me");
+ window.add (button); //adds the button to the window
+
+ window.window_position = WindowPosition.CENTER;
+
+ /* The "clicked" signal is emitted when the
+ button is clicked. The signal is connected to
+ the button_clicked_cb method defined above.*/
+ button.clicked.connect (button_clicked_cb);
+
+ /*The "destroy" signal is emitted when the x
+ in the top right of the window is clicked.
+ The destroy signal is connected to the
+ main_quit method, which destroys the window
+ and exits the program.*/
+ window.destroy.connect (main_quit);
+
+ window.show_all ();
+
+ Gtk.main ();
+ return 0;
+}
]]></code>
+<p>
+ In this sample we used the following:
+</p>
+<list>
+ <item><p><link href="">thing1</link></p></item>
+</list>
</page>
diff --git a/platform-demos/C/samples/button.vala b/platform-demos/C/samples/button.vala
new file mode 100644
index 0000000..65599fd
--- /dev/null
+++ b/platform-demos/C/samples/button.vala
@@ -0,0 +1,38 @@
+using Gtk;
+
+/*callback for the "clicked" signal.*/
+void button_clicked_cb () {
+ stdout.printf ("You clicked the button!\n");
+ //TODO: add a modal window
+}
+
+int main (string[] args) {
+
+ init (ref args);
+
+ var window = new Window ();
+ window.title = "GNOME Button";
+ window.set_default_size (250,50);
+
+ var button = new Button.with_label ("Click Me");
+ window.add (button);
+
+ window.window_position = WindowPosition.CENTER;
+
+ /* The "clicked" signal is emitted when the
+ button is clicked. The signal is connected to
+ the button_clicked_cb method defined above.*/
+ button.clicked.connect (button_clicked_cb);
+
+ /*The "destroy" signal is emitted when the x
+ in the top right of the window is clicked.
+ The destroy signal is connected to the
+ main_quit method, which destroys the window
+ and exits the program.*/
+ window.destroy.connect (main_quit);
+
+ window.show_all ();
+
+ Gtk.main ();
+ return 0;
+}
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index 773da2c..6f49dbb 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -24,7 +24,7 @@ demo_sources = \
DOC_FIGURES = \
media/ubuntu.png \
- media/button.png \
+ media/button_with_progress_bar.png \
media/entry.png \
media/fedora.png \
media/opensuse.png \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]