seed r789 - in trunk: examples/twitter libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r789 - in trunk: examples/twitter libseed
- Date: Wed, 21 Jan 2009 02:39:55 +0000 (UTC)
Author: racarr
Date: Wed Jan 21 02:39:55 2009
New Revision: 789
URL: http://svn.gnome.org/viewvc/seed?rev=789&view=rev
Log:
Make twitter example download images async
Modified:
trunk/examples/twitter/twitter.js
trunk/libseed/seed-closure.c
Modified: trunk/examples/twitter/twitter.js
==============================================================================
--- trunk/examples/twitter/twitter.js (original)
+++ trunk/examples/twitter/twitter.js Wed Jan 21 02:39:55 2009
@@ -24,31 +24,34 @@
Gtk.rc_parse_string(
'style "tv" {base[NORMAL] = @bg_color} widget_class "*GtkTextView" style "tv"');
-function get_pixbuf(uri) {
- var loader = new GdkPixbuf.PixbufLoader();
+function put_pixbuf(container, uri)
+{
var file = Gio.file_new_for_uri(uri);
-
- var dstream = new Gio.DataInputStream.c_new(file.read());
-
- // FIXME: HACK
- try
- {
- while (1)
- {
- loader.write([dstream.read_byte()], 1);
- }
- }
- catch (e)
- {
- Seed.print(e.name + " " + e.message);
- }
-
- return loader.get_pixbuf();
+ file.read_async(0, null, function(source, result)
+ {
+ var loader = new GdkPixbuf.PixbufLoader();
+ var stream = source.read_finish(result);
+ var dstream = new Gio.DataInputStream.c_new(stream);
+
+ try
+ {
+ while (1)
+ {
+ loader.write([dstream.read_byte()], 1);
+ }
+ }
+ catch (e)
+ {
+ Seed.print(e.name + " " + e.message);
+ }
+ container.pack_start(
+ new Gtk.Image.from_pixbuf(loader.get_pixbuf()));
+ container.show_all();
+ });
}
// This function generates the GTK+ widgets that display the retrieved messages
function make_block(data) {
- var pixbuf = get_pixbuf(data.profile_image_url);
var vbox = new Gtk.VBox({"spacing": 10, "border-width": 5});
var hbox = new Gtk.HBox();
@@ -68,7 +71,8 @@
heading.set_alignment(0, 0);
vbox.pack_start(hbox);
hbox.pack_start(heading);
- hbox.pack_start(new Gtk.Image.from_pixbuf(pixbuf), true);
+// hbox.pack_start(new Gtk.Image.from_pixbuf(pixbuf), true);
+ put_pixbuf(hbox, data.profile_image_url);
vbox.pack_start(message);
var frame = new Gtk.Frame({"border-width": 5});
@@ -125,6 +129,7 @@
window.add(layout);
window.show_all();
+window.resize(300, 500);
// Start the main GTK+ loop and initiate the program
Gtk.main();
Modified: trunk/libseed/seed-closure.c
==============================================================================
--- trunk/libseed/seed-closure.c (original)
+++ trunk/libseed/seed-closure.c Wed Jan 21 02:39:55 2009
@@ -397,6 +397,8 @@
ffi_prep_cif(cif, FFI_DEFAULT_ABI, num_args,
get_ffi_type(return_type), arg_types);
ffi_prep_closure(closure, cif, seed_handle_closure, privates);
+
+ JSValueProtect(ctx, function);
seed_object_set_property(ctx, (JSObjectRef) function,
"__seed_native_closure",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]