[gnome-devel-docs] Vala samples: tidied up gmenu and aboutdialog pages.



commit a758009a3695672ac06400d6c28edcee22ce718c
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date:   Thu May 3 15:09:29 2012 -0400

    Vala samples: tidied up gmenu and aboutdialog pages.

 platform-demos/C/aboutdialog.vala.page    |   41 +++++++++++++++++++++++++
 platform-demos/C/gmenu.vala.page          |    2 +-
 platform-demos/C/media/gmenu.vala.png     |  Bin 22136 -> 20672 bytes
 platform-demos/C/samples/aboutdialog.vala |   31 ++++++++++++-------
 platform-demos/C/samples/gmenu.vala       |   46 +++++++++++++++++++++++++++++
 platform-demos/Makefile.am                |    5 ++-
 6 files changed, 111 insertions(+), 14 deletions(-)
---
diff --git a/platform-demos/C/aboutdialog.vala.page b/platform-demos/C/aboutdialog.vala.page
new file mode 100644
index 0000000..27725a9
--- /dev/null
+++ b/platform-demos/C/aboutdialog.vala.page
@@ -0,0 +1,41 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:xi="http://www.w3.org/2001/XInclude";
+      type="guide" style="task"
+      id="aboutdialog_GMenu.vala">
+  <info>
+    <link type="guide" xref="beginner.vala#windows"/>
+    <revision version="0.1" date="2012-04-07" status="stub"/>
+
+    <credit type="author copyright">
+      <name>Ryan Lortie</name>
+      <email>desrt desrt ca</email>
+      <years>2012</years>
+    </credit>
+
+    <credit type="author">
+      <name>Tiffany Antopolski</name>
+      <email>tiffany antopolski gmail com</email>
+    </credit>
+
+
+    <desc>Display information about an application</desc>
+  </info>
+
+  <title>AboutDialog</title>
+  <media type="image" mime="image/png" src="media/aboutdialog_GMenu.png"/>
+  <p>An AboutDialog example using Gtk.ApplicationWindow and Menu</p>
+  <note><p><em style="bold">You need to be running Gtk3.4 or later for this to work</em></p></note>
+
+<code mime="text/x-vala" style="numbered">
+<xi:include href="samples/aboutdialog.vala" parse="text"><xi:fallback/></xi:include>		
+</code>
+<p>
+  In this sample we used the following:
+</p>
+<list>
+  <item><p><link href="http://references.valadoc.org/#!api=gtk+-3.0/Gtk.Application";>Gtk.Application</link></p></item>
+  <item><p><link href="http://references.valadoc.org/#!api=gtk+-3.0/Gtk.ApplicationWindow";>Gtk.ApplicationWindow</link></p></item>
+  <item><p><link href="http://www.valadoc.org/#!api=gtk+-3.0/Gtk.Window.set_default_size";>set_default_size</link></p></item>
+  <item><p><link href="button.vala.page">Gtk.Button.with_label</link></p></item>
+</list>
+</page>
diff --git a/platform-demos/C/gmenu.vala.page b/platform-demos/C/gmenu.vala.page
index 716f063..b4e5077 100644
--- a/platform-demos/C/gmenu.vala.page
+++ b/platform-demos/C/gmenu.vala.page
@@ -31,7 +31,7 @@
     <p>A GtkApplication with a simple GMenu and SimpleActions</p>
 
 <code mime="text/x-vala" style="numbered">
-<xi:include href="samples/aboutdialog_GMenu.vala" parse="text"><xi:fallback/></xi:include>
+<xi:include href="samples/gmenu.vala" parse="text"><xi:fallback/></xi:include>
 </code>
 <p>
   In this sample we used the following:
diff --git a/platform-demos/C/media/gmenu.vala.png b/platform-demos/C/media/gmenu.vala.png
index 7488c7c..f93e559 100644
Binary files a/platform-demos/C/media/gmenu.vala.png and b/platform-demos/C/media/gmenu.vala.png differ
diff --git a/platform-demos/C/samples/aboutdialog.vala b/platform-demos/C/samples/aboutdialog.vala
index 0c01148..151cbb7 100644
--- a/platform-demos/C/samples/aboutdialog.vala
+++ b/platform-demos/C/samples/aboutdialog.vala
@@ -1,25 +1,21 @@
-//An AboutDialog example using Gtk.Application 
-
-/*** You need to be running Gtk3.4 or later for this to work ***/
-
 //A window in the application
 public class Window : Gtk.ApplicationWindow {
 	public Window (Application app) {
 		Object (application: app, title: "AboutDialog Example");
-		this.set_default_size (400, 200);
-		var button = new Gtk.Button.with_label ("About");
-		button.clicked.connect (about_clicked);
-		this.add (button);
+
+		var about_action = new SimpleAction ("about", null);
+		about_action.activate.connect (about);
+		this.add_action (about_action);
 
 		this.show_all ();
 	}
 
-	void about_clicked () {
+	void about () {
 		string[] authors = { "GNOME Documentation Team", null };
-		string[] documenters = {"GNOME Documentation Team", null };
+		string[] documenters = { "GNOME Documentation Team", null };
 
 		Gtk.show_about_dialog (this,
-	                       "program-name", ("AboutDialog Example"),
+	                       "program-name", ("GtkApplication Example"),
 	                       "copyright", ("Copyright \xc2\xa9 2012 GNOME Documentation Team"),
 	                       "authors", authors,
 	                       "documenters", documenters,
@@ -35,6 +31,19 @@ public class Application : Gtk.Application {
 		new Window (this);
 	}
 
+	protected override void startup () {
+		base.startup ();
+
+		var menu = new Menu ();
+		menu.append ("About", "win.about");
+		menu.append ("Quit", "app.quit");
+		this.app_menu = menu;
+
+		var quit_action = new SimpleAction ("quit", null);
+		//quit_action.activate.connect (this.quit);
+		this.add_action (quit_action);
+	}
+
 	public Application () {
 		Object (application_id: "org.example.application");
 	}
diff --git a/platform-demos/C/samples/gmenu.vala b/platform-demos/C/samples/gmenu.vala
new file mode 100644
index 0000000..3e503f8
--- /dev/null
+++ b/platform-demos/C/samples/gmenu.vala
@@ -0,0 +1,46 @@
+//A window in the application
+public class Window : Gtk.ApplicationWindow {
+	public Window (Application app) {
+		Object (application: app, title: "Gmenu Example");
+
+		var about_action = new SimpleAction ("about", null);
+		about_action.activate.connect (about);
+		this.add_action (about_action);
+
+		this.show_all ();
+	}
+
+	void about () {
+		print ("This does nothing.  It is only a demonstration\n");
+	}
+}
+
+//This is the Application
+public class Application : Gtk.Application {
+	protected override void activate () {
+		new Window (this);
+	}
+
+	protected override void startup () {
+		base.startup ();
+
+		var menu = new Menu ();
+		menu.append ("About", "win.about");
+		menu.append ("Quit", "app.quit");
+		this.app_menu = menu;
+
+		var quit_action = new SimpleAction ("quit", null);
+		//quit_action.activate.connect (this.quit);
+		this.add_action (quit_action);
+	}
+
+	public Application () {
+		Object (application_id: "org.example.application");
+	}
+}
+
+//main function creates Application and runs it
+int main (string[] args) {
+	return new Application ().run (args);
+}
+
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index 253381c..875d80f 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -21,12 +21,13 @@ demo_sources = \
 	message-board/message-board.c 		\
 	photo-wall/photo-wall.c 		\		
 	record-collection/record-collection.js 	\
-	samples/aboutdialog_GMenu.vala		\
+	samples/aboutdialog.vala		\
 	samples/button.vala			\
 	samples/dialog.vala			\
 	samples/gmenu.c				\
 	samples/gmenu.js			\
 	samples/gmenu.py			\
+	samples/gmenu.vala			\
 	samples/grid.py				\
 	samples/GtkApplicationWindow.c		\
         samples/GtkApplicationWindow.js		\
@@ -70,7 +71,7 @@ DOC_FIGURES = \
 	$(demo_sources)
 
 DOC_PAGES =				\
-	aboutdialog_GMenu.vala.page	\
+	aboutdialog.vala.page		\
 	audio-player.vala.page		\
 	beginner.c.page			\
 	beginner.js.page		\



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