[seed] Some tutorial updates



commit b4adaa4bdd36f2cee652052fa56d8c5208a8302c
Author: Robert Carr <racarr svn gnome org>
Date:   Fri Apr 17 14:43:15 2009 -0400

    Some tutorial updates
---
 doc/tutorial-standalone/1.js             |    4 +-
 doc/tutorial-standalone/2.js             |   20 ++++++------
 doc/tutorial-standalone/3.js             |   50 +++++++++++++++---------------
 doc/tutorial-standalone/tutorial.html.in |   10 +++---
 4 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/doc/tutorial-standalone/1.js b/doc/tutorial-standalone/1.js
index 0cc8524..9943750 100755
--- a/doc/tutorial-standalone/1.js
+++ b/doc/tutorial-standalone/1.js
@@ -1,6 +1,6 @@
 #!/usr/bin/env seed
 
-Seed.import_namespace("Gtk");
+Gtk = imports.gi.Gtk;
 Gtk.init(null, null);
 
 BrowserToolbar = new GType({
@@ -34,7 +34,7 @@ BrowserToolbar = new GType({
         {
             Seed.print("Navigate to: " + url.text);
         };
-        
+
         // Implementation
         back_button.signal.clicked.connect(back);
         forward_button.signal.clicked.connect(forward);
diff --git a/doc/tutorial-standalone/2.js b/doc/tutorial-standalone/2.js
index e3dc5dc..51577ac 100755
--- a/doc/tutorial-standalone/2.js
+++ b/doc/tutorial-standalone/2.js
@@ -2,8 +2,8 @@
 
 var home_page = "http://www.google.com";;
 
-Seed.import_namespace("Gtk");
-Seed.import_namespace("WebKit");
+Gtk = imports.gi.Gtk;
+WebKit = imports.gi.WebKit;
 Gtk.init(null, null);
 
 Browser = new GType({
@@ -15,7 +15,7 @@ Browser = new GType({
         var toolbar = new BrowserToolbar();
         var web_view = new BrowserView();
         var scroll_view = new Gtk.ScrolledWindow();
-        
+
         // Public
         this.get_toolbar = function ()
         {
@@ -26,7 +26,7 @@ Browser = new GType({
         {
             return web_view;
         };
-        
+
         // Implementation
         scroll_view.smooth_scroll = true;
         scroll_view.add(web_view);
@@ -48,12 +48,12 @@ BrowserView = new GType({
         var update_url = function (web_view, web_frame)
         {
             var toolbar = browser.get_toolbar();
-            
+
             toolbar.set_url(web_frame.get_uri());
             toolbar.set_can_go_back(web_view.can_go_back());
             toolbar.set_can_go_forward(web_view.can_go_forward());
         };
-        
+
         // Public
         this.browse = function (url)
         {
@@ -62,7 +62,7 @@ BrowserView = new GType({
 
             this.open(url);
         };
-        
+
         // Implementation
         this.set_scroll_adjustments(null, null);
         this.signal.load_committed.connect(update_url);
@@ -106,17 +106,17 @@ BrowserToolbar = new GType({
         {
             url_bar.text = url;
         };
-        
+
         this.set_can_go_back = function (can_go_back)
         {
             back_button.sensitive = can_go_back;
         };
-        
+
         this.set_can_go_forward = function (can_go_forward)
         {
             forward_button.sensitive = can_go_forward;
         };
-        
+
         // Implementation
         back_button.signal.clicked.connect(back);
         forward_button.signal.clicked.connect(forward);
diff --git a/doc/tutorial-standalone/3.js b/doc/tutorial-standalone/3.js
index 122fe12..40fe261 100755
--- a/doc/tutorial-standalone/3.js
+++ b/doc/tutorial-standalone/3.js
@@ -2,8 +2,8 @@
 
 var home_page = "http://www.google.com";;
 
-Seed.import_namespace("Gtk");
-Seed.import_namespace("WebKit");
+Gtk = imports.gi.Gtk;
+WebKit = imports.gi.WebKit;
 Gtk.init(null, null);
 
 TabbedBrowser = new GType({
@@ -16,31 +16,31 @@ TabbedBrowser = new GType({
         {
             browser.remove_page(browser.page_num(tab));
             tab.destroy();
-            
+
             if(!browser.get_n_pages())
             {
                 browser.new_tab(home_page);
             }
         };
-        
+
         this.new_tab = function (url)
         {
             var new_tab = new BrowserTab();
             new_tab.get_web_view().browse(url);
-            
+
             var tab_label = new Gtk.Label({label:"Untitled"});
             var tab_button = new Gtk.Button({relief: Gtk.ReliefStyle.NONE});
-            tab_button.set_image(new Gtk.Image({stock: "gtk-close", 
+            tab_button.set_image(new Gtk.Image({stock: "gtk-close",
                                                 icon_size: Gtk.IconSize.MENU}));
             tab_button.signal.clicked.connect(this.close_tab, this);
-            
+
             var tab_title = new Gtk.HBox();
             tab_title.pack_start(tab_label);
             tab_title.pack_start(tab_button);
             tab_title.show_all();
-            
+
             new_tab.set_tab_label(tab_label);
-            
+
             this.append_page(new_tab, tab_title);
         };
 
@@ -64,7 +64,7 @@ BrowserTab = new GType({
         var web_view = new BrowserView();
         var scroll_view = new Gtk.ScrolledWindow();
         var tab_label;
-        
+
         // Public
         this.get_toolbar = function ()
         {
@@ -75,20 +75,20 @@ BrowserTab = new GType({
         {
             return web_view;
         };
-        
+
         this.set_tab_label = function (new_tab_label)
         {
             tab_label = new_tab_label;
         };
-        
+
         this.get_tab_label = function ()
         {
             return tab_label;
         };
-        
+
         // Implementation
         web_view.set_tab(this);
-        
+
         scroll_view.smooth_scroll = true;
         scroll_view.add(web_view);
         scroll_view.set_policy(Gtk.PolicyType.AUTOMATIC,
@@ -107,24 +107,24 @@ BrowserView = new GType({
     {
         // Private
         var tab;
-        
+
         var update_title = function (web_view, web_frame, title)
         {
             if(title.length > 25)
                 title = title.slice(0,25) + "...";
-            
+
             tab.get_tab_label().label = title;
         };
-        
+
         var update_url = function (web_view, web_frame)
         {
             var toolbar = tab.get_toolbar();
-            
+
             toolbar.set_url(web_frame.get_uri());
             toolbar.set_can_go_back(web_view.can_go_back());
             toolbar.set_can_go_forward(web_view.can_go_forward());
         };
-        
+
         // Public
         this.browse = function (url)
         {
@@ -133,17 +133,17 @@ BrowserView = new GType({
 
             this.open(url);
         };
-        
+
         this.set_tab = function (new_tab)
         {
             tab = new_tab;
         }
-        
+
         this.get_tab = function ()
         {
             return tab;
         };
-        
+
         // Implementation
         this.set_scroll_adjustments(null, null);
         this.signal.title_changed.connect(update_title);
@@ -188,17 +188,17 @@ BrowserToolbar = new GType({
         {
             url_bar.text = url;
         };
-        
+
         this.set_can_go_back = function (can_go_back)
         {
             back_button.sensitive = can_go_back;
         };
-        
+
         this.set_can_go_forward = function (can_go_forward)
         {
             forward_button.sensitive = can_go_forward;
         };
-        
+
         // Implementation
         back_button.signal.clicked.connect(back);
         forward_button.signal.clicked.connect(forward);
diff --git a/doc/tutorial-standalone/tutorial.html.in b/doc/tutorial-standalone/tutorial.html.in
index 009c76a..e1d8f2d 100644
--- a/doc/tutorial-standalone/tutorial.html.in
+++ b/doc/tutorial-standalone/tutorial.html.in
@@ -47,7 +47,7 @@ Hello, world!
 <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. This interface is in the <b>readline</b> module, which <u>must</u> be imported before it can be used. The only argument <code>readline.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 class="sh_javascript">
-Seed.import_namespace("readline");
+readline = imports.readline;
 var my_name = readline.readline("Your name? ");
 var my_age = readline.readline("Your age? ");
 var old = 25;
@@ -95,7 +95,7 @@ catch(e)
 <pre class="sh_javascript">
 #!/usr/bin/env seed
 
-Seed.import_namespace("readline");
+readline = imports.readline;
 
 while(1)
 {
@@ -112,13 +112,13 @@ while(1)
 <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>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>Gtk = imports.gi.Gtk</code>, does this for us. The imports.gi object is a special object which handles importing libraries from introspection data.</p>
+<p>Once the library has been imported</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 class="sh_javascript">
 #!/usr/bin/env seed
 
-Seed.import_namespace("Gtk");
+Gtk = imports.gi.Gtk;
 Gtk.init(null, null);
 
 var window = new Gtk.Window();



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