conduit r1785 - in trunk: . conduit/modules/FileModule conduit/platform



Author: jstowers
Date: Tue Oct 28 09:53:28 2008
New Revision: 1785
URL: http://svn.gnome.org/viewvc/conduit?rev=1785&view=rev

Log:
2008-10-28  John Stowers  <john stowers gmail com>

	* conduit/modules/FileModule/FileModule.py:
	* conduit/platform/FileGio.py:
	* conduit/platform/FileGnomeVfs.py:
	* conduit/platform/__init__.py: Implement FileMonitor for GIO
	Fixes #558176it__.py:



Modified:
   trunk/ChangeLog
   trunk/conduit/modules/FileModule/FileModule.py
   trunk/conduit/platform/FileGio.py
   trunk/conduit/platform/FileGnomeVfs.py
   trunk/conduit/platform/__init__.py

Modified: trunk/conduit/modules/FileModule/FileModule.py
==============================================================================
--- trunk/conduit/modules/FileModule/FileModule.py	(original)
+++ trunk/conduit/modules/FileModule/FileModule.py	Tue Oct 28 09:53:28 2008
@@ -121,7 +121,7 @@
     def _monitor_folder(self):
         self._monitor.add(self.folder, self._monitor.MONITOR_DIRECTORY)
 
-    def _monitor_folder_cb(self, sender, monitor_uri, event_uri, event):
+    def _monitor_folder_cb(self, sender, event_uri, event):
         """
         Called when a file in the current folder is changed, added or deleted
         """

Modified: trunk/conduit/platform/FileGio.py
==============================================================================
--- trunk/conduit/platform/FileGio.py	(original)
+++ trunk/conduit/platform/FileGio.py	Tue Oct 28 09:53:28 2008
@@ -299,8 +299,34 @@
         return vols
 
 class FileMonitor(conduit.platform.FileMonitor):
-    pass
 
+    MONITOR_EVENT_CREATED =             gio.FILE_MONITOR_EVENT_CREATED
+    MONITOR_EVENT_CHANGED =             gio.FILE_MONITOR_EVENT_CHANGED
+    MONITOR_EVENT_DELETED =             gio.FILE_MONITOR_EVENT_DELETED
+    MONITOR_DIRECTORY =                 255
+
+    def __init__(self):
+        conduit.platform.FileMonitor.__init__(self)
+        self._fm = None
+
+    def _on_change(self, monitor, f1, f2, event):
+        self.emit("changed", f1.get_uri(), event)
+
+    def add(self, URI, monitorType):
+        if monitorType == self.MONITOR_DIRECTORY:
+            self._fm = gio.File(URI).monitor_directory()
+        else:
+            self._fm = gio.File(URI).monitor_file()
+
+        self._fm.connect("changed", self._on_change)
+
+    def cancel(self):
+        if self._fm:
+            try:
+                self._fm.disconnect_by_func(self._on_change)
+            except TypeError:
+                pass
+            
 class FolderScanner(conduit.platform.FolderScanner):
     def run(self):
         delta = 0

Modified: trunk/conduit/platform/FileGnomeVfs.py
==============================================================================
--- trunk/conduit/platform/FileGnomeVfs.py	(original)
+++ trunk/conduit/platform/FileGnomeVfs.py	Tue Oct 28 09:53:28 2008
@@ -319,7 +319,7 @@
         self._id = None
 
     def _monitor_cb(self, monitor_uri, event_uri, event):
-        self.emit("changed", monitor_uri, event_uri, event)
+        self.emit("changed", event_uri, event)
 
     def add(self, folder, monitorType):
         if self._id != None:

Modified: trunk/conduit/platform/__init__.py
==============================================================================
--- trunk/conduit/platform/__init__.py	(original)
+++ trunk/conduit/platform/__init__.py	Tue Oct 28 09:53:28 2008
@@ -117,9 +117,8 @@
 
     __gsignals__ = {
         "changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
-            gobject.TYPE_PYOBJECT,
-            gobject.TYPE_PYOBJECT,
-            gobject.TYPE_PYOBJECT])
+            gobject.TYPE_PYOBJECT,      #uri that changed
+            gobject.TYPE_PYOBJECT])     #event type
         }
 
     MONITOR_EVENT_CREATED = 1



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