[seed] Add an example of dbus signal connection to dbus-banshee example



commit eabccebae1021392f4b29a228f261906c5d1f5fc
Author: Robert Carr <racarr svn gnome org>
Date:   Sun May 10 00:54:14 2009 -0400

    Add an example of dbus signal connection to dbus-banshee example
---
 examples/dbus-banshee.js |   31 ++++++++++++++++++++++++++++---
 libseed/seed-closure.c   |    6 +-----
 libseed/seed-closure.h   |    3 ---
 libseed/seed-signals.c   |    2 +-
 4 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/examples/dbus-banshee.js b/examples/dbus-banshee.js
index 2999737..77b0146 100755
--- a/examples/dbus-banshee.js
+++ b/examples/dbus-banshee.js
@@ -14,18 +14,43 @@ PlayerEngine.prototype = {
 
 var PlayerEngineIface = {
     name: 'org.bansheeproject.Banshee.PlayerEngine',
-    methods: [{name:'Play', inSignature: ''},
-	      {name:'Open', inSignature: 's'}],
+    methods: [
+	{ name: 'Open', inSignature: 's', outSignature: '' },
+	{ name: 'Close', inSignature: '', outSignature: '' },
+	{ name: 'Pause', inSignature: '', outSignature: '' },
+	{ name: 'Play', inSignature: '', outSignature: '' },
+	{ name: 'TogglePlaying', inSignature: '', outSignature: '' }
+    ],
+    signals: [
+	{ name: 'EventChanged', inSignature: '', outSignature: 'ssd' },
+	{ name: 'StateChanged', inSignature: '', outSignature: 's' }
+    ],
+    properties: [
+	{ name: 'CurrentTrack', signature: 'a{sv}', access: 'read' },
+	{ name: 'CurrentUri', signature: 's', access: 'read' },
+	{ name: 'CurrentState', signature: 's', access: 'read' },
+	{ name: 'LastState', signature: 's', access: 'read' },
+	{ name: 'Volume', signature: 'q', access: 'readwrite' },
+	{ name: 'Position', signature: 'u', access: 'readwrite' },
+	{ name: 'CanSeek', signature: 'b', access: 'read' },
+	{ name: 'CanPause', signature: 'b', access: 'read' },
+	{ name: 'Length', signature: 'u', access: 'read' }
+    ]
 };
 
+
 DBus.proxifyPrototype (PlayerEngine.prototype, PlayerEngineIface);
 
 proxy = new PlayerEngine();
 proxy.OpenRemote(Seed.argv[2]);
 proxy.PlayRemote(function(){
     Seed.print("proxy.PlayRemote returned");
-    Seed.quit();
 });
 
+proxy.connect("StateChanged", 
+	      function(emitter, state){
+		  Seed.print("Banshee state changed: " + state);
+	      });
+
 mainloop = GLib.main_loop_new();
 GLib.main_loop_run(mainloop);
diff --git a/libseed/seed-closure.c b/libseed/seed-closure.c
index 522222f..6e4e9c7 100644
--- a/libseed/seed-closure.c
+++ b/libseed/seed-closure.c
@@ -384,17 +384,13 @@ seed_make_gclosure (JSContextRef ctx, JSObjectRef function, JSObjectRef user_dat
   g_closure_add_finalize_notifier (closure, 0, closure_invalidated);
   g_closure_set_marshal (closure, seed_signal_marshal_func);
 
+  JSValueProtect (ctx, function);
   ((SeedClosure *) closure)->function = function;
-  ((SeedClosure *) closure)->object = 0;
   if (user_data && !JSValueIsNull (ctx, user_data))
     {
       ((SeedClosure *) closure)->user_data = user_data;
       JSValueProtect(ctx, user_data);
     }
-  else
-    ((SeedClosure *) closure)->user_data = NULL;
-  
-  JSValueProtect (eng->context, function);
 
   return closure;
 }
diff --git a/libseed/seed-closure.h b/libseed/seed-closure.h
index 3b403ef..aea4a5d 100644
--- a/libseed/seed-closure.h
+++ b/libseed/seed-closure.h
@@ -29,9 +29,6 @@ typedef struct _SeedClosure
   GClosure closure;
 
   JSObjectRef function;
-  JSObjectRef object;
-  JSObjectRef this;
-
   JSValueRef user_data;
 
   GType return_type;
diff --git a/libseed/seed-signals.c b/libseed/seed-signals.c
index 2e5a56a..4ebd756 100644
--- a/libseed/seed-signals.c
+++ b/libseed/seed-signals.c
@@ -172,7 +172,7 @@ seed_signal_marshal_func (GClosure * closure,
     args[i] = JSValueMakeNull (ctx);
 
   ret = JSObjectCallAsFunction (ctx, seed_closure->function,
-				seed_closure->this,
+				NULL,
 				n_param_values + 1, args, &exception);
 
   if (exception)



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