Re: Goals for 0.3.4



>> >  * Add Sync() and Refresh() to Conduit objects. We still need the
>> shared
>> > sync_manager approach because of gtk signal foo
>>
>> The first bit of this should be done. I would like to move the signals
>> on
>> to the Conduit object too if no one objects? I would probably strip them
>> off the *Worker classes and emit through the Conduit class directly, if
>> that makes sense!
>>
>> nzjrs, if you don't grok what i'm thinking i could do the work and post
>> a
>> patch?
>
> I know what you mean. I believe I have already done this in DBus. See the
> DBus Conduit proxy object for how its done (or at least one possible
> implementation)
>

I was thinking more like the attached... Note I haven't updated
Synchronization.py, Conduit.py or Canvas.py yet, just wanted to give you
an idea before I wasted my time :-).. The lambda's I can break out, but
the main point here is reducing the places where we touch sync_manager.

Make sense? sync_manager is really backend utility code for the Model to
run inside a thread, so i'm trying to hide it from the View.

John
Index: conduit/DBus.py
===================================================================
--- conduit/DBus.py	(revision 802)
+++ conduit/DBus.py	(working copy)
@@ -107,34 +107,16 @@
         logd("DBus Message from %s: %s" % (self.get_path(), message))
 
 class ConduitDBusItem(DBusItem):
-    def __init__(self, sync_manager, conduit, uuid):
+    def __init__(self, conduit, uuid):
         DBusItem.__init__(self, iface=CONDUIT_DBUS_IFACE, path="/conduit/%s" % uuid)
 
-        self.sync_manager = sync_manager
         self.conduit = conduit
-        self.sync_manager.add_syncworker_callbacks(
-                                self._on_sync_started, 
-                                self._on_sync_completed, 
-                                self._on_sync_conflict,
-                                self._on_sync_progress
-                                )
 
-    def _on_sync_started(self, thread):
-        if thread.conduit == self.conduit:
-            self.SyncStarted()
+        self.conduit.connect("sync-started", self.SyncStarted)
+        self.conduit.connect("sync-completed", lambda a, e, c: self.SyncCompleted(bool(a), bool(e), bool(c)))
+        self.conduit.connect("sync-progress", lambda p: self.SyncProgress(float(p)))
+        self.conduit.connect("sync-conflict", self.SyncConflict)
 
-    def _on_sync_completed(self, thread, aborted, error, conflict):
-        if thread.conduit == self.conduit:
-            self.SyncCompleted(bool(aborted), bool(error), bool(conflict))
-
-    def _on_sync_progress(self, thread, progress):
-        if thread.conduit == self.conduit:
-            self.SyncProgress(float(progress))
-
-    def _on_sync_conflict(self, thread, source, sourceData, sink, sinkData, validChoices, isDeleted):
-        if thread.conduit == self.conduit:
-            self.SyncConflict()   
-
     #
     # org.conduit.Conduit
     #
@@ -347,7 +329,7 @@
                 raise ConduitException("Error adding source to conduit")
 
         i = Utils.uuid_string()
-        new = ConduitDBusItem(self.sync_manager, cond, i)
+        new = ConduitDBusItem(cond, i)
         EXPORTED_OBJECTS[new.get_path()] = new
         return new
 


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