sabayon r1046 - in trunk: . lib



Author: aklapper
Date: Thu Feb  5 19:37:42 2009
New Revision: 1046
URL: http://svn.gnome.org/viewvc/sabayon?rev=1046&view=rev

Log:
2009-02-05  Andre Klapper  <a9016009 gmx de>

	* configure.ac:
	* lib/dirmonitor.py:
	Port to GIO. Patch by Evan Briones. Fixes bug #527541.



Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/lib/dirmonitor.py

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Thu Feb  5 19:37:42 2009
@@ -31,7 +31,7 @@
 # Check for GDK/X11 and PyGObject
 PKG_CHECK_MODULES(XLIB_MODULE, gdk-x11-2.0 pygobject-2.0)
 
-PYGOBJECT_REQUIRED_VERSION=2.12.0
+PYGOBJECT_REQUIRED_VERSION=2.15.0
 AC_MSG_CHECKING(for pygobject $PYGOBJECT_REQUIRED_VERSION or greater)
 if $PKG_CONFIG --atleast-version $PYGOBJECT_REQUIRED_VERSION pygobject-2.0
 then

Modified: trunk/lib/dirmonitor.py
==============================================================================
--- trunk/lib/dirmonitor.py	(original)
+++ trunk/lib/dirmonitor.py	Thu Feb  5 19:37:42 2009
@@ -19,7 +19,7 @@
 import os
 import os.path
 import gobject
-import gnomevfs
+import gio
 import util
 import fnmatch
 import debuglog
@@ -27,9 +27,9 @@
 
 N_WATCHES_LIMIT = 200
 
-CHANGED = gnomevfs.MONITOR_EVENT_CHANGED
-DELETED = gnomevfs.MONITOR_EVENT_DELETED
-CREATED = gnomevfs.MONITOR_EVENT_CREATED
+CHANGED = gio.FILE_MONITOR_EVENT_CHANGED
+DELETED = gio.FILE_MONITOR_EVENT_DELETED
+CREATED = gio.FILE_MONITOR_EVENT_CREATED
 
 def dprint (fmt, *args):
     debuglog.debug_log (False, debuglog.DEBUG_LOG_DOMAIN_DIR_MONITOR, fmt % args)
@@ -49,7 +49,7 @@
         self.directory = directory
         self.callback = callback
         self.data = data
-        self.watches = {} # maps filename => gnome_vfs_monitor handle
+        self.watches = {} # maps filename => FileMonitor handle
         self.too_many_watches = False
         self.dirs_to_ignore = []
         self.files_to_ignore = []
@@ -75,18 +75,16 @@
             self.callback (path, event)
 
     #
-    # Processing of a gnomevfs callback
+    # Processing of a file_monitor callback
     #
-    def __handle_gnomevfs_event (self, dir_uri, file_uri, event):
+    def __handle_file_monitor_event (self, dir_uri, file_uri, event, data):
         if event == CHANGED or event == DELETED or event == CREATED:
-            # Strip 'file://' and replace %xx with equivalent characters.
-            path = file_uri [7:]
-            path = urllib.unquote (path)
-
+            path = file_uri.get_path ()
+            
             # Strip trailing '/'.
             path = os.path.normpath (path)
             
-            dprint ("Got gnomevfs event '%s' on '%s'", event_to_string (event), path)
+            dprint ("Got file_monitor event '%s' on '%s'", event_to_string (event), path)
 
             if not self.__should_ignore_dir (path) and \
                not self.__should_ignore_file (path):
@@ -97,7 +95,7 @@
                 elif event == DELETED:
                     if path != self.directory and self.watches.has_key (path):
                         dprint ("Deleting watch for '%s' since it got deleted", path)
-                        gnomevfs.monitor_cancel (self.watches [path])
+                        self.watches [path].cancel ()
                         del self.watches[path]
                         if len (self.watches) < N_WATCHES_LIMIT:
                             self.too_many_watches = False
@@ -120,7 +118,9 @@
             return
 
         try:
-            self.watches [dir] = gnomevfs.monitor_add (dir, gnomevfs.MONITOR_DIRECTORY, self.__handle_gnomevfs_event)
+            gfile = gio.File (dir)
+            self.watches [dir] = gfile.monitor_directory ()
+            self.watches [dir].connect ("changed", self.__handle_file_monitor_event) 
             dprint ("Added directory watch for '%s'", dir)
         except:
             print ("Failed to add monitor for %s") % (dir)
@@ -160,7 +160,7 @@
         dprint ("Stopping recursive monitoring of '%s'", self.directory)
 
         for path in self.watches:
-            gnomevfs.monitor_cancel (self.watches [path])
+            self.watches [path].cancel ()
 
 def run_unit_tests ():
     import tempfile



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