gnome-menus r825 - in trunk: . libmenu



Author: wbolster
Date: Tue Jan  8 12:41:59 2008
New Revision: 825
URL: http://svn.gnome.org/viewvc/gnome-menus?rev=825&view=rev

Log:
2008-01-08  Wouter Bolsterlee  <wbolster svn gnome org>

	reviewed by: Vincent Untz

	* configure.in:
	* libmenu/menu-monitor-gio.c:
	(menu_monitor_backend_register_monitor),
	(menu_monitor_backend_unregister_monitor):

	Adapt to GIO file and directory monitoring API changes.
	Initial patch by Sebastian Bacher, but updated to
	actually do the right thing by Wouter Bolsterlee.
	Fixes bug #507938


Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/libmenu/menu-monitor-gio.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Jan  8 12:41:59 2008
@@ -48,7 +48,7 @@
 
 used_monitor_backend=
 if test "x$with_monitor_backend" = "xgio" -o "x$with_monitor_backend" = "xauto"; then
-  PKG_CHECK_MODULES(GIO, gio-2.0 >= 0.1, have_gio=yes, have_gio=no)
+  PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.15.1, have_gio=yes, have_gio=no)
 	
   if test "x$with_monitor_backend" = "gio" -a "x$have_gio" = "xno"; then
     AC_MSG_ERROR([No GIO found -- cannot enable GIO support])

Modified: trunk/libmenu/menu-monitor-gio.c
==============================================================================
--- trunk/libmenu/menu-monitor-gio.c	(original)
+++ trunk/libmenu/menu-monitor-gio.c	Tue Jan  8 12:41:59 2008
@@ -68,8 +68,8 @@
 void
 menu_monitor_backend_register_monitor (MenuMonitor *monitor)
 {
-  GObject *backend = NULL;
   GFile *file;
+  GFileMonitor *file_monitor;
 
   file = g_file_new_for_path (menu_monitor_get_path (monitor));
 
@@ -82,47 +82,33 @@
     }
 
   if (menu_monitor_get_is_directory (monitor))
-    {
-      GDirectoryMonitor *dmonitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL);
-
-      if (dmonitor)
-        backend = G_OBJECT (dmonitor);
-    }
+      file_monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL);
   else
-    {
-      GFileMonitor *fmonitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL);
-
-      if (fmonitor)
-        backend = G_OBJECT (fmonitor);
-    }
+      file_monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL);
 
   g_object_unref (G_OBJECT (file));
 
-  if (backend == NULL)
+  if (file_monitor == NULL)
     {
       menu_verbose ("Not adding %s monitor on '%s', failed to create monitor\n",
                     menu_monitor_get_is_directory (monitor) ? "directory" : "file",
                     menu_monitor_get_path (monitor));
       return;
     }
-  
-  g_signal_connect (backend, "changed", G_CALLBACK (monitor_callback), monitor);
 
-  menu_monitor_set_backend_data (monitor, backend);
+  g_signal_connect (file_monitor, "changed", G_CALLBACK (monitor_callback), monitor);
+
+  menu_monitor_set_backend_data (monitor, file_monitor);
 }
 
 void
 menu_monitor_backend_unregister_monitor (MenuMonitor *monitor)
 {
-  GObject *backend;
+  GFileMonitor *file_monitor;
 
-  if ((backend = G_OBJECT (menu_monitor_get_backend_data (monitor))) != NULL)
+  if ((file_monitor = menu_monitor_get_backend_data (monitor)) != NULL)
     {
-      if (G_IS_FILE_MONITOR (backend)) 
-        g_file_monitor_cancel (G_FILE_MONITOR (backend));
-      else
-        g_directory_monitor_cancel (G_DIRECTORY_MONITOR (backend));
-      
-      g_object_unref (backend);
+      g_file_monitor_cancel (file_monitor);
+      g_object_unref (file_monitor);
     }
 }



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