[seed] A bunch of more minor examples updated
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] A bunch of more minor examples updated
- Date: Sun, 12 Apr 2009 17:25:16 -0400 (EDT)
commit 345812d7124fa8766803a16e7de8f545a0e62969
Author: Robert Carr <racarr mireia (none)>
Date: Sun Apr 12 17:25:09 2009 -0400
A bunch of more minor examples updated
---
examples/n-oscillator.js | 26 +++++++++++++-------------
examples/notify-test.js | 8 ++++----
examples/poppler.js | 40 ++++++++++++++++++++--------------------
examples/quine.js | 2 +-
examples/repl.js | 2 +-
examples/soup.js | 2 +-
examples/threaded-repl.js | 4 ++--
7 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/examples/n-oscillator.js b/examples/n-oscillator.js
index 9cf1026..c0a73dd 100755
--- a/examples/n-oscillator.js
+++ b/examples/n-oscillator.js
@@ -1,6 +1,6 @@
#!/usr/bin/env seed
-Seed.import_namespace("Gtk","2.0");
-Seed.import_namespace("Gst","0.10");
+Gtk = imports.gi.Gtk;
+Gst = imports.gi.Gst;
Gst.init(null, null);
Gtk.init(null, null);
@@ -14,7 +14,7 @@ function oscillator(freq)
var vscale = new Gtk.VScale();
var volscale = new Gtk.VScale();
var button = new Gtk.Button({label: "Toggle"});
-
+
var pipeline = new Gst.Pipeline({name: "test"});
// No actual introspection data for audiotestsrc, so can not
// instantiate one with a constructor, have to use element_factory,
@@ -23,27 +23,27 @@ function oscillator(freq)
var audiosink = Gst.ElementFactory.make("alsasink", "sink");
var volume = Gst.ElementFactory.make("volume", "vcontrol");
audiosrc.freq = freq;
-
+
pipeline.add(audiosrc);
pipeline.add(audiosink);
pipeline.add(volume);
audiosrc.link(volume);
volume.link(audiosink);
-
+
var playing = false;
-
+
vscale.adjustment.upper = 3000;
vscale.adjustment.value = freq;
-
+
volscale.adjustment.upper = 10;
volscale.adjustment.value = volume.volume;
-
+
hbox.pack_start(vscale, true, true, 10);
hbox.pack_start(volscale, true, true, 10);
this.vbox.pack_start(hbox, true, true, 10);
this.vbox.pack_start(button, false, false, 10);
-
- var toggle = function(button, that)
+
+ var toggle = function(button, that)
{
if (playing === false)
{
@@ -56,17 +56,17 @@ function oscillator(freq)
playing = false;
}
};
-
+
var update_freq = function(range)
{
audiosrc.freq = range.get_value();
};
-
+
var update_vol = function(range)
{
volume.volume = range.get_value();
};
-
+
button.signal.clicked.connect(toggle);
vscale.signal.value_changed.connect(update_freq);
volscale.signal.value_changed.connect(update_vol);
diff --git a/examples/notify-test.js b/examples/notify-test.js
index 6c6dc5e..6239be2 100755
--- a/examples/notify-test.js
+++ b/examples/notify-test.js
@@ -1,13 +1,13 @@
#!/usr/bin/env seed
-Seed.import_namespace("Gtk");
-Seed.import_namespace("Gio");
-Seed.import_namespace("Notify");
+Gtk = imports.gi.Gtk;
+Gio = imports.gi.Gio;
+Notify = imports.gi.Notify;
Gtk.init(null, null);
function file_changed(monitor, child, other, event)
{
- var notification =
+ var notification =
new Notify.Notification({summary: "File Notification",
body : "It's not clear what notification system this file is providing an example of." });
notification.set_timeout(5000);
diff --git a/examples/poppler.js b/examples/poppler.js
index 4031606..2cb3d57 100755
--- a/examples/poppler.js
+++ b/examples/poppler.js
@@ -1,9 +1,9 @@
#!/usr/bin/env seed
-Seed.import_namespace("cairo");
-Seed.import_namespace("Gdk");
-Seed.import_namespace("Gtk");
-Seed.import_namespace("Poppler");
+cairo = imports.gi.cairo;
+Gdk = imports.gi.Gdk;
+Gtk = imports.gi.Gtk;
+Poppler = imports.gi.Poppler;
Gtk.init(null, null);
@@ -21,7 +21,7 @@ function draw_document()
cairo = Gdk.cairo_create(drawing_area.window);
current_page.render(cairo);
}
-
+
return true;
}
@@ -32,25 +32,25 @@ function set_page(num)
set_page(0);
return;
}
-
+
if(num >= num_pages)
{
set_page(num_pages - 1);
return;
}
-
+
current_page = current_document.get_page(num);
draw_document();
-
+
//Get rid of precision.
entry.text = Seed.sprintf("%d",num+1);
page_num = num;
-
+
if (page_num == num_pages-1)
next_button.sensitive = false;
else
next_button.sensitive = true;
-
+
if (page_num)
previous_button.sensitive = true;
else
@@ -66,7 +66,7 @@ function open_file(sv)
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)
{
// Poppler.Document will not take a uri as a construction property,
@@ -75,17 +75,17 @@ function open_file(sv)
Poppler.Document.from_file(file_chooser.get_uri());
num_pages = current_document.get_n_pages();
set_page(0);
-
+
if(num_pages == 1)
next_button.sensitive = previous_button.sensitive = false;
-
+
page_label.label = " of " + num_pages;
draw_document();
-
+
if (num_pages > 1)
next_button.sensitive = true;
}
-
+
file_chooser.destroy();
}
@@ -94,7 +94,7 @@ function make_toolbar()
var window = new Gtk.Window();
var toolbar = new Gtk.Toolbar();
var main_vbox = new Gtk.VBox();
-
+
var open_button = new Gtk.ToolButton({stock_id:"gtk-open"});
previous_button = new Gtk.ToolButton({stock_id:"gtk-go-up"});
next_button = new Gtk.ToolButton({stock_id:"gtk-go-down"});
@@ -106,7 +106,7 @@ function make_toolbar()
var label_item = new Gtk.ToolItem();
page_label = new Gtk.Label({label: " of 0"});
label_item.add(page_label);
-
+
open_button.signal.clicked.connect(open_file);
next_button.signal.clicked.connect(
function(button)
@@ -119,8 +119,8 @@ function make_toolbar()
set_page(page_num-1);
});
next_button.sensitive = previous_button.sensitive = false;
-
-
+
+
toolbar.insert(open_button,-1);
toolbar.insert(previous_button, -1);
toolbar.insert(next_button, -1);
@@ -128,7 +128,7 @@ function make_toolbar()
toolbar.insert(entry_item, -1);
toolbar.insert(label_item, -1);
toolbar.insert(new Gtk.SeparatorToolItem(), -1);
-
+
return toolbar;
}
diff --git a/examples/quine.js b/examples/quine.js
index fae5188..dc16054 100755
--- a/examples/quine.js
+++ b/examples/quine.js
@@ -1,5 +1,5 @@
#!/usr/bin/env seed
-Seed.import_namespace("Gio");
+Gio = imports.gi.Gio;
file = Gio.file_new_for_path(Seed.argv[1]);
input = file.read();
diff --git a/examples/repl.js b/examples/repl.js
index 0d34ab6..b30d3b2 100755
--- a/examples/repl.js
+++ b/examples/repl.js
@@ -1,6 +1,6 @@
#!/usr/bin/env seed
-Seed.import_namespace("readline");
+readline = imports.readline;
while(1)
{
diff --git a/examples/soup.js b/examples/soup.js
index 9c04b41..e0733d3 100755
--- a/examples/soup.js
+++ b/examples/soup.js
@@ -1,6 +1,6 @@
#!/usr/bin/env seed
-Seed.import_namespace("Soup");
+Soup = imports.gi.Soup;
var session = new Soup.SessionSync();
diff --git a/examples/threaded-repl.js b/examples/threaded-repl.js
index 3cf3a45..95638f4 100755
--- a/examples/threaded-repl.js
+++ b/examples/threaded-repl.js
@@ -1,7 +1,7 @@
#!/usr/bin/env seed
-Seed.import_namespace("Gtk");
-Seed.import_namespace("GLib");
+Gtk = imports.gi.Gtk;
+GLib = imports.gi.GLib;
Gtk.init(null, null);
var w = new Gtk.Window();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]