seed r75 - in trunk: doc/tutorial-standalone examples examples/ide examples/lightsoff examples/shader tests



Author: racarr
Date: Mon Nov  3 06:39:34 2008
New Revision: 75
URL: http://svn.gnome.org/viewvc/seed?rev=75&view=rev

Log:
Readd most of what...somehow dissapeared?


Added:
   trunk/doc/tutorial-standalone/
   trunk/doc/tutorial-standalone/1.js   (contents, props changed)
   trunk/doc/tutorial-standalone/1.png   (contents, props changed)
   trunk/doc/tutorial-standalone/2.js   (contents, props changed)
   trunk/doc/tutorial-standalone/2.png   (contents, props changed)
   trunk/doc/tutorial-standalone/3.js   (contents, props changed)
   trunk/doc/tutorial-standalone/3.png   (contents, props changed)
   trunk/doc/tutorial-standalone/4.png   (contents, props changed)
   trunk/doc/tutorial-standalone/packing.png   (contents, props changed)
   trunk/doc/tutorial-standalone/packing.svg
   trunk/doc/tutorial-standalone/tutorial.html
   trunk/examples/calculator.js   (contents, props changed)
   trunk/examples/clutter.js   (contents, props changed)
   trunk/examples/ide/
   trunk/examples/ide/exception.svg
   trunk/examples/ide/ide.js
   trunk/examples/ide/tabview.js
   trunk/examples/ide/toolbar.js
   trunk/examples/lightsoff/
   trunk/examples/lightsoff/lightsoff.js   (contents, props changed)
   trunk/examples/lightsoff/tim-off.svg
   trunk/examples/lightsoff/tim-on.svg
   trunk/examples/ls.js   (contents, props changed)
   trunk/examples/mini-browser.js   (contents, props changed)
   trunk/examples/n-oscillator.js   (contents, props changed)
   trunk/examples/notify-test.js   (contents, props changed)
   trunk/examples/quine.js   (contents, props changed)
   trunk/examples/repl.js   (contents, props changed)
   trunk/examples/shader/
   trunk/examples/shader/ShaderView.js
   trunk/examples/shader/bob.jpg   (contents, props changed)
   trunk/examples/shader/default.glsl
   trunk/examples/shader/main.js   (contents, props changed)
   trunk/examples/vte-test.js   (contents, props changed)
   trunk/tests/
   trunk/tests/argv.js   (contents, props changed)
   trunk/tests/compare.js   (contents, props changed)
   trunk/tests/enum.js   (contents, props changed)
   trunk/tests/gobject-scope.js   (contents, props changed)
   trunk/tests/include.js   (contents, props changed)
   trunk/tests/json-constructor.js   (contents, props changed)
   trunk/tests/print.js   (contents, props changed)
   trunk/tests/printprint.js   (contents, props changed)
   trunk/tests/property-benchmark.js   (contents, props changed)
   trunk/tests/readline.js   (contents, props changed)
   trunk/tests/run-tests.py   (contents, props changed)
   trunk/tests/signal.js   (contents, props changed)
   trunk/tests/syntax-test.js   (contents, props changed)

Added: trunk/doc/tutorial-standalone/1.js
==============================================================================
--- (empty file)
+++ trunk/doc/tutorial-standalone/1.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,64 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+var window = new Gtk.Window({title: "Browser"});
+
+function quit()
+{
+    Gtk.main_quit();
+}
+
+window.signal_hide.connect(quit);
+
+function create_ui()
+{
+    var main_ui = new Gtk.VBox();
+    var toolbar = new Gtk.HBox();
+
+    var back_button = new Gtk.ToolButton({stock_id: "gtk-go-back"});
+    var forward_button = new Gtk.ToolButton({stock_id: "gtk-go-forward"});
+    var refresh_button = new Gtk.ToolButton({stock_id: "gtk-refresh"});
+
+    var url_entry = new Gtk.Entry();
+
+    back_button.signal_clicked.connect(back);
+    forward_button.signal_clicked.connect(forward);
+    refresh_button.signal_clicked.connect(refresh);
+
+    url_entry.signal_activate.connect(browse);
+
+    toolbar.pack_start(back_button);
+    toolbar.pack_start(forward_button);
+    toolbar.pack_start(refresh_button);
+    toolbar.pack_start(url_entry, true, true);
+
+    main_ui.pack_start(toolbar);
+    return main_ui;
+}
+
+function forward(button)
+{
+    Seed.print("forward");
+}
+
+function back(button)
+{
+    Seed.print("back");
+}
+
+function refresh(button)
+{
+    Seed.print("refresh");
+}
+
+function browse(button)
+{
+    Seed.print("browser");
+}
+
+window.add(create_ui());
+window.show_all();
+
+Gtk.main();

Added: trunk/doc/tutorial-standalone/1.png
==============================================================================
Binary file. No diff available.

Added: trunk/doc/tutorial-standalone/2.js
==============================================================================
--- (empty file)
+++ trunk/doc/tutorial-standalone/2.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,69 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gtk");
+Seed.import_namespace("WebKit");
+Gtk.init(null, null);
+
+var window = new Gtk.Window({title: "Browser"});
+window.resize(600,600);
+
+function quit()
+{
+    Gtk.main_quit();
+}
+
+window.signal_hide.connect(quit);
+
+function create_ui()
+{
+    var main_ui = new Gtk.VBox();
+    var toolbar = new Gtk.HBox();
+    
+    var browser = new WebKit.WebView();
+
+    var back_button = new Gtk.ToolButton({stock_id: "gtk-go-back"});
+    var forward_button = new Gtk.ToolButton({stock_id: "gtk-go-forward"});
+    var refresh_button = new Gtk.ToolButton({stock_id: "gtk-refresh"});
+
+    var url_entry = new Gtk.Entry();
+
+    back_button.signal_clicked.connect(back, browser);
+    forward_button.signal_clicked.connect(forward, browser);
+    refresh_button.signal_clicked.connect(refresh, browser);
+
+    url_entry.signal_activate.connect(browse, browser);
+
+    toolbar.pack_start(back_button);
+    toolbar.pack_start(forward_button);
+    toolbar.pack_start(refresh_button);
+    toolbar.pack_start(url_entry, true, true);
+
+    main_ui.pack_start(toolbar);
+    main_ui.pack_start(browser, true, true);
+    return main_ui;
+}
+
+function forward(button)
+{
+    Seed.print("forward");
+}
+
+function back(button)
+{
+    Seed.print("back");
+}
+
+function refresh(button)
+{
+    Seed.print("refresh");
+}
+
+function browse(button)
+{
+    Seed.print("browser");
+}
+
+window.add(create_ui());
+window.show_all();
+
+Gtk.main();

Added: trunk/doc/tutorial-standalone/2.png
==============================================================================
Binary file. No diff available.

Added: trunk/doc/tutorial-standalone/3.js
==============================================================================
--- (empty file)
+++ trunk/doc/tutorial-standalone/3.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,81 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gtk");
+Seed.import_namespace("WebKit");
+Gtk.init(null, null);
+
+var window = new Gtk.Window({title: "Browser"});
+window.resize(600,600);
+
+function quit()
+{
+    Gtk.main_quit();
+}
+
+window.signal_hide.connect(quit);
+
+function create_ui()
+{
+    var main_ui = new Gtk.VBox();
+    var toolbar = new Gtk.HBox();
+    
+    var browser = new WebKit.WebView();
+    browser.open("http://www.gnome.org";);
+
+    var back_button = new Gtk.ToolButton({stock_id: "gtk-go-back"});
+    var forward_button = new Gtk.ToolButton({stock_id: "gtk-go-forward"});
+    var refresh_button = new Gtk.ToolButton({stock_id: "gtk-refresh"});
+
+    var url_entry = new Gtk.Entry();
+
+    back_button.signal_clicked.connect(back, browser);
+    forward_button.signal_clicked.connect(forward, browser);
+    refresh_button.signal_clicked.connect(refresh, browser);
+
+    url_entry.signal_activate.connect(browse, browser);
+    browser.signal_load_committed.connect(url_changed, url_entry);
+
+    toolbar.pack_start(back_button);
+    toolbar.pack_start(forward_button);
+    toolbar.pack_start(refresh_button);
+    toolbar.pack_start(url_entry, true, true);
+
+    main_ui.pack_start(toolbar);
+    main_ui.pack_start(browser, true, true);
+    return main_ui;
+}
+
+function forward(button)
+{
+	this.go_forward();
+}
+
+function back(button)
+{
+	this.go_back();
+}
+
+function refresh(button)
+{
+	this.reload();
+}
+
+function browse(url)
+{
+	if (url.text.search("://") < 0)
+	{
+		url.text = "http://"; + url.text;
+	}
+	
+	this.open(url.text);
+}
+
+function url_changed(browser, frame)
+{
+    this.text = frame.get_uri();
+}
+
+window.add(create_ui());
+window.show_all();
+
+Gtk.main();

Added: trunk/doc/tutorial-standalone/3.png
==============================================================================
Binary file. No diff available.

Added: trunk/doc/tutorial-standalone/4.png
==============================================================================
Binary file. No diff available.

Added: trunk/doc/tutorial-standalone/packing.png
==============================================================================
Binary file. No diff available.

Added: trunk/doc/tutorial-standalone/packing.svg
==============================================================================
--- (empty file)
+++ trunk/doc/tutorial-standalone/packing.svg	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="744.09448819"
+   height="1052.3622047"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   sodipodi:docname="packing.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
+   inkscape:export-filename="/home/hortont/seed/doc/tutorial-standalone/packing.png"
+   inkscape:export-xdpi="51.161964"
+   inkscape:export-ydpi="51.161964">
+  <defs
+     id="defs4">
+    <marker
+       inkscape:stockid="TriangleInM"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="TriangleInM"
+       style="overflow:visible">
+      <path
+         id="path3850"
+         d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
+         transform="scale(-0.4)" />
+    </marker>
+    <marker
+       inkscape:stockid="TriangleOutM"
+       orient="auto"
+       refY="0.0"
+       refX="0.0"
+       id="TriangleOutM"
+       style="overflow:visible">
+      <path
+         id="path3859"
+         d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z "
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
+         transform="scale(0.4)" />
+    </marker>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective10" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10000"
+     guidetolerance="10"
+     objecttolerance="10"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.558743"
+     inkscape:cx="49.895553"
+     inkscape:cy="526.18109"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1440"
+     inkscape:window-height="817"
+     inkscape:window-x="0"
+     inkscape:window-y="33" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1">
+    <rect
+       style="opacity:1;fill:#000000;fill-opacity:0.21568628;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect3185"
+       width="522.73578"
+       height="671.83783"
+       x="114.47574"
+       y="187.57755"
+       rx="20"
+       ry="19.999996" />
+    <rect
+       style="opacity:1;fill:#000000;fill-opacity:0.21585903;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect3183"
+       width="469.05389"
+       height="139.74329"
+       x="140.42181"
+       y="219.17"
+       rx="20"
+       ry="19.999996" />
+    <rect
+       style="opacity:1;fill:#000000;fill-opacity:0.68627453;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect3157"
+       width="95"
+       height="94.999992"
+       x="159.47131"
+       y="240.44977"
+       rx="20"
+       ry="19.999998" />
+    <rect
+       style="opacity:1;fill:#000000;fill-opacity:0.68627453;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect3159"
+       width="95"
+       height="94.999992"
+       x="276.44141"
+       y="241.07245"
+       rx="20"
+       ry="19.999998" />
+    <rect
+       style="opacity:1;fill:#000000;fill-opacity:0.68627453;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect3161"
+       width="198.80443"
+       height="94.999992"
+       x="394.56372"
+       y="242.86218"
+       rx="20"
+       ry="19.999998" />
+    <rect
+       style="opacity:1;fill:#000000;fill-opacity:0.68627453;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect3187"
+       width="469.05389"
+       height="461.89499"
+       x="142.89615"
+       y="373.98181"
+       rx="20"
+       ry="19.999996" />
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+       x="229.08563"
+       y="105.3839"
+       id="text3189"><tspan
+         sodipodi:role="line"
+         id="tspan3191"
+         x="229.08563"
+         y="105.3839">VBox</tspan></text>
+    <text
+       xml:space="preserve"
+       style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
+       x="420.58694"
+       y="107.3839"
+       id="text3193"><tspan
+         sodipodi:role="line"
+         id="tspan3195"
+         x="420.58694"
+         y="107.3839">HBox</tspan></text>
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;marker-start:none;marker-end:url(#TriangleOutM);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 282.77759,110.54282 L 264.88028,173.18343"
+       id="path3197" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;marker-start:url(#TriangleInM);stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 465.33022,201.60887 L 479.64807,113.91202"
+       id="path3199" />
+  </g>
+</svg>

Added: trunk/doc/tutorial-standalone/tutorial.html
==============================================================================
--- (empty file)
+++ trunk/doc/tutorial-standalone/tutorial.html	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,368 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml"; lang="en" xml:lang="en">
+<head>
+	<title>Seed Tutorial : Standalone</title>
+	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+	<style type="text/css">
+body
+{
+	font-size: 10pt;
+	font-family: "sans-serif";
+	text-align: justify;
+}
+
+#header
+{
+	text-align: right;
+	font-size: 18pt;
+	width: 100%;
+	border-bottom: 1px solid #aaa;
+	
+}
+
+#subheader
+{
+	text-align: right;
+	font-size: 12pt;
+	width: 100%;
+}
+
+div.section
+{
+	font-size: 16pt;
+	font-weight: bold;
+	width: 100%;
+	border-bottom: 1px solid #ccc;
+	margin-bottom: 10px;
+}
+
+p
+{
+	margin-left: 10px;
+	text-indent: 0em;
+}
+
+pre
+{
+	margin-left: 20px;
+	padding-left: 5px;
+	border-left: 2px solid #ddd;
+}
+
+div.filename
+{
+    margin-left: 25px;
+    font-weight: bold;
+    width: 70%;
+    border-bottom: 1px solid #ccc;
+}
+
+code
+{
+    font-weight: bold;
+}
+
+span.changed
+{
+    color: red;
+}
+	</style>
+</head>
+<body>
+<div id="header">Seed Tutorial : Standalone</div>
+<div id="subheader">v.0.1</div>
+<div class="section">Introduction</div>
+<p>Seed, first and foremost, provides an easily embeddable Javascript engine to developers looking for a straightforward way to create extensible applications. It also provides bindings between <a href="http://library.gnome.org/devel/gobject/stable/";>GObject</a> and the <a href="http://www.webkit.org";>WebKit</a> Javascript engine, giving new developers access to the power of the GNOME stack from a familiar and simple language, and allowing rapid prototyping of applications for hardened GNOME developers.</p>
+<p>This tutorial begins with a few brief examples, and then dives right in, following the development of a simple Seed program, from beginning to end. By the end of the tutorial, you'll have your very own tiny WebKit-based web browser, as well as a summary knowledge of the use of Seed to build Gtk+ applications.</p>
+<div class="section">Beginning Seed</div>
+<p>It makes sense to start our exploration with a program you're probably quite familiar with:</p>
+<pre>
+#!/usr/local/bin/seed
+
+Seed.print("Hello, world!");
+</pre>
+<p>If you were to make this script executable (<code>chmod +x hello.js</code>), and run it, you'd hopefully see the following, just as expected (if you don't, for some reason, make sure you have the latest version of Seed installed, then <a href="racarr svn gnome org">email us</a>):</p>
+<pre>
+Hello, world!
+</pre>
+<p>In order to make the file executable, include (<code>#!/usr/local/bin/seed</code>) at the top of every Seed program you write. This is known as the <em>shebang line</em>, and tells your shell where to find the <code>seed</code> interpreter; I'm only going to include it when listing a whole file, from now on.</p>
+<p>Variables in Javascript are not given any <em>type</em>, and conversion between different kinds of values is automatic and painless. For example, you can:</p>
+<ul>
+<li>Add two strings <code>("Hello, " + "World!")</code> turns into <code>"Hello, World!"</code></li>
+<li>Add a number to a string <code>("Example" + (2 * 2))</code> turns into <code>"Example4"</code></li>
+</ul>
+<p>There is one exception: in order to convert a string of digits into a 'number', Javascript needs to be explicitly instructed to do so: <code>parseFloat("42.5")</code>.</p>
+<p>Seed also provides a very simple interface to the <a href="http://directory.fsf.org/project/readline/";>GNU Readline</a> library, which allows programs to ask the user for input. The only argument <code>Seed.readline()</code> requires is the prompt for the user. Also, the current version of Seed ensures that everything typed is automatically saved in the prompt's history; if you press the up key while at a prompt, you can access and edit lines you've previously entered. Future versions of Seed will provide more control over the history and other parts of readline.</p>
+<pre>
+var my_name = Seed.readline("Your name? ");
+var my_age = Seed.readline("Your age? ");
+var old = 25;
+var old_age = old + parseFloat(my_age);
+Seed.print(my_name + " will be " + old_age + " in " + old + " years!");
+</pre>
+<p>You've probably noticed that the word '<code>var</code>' precedes the first use of every variable in Javascript. This is important, because it ensures that the memory consumed by the variable is freed to be used elsewhere at the end of the current block of code, when the variable goes <em>out of scope</em>. If, instead, you want to create a variable which is <em>global</em> (available forever, after it is created), you can omit the '<code>var</code>'. Keep in mind that making many global variables is generally considered bad practice, and can be expensive in terms of memory use.</p>
+<div class="section">A Javascript Shell</div>
+<p>Javascript, being a scripting language, includes a construct, <code>eval()</code> which allows you to evaluate a <em>string</em> of Javascript. This allows, for example, a user to input Javascript with <code>readline</code>, and it to be executed as if it had been part of your source file. In addition, <code>eval()</code>'s return value is the return value of the snippet of code. For example:</p>
+<pre>
+var output = eval("2+2");
+Seed.print(output);
+</pre>
+<p>Will output:</p>
+<pre>
+4.000000
+</pre>
+<p>When something goes <em>wrong</em> in a piece of Javascript code, the program will exit, most likely leaving the user in a confused state. For example, if you try to access a variable that doesn't exist: <code>Seed.print(asdf);</code> Seed will exit with the message: <code>ReferenceError Can't find variable: asdf</code>. It is possible to catch this sort of error, or exception, inside of your Javascript program, ensuring that it doesn't terminate your program - or that if it does, it prints a useful error message. The <code>try/catch</code> construct provides a way to <em>try</em> to execute a segment of Javascript, and, if it fails, run a second segment, without exiting the program. The second segment could print a user-friendly error message, ignore the exception entirely, or try to work around the problem. A quick example of <code>try/catch</code>:</p>
+<pre>
+try
+{
+    Seed.print(asdf);
+}
+catch(e)
+{
+    Seed.print("Something went wrong!");
+}
+</pre>
+<p>It's also possible to determine what, exactly, went wrong. The '<code>e</code>' in the <code>catch</code> statement (which, by the way, you <em>cannot</em> omit) is actually an object containing information about the exception! We can access some of the basic properties of this object:</p>
+<pre>
+try
+{
+    Seed.print(asdf);
+}
+catch(e)
+{
+    Seed.print("Something went wrong!");
+    Seed.print(e.name);
+    Seed.print(e.message);
+}
+</pre>
+<p>This will print a message similar to what would be printed if you hadn't caught the exception, but <em>without exiting the program!</em></p>
+<p>Combining <code>readline</code>, <code>eval</code>, exceptions, and <code>print</code>, we can write a simple shell, allowing interactive use of Seed. This shell is included in the Seed distribution, in <code>examples/repl.js</code>. Looking at the source, you'll note that it takes very little code to implement a shell:</p>
+<div class="filename">examples/repl.js</div>
+<pre>
+#!/usr/local/bin/seed
+
+while(1)
+{
+    try
+    {
+        Seed.print(eval(Seed.readline("> ")));
+    }
+    catch(e)
+    {
+        Seed.print(e.name + " " + e.message);
+    }
+}
+</pre>
+<p>You can (and <em>should!</em>) use this shell in order to experiment with and learn to use Seed.</p>
+<div class="section">Getting GTK Going</div>
+<p>Thus far in this tutorial, we've been completely ignoring the most useful part of Seed: the ability to use external libraries from within Javascript. The single most useful of these libraries is GTK, the widget and windowing toolkit used by all GNOME applications, which will provide the ability to create and manipulate graphical windows, as well as just about any sort of widget you should require.</p>
+<p>In order to use GTK (or any other external library) in a Seed program, you first have to import the functions from said library. <code>Seed.import_namespace()</code>, taking as its only argument the name of the library to import, does this for us.</p>
+<p>Once the library has been imported, all of its functions are available on a global object with the same name as the library. For example, if we <code>Seed.import_namespace("Gtk")</code>, all of the imported functions are available on the Gtk object: <code><a href="http://library.gnome.org/devel/gtk/2.14/gtk-General.html#gtk-init";>Gtk.init()</a></code>, etc.</p>
+<p>Let's start off the development of our browser by getting Gtk working. It takes very little to get a window displayed with Seed:</p>
+<pre>
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+var window = new Gtk.Window();
+window.show_all();
+
+Gtk.main();
+</pre>
+<p>If you've ever used GTK from C, you'll notice some similarities here. All of the GTK functions have been mapped into Javascript in a reasonable way, but it will certainly take a bit to get used to, for example, <code>new Gtk.Window()</code> instead of <code>gtk_window_new()</code>.</p>
+<p>Executing the above script should give you a window that looks entirely empty and boring, something like the following:</p>
+<div style="text-align: center;"><img src="1.png" alt="Blank GTK Window"/></div>
+<div class="section">JSON Constructors</div>
+<p>Notice that the title of the window is 'seed'. We'll fix that, using another Seed feature: you can use <a href="http://www.json.org/js.html";>JSON notation</a> to set properties while constructing objects, like so:</p>
+<pre>
+var window = new Gtk.Window({title: "Browser"});
+</pre>
+<p>This saves a lot of typing from the alternative, conventional method:</p>
+<pre>
+var window = new Gtk.Window();
+window.set_title("Browser");
+</pre>
+<p>You can set any number of properties this way, by separating them by commas (<code>{"title": "Browser", "default-height": 500}</code>, etc.). This method should work for any GObject constructor.</p>
+<div class="section">Signals</div>
+<p>You'll notice that our program, as it stands, fails to quit when you click the 'Close' button. You can, of course, quit it with Ctrl-C, but this is certainly unacceptable behaviour. To fix it, we'll connect a Javascript function to the signal that gets emitted when the 'Close' button is clicked:</p>
+<pre>
+function quit()
+{
+    Gtk.main_quit();
+}
+
+window.signal_hide.connect(quit);
+</pre>
+<p>The signal names are the same as in the <a href="http://library.gnome.org/devel/gtk/stable/";>GTK documentation</a>, except using underscores instead of dashes between words. </p>
+<div class="section">Local Context with '<code>this</code>'</div>
+<p>Javascript, like some other object-oriented languages, has the concept of a local <i>context</i>. Accessed with the '<code>this</code>' keyword, local contexts allow for neatly contained, transparent signal callbacks, among other things. Imagine we have, a WebKit view, say, <code>browser</code>, and a button, call it <code>back_button</code>. We could certainly make the browser object global, but this would make having multiple browsers (think tabs!) rather annoying. Instead, when setting up the callback, we can provide <code>browser</code> as the '<code>this</code>' object. This gives us the following code:</p>
+<pre>
+function back(button)
+{
+    this.go_back();
+}
+
+function create_browser()
+{
+    var browser;
+    var back_button;
+
+    ...
+
+    back_button.signal_clicked.connect(back, browser);
+}
+</pre>
+<p>In this case, the <code>browser</code> object is passed as the magical <code>this</code> object into the <code>back()</code> function, so <code>go_back()</code> is actually called on <code>browser</code>. The upside to this model is that, no matter how many times <code>create_browser()</code> is called, <code>back()</code> is always provided the <code>browser</code> that corresponds with its <code>back_button</code>.</p>
+<div class="section">Working with Widgets</div>
+<p>We'll start by making the browser's toolbar buttons. GTK provides a ToolButton widget, which is generally used for making such toolbars, as well as various different stock icons (to ensure consistency within all GTK applications). Browsing through <a href="http://library.gnome.org/devel/gtk/2.14/gtk-Stock-Items.html";>the GTK Stock Item documentation</a>, we find that we're looking for "<code>gtk-go-back</code>", "<code>gtk-go-forward</code>", and "<code>gtk-refresh</code>". A glance at the <a href="">GtkToolButton documentation</a> shows us that we can choose a stock icon by setting the <code>stock-id</code> property - we'll use JSON constructors to keep things tidy. Do note that we use underscores instead of dashes, because the property name isn't quoted (thus, a dash would indicate subtraction, which isn't what we're looking for!):</p>
+<pre>
+function create_ui()
+{
+    var main_ui = new Gtk.VBox();
+    var toolbar = new Gtk.HBox();
+
+    var back_button = new Gtk.ToolButton({stock_id: "gtk-go-back"});
+    var forward_button = new Gtk.ToolButton({stock_id: "gtk-go-forward"});
+    var refresh_button = new Gtk.ToolButton({stock_id: "gtk-refresh"});
+
+    var url_entry = new Gtk.Entry();
+
+    back_button.signal_clicked.connect(back);
+    forward_button.signal_clicked.connect(forward);
+    refresh_button.signal_clicked.connect(refresh);
+
+    url_entry.signal_activate.connect(browse);
+
+    toolbar.pack_start(back_button);
+    toolbar.pack_start(forward_button);
+    toolbar.pack_start(refresh_button);
+    toolbar.pack_start(url_entry, true, true);
+
+    main_ui.pack_start(toolbar);
+    return main_ui;
+}
+</pre>
+<p>There are a few things in the snippet above which you probably haven't seen before (unless you've used GTK in another language). Firstly, the Gtk.Entry widget is a simple text entry field, like you would expect in a browser's URL bar. Secondly, you'll notice the use of the Gtk.HBox widget, and its <code>pack_start()</code> function. These serve as the foundation of GUI layout in GTK: a window is subdivided into boxes, which 'pack' widgets in a particular direction (HBoxes pack horizontally, VBoxes pack vertically, as expected). We use a HBox, since we want our toolbar arranged horizontally. <code>pack_start()</code> adds a widget to a Box; widgets are packed in the order they're added. There are optional arguments, which are addressed in more depth in the <a href="http://library.gnome.org/devel/gtk/2.14/GtkBox.html";>GtkBox documentation</a>, which allow you to force widgets to expand into the usable space (the second and third arguments used when packing <code>url_entry</
 code> above serve this purpose).</p>
+<p>We also need a bunch of callbacks (for all three buttons, and for when you're done entering text in the URL bar). We'll make them just print the function they're supposed to perform, for now, since we don't have a WebKit view to operate on yet.</p>
+<pre>
+function forward(button)
+{
+    Seed.print("forward");
+}
+
+function back(button)
+{
+    Seed.print("back");
+}
+
+function refresh(button)
+{
+    Seed.print("refresh");
+}
+
+function browse(button)
+{
+    Seed.print("browser");
+}
+</pre>
+<p>You'll notice that <code>create_ui()</code> returns an VBox with all of the widgets in it - thinking ahead, we're packing the toolbar HBox into a VBox (eventually, we'll add the WebKit view, too!). In fact, to try and get a more visual feel of packing, let's take a look at the Box layout for our browser:</p>
+<div style="text-align: center;"><img src="packing.png" alt="Packing Layout"/></div>
+<p>Right now, nothing's calling <code>create_ui()</code>, so you won't see the toolbar drawn. To remedy this, before <code>window.show_all()</code>, add a line to pack the toolbar:</p>
+<pre>
+window.add(create_ui());
+</pre>
+<p>Your code should be in a runnable state now; take a minute to try it out, stand back, and admire what you've learned:</p>
+<div style="text-align: center;"><img src="2.png" alt="GTK Window with buttons and text entry field" /></div>
+<p>If, for some reason, something doesn't work, compare your code to <a href="1.js">the tutorial version</a>.</p>
+<div class="section">Adding WebKit</div>
+<p>It's finally time to start displaying some web pages with our little browser! Let's create and pack a WebKit web view below our toolbar, first. Create the browser at the top of the <code>create_ui()</code> function (we'll also need to pass the browser as the <code>this</code> object for our button callbacks, so it needs to already be created), and pack it into the <code>main_ui</code> VBox <em>after</em> you pack the toolbar. Here's an updated version of our <code>create_ui()</code> function:</p>
+<pre>
+function create_ui()
+{
+    var main_ui = new Gtk.VBox();
+    var toolbar = new Gtk.HBox();
+
+    <span class="changed">var browser = new WebKit.WebView();</span>
+
+    var back_button = new Gtk.ToolButton({stock_id: "gtk-go-back"});
+    var forward_button = new Gtk.ToolButton({stock_id: "gtk-go-forward"});
+    var refresh_button = new Gtk.ToolButton({stock_id: "gtk-refresh"});
+
+    var url_entry = new Gtk.Entry();
+
+    back_button.signal_clicked.connect(back<span class="changed">, browser</span>);
+    forward_button.signal_clicked.connect(forward<span class="changed">, browser</span>);
+    refresh_button.signal_clicked.connect(refresh<span class="changed">, browser</span>);
+
+    url_entry.signal_activate.connect(browse<span class="changed">, browser</span>);
+
+    toolbar.pack_start(back_button);
+    toolbar.pack_start(forward_button);
+    toolbar.pack_start(refresh_button);
+    toolbar.pack_start(url_entry, true, true);
+
+    main_ui.pack_start(toolbar);
+    <span class="changed">main_ui.pack_start(browser, true, true);</span>
+    return main_ui;
+}
+</pre>
+<p>Also, remember that we need to import a namespace before its functions are available to us! So, go back to the top of the file and import "WebKit", just after you import "Gtk". One final thing, before you again try to run your browser: we haven't yet specified a 'recommended' size for our window - let's go ahead and do that (if we didn't do so, the WebKit view would have no space to fill!). Just after you create the Gtk.Window(), add:</p>
+<pre>
+window.resize(600,600);
+</pre>
+<p>Now, fire up your browser! Hopefully, you'll see a nice blank WebKit view, like below. If you don't, take a peek at <a href="2.js">our version</a>.</p>
+<div style="text-align: center;"><img src="3.png" alt="GTK Window with toolbar and empty browser view" /></div>
+<p>That's really not a very interesting browser, at all - nothing works yet, and there's no way to navigate! Still, we're almost done.</p>
+<div class="section">Finishing our Browser</div>
+<p>Poking around in the <a href="http://svn.webkit.org/repository/webkit/trunk/WebKit/gtk/webkit/webkitwebview.h";>WebKit documentation</a> (the WebKit team is a bit behind on documentation, so all we have to work with is header files), we find that the <code>open()</code> function on a WebView allows you to navigate to a particular page. Just after you create the WebView, have it navigate to your favorite page:</p>
+<pre>
+browser.open("http://www.gnome.org";);
+</pre>
+<p>A quick note about WebKit: if you omit the protocol part of a URL (e.g., http://), WebKit won't even bother to try to figure it out - so make sure you specify it! This is also important for the browse() callback, which is called when you press enter in the URL field, which we'll implement now. To get around this shortcoming, we'll use Javascript's string search function to see if a protocol has been specified, and, if it hasn't, we'll assume it's '<code>http://</code>':</p>
+<pre>
+function browse(url)
+{
+    if(url.text.search("://") < 0)
+    {
+        url.text = "http://"; + url.text;
+    }
+
+    this.open(url.text);
+}
+</pre>
+<p>Almost done! Next we need to implement the button callbacks. Again browsing webkitwebview.h, we find reload(), go_forward(), and go_back() - the last functions needed to finish our browser! Remembering that the browser view is passed as '<code>this</code>' to the functions, go ahead and fill them in:</p>
+<pre>
+function forward(button)
+{
+    this.go_forward();
+}
+
+function back(button)
+{
+    this.go_back();
+}
+
+function refresh(button)
+{
+    this.reload();
+}
+</pre>
+<p>Our final modification will listen to a WebKit signal, and adjust the URL bar when you click a link. The aforementioned webkitwebview.h header file provides us with the name of the signal (load_committed). This signal is different than those we've worked with in the past, as it provides two arguments: the WebView, and a WebFrame. The distinction is important in WebKit-land, but we'll ignore it, noting only that (from the headers, again - this time, webkitwebframe.h) there is a WebFrame get_uri() function which provides the current URL of the frame. Let's first add our signal connection code. Make sure to connect to load_committed <em>after</em> you've created both the WebView and the URL entry field, as the signal is <em>on</em> the browser view, and we want to pass the URL entry field as its <code>this</code> object:</p>
+<pre>
+    browser.signal_load_committed.connect(url_changed, url_entry);
+</pre>
+<p>Next, the callback, <code>url_changed</code>. Remember that we're given two arguments, and that <code>this</code> is the URL entry field:</p>
+<pre>
+function url_changed(browser, frame)
+{
+    this.text = frame.get_uri();
+}
+</pre>
+<p>If all goes well, your browser should now be in a working state, looking much like the following:</p>
+<div style="text-align: center;"><img src="4.png" alt="GTK Window with toolbar and browser view at GNOME.org" /></div>
+<p>You will probably notice, at some point, that opening content in a new tab or new window doesn't work in your browser. This is, in fact, due to an open WebKit bug, <a href="http://bugs.webkit.org/show_bug.cgi?id=19130";>#19130</a>. Once this bug is fixed, the straightforward design of your browser will make it <em>simple</em> to add support for multiple windows.</p>
+<p>The final version of the tutorial's source code is available if you're having trouble; if, however, you made easy work of the tutorial, you should consider making some improvements to your browser: change the window title when the web page title changes (look at the title_changed signal!); add tabs (GtkNotebook is probably what you're looking for); bookmarks are often useful!; perhaps a status menu? Or, go ahead and write your own application in Seed!</p>
+</body>
+</html>

Added: trunk/examples/calculator.js
==============================================================================
--- (empty file)
+++ trunk/examples/calculator.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,152 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gdk");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("GLib");
+
+Gtk.init(null, null);
+
+var window, label;
+var calc_val = "";
+
+function end_program()
+{
+	Gtk.main_quit();
+}
+
+function update_display()
+{
+	label.set_markup("<span size='30000'>" + calc_val + "</span>");
+	
+	if(calc_val == "")
+	{
+		label.set_markup("<span size='30000'>0</span>");
+	}
+}
+
+function clear(button)
+{
+	calc_val = "";
+	update_display();
+}
+
+function backspace(button)
+{
+	calc_val = calc_val.substring(0, calc_val.length - 1);
+	update_display();
+}
+
+function pressed_equals(button)
+{
+	calc_val = calc_val.replace("sin", "Math.sin");
+	calc_val = calc_val.replace("cos", "Math.cos");
+	calc_val = calc_val.replace("tan", "Math.tan");
+	calc_val = eval(calc_val) + "";
+	label.set_markup("<span size='30000'>" + calc_val + "</span>");
+}
+
+function pressed_operator(button)
+{
+	calc_val += button.label;
+	update_display();
+}
+
+function pressed_number(button)
+{
+	calc_val = (((calc_val == 0) ? "" : calc_val) + button.label);
+	update_display();
+}
+
+function swap_sign(button)
+{
+	calc_val = ((calc_val[0] == "-") ? 
+		    calc_val.substring(1) : "-" + calc_val) 
+	update_display();
+}
+
+function random_num()
+{
+	calc_val = Math.floor(Math.random() * 1000) + "";	
+	update_display();
+}
+
+function pack_buttons(buttons, vbox)
+{
+	var hbox = new Gtk.HBox();
+	
+	hbox.homogeneous = true;
+
+	vbox.pack_start(hbox, true, true, 2);
+	
+	for(i = 0; i <= 4; i++)
+	{
+		hbox.pack_start(buttons[i], true, true, 1);
+	}
+}
+
+function create_button(str, func)
+{
+	var btn = new Gtk.Button({label:str});
+	btn.signal_clicked.connect(func, btn);
+	return btn;
+}
+
+function create_buttons()
+{
+	var vbox = new Gtk.VBox();
+	
+	vbox.homogeneous = true;
+	
+	pack_buttons([	create_button("(", pressed_number),
+						create_button("â", backspace),
+						create_button("â", random_num),
+						create_button("Clr", clear),
+						create_button("Â", swap_sign)], vbox);
+						
+
+	pack_buttons([	create_button(")", pressed_number),
+						create_button("7", pressed_number),
+						create_button("8", pressed_number),
+						create_button("9", pressed_number),
+						create_button("/", pressed_operator)], vbox);
+	
+	pack_buttons([	create_button("sin(", pressed_number),
+						create_button("4", pressed_number),
+						create_button("5", pressed_number),
+						create_button("6", pressed_number),
+						create_button("*", pressed_operator)], vbox);
+
+	pack_buttons([	create_button("cos(", pressed_number),
+						create_button("1", pressed_number),
+						create_button("2", pressed_number),
+						create_button("3", pressed_number),
+						create_button("-", pressed_operator)], vbox);
+	
+	pack_buttons([	create_button("tan(", pressed_number),
+						create_button("0", pressed_number),
+						create_button(".", pressed_number),
+						create_button("=", pressed_equals),
+						create_button("+", pressed_operator)], vbox);
+
+	return vbox;
+}
+
+var window = new Gtk.Window({title: "Calculator", resizable: false});
+
+window.resize(250, 250);
+window.signal_hide.connect(end_program);
+window.opacity = 0.95;
+
+var label = new Gtk.Label({label: ""});
+label.set_alignment(1,0);
+update_display();
+
+var mainvbox = new Gtk.VBox();
+mainvbox.pack_start(label, false, true, 1);
+mainvbox.pack_start(new Gtk.HSeparator(), false, true, 5);
+mainvbox.pack_start(create_buttons(), true, true, 2);
+
+window.add(mainvbox);
+window.show_all();
+Gtk.main();
+

Added: trunk/examples/clutter.js
==============================================================================
--- (empty file)
+++ trunk/examples/clutter.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,44 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Clutter");
+
+Clutter.init(null, null);
+
+var stage = new Clutter.Stage();
+var texture = new Clutter.Texture({filename:"bob.jpg"});
+var reflection = new Clutter.CloneTexture({parent_texture:texture});
+var black = Clutter.Color._new();
+
+Clutter.color_parse("Black", black);
+
+
+stage.set_color(black);
+stage.add_actor(texture);
+stage.add_actor(reflection);
+
+reflection.width = reflection.height = 
+   texture.height = texture.width = .55*stage.height;
+texture.x = stage.width/2;
+texture.y = stage.height/2;
+reflection.x = texture.x
+reflection.y = texture.y+texture.height;
+reflection.rotation_angle_z = 180;
+
+reflection.opacity = 80;
+
+reflection.anchor_x = texture.anchor_x = texture.width/2;
+reflection.anchor_y = texture.anchor_y = texture.height/2;
+
+reflection.rotation_angle_y=330;
+texture.rotation_angle_y=30;
+timeline = new Clutter.Timeline({fps:30, num_frames: 60});
+timeline.signal_new_frame.connect(function(timeline, frame_num)
+			  {
+			      texture.rotation_angle_y+=3;
+			      reflection.rotation_angle_y-=3;
+			  });
+timeline.start();
+
+
+stage.show_all();
+Clutter.main();
+

Added: trunk/examples/ide/exception.svg
==============================================================================
--- (empty file)
+++ trunk/examples/ide/exception.svg	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="193.57143"
+   height="193.57143"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   version="1.0"
+   sodipodi:docname="exception.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <defs
+     id="defs4">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective10" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10000"
+     guidetolerance="10"
+     objecttolerance="10"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.35"
+     inkscape:cx="-139.28571"
+     inkscape:cy="520"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1440"
+     inkscape:window-height="817"
+     inkscape:window-x="0"
+     inkscape:window-y="33" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-280.35714,-232.71932)">
+    <path
+       sodipodi:type="arc"
+       style="opacity:1;fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="path2383"
+       sodipodi:cx="377.14285"
+       sodipodi:cy="329.50504"
+       sodipodi:rx="94.285713"
+       sodipodi:ry="94.285713"
+       d="M 471.42857,329.50504 A 94.285713,94.285713 0 1 1 282.85714,329.50504 A 94.285713,94.285713 0 1 1 471.42857,329.50504 z" />
+  </g>
+</svg>

Added: trunk/examples/ide/ide.js
==============================================================================
--- (empty file)
+++ trunk/examples/ide/ide.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,140 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Vte");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("GtkSource");
+Seed.import_namespace("Gio");
+
+Gtk.init(null, null);
+
+Seed.include("toolbar.js");
+Seed.include("tabview.js");
+
+//var itr = Gtk.text_iter_create();
+
+function exception_clear(sbuf)
+{
+    //var begin = Gtk.text_iter_create();
+    //var end = Gtk.text_iter_create();
+    
+    //sbuf.get_start_iter(begin);
+    //sbuf.get_end_iter(end);
+    
+    //sbuf.remove_source_marks(begin, end, "exception");
+}
+
+function exception_line(sbuf, e)
+{
+    //var itr = Gtk.text_iter_create();
+
+    //sbuf.get_iter_at_line(itr, e.line - 1);
+    
+    //exception_clear(sbuf);
+    
+    //sbuf.create_source_mark("error!!", "exception", itr);
+}
+
+function text_changed(sbuf)
+{
+    sbuf.update_undo_state(this);
+    
+    var text = sbuf.text.replace(/#!.*/, "");
+    
+    try
+    {
+        Seed.check_syntax(text);
+    }
+    catch(e)
+    {
+        exception_line(sbuf, e);
+        return;
+    }
+    
+    exception_clear(sbuf);
+}
+
+function update_window(new_filename)
+{
+    var shortfilename = new_filename.split("/").slice(-1);
+    
+    if(new_filename != "")
+        window.title = "Seed IDE - " + shortfilename;
+    else
+        window.title = "Seed IDE";
+}
+
+function update_filename(new_filename, tab)
+{
+    tab.filename = new_filename;
+    
+    update_window(new_filename);
+    
+    var shortfilename = new_filename.split("/").slice(-1);
+    
+    if(tab.filename != "")
+        tab.tab_header.tab_label.label = shortfilename;
+    else
+        tab.tab_header.tab_label.label = "Untitled";
+    
+}
+
+function ide_source_view()
+{
+    var source_lang_mgr = new GtkSource.SourceLanguageManager();
+    var js_lang = source_lang_mgr.get_language("js");
+
+    this.source_buf = new GtkSource.SourceBuffer({language: js_lang});
+    
+    Seed.prototype(GtkSource.SourceBuffer).load_file_data = function(new_filename, tab)
+    {
+        update_filename(new_filename, tab);
+        
+        var file = Gio.file_new_for_path(tab.filename);
+        
+        this.begin_not_undoable_action();
+        this.text = file.read().get_contents();
+        this.end_not_undoable_action();
+    }
+    
+    Seed.prototype(GtkSource.SourceBuffer).update_undo_state = function(tbar)
+    {
+        tbar.undo_button.sensitive = this.can_undo;
+        tbar.redo_button.sensitive = this.can_redo;
+    }
+    
+    var epb = new Gtk.Image({"file": "./exception.svg"});
+    
+    this.source_view = GtkSource.SourceView.new_with_buffer(this.source_buf);
+    this.source_view.set_show_line_numbers(true);
+    this.source_view.set_show_right_margin(true);
+    this.source_view.set_highlight_current_line(true);
+    this.source_view.set_right_margin_position(80);
+    this.source_view.set_mark_category_pixbuf("exception", epb.pixbuf);
+    this.source_view.set_show_line_marks(true);
+}
+
+function create_frame(child)
+{
+    var scroll = new Gtk.ScrolledWindow({vscrollbar_policy: Gtk.PolicyType.automatic, hscrollbar_policy: Gtk.PolicyType.automatic});
+    scroll.add(child);
+    
+    var frame = new Gtk.Frame();
+    frame.set_shadow_type(1); // fricking enums don't work.
+    frame.add(scroll);
+    
+    return frame;
+}
+
+function ide_init()
+{
+    window = new Gtk.Window();
+    window.resize(600, 600);
+    window.signal_hide.connect(Gtk.main_quit);
+    ui = new ide_ui();
+    window.add(tabs);
+    window.show_all();
+    
+    Gtk.main();
+}
+
+ide_init();

Added: trunk/examples/ide/tabview.js
==============================================================================
--- (empty file)
+++ trunk/examples/ide/tabview.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,85 @@
+function close_tab(button)
+{
+    if(tabs.get_n_pages() > 1)
+    {
+        tabs.remove_page(tabs.page_num(this));
+    }
+    else
+    {
+        tabs.remove_page(tabs.page_num(this));
+        new ide_tab("");
+    }
+}
+
+function tab_header(nm, tab)
+{
+    var close_button = new Gtk.Button();
+	close_button.set_image(new Gtk.Image({stock: "gtk-close", icon_size: Gtk.IconSize.menu}));
+	close_button.signal_clicked.connect(close_tab, tab);
+	close_button.set_relief(Gtk.ReliefStyle.none);
+	
+	this.tab_label = new Gtk.Label({label:nm});
+	
+	this.tab_header = new Gtk.HBox();
+	this.tab_header.pack_start(this.tab_label);
+	this.tab_header.pack_start(close_button);
+	this.tab_header.show_all();
+}
+
+function ide_tab(fn)
+{
+    this.source_view = new ide_source_view();
+    this.terminal = new Vte.Terminal();
+    this.toolbar = new ide_toolbar(this);
+    this.pane = new Gtk.VPaned();
+
+    this.pane.add1(create_frame(this.source_view.source_view));
+    this.pane.add2(create_frame(this.terminal));
+    
+    this.pane.set_position(600 * (2/3));
+
+    this.source_view.source_buf.signal_changed.connect(text_changed, this.toolbar);
+    this.source_view.source_buf.update_undo_state(this.toolbar);
+    
+    this.main_vbox = new Gtk.VBox();
+    this.main_vbox.pack_start(this.toolbar.toolbar);
+    this.main_vbox.pack_start(this.pane, true, true);
+    
+    this.tab_header = new tab_header(this.filename, this.main_vbox);
+    
+    if(!fn == "")
+        this.source_view.source_buf.load_file_data(fn, this);
+    else
+        update_filename("", this);
+    
+    tabs.append_page(this.main_vbox, this.tab_header.tab_header);
+	tabs.set_tab_reorderable(this.main_vbox, true);
+	tabs.show_all();
+}
+
+function change_page(a, b, c)
+{
+    Seed.print("lol");
+    //Seed.print(tabs.get_tab_label(tabs.get_nth_page(n)));
+    //update_window();
+}
+
+function select_page(nb, tab, n)
+{
+    tabs.set_current_page(n);
+}
+
+function ide_ui()
+{
+    tabs = new Gtk.Notebook();
+    
+    // FIXME: ROBB: tabs.signal_switch_page.connect(change_page);
+    
+    //tabs.signal_switch_page.connect(change_page);
+    tabs.signal_page_added.connect(select_page);
+    
+    tabs.set_scrollable(true);
+    
+    var tab = new ide_tab("../ls.js");
+}
+

Added: trunk/examples/ide/toolbar.js
==============================================================================
--- (empty file)
+++ trunk/examples/ide/toolbar.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,105 @@
+function new_file(sv)
+{
+    var tab = new ide_tab("");
+}
+
+function open_file(sv)
+{
+    var file_chooser = new Gtk.FileChooserDialog();
+    var file_filter = new Gtk.FileFilter();
+    file_filter.add_mime_type("text/javascript");
+    file_chooser.set_filter(file_filter);
+    file_chooser.add_button("Cancel", Gtk.ResponseType.cancel);
+    file_chooser.add_button("Open", Gtk.ResponseType.accept);
+    file_chooser.set_action(Gtk.FileChooserAction.open);
+    
+    if(file_chooser.run() == Gtk.ResponseType.accept)
+    {
+        if(this.filename == "")
+            this.source_view.source_buf.load_file_data(file_chooser.get_filename(), this);
+        else
+            var tab = new ide_tab(file_chooser.get_filename());
+    }
+    
+    file_chooser.destroy();
+}
+
+function save_file()
+{
+    if(this.filename == "")
+    {
+        var file_chooser = new Gtk.FileChooserDialog();
+        var file_filter = new Gtk.FileFilter();
+        file_filter.add_mime_type("text/javascript");
+        file_chooser.set_filter(file_filter);
+        file_chooser.add_button("Cancel", Gtk.ResponseType.cancel);
+        file_chooser.add_button("Save", Gtk.ResponseType.accept);
+        file_chooser.set_action(Gtk.FileChooserAction.save);
+
+        if(file_chooser.run() == Gtk.ResponseType.accept)
+        {
+            update_filename(file_chooser.get_filename(), this);
+        }
+
+        file_chooser.destroy();
+    }
+    
+    if(this.filename != "")
+        Gio.simple_write(this.filename, this.source_view.source_buf.text);
+}
+
+function undo(button)
+{
+    this.source_view.source_buf.undo();
+    this.source_view.source_buf.update_undo_state(this.toolbar);
+}
+
+function redo(button)
+{
+    this.source_view.source_buf.redo();
+    this.source_view.source_buf.update_undo_state(this.toolbar);
+}
+
+function execute()
+{
+    if(this.filename == "")
+        return; // TODO: something more intelligent!
+    
+    Gio.simple_write(this.filename, this.source_view.source_buf.text);
+    
+    this.terminal.reset(true, true);
+    this.terminal.fork_command("/bin/dash");
+    
+    var command = "clear ; /usr/local/bin/seed \"" + this.filename + "\" ; sleep 1d\n";
+    
+    this.terminal.feed_child(command, command.length);
+}
+
+function ide_toolbar(tab)
+{
+    this.toolbar = new Gtk.Toolbar();
+    
+    this.new_button = new Gtk.ToolButton({stock_id:"gtk-new"});
+    this.open_button = new Gtk.ToolButton({stock_id:"gtk-open"});
+    this.save_button = new Gtk.ToolButton({stock_id:"gtk-save"});
+    this.undo_button = new Gtk.ToolButton({stock_id:"gtk-undo"});
+    this.redo_button = new Gtk.ToolButton({stock_id:"gtk-redo"});
+    this.run_button = new Gtk.ToolButton({stock_id:"gtk-execute"});
+
+    this.new_button.signal_clicked.connect(new_file, tab);
+    this.open_button.signal_clicked.connect(open_file, tab);
+    this.save_button.signal_clicked.connect(save_file, tab);
+    this.undo_button.signal_clicked.connect(undo, tab);
+    this.redo_button.signal_clicked.connect(redo, tab);
+    this.run_button.signal_clicked.connect(execute, tab);
+    
+    this.toolbar.insert(this.new_button, -1);
+    this.toolbar.insert(this.open_button, -1);
+    this.toolbar.insert(this.save_button, -1);
+    this.toolbar.insert(new Gtk.SeparatorToolItem(), -1);
+    this.toolbar.insert(this.undo_button, -1);
+    this.toolbar.insert(this.redo_button, -1);
+    this.toolbar.insert(new Gtk.SeparatorToolItem(), -1);
+    this.toolbar.insert(this.run_button, -1);
+}
+

Added: trunk/examples/lightsoff/lightsoff.js
==============================================================================
--- (empty file)
+++ trunk/examples/lightsoff/lightsoff.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,198 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gtk");
+
+image_off = new Gtk.Image({"file": "./tim-off.svg"});
+image_on = new Gtk.Image({"file": "./tim-on.svg"});
+
+/* SxS size*/
+var size = 5;
+var wincount = 0;
+var moves = 0;
+
+function create_board_size_menu()
+{
+    var menu = new Gtk.Menu();
+    
+    var size_5 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "5x5"})});
+    var size_7 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "7x7"})});
+    var size_9 = new Gtk.MenuItem({"child": new Gtk.Label({"label": "9x9"})});
+    
+    menu.append(size_5);
+    menu.append(size_7);
+    menu.append(size_9);
+    
+    return menu;
+}
+
+function create_menu()
+{
+    var menu = new Gtk.MenuBar();
+    
+    var game_menu = new Gtk.Menu();
+    var size_item = new Gtk.MenuItem({"child":
+                                      new Gtk.Label({"label": "Board Size"})});
+    size_item.signal_activate.connect(Gtk.main_quit);
+    //size_item.submenu = create_board_size_menu(); // crashy?!
+    
+    var quit_item = new Gtk.MenuItem({"child":
+                                      new Gtk.Label({"label": "Quit"})});
+    quit_item.signal_activate.connect(Gtk.main_quit);
+    
+    game_menu.append(size_item);
+    game_menu.append(quit_item);
+    
+    var game_menu_item = new Gtk.MenuItem({"child":
+                                           new Gtk.Label({"label": "Game"})});
+    game_menu_item.submenu = game_menu;
+    
+    menu.append(game_menu_item);
+    
+    return menu;
+}
+
+function create_board()
+{
+	var table = new Gtk.Table();
+	table.resize(size,size);
+    
+	buttons = new Array(size);
+
+	for (i = 0; i < size; ++i)
+	{
+		buttons[i] = new Array(size);
+		for (j = 0; j < size; ++j)
+		{
+			buttons[i][j] = new Gtk.Button();
+	
+			buttons[i][j].x = i;
+			buttons[i][j].y = j;
+
+			buttons[i][j].set_relief(Gtk.ReliefStyle.none);
+			buttons[i][j].can_focus = false;
+		
+			buttons[i][j].signal_clicked.connect(button_clicked,
+							     buttons[i][j]);
+			table.attach_defaults(buttons[i][j], j, j+1, i, i+1);
+		}
+	}
+    
+	return table;
+}
+
+function clear_board()
+{
+	for(i = 0; i < size; ++i)
+	{
+		for(j = 0; j < size; ++j)
+		{
+			buttons[i][j].lit = false;
+			buttons[i][j].set_image(new Gtk.Image({"pixbuf": 
+							image_off.pixbuf}));
+		}
+	}
+}
+
+function initialize_game()
+{
+	wincount = 0;
+	  
+	clear_board();
+	random_clicks(); // generate random puzzle
+	
+	moves = 0;
+}
+
+function do_click(x , y)
+{
+	if ( x < size - 1 )
+		flip_color(x + 1, y);
+	if ( x > 0 )
+		flip_color(x - 1, y);
+	if ( y < size - 1 )
+		flip_color(x, y + 1);
+	if ( y > 0 )
+		flip_color(x, y - 1);
+
+	flip_color(x,y);
+	
+	++moves;
+}
+
+function button_clicked( button )
+{
+	do_click(this.x, this.y);
+
+	if ( wincount == 0 )
+	{
+		Seed.print("GLORIOUS VICTORY in " + moves + " moves!");
+		initialize_game();
+	}
+}
+
+/* simulate random clicks to generate a random but solvable puzzle */
+function random_clicks()
+{
+	var count = Math.round(size*5* Math.random());
+
+	var sym = Math.floor(3*Math.random());
+
+	for (q = 0; q < count + 5; ++q)
+	{
+		i = Math.round((size-1) * Math.random());
+		j = Math.round((size-1) * Math.random());
+	    
+		do_click(i, j);
+	    
+		if (sym == 0)
+		{
+			do_click(Math.abs(i-(size-1)), j);
+		}
+		else if (sym == 1)
+		{
+			do_click(Math.abs(i-(size-1)), Math.abs(j-(size-1)));
+		}
+		else
+		{
+			do_click(i,Math.abs(j-(size-1)));
+		}
+	}
+	//do it again if you won already
+	if ( wincount == 0 )
+		random_clicks();
+}
+
+function flip_color(i, j)
+{
+	if ( buttons[i][j].lit )
+	{
+		--wincount;
+		buttons[i][j].set_image(new Gtk.Image({"pixbuf":
+						image_off.pixbuf}));
+	}
+	else
+	{
+		++wincount;
+		buttons[i][j].set_image(new Gtk.Image({"pixbuf": 
+						image_on.pixbuf}));
+	}
+
+	buttons[i][j].lit = !buttons[i][j].lit;
+}
+
+Gtk.init(null, null);
+
+var window = new Gtk.Window({"title": "Lights Off", "resizable" : false});
+window.signal_hide.connect(Gtk.main_quit);
+
+vbox = new Gtk.VBox();
+
+vbox.pack_start(create_menu());
+vbox.pack_start(create_board());
+
+window.add(vbox);
+
+window.show_all();
+initialize_game();
+
+Gtk.main();
+

Added: trunk/examples/lightsoff/tim-off.svg
==============================================================================
--- (empty file)
+++ trunk/examples/lightsoff/tim-off.svg	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,228 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="49.999996"
+   height="49.999996"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   sodipodi:docname="tim-off.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
+   version="1.0">
+  <defs
+     id="defs4">
+    <linearGradient
+       id="linearGradient3537">
+      <stop
+         id="stop3539"
+         offset="0"
+         style="stop-color:#ffffff;stop-opacity:1;" />
+      <stop
+         id="stop3541"
+         offset="1"
+         style="stop-color:#ffffff;stop-opacity:0;" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3486">
+      <stop
+         id="stop3488"
+         offset="0"
+         style="stop-color:#000000;stop-opacity:1;" />
+      <stop
+         id="stop3492"
+         offset="1"
+         style="stop-color:#000000;stop-opacity:0;" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3444">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop3446" />
+      <stop
+         id="stop3452"
+         offset="0.5"
+         style="stop-color:#ffffff;stop-opacity:0;" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0;"
+         offset="1"
+         id="stop3448" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective10" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3444"
+       id="linearGradient3450"
+       x1="523.37036"
+       y1="199.07346"
+       x2="523.37036"
+       y2="491.56064"
+       gradientUnits="userSpaceOnUse" />
+    <filter
+       inkscape:collect="always"
+       id="filter3478">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="4.3633868"
+         id="feGaussianBlur3480" />
+    </filter>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3486"
+       id="linearGradient3484"
+       gradientUnits="userSpaceOnUse"
+       x1="523.37036"
+       y1="199.07346"
+       x2="523.37036"
+       y2="491.56064" />
+    <filter
+       inkscape:collect="always"
+       id="filter3522">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="7.7237026"
+         id="feGaussianBlur3524" />
+    </filter>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3537"
+       id="linearGradient3535"
+       x1="230.45604"
+       y1="258.33267"
+       x2="526.98688"
+       y2="258.33267"
+       gradientUnits="userSpaceOnUse" />
+    <filter
+       inkscape:collect="always"
+       id="filter3555">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="2.1159682"
+         id="feGaussianBlur3557" />
+    </filter>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3444"
+       id="linearGradient2463"
+       gradientUnits="userSpaceOnUse"
+       x1="523.37036"
+       y1="199.07346"
+       x2="523.37036"
+       y2="491.56064" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3486"
+       id="linearGradient2465"
+       gradientUnits="userSpaceOnUse"
+       x1="523.37036"
+       y1="199.07346"
+       x2="523.37036"
+       y2="491.56064" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3537"
+       id="linearGradient2467"
+       gradientUnits="userSpaceOnUse"
+       x1="230.45604"
+       y1="258.33267"
+       x2="526.98688"
+       y2="258.33267" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10000"
+     guidetolerance="10"
+     objecttolerance="10"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="11.700001"
+     inkscape:cx="9.615384"
+     inkscape:cy="24.999998"
+     inkscape:document-units="px"
+     inkscape:current-layer="g2456"
+     showgrid="false"
+     inkscape:window-width="1385"
+     inkscape:window-height="814"
+     inkscape:window-x="47"
+     inkscape:window-y="33" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-228.95604,-443.03212)">
+    <g
+       id="g2456"
+       transform="matrix(0.1669277,0,0,0.1669277,190.73693,410.7314)">
+      <rect
+         ry="20"
+         rx="20"
+         y="195.00127"
+         x="230.45604"
+         height="296.53085"
+         width="296.53085"
+         id="rect2650"
+         style="fill:#203746;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <rect
+         style="opacity:0.43781098;fill:url(#linearGradient2463);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.94291234;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter3478)"
+         id="rect3442"
+         width="289.29773"
+         height="292.48718"
+         x="234.0726"
+         y="199.07346"
+         rx="19.512152"
+         ry="19.72727" />
+      <rect
+         transform="matrix(1,0,0,-0.4905991,0,589.22589)"
+         ry="19.72727"
+         rx="19.512152"
+         y="199.07346"
+         x="234.0726"
+         height="292.48718"
+         width="289.29773"
+         id="rect3482"
+         style="opacity:0.43781098;fill:url(#linearGradient2465);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.94291234;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter3522)" />
+      <path
+         sodipodi:nodetypes="cccccc"
+         id="rect3526"
+         d="M 250.45604,195.00127 L 506.98689,195.00127 C 518.06689,195.00127 526.98689,203.92127 526.98689,215.00127 L 526.80938,321.40374 C 327.27502,327.77728 230.45604,215.00127 230.45604,215.00127 C 230.45604,203.92127 239.37604,195.00127 250.45604,195.00127 z"
+         style="opacity:0.12601626;fill:url(#linearGradient2467);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;filter:url(#filter3555)" />
+      <rect
+         style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+         id="rect3559"
+         width="296.53085"
+         height="296.53085"
+         x="230.45604"
+         y="195.00127"
+         rx="20"
+         ry="20" />
+    </g>
+  </g>
+</svg>

Added: trunk/examples/lightsoff/tim-on.svg
==============================================================================
--- (empty file)
+++ trunk/examples/lightsoff/tim-on.svg	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="49.999996"
+   height="49.999996"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   sodipodi:docname="tim-on.svg"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape"
+   inkscape:export-filename="/Users/hortont/Desktop/drawingON.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90"
+   version="1.0">
+  <defs
+     id="defs4">
+    <linearGradient
+       id="linearGradient3537">
+      <stop
+         id="stop3539"
+         offset="0"
+         style="stop-color:#ffffff;stop-opacity:1;" />
+      <stop
+         id="stop3541"
+         offset="1"
+         style="stop-color:#ffffff;stop-opacity:0;" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3486">
+      <stop
+         id="stop3488"
+         offset="0"
+         style="stop-color:#000000;stop-opacity:1;" />
+      <stop
+         id="stop3492"
+         offset="1"
+         style="stop-color:#000000;stop-opacity:0;" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3444">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop3446" />
+      <stop
+         id="stop3452"
+         offset="0.5"
+         style="stop-color:#ffffff;stop-opacity:0;" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0;"
+         offset="1"
+         id="stop3448" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective10" />
+    <filter
+       inkscape:collect="always"
+       id="filter3478">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="4.3633868"
+         id="feGaussianBlur3480" />
+    </filter>
+    <filter
+       inkscape:collect="always"
+       id="filter3522">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="7.7237026"
+         id="feGaussianBlur3524" />
+    </filter>
+    <filter
+       inkscape:collect="always"
+       id="filter3555">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="2.1159682"
+         id="feGaussianBlur3557" />
+    </filter>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3444"
+       id="linearGradient2440"
+       gradientUnits="userSpaceOnUse"
+       x1="523.37036"
+       y1="199.07346"
+       x2="523.37036"
+       y2="491.56064" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3486"
+       id="linearGradient2442"
+       gradientUnits="userSpaceOnUse"
+       x1="523.37036"
+       y1="199.07346"
+       x2="523.37036"
+       y2="491.56064" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3537"
+       id="linearGradient2444"
+       gradientUnits="userSpaceOnUse"
+       x1="230.45604"
+       y1="258.33267"
+       x2="526.98688"
+       y2="258.33267" />
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10000"
+     guidetolerance="10"
+     objecttolerance="10"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="11.700001"
+     inkscape:cx="24.999998"
+     inkscape:cy="24.999998"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1385"
+     inkscape:window-height="814"
+     inkscape:window-x="0"
+     inkscape:window-y="33" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-353.37656,-318.61163)">
+    <g
+       id="g2433"
+       transform="matrix(0.1669277,0,0,0.1669277,315.15745,286.31091)">
+      <rect
+         ry="20"
+         rx="20"
+         y="195.00127"
+         x="230.45604"
+         height="296.53085"
+         width="296.53085"
+         id="rect2650"
+         style="fill:#1ea3f9;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <rect
+         style="opacity:0.94527366;fill:url(#linearGradient2440);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.94291234;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter3478)"
+         id="rect3442"
+         width="289.29773"
+         height="292.48718"
+         x="234.0726"
+         y="199.07346"
+         rx="19.512152"
+         ry="19.72727" />
+      <rect
+         transform="matrix(1,0,0,-0.4905991,0,589.22589)"
+         ry="19.72727"
+         rx="19.512152"
+         y="199.07346"
+         x="234.0726"
+         height="292.48718"
+         width="289.29773"
+         id="rect3482"
+         style="opacity:0.7761194;fill:url(#linearGradient2442);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.94291234;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter3522)" />
+      <path
+         sodipodi:nodetypes="cccccc"
+         id="rect3526"
+         d="M 250.45604,195.00127 L 506.98689,195.00127 C 518.06689,195.00127 526.98689,203.92127 526.98689,215.00127 L 526.80938,321.40374 C 327.27502,327.77728 230.45604,215.00127 230.45604,215.00127 C 230.45604,203.92127 239.37604,195.00127 250.45604,195.00127 z"
+         style="opacity:0.89054727;fill:url(#linearGradient2444);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;filter:url(#filter3555)" />
+      <rect
+         style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+         id="rect3559"
+         width="296.53085"
+         height="296.53085"
+         x="230.45604"
+         y="195.00127"
+         rx="20"
+         ry="20" />
+    </g>
+  </g>
+</svg>

Added: trunk/examples/ls.js
==============================================================================
--- (empty file)
+++ trunk/examples/ls.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,14 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gio");
+
+if (Seed.argv.length < 3)
+    file = Gio.file_new_for_path(".");
+else
+    file = Gio.file_new_for_path(Seed.argv[2]);
+
+enumerator = file.enumerate_children("standard::name");
+
+while (child = enumerator.next_file())
+{
+	Seed.print(child.get_name());
+}

Added: trunk/examples/mini-browser.js
==============================================================================
--- (empty file)
+++ trunk/examples/mini-browser.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,152 @@
+#!/usr/local/bin/seed
+
+Seed.import_namespace("Gtk");
+Seed.import_namespace("WebKit");
+
+var tabs;
+
+function forward(button)
+{
+	this.go_forward();
+}
+
+function back(button)
+{
+	this.go_back();
+}
+
+function refresh(button)
+{
+	this.reload();
+}
+
+function title_changed(view, title)
+{
+	var tab_title = title.title;
+	
+	if(tab_title.length > 25)
+		tab_title = tab_title.slice(0,25) + "...";
+	
+   this.label = tab_title;
+}
+
+function browse(url_entry)
+{
+	if (url_entry.text.search("://") < 0)
+	{
+		url_entry.text = "http://"; + url_entry.text;
+	}
+	
+	this.open(url_entry.text);
+}
+
+function new_tab(browser_view, browser_frame, new_frame)
+{
+	//new_frame = new WebKit.WebView();
+	//Seed.print(browser_view);
+	//Seed.print(browser_frame);
+	//Seed.print(new_frame);
+	new_frame = this.create_tab("");
+	return true;
+}
+
+function url_changed(browser_view, browser_frame)
+{
+	this.text = browser_frame.get_uri();
+	return true;
+}
+
+function close_tab(button)
+{
+    if(tabs.get_n_pages() > 1)
+    {
+        tabs.remove_page(tabs.page_num(this));
+    }
+}
+
+function create_toolbar(browser_view)
+{
+	var toolbar = new Gtk.HBox();
+	
+	var back_button = new Gtk.ToolButton({stock_id:"gtk-go-back"});
+	back_button.signal_clicked.connect(back, browser_view);
+	
+	var forward_button = new Gtk.ToolButton({stock_id:"gtk-go-forward"});
+	forward_button.signal_clicked.connect(forward, browser_view);
+	
+	var refresh_button = new Gtk.ToolButton({stock_id:"gtk-refresh"});
+	refresh_button.signal_clicked.connect(refresh, browser_view);
+	
+	toolbar.pack_start(back_button);
+	toolbar.pack_start(forward_button);
+	toolbar.pack_start(refresh_button);
+	
+	return toolbar;
+}
+
+function create_tab(loc)
+{
+	var tab = new Gtk.VBox();
+	
+	var browser_title = new Gtk.Label({label:"Untitled"});
+	var browser_view = new WebKit.WebView();
+	
+	var url_entry = new Gtk.Entry();
+	url_entry.signal_activate.connect(browse, browser_view);
+
+	browser_view.set_scroll_adjustments(null,null);
+	browser_view.signal_title_changed.connect(title_changed, browser_title);
+	browser_view.signal_load_committed.connect(url_changed, url_entry);
+	//browser_view.signal_create_web_view.connect(new_tab, this);
+	browser_view.open(loc);
+	
+	var toolbar = create_toolbar(browser_view);
+	toolbar.pack_start(url_entry, true, true);
+	
+	tab.pack_start(toolbar);
+	tab.pack_start(browser_view, true, true);
+	
+	var close_button = new Gtk.Button();
+	close_button.set_image(new Gtk.Image({stock: "gtk-close", icon_size: Gtk.IconSize.menu}));
+	close_button.signal_clicked.connect(close_tab, tab);
+	close_button.set_relief(Gtk.ReliefStyle.none);
+	
+	var tab_header = new Gtk.HBox();
+	tab_header.pack_start(browser_title);
+	tab_header.pack_start(close_button);
+	tab_header.show_all();
+	
+	this.append_page(tab, tab_header);
+	this.set_tab_reorderable(tab, true);
+	this.show_all();
+}
+
+function create_ui()
+{
+	var vbox = new Gtk.VBox();
+	
+	tabs = new Gtk.Notebook();
+	tabs.create_tab = create_tab;
+	
+	tabs.create_tab("http://www.reddit.com/";);
+	tabs.create_tab("http://www.google.com/";);
+	vbox.pack_start(tabs, true, true);
+	
+	return vbox;
+}
+
+function browser_init()
+{
+	Gtk.init(null, null);
+	var window = new Gtk.Window({title: "Browser"});
+	window.signal_hide.connect(Gtk.main_quit);
+	window.resize(800,800);
+	
+	window.add(create_ui());
+	
+	window.show_all();
+	Gtk.main();
+}
+
+browser_init();
+

Added: trunk/examples/n-oscillator.js
==============================================================================
--- (empty file)
+++ trunk/examples/n-oscillator.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,100 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gtk","2.0");
+Seed.import_namespace("Gst","0.10");
+
+Gst.init(null, null);
+Gtk.init(null, null);
+
+function oscillator(freq)
+{
+	this.vbox = new Gtk.VBox();
+	this.hbox = new Gtk.HBox();
+	this.vscale = new Gtk.VScale();
+	this.volscale = new Gtk.VScale();
+	this.button = new Gtk.Button({label: "Toggle"});
+	
+	this.pipeline = new Gst.Pipeline({name: "test"});
+	this.audiosrc = Gst.element_factory_make("audiotestsrc", "audio");
+	this.audiosink = Gst.element_factory_make("alsasink", "sink");
+	this.volume = Gst.element_factory_make("volume", "vcontrol");
+	this.audiosrc.freq = freq;
+	
+	this.pipeline.add(this.audiosrc);
+	this.pipeline.add(this.audiosink);
+	this.pipeline.add(this.volume);
+	this.audiosrc.link(this.volume);
+	this.volume.link(this.audiosink);
+	
+	this.playing = false;
+	
+	var adjustment = this.vscale.get_adjustment();
+	adjustment.upper = 3000;
+	adjustment.value = freq;
+	
+	var adjustment = this.volscale.get_adjustment();
+	adjustment.upper = 10;
+	adjustment.value = this.volume.volume;
+	
+	this.hbox.pack_start(this.vscale, true, true, 10);
+	this.hbox.pack_start(this.volscale, true, true, 10);
+	this.vbox.pack_start(this.hbox, true, true, 10);
+	this.vbox.pack_start(this.button, false, false, 10);
+	
+	this.toggle = function(button) 
+	{
+		if (this.playing == false)
+		{
+			this.pipeline.set_state(Gst.State.playing);
+			this.playing = true;
+		}
+		else
+		{
+			this.pipeline.set_state(Gst.State.paused);
+			this.playing = false;
+		}
+	}
+	this.update_freq = function(range)
+	{
+		this.audiosrc.freq = range.get_value();
+	}
+	this.update_vol = function(range)
+	{
+		this.volume.volume = range.get_value();
+	}
+	this.button.signal_clicked.connect(this.toggle, this);
+	this.vscale.signal_value_changed.connect(this.update_freq, this);
+	this.volscale.signal_value_changed.connect(this.update_vol, this);
+}
+
+function end_program()
+{
+	Gtk.main_quit();
+}
+
+var window = new Gtk.Window();
+var button = new Gtk.Button({label: "Add Oscillator"});
+
+window.signal_hide.connect(end_program);
+window.resize(600,300);
+var hbox = new Gtk.HBox();
+
+var os1 = new oscillator(500);
+var os2 = new oscillator(700);
+
+function add_oscillator(button)
+{
+	var os = new oscillator(300);
+	this.pack_start(os.vbox, true, true, 10);
+	os.vbox.show_all();
+}
+button.signal_clicked.connect(add_oscillator, hbox);
+
+window.add(hbox);
+hbox.pack_start(button, true, true, 10);
+hbox.pack_start(os1.vbox, true, true, 10);
+hbox.pack_start(os2.vbox, true, true, 10);
+window.show_all();
+
+
+Gtk.main();
+

Added: trunk/examples/notify-test.js
==============================================================================
--- (empty file)
+++ trunk/examples/notify-test.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,25 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gtk");
+Seed.import_namespace("Gio");
+Seed.import_namespace("Notify");
+
+Gtk.init(null, null);
+
+function file_changed(monitor, child, other, event)
+{
+    var notification = 
+	new Notify.Notification({summary: "File Notification",
+				 body : "This is a poor libnotify example" });
+    notification.set_timeout(5000);
+    notification.show();
+}
+
+Notify.init("Seed Test!");
+
+file = Gio.file_new_for_path(".");
+monitor = file.monitor_directory();
+
+monitor.signal_changed.connect(file_changed);
+
+Gtk.main();
+

Added: trunk/examples/quine.js
==============================================================================
--- (empty file)
+++ trunk/examples/quine.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gio");
+
+file = Gio.file_new_for_path(Seed.argv[1])
+input = file.read();
+
+Seed.print(input.get_contents());
\ No newline at end of file

Added: trunk/examples/repl.js
==============================================================================
--- (empty file)
+++ trunk/examples/repl.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,13 @@
+#!/usr/local/bin/seed
+
+while(1)
+{
+	try
+	{
+		Seed.print(eval(Seed.readline("> ")));
+	}
+	catch(e)
+	{
+		Seed.print(e.name + " " + e.message);
+	}
+}

Added: trunk/examples/shader/ShaderView.js
==============================================================================
--- (empty file)
+++ trunk/examples/shader/ShaderView.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,45 @@
+#!/usr/local/bin/seed
+function ShaderView(source_type, actor, reflection)
+{
+    this.hbox = new Gtk.HBox();
+    
+    var source_lang_mgr = new GtkSource.SourceLanguageManager();
+    var js_lang = source_lang_mgr.get_language("c");
+
+    var source_buf = new GtkSource.SourceBuffer({language: js_lang});
+    source_buf.text = Gio.simple_read("default.glsl");
+    var source_view = GtkSource.SourceView.new_with_buffer(source_buf);
+    source_view.set_show_line_numbers(true);
+    source_view.set_show_right_margin(true);
+    source_view.set_highlight_current_line(true);
+    source_view.set_right_margin_position(80);
+    
+    this.source_type = source_type;
+    
+    var compile = new Gtk.Button({label: "Compile"});
+
+    var scrolled_window = new Gtk.ScrolledWindow(
+			   {vscrollbar_policy: Gtk.PolicyType.automatic, 
+			    hscrollbar_policy: Gtk.PolicyType.automatic});
+    scrolled_window.add(source_view);
+    
+    this.hbox.pack_start(scrolled_window, true, true);
+    this.hbox.pack_start(compile);
+    this.actor = actor;
+    this.reflection = reflection;
+    
+    this.make_shader = function()
+    {
+	shader.enabled = false;
+	if (this.source_type == "fragment_source")
+	    shader.fragment_source = source_buf.text;
+	else
+	    shader.vertex_source = source_buf.text;
+	shader.compile();
+	shader.enabled = true;
+	this.actor.set_shader(shader);
+	this.reflection.set_shader(shader);
+    }
+
+    compile.signal_clicked.connect(this.make_shader, this);
+}
\ No newline at end of file

Added: trunk/examples/shader/bob.jpg
==============================================================================
Binary file. No diff available.

Added: trunk/examples/shader/default.glsl
==============================================================================
--- (empty file)
+++ trunk/examples/shader/default.glsl	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,11 @@
+uniform sampler2D sampler0;
+
+void main(void)
+{
+        vec4 sample;
+        sample = texture2D(sampler0,
+        gl_TexCoord[0].st);
+        gl_FragColor = 1-sample;
+	gl_FragColor.a = gl_Color.a;
+}
+

Added: trunk/examples/shader/main.js
==============================================================================
--- (empty file)
+++ trunk/examples/shader/main.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,51 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Clutter");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("GtkSource");
+Seed.import_namespace("GtkClutter");
+Seed.import_namespace("Gio");
+Seed.include("ShaderView.js");
+
+Gtk.init(null, null);
+GtkClutter.init(null, null);
+
+var window = new Gtk.Window();
+var gtkstage = new GtkClutter.Embed();
+var stage = gtkstage.get_stage();
+var texture = new Clutter.Texture({filename:"bob.jpg"});
+var reflection = new Clutter.CloneTexture({parent_texture: texture});
+shader = new Clutter.Shader();
+var shaderfield = new ShaderView("fragment_source", texture,reflection);
+var vbox = new Gtk.VBox();
+var notebook = new Gtk.Notebook();
+var c = Clutter.Color._new();
+Clutter.color_parse("Black",c);
+
+notebook.append_page(shaderfield.hbox, new Gtk.Label({label:"Fragment"}));
+reflection.width = reflection.height = texture.width = texture.height = 300;
+
+
+gtkstage.set_size_request(500,500);
+vbox.pack_start(gtkstage, false, true);
+vbox.pack_start(notebook, true, true);
+
+window.add(vbox);
+stage.add_actor(texture);
+stage.add_actor(reflection);
+
+reflection.anchor_x = texture.anchor_x = texture.width/2;
+reflection.anchor_y = texture.anchor_y = texture.height/2;
+texture.x = stage.width/2-texture.width/4;
+texture.y = stage.height/2;
+
+reflection.x = stage.width/2-texture.width/4;
+reflection.y = stage.height/2+texture.height;
+reflection.rotation_angle_z = 180;
+reflection.opacity = 80;
+
+stage.color = c;
+
+window.show_all();
+stage.show_all();
+
+Gtk.main();

Added: trunk/examples/vte-test.js
==============================================================================
--- (empty file)
+++ trunk/examples/vte-test.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,23 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gtk","2.0");
+Seed.import_namespace("Vte");
+
+Gtk.init(null, null);
+
+var window = new Gtk.Window();
+
+var vte = new Vte.Terminal();
+vte.fork_command("/bin/bash");
+vte.signal_child_exited.connect(Gtk.main_quit);
+vte.signal_window_title_changed.connect
+    (function(terminal)
+     {
+	 this.set_title(terminal.get_window_title());
+     }, window);
+
+window.add(vte);
+
+window.show_all();
+
+Gtk.main();
+

Added: trunk/tests/argv.js
==============================================================================
--- (empty file)
+++ trunk/tests/argv.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,6 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:/usr/local/bin/seed
+// STDERR:
+Seed.print(Seed.argv[0]);

Added: trunk/tests/compare.js
==============================================================================
--- (empty file)
+++ trunk/tests/compare.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,15 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:0.000000\n1.000000
+// STDERR:
+
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+var a = new Gtk.Button();
+var b = new Gtk.Button();
+var c = a;
+
+Seed.print(a.equals(b));
+Seed.print(a.equals(c));

Added: trunk/tests/enum.js
==============================================================================
--- (empty file)
+++ trunk/tests/enum.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,15 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:2.000000
+// STDERR:
+ 
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+b = new Gtk.Button();
+b.relief = Gtk.ReliefStyle.none;
+
+Seed.print(Gtk.ReliefStyle.none);
+
+

Added: trunk/tests/gobject-scope.js
==============================================================================
--- (empty file)
+++ trunk/tests/gobject-scope.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,15 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:
+// STDERR:
+
+Seed.import_namespace("Gtk");
+
+Gtk.init(null, null);
+
+for(var i = 0; i < 100; i++)
+{
+    var button = new Gtk.Button({label: "Test!"});
+}
+

Added: trunk/tests/include.js
==============================================================================
--- (empty file)
+++ trunk/tests/include.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:Hello, world!
+// STDERR:
+
+Seed.include("print.js");

Added: trunk/tests/json-constructor.js
==============================================================================
--- (empty file)
+++ trunk/tests/json-constructor.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,15 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:JSON Win!
+// STDERR:
+
+Seed.import_namespace("Gtk");
+Seed.import_namespace("GLib");
+
+Gtk.init(null, null);
+window = new Gtk.Window({title: "JSON Win!"});
+window.show_all();
+
+Seed.print(window.title);
+

Added: trunk/tests/print.js
==============================================================================
--- (empty file)
+++ trunk/tests/print.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:Hello, world!
+// STDERR:
+
+Seed.print("Hello, world!");

Added: trunk/tests/printprint.js
==============================================================================
--- (empty file)
+++ trunk/tests/printprint.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,6 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:Hello World!\n\[null\]
+// STDERR:
+Seed.print(Seed.print("Hello World!"));

Added: trunk/tests/property-benchmark.js
==============================================================================
--- (empty file)
+++ trunk/tests/property-benchmark.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,17 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:
+// STDERR:
+
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+window = new Gtk.Window();
+window.title="HI";
+window.name="HI";
+for (i = 0; i < 100000; i++)
+{
+	a = window.title;
+	b = window.name;
+}

Added: trunk/tests/readline.js
==============================================================================
--- (empty file)
+++ trunk/tests/readline.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,7 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:2+2
+// STDOUT:4.000000
+// STDERR:
+
+Seed.print(eval(Seed.readline("")));

Added: trunk/tests/run-tests.py
==============================================================================
--- (empty file)
+++ trunk/tests/run-tests.py	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+
+#######################
+# Kram Test Framework #
+#   Seed Unit Tests   #
+#######################
+
+# So! Ideas...
+# We obviously need not just 'pass' tests, but also 'fail' tests, and to make
+# sure that they throw the correct exceptions. Something a bit more flexible
+# than a Bash script that just checks to make sure all the .jses exit properly.
+
+# I'm thinking of a comment directly after the shebang in the tests that gives
+# expected output (on one line) and expected exit value... scripts get run
+# by Python, which checks the comment and the exit value, runs the tests,
+# and records run information (rev #, uname, test times, etc.) in an
+# easily-emailed format (and append to a log file, for safekeeping).
+
+# Test script could also have an option to perform timing/memory-use tests, 
+# automatically running numerous times and averaging, etc... (find a way around
+# launching overhead... reimplement main.c here?), and recording to a running
+# log so we can keep track of performance/mem-use regressions, etc...
+
+# TODO: test return value
+
+import os
+import re
+import sys
+
+passed = []
+failed = []
+
+for f in os.listdir("."):
+	if f.endswith(".js"):
+		rfile = open(f, "r")
+		test_code = rfile.readlines()
+		test_in = test_code[2].replace("// STDIN:","").rstrip().replace("\\n","\n");
+		test_out = "^" + test_code[3].replace("// STDOUT:","").rstrip().replace("\\n","\n") + "$";
+		test_err = "^" + test_code[4].replace("// STDERR:","").rstrip().replace("\\n","\n") + "$";
+		
+		(n,out,err) = os.popen3("./" + f)
+		
+		if(test_in != ""):
+			n.write(test_in + "\004")
+			n.close()
+		
+		run_out = "".join(out.readlines()).rstrip()
+		run_err = "".join(err.readlines()).rstrip()
+	
+		if not re.match(test_out,run_out):
+			failed.append([f,test_out,run_out,0,run_err])
+			sys.stdout.write("x")
+		elif not re.match(test_err,run_err):
+			failed.append([f,test_err,run_err,1])
+			sys.stdout.write("x")
+		else:
+			passed.append([f,test_out,run_out])
+			sys.stdout.write(".")
+		sys.stdout.flush()
+print
+
+revnof = os.popen("svn info | grep \"Revision\"")
+revno = "".join(revnof.readlines()).rstrip()
+
+print "libseed test run (%s):" % revno
+print "%d tests passed; %d tests failed.\n" % (len(passed), len(failed))
+for fail in failed:
+	print "-------------FAILED TEST---------------"
+	print "Name: %s" % fail[0]
+	if fail[3]:
+		print "  Expected Error:\t" + fail[1]
+		print "  Actual Error:\t" + fail[2]
+	else:
+		print "  Expected Output:\t" + fail[1]
+		print "  Actual Output:\t" + fail[2]
+		print "  STDERR:\t\t" + fail[4]
+if len(failed):
+	print "---------------------------------------"	

Added: trunk/tests/signal.js
==============================================================================
--- (empty file)
+++ trunk/tests/signal.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,18 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:Window mapped.
+// STDERR:
+
+Seed.import_namespace("Gtk");
+Gtk.init(null, null);
+
+function mapped(window)
+{
+    Seed.print("Window mapped.");
+}
+
+w = new Gtk.Window();
+w.signal_map.connect(mapped);
+
+w.show_all();

Added: trunk/tests/syntax-test.js
==============================================================================
--- (empty file)
+++ trunk/tests/syntax-test.js	Mon Nov  3 06:39:34 2008
@@ -0,0 +1,18 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:
+// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: SyntaxError\. Parse error in \.\/syntax-test\.js at line 6
+
+new = 3
+
+
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:
+// STDERR:\n\*\* \(seed:[0-9]+\): CRITICAL \*\*: SyntaxError\. Parse error in \.\/syntax-test\.js at line 6
+
+new = 3
+
+



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