[gnome-devel-docs] tutorials samples vala: Gtk.Dialog example



commit 3bf46529e0364cab067e6b4faa30bf31376e2467
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date:   Wed Apr 11 00:27:46 2012 -0400

    tutorials samples vala: Gtk.Dialog example

 platform-demos/C/dialog.vala.page    |   58 ++++++++++++++++++++++++++++++
 platform-demos/C/media/dialog.png    |  Bin 0 -> 7318 bytes
 platform-demos/C/response-type.page  |   64 ++++++++++++++++++++++++++++++++++
 platform-demos/C/samples/dialog.vala |   24 +++++++++++++
 4 files changed, 146 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/dialog.vala.page b/platform-demos/C/dialog.vala.page
new file mode 100644
index 0000000..e102096
--- /dev/null
+++ b/platform-demos/C/dialog.vala.page
@@ -0,0 +1,58 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      type="guide" style="task"
+      id="dialog.vala">
+  <info>
+    <link type="guide" xref="beginner.vala#windows"/>
+    <revision version="0.1" date="2012-04-07" status="stub"/>
+
+    <credit type="author copyright">
+      <name>Tiffany Antopolski</name>
+      <email>tiffany antopolski gmail com</email>
+      <years>2012</years>
+    </credit>
+
+    <desc>A popup window</desc>
+  </info>
+
+  <title>Dialog</title>
+  <media type="image" mime="image/png" src="media/dialog.png"/>
+  <p>More specific description of this particular example.</p>
+  
+      <code mime="text/x-vala" style="numbered"><![CDATA[
+using Gtk;
+
+void on_response (int response_id) {
+
+    /*To see the int value of the ResponseType*/
+    print ("response is %d\n", response_id);
+    
+    main_quit ();
+}
+int main (string[] args) {
+
+    init (ref args);
+
+    var dialog = new Dialog.with_buttons ("A Gtk+ Dialog", null, 0, Stock.OK, ResponseType.OK, null);
+    var content_area = dialog.get_content_area ();
+    var label = new Label ("This demonstrates a dialog with a label");
+    
+    content_area.add (label);
+    dialog.response.connect (on_response);
+    dialog.show_all ();
+
+    Gtk.main ();
+    return 0;
+}
+]]></code>
+
+<p>
+  In this sample we used the following:
+</p>
+<list>
+  <item><p><link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Dialog";>Gtk.Dialog</link></p></item>
+  <item><p><link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Dialog.Dialog.with_buttons";>Gtk.Dialog.with_buttons</link></p></item>
+  <item><p><link href="http://references.valadoc.org/#!api=gtk+-3.0/Gtk.Label";>Gtk.Label</link></p></item>
+  <item><p><link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Dialog.get_content_area";>get_content_area</link></p></item>
+  <item><p><link xref="response-type"/></p></item>
+</list>
+</page>
diff --git a/platform-demos/C/media/dialog.png b/platform-demos/C/media/dialog.png
new file mode 100644
index 0000000..b14a28e
Binary files /dev/null and b/platform-demos/C/media/dialog.png differ
diff --git a/platform-demos/C/response-type.page b/platform-demos/C/response-type.page
new file mode 100644
index 0000000..e1930f7
--- /dev/null
+++ b/platform-demos/C/response-type.page
@@ -0,0 +1,64 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      type="topic" style="task"
+      id="response-type">
+  <info>
+    <revision version="0.1" date="2012-04-10" status="stub"/>
+
+    <credit type="author copyright">
+      <name>Tiffany Antopolski</name>
+      <email>tiffany antopolski gmail com</email>
+      <years>2012</years>
+    </credit>
+
+    <desc></desc>
+  </info>
+
+  <title>enum ResponseType</title>
+
+  <terms>
+    <item>
+  <title>ResponseType.NONE         = -1</title>
+  <p>Returned if an action widget has no response id, or if the dialog gets programmatically hidden or destroyed</p>
+    </item>
+    <item>
+  <title>ResponseType.REJECT       = -2</title>
+  <p>Generic response id, not used by GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.ACCEPT       = -3</title>
+  <p>Generic response id, not used by GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.DELETE_EVENT = -4</title>
+  <p>Returned if the dialog is deleted</p>
+    </item>
+    <item>
+  <title>ResponseType.OK           = -5</title>
+  <p>Returned by OK buttons in GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.CANCEL       = -6</title>
+  <p>Returned by Cancel buttons in GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.CLOSE        = -7</title>
+  <p>Returned by Close buttons in GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.YES          = -8</title>
+  <p>Returned by Yes buttons in GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.NO           = -9</title>
+  <p>Returned by No buttons in GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.APPLY        = -10</title>
+  <p>Returned by Apply buttons in GTK+ dialogs</p>
+    </item>
+    <item>
+  <title>ResponseType.HELP         = -11</title>
+  <p>Returned by Help buttons in GTK+ dialogs</p>
+    </item>
+</terms>
+</page>
diff --git a/platform-demos/C/samples/dialog.vala b/platform-demos/C/samples/dialog.vala
new file mode 100644
index 0000000..09dae91
--- /dev/null
+++ b/platform-demos/C/samples/dialog.vala
@@ -0,0 +1,24 @@
+using Gtk;
+
+void on_response (int response_id) {
+
+	/*To see the int value of the ResponseType*/
+	print ("response is %d\n", response_id);
+	
+	main_quit ();
+}
+int main (string[] args) {
+
+	init (ref args);
+
+	var dialog = new Dialog.with_buttons ("A Gtk+ Dialog", null, 0, Stock.OK, ResponseType.OK, null);
+	var content_area = dialog.get_content_area ();
+	var label = new Label ("This demonstrates a dialog with a label");
+	
+	content_area.add (label);
+	dialog.response.connect (on_response);
+	dialog.show_all ();
+
+	Gtk.main ();
+	return 0;
+}



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