conduit r1784 - in branches/gnome-2-24: . conduit/modules/FileModule conduit/platform



Author: jstowers
Date: Tue Oct 28 09:51:57 2008
New Revision: 1784
URL: http://svn.gnome.org/viewvc/conduit?rev=1784&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 #558176



Modified:
   branches/gnome-2-24/ChangeLog
   branches/gnome-2-24/conduit/modules/FileModule/FileModule.py
   branches/gnome-2-24/conduit/platform/FileGio.py
   branches/gnome-2-24/conduit/platform/FileGnomeVfs.py
   branches/gnome-2-24/conduit/platform/__init__.py

Modified: branches/gnome-2-24/conduit/modules/FileModule/FileModule.py
==============================================================================
--- branches/gnome-2-24/conduit/modules/FileModule/FileModule.py	(original)
+++ branches/gnome-2-24/conduit/modules/FileModule/FileModule.py	Tue Oct 28 09:51:57 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: branches/gnome-2-24/conduit/platform/FileGio.py
==============================================================================
--- branches/gnome-2-24/conduit/platform/FileGio.py	(original)
+++ branches/gnome-2-24/conduit/platform/FileGio.py	Tue Oct 28 09:51:57 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: branches/gnome-2-24/conduit/platform/FileGnomeVfs.py
==============================================================================
--- branches/gnome-2-24/conduit/platform/FileGnomeVfs.py	(original)
+++ branches/gnome-2-24/conduit/platform/FileGnomeVfs.py	Tue Oct 28 09:51:57 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: branches/gnome-2-24/conduit/platform/__init__.py
==============================================================================
--- branches/gnome-2-24/conduit/platform/__init__.py	(original)
+++ branches/gnome-2-24/conduit/platform/__init__.py	Tue Oct 28 09:51:57 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]