[gnome-devel-docs] New pages for JavaScript demos
- From: Susanna Huhtanen <susannah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] New pages for JavaScript demos
- Date: Mon, 20 Feb 2012 09:12:46 +0000 (UTC)
commit 697d351b6819fe965ae1131aafee340b86a7e519
Author: Susanna Huhtanen <ihmis suski gmail com>
Date: Sun Feb 19 19:35:53 2012 +0200
New pages for JavaScript demos
platform-demos/C/beginner.js.page | 30 +++++++++++++++++++
platform-demos/C/entry.js.page | 53 +++++++++++++++++++++++++++++++++++
platform-demos/C/helloWorld.js.page | 48 +++++++++++++++++++++++++++++++
platform-demos/C/media/entry.png | Bin 0 -> 15102 bytes
4 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/beginner.js.page b/platform-demos/C/beginner.js.page
new file mode 100644
index 0000000..dbb74de
--- /dev/null
+++ b/platform-demos/C/beginner.js.page
@@ -0,0 +1,30 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ type="guide" style="task"
+ id="beginner.js">
+ <info>
+ <link type="guide" xref="index#js"/>
+ <revision version="0.1" date="2012-02-19" status="stub"/>
+
+ <credit type="author copyright">
+ <name>Susanna Huhtanen</name>
+ <email>ihmis suski gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A complete beginner's guide to GTK+ programming</desc>
+ </info>
+
+ <title>0 Beginner's Tutorials</title>
+ <p>Here be dragons!</p>
+
+ <section id="hello_world">
+ <title>Hello World</title>
+ <p></p>
+ </section>
+
+ <section id="samples">
+ <title>Samples</title>
+ <p></p>
+ </section>
+
+</page>
diff --git a/platform-demos/C/entry.js.page b/platform-demos/C/entry.js.page
new file mode 100644
index 0000000..c3479d8
--- /dev/null
+++ b/platform-demos/C/entry.js.page
@@ -0,0 +1,53 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ type="guide" style="task"
+ id="entry.js">
+ <info>
+ <link type="guide" xref="beginner.js#samples"/>
+ <revision version="0.1" date="2012-02-19" status="stub"/>
+
+ <credit type="author copyright">
+ <name>Susanna Huhtanen</name>
+ <email>ihmis suski gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc></desc>
+ </info>
+
+ <title>Entry</title>
+
+ <media type="image" mime="image/png" src="media/entry.png"/>
+ <p>This an entry widget</p>
+
+ <code mime="text/javascript" style="numbered"><![CDATA[
+#!/usr/bin/gjs
+Gtk = imports.gi.Gtk;
+Gtk.init(null, 0);
+myW = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
+myW.title = "TestForm";
+myW.connect("destroy", function(){Gtk.main_quit()});
+grid = new Gtk.Grid();
+myW.add(grid);
+
+var entry = new Gtk.Entry({text: "Write something here"});
+entry.set_width_chars(50);
+var label = new Gtk.Label({label: "This is an etry widget: "});
+var connectionbutton = new Gtk.Button({label: "It's contents are connected to the label after this button"});
+this.resultlabel = new Gtk.Label({
+ label: "The contents of the entry will be here after you click the button"
+});
+connectionbutton.connect("clicked", function(widget, event) {
+ var whatWasTyped = entry.get_text();
+ this.resultlabel.set_text(whatWasTyped);
+});
+
+grid.attach(label, 1, 1, 1, 1);
+grid.attach_next_to(entry,label,1,1,1);
+grid.attach_next_to(connectionbutton,label,3,1,1);
+grid.attach_next_to(resultlabel,entry,3,1,1);
+
+myW.show_all();
+Gtk.main();
+]]></code>
+
+</page>
diff --git a/platform-demos/C/helloWorld.js.page b/platform-demos/C/helloWorld.js.page
new file mode 100644
index 0000000..c5e5046
--- /dev/null
+++ b/platform-demos/C/helloWorld.js.page
@@ -0,0 +1,48 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ type="guide" style="task"
+ id="helloWorld.js">
+ <info>
+ <link type="guide" xref="beginner.js#hello_world"/>
+ <revision version="0.1" date="2012-02-19" status="stub"/>
+
+ <credit type="author copyright">
+ <name>Susanna Huhtanen</name>
+ <email>ihmis suski gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc></desc>
+ </info>
+ <title>Hello World</title>
+
+ <synopsis>
+ <p>In this guide we'll construct a small program, Hello World, using JavaScript and GTK+. To do and run all the code examples yourself, you need an editor to write code in, terminal and GNOME 3. or higher installed into your computer.</p>
+ </synopsis>
+
+ <section id=".js">
+ <title>HelloWorld.js</title>
+ <p>This a basic Hello World done with JavaScript. If you are unfamiliar with JavaScript, read <link href="http://eloquentjavascript.net/contents.html">Eloquent JavaScript</link> or your preferred guide to JavaScript. </p>
+ <code mime="text/javascript" style="numbered"><![CDATA[
+#!/usr/bin/gjs
+//The previous line is a hash bang tells how to run the script.
+// Note that the script has to be executable (run in terminal in the right folder: chmod +x scriptname)
+
+var Gtk, mywindow, label;
+
+Gtk = imports.gi.Gtk;
+// Initialize the gtk
+Gtk.init(null, 0);
+//create your window, name it and connect the x to quit function. Remember that window is a taken word
+mywindow = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
+mywindow.title = "Hello World!";
+mywindow.connect("destroy", function(){Gtk.main_quit()});
+//Set some text to your window
+label = new Gtk.Label({label: "Hello World"});
+mywindow.add(label);
+//show everything you have done
+label.show();
+mywindow.show();
+//and run it
+Gtk.main();]]></code>
+ </section>
+</page>
diff --git a/platform-demos/C/media/entry.png b/platform-demos/C/media/entry.png
new file mode 100644
index 0000000..9d93032
Binary files /dev/null and b/platform-demos/C/media/entry.png differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]