[gnome-devel-docs] Added JavaScript window tutorial and code sample



commit d72db3c794ae50806ec8648e33fe2a23dade1920
Author: Taryn Fox <jewelfox fursona net>
Date:   Sun Apr 15 05:17:16 2012 -0400

    Added JavaScript window tutorial and code sample

 platform-demos/C/samples/window.js |   25 ++++++++++++++++++
 platform-demos/C/window.js.page    |   50 ++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/samples/window.js b/platform-demos/C/samples/window.js
new file mode 100644
index 0000000..c417fde
--- /dev/null
+++ b/platform-demos/C/samples/window.js
@@ -0,0 +1,25 @@
+#!/usr/bin/gjs
+
+var Gtk = imports.gi.Gtk;
+Gtk.init(null, 0);
+
+// Create window and give it a name
+// You can't call it "window" as that name is a JavaScript word.
+var sampleWindow = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
+sampleWindow.title = "Welcome to GNOME";
+
+/* The "destroy" signal is sent out when you click the X button.
+   Here, we connect that signal to the GTK+ function to close the window. */
+sampleWindow.connect("destroy", function(){Gtk.main_quit()});
+
+/* Here are a few ways we can customize our window.
+   Try uncommenting them or changing their values! */
+// sampleWindow.set_default_size (400,200);
+// sampleWindow.set_has_resize_grip (false);
+// sampleWindow.set_opacity (0.5);
+// sampleWindow.maximize ();
+
+// If the window has widgets in it, you'll want to use show_all() instead.
+sampleWindow.show();
+
+Gtk.main();
diff --git a/platform-demos/C/window.js.page b/platform-demos/C/window.js.page
new file mode 100644
index 0000000..7d8835c
--- /dev/null
+++ b/platform-demos/C/window.js.page
@@ -0,0 +1,50 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      type="guide" style="task"
+      id="window.js">
+  <info>
+    <link type="guide" xref="beginner.js#windows"/>
+    <revision version="0.1" date="2012-04-14" status="draft"/>
+
+    <credit type="author copyright">
+      <name>Taryn Fox</name>
+      <email>jewelfox fursona net</email>
+      <years>2012</years>
+    </credit>
+
+    <desc>A basic window which can contain other widgets</desc>
+  </info>
+
+  <title>Window</title>
+  <media type="image" mime="image/png" src="media/window.png"/>
+  <p>A plain window, without other widgets added to it.</p>
+  
+      <code mime="text/javascript" style="numbered"><![CDATA[
+]]>#!/usr/bin/gjs
+
+var Gtk = imports.gi.Gtk;
+Gtk.init(null, 0);
+
+// Create window and give it a name
+// You can't call it "window" as that name is reserved by GNOME.
+var sampleWindow = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
+sampleWindow.title = "Welcome to GNOME";
+
+/* The "destroy" signal is sent out when you click the X button.
+   Here, we connect that signal to the GTK+ function to close the window. */
+sampleWindow.connect("destroy", function(){Gtk.main_quit()});
+
+/* Here are a few ways we can customize our window.
+   Try uncommenting them or changing their values! */
+// sampleWindow.set_default_size (400,200);
+// sampleWindow.set_has_resize_grip (false);
+// sampleWindow.set_opacity (0.5);
+// sampleWindow.maximize ();
+
+// If the window has widgets in it, you'll want to use show_all() instead.
+sampleWindow.show();
+
+Gtk.main();</code>
+<p>
+  In this sample we used the following widget: <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Window.html";>Gtk.Window</link>
+</p>
+</page>



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