Author: jannis Date: 2008-11-27 17:42:04 +0000 (Thu, 27 Nov 2008) New Revision: 28928
Modified: thunar/trunk/ChangeLog thunar/trunk/configure.in.in thunar/trunk/thunar-vfs/thunar-vfs-monitor.c Log: * configure.in.in, thunar-vfs/thunar-vfs-monitor.c: Add HAVE_LINUX define to config.h and implement support for excluding certain base paths (such as /dev and /proc) from being being monitored. Gamin does the same but only for dnotify and inotify, not for polling. Modified: thunar/trunk/ChangeLog =================================================================== --- thunar/trunk/ChangeLog 2008-11-27 17:17:38 UTC (rev 28927) +++ thunar/trunk/ChangeLog 2008-11-27 17:42:04 UTC (rev 28928) @@ -1,3 +1,10 @@ +2008-11-27 Jannis Pohlmann <[EMAIL PROTECTED]> + + * configure.in.in, thunar-vfs/thunar-vfs-monitor.c: Add HAVE_LINUX + define to config.h and implement support for excluding certain base + paths (such as /dev and /proc) from being being monitored. Gamin + does the same but only for dnotify and inotify, not for polling. + 2008-11-26 Nick Schermer <[EMAIL PROTECTED]> * thunar/thunar-application.c: Create a new window group for Modified: thunar/trunk/configure.in.in =================================================================== --- thunar/trunk/configure.in.in 2008-11-27 17:17:38 UTC (rev 28927) +++ thunar/trunk/configure.in.in 2008-11-27 17:42:04 UTC (rev 28928) @@ -49,6 +49,10 @@ AC_ISC_POSIX() AC_MINIX() +if test "x$target_os" = "xlinux-gnu"; then + AC_DEFINE([HAVE_LINUX], [], [Whether we are building on Linux or not]) +fi + dnl ******************************** dnl *** Check for basic programs *** dnl ******************************** Modified: thunar/trunk/thunar-vfs/thunar-vfs-monitor.c =================================================================== --- thunar/trunk/thunar-vfs/thunar-vfs-monitor.c 2008-11-27 17:17:38 UTC (rev 28927) +++ thunar/trunk/thunar-vfs/thunar-vfs-monitor.c 2008-11-27 17:42:04 UTC (rev 28928) @@ -73,6 +73,8 @@ GIOCondition condition, gpointer user_data); #endif +static gboolean thunar_vfs_monitor_is_excluded_path (ThunarVfsMonitor *monitor, + ThunarVfsPath *path); @@ -102,6 +104,9 @@ FAMConnection fc; gint fc_watch_id; #endif + + /* Excluded paths */ + GList *excluded_paths; }; struct _ThunarVfsMonitorHandle @@ -134,8 +139,17 @@ static GObjectClass *thunar_vfs_monitor_parent_class; +static const gchar *excluded_paths[] = +{ +#ifdef HAVE_LINUX + "/proc/*", + "/dev/*", +#endif + NULL +}; + GType thunar_vfs_monitor_get_type (void) { @@ -174,10 +188,17 @@ static void thunar_vfs_monitor_init (ThunarVfsMonitor *monitor) { + gint i; + /* initialize the monitor */ monitor->cond = g_cond_new (); monitor->lock = g_mutex_new (); + /* Generate pattern specs for excluded paths */ + monitor->excluded_paths = NULL; + for (i = 0; excluded_paths[i] != NULL; ++i) + monitor->excluded_paths = g_list_append (monitor->excluded_paths, g_pattern_spec_new (excluded_paths[i])); + #ifdef HAVE_LIBFAM if (FAMOpen2 (&monitor->fc, PACKAGE_NAME) == 0) { @@ -214,6 +235,9 @@ thunar_vfs_monitor_fam_cancel (monitor); #endif + /* drop excluded path patterns */ + g_list_foreach (monitor->excluded_paths, (GFunc) g_pattern_spec_free, NULL); + /* drop the notifications timer source */ if (G_UNLIKELY (monitor->notifications_timer_id != 0)) g_source_remove (monitor->notifications_timer_id); @@ -492,6 +516,53 @@ /** + * thunar_vfs_monitor_is_excluded_path: + * @monitor : a #ThunarVfsMonitor. + * @path : a #ThunarVfsPath + * + * Checks whether the path is among the paths to be excluded from + * monitoring. + * + * Return value: %TRUE if @path should be excluded from monitoring, + * %FALSE otherwise. + **/ +static gboolean +thunar_vfs_monitor_is_excluded_path (ThunarVfsMonitor *monitor, + ThunarVfsPath *path) +{ + GList *iter; + gboolean excluded = FALSE; + gchar *path_string; + gint length; + + _thunar_vfs_return_val_if_fail (THUNAR_VFS_IS_MONITOR (monitor), TRUE); + _thunar_vfs_return_val_if_fail (path != NULL, TRUE); + + /* Turn path into a string */ + path_string = thunar_vfs_path_dup_string (path); + + if (G_LIKELY (path_string != NULL)) + { + length = strlen (path_string); + + /* Match path against all exclude patterns. Return TRUE if it matches at + * least one of these patterns */ + for (iter = g_list_first (monitor->excluded_paths); iter != NULL; iter = g_list_next (iter)) + if (g_pattern_match (iter->data, length, path_string, NULL)) + { + excluded = TRUE; + break; + } + + g_free (path_string); + } + + return excluded; +} + + + +/** * thunar_vfs_monitor_get_default: * * Returns the shared #ThunarVfsMonitor instance. The caller @@ -540,6 +611,9 @@ g_return_val_if_fail (callback != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); + if (G_UNLIKELY (_thunar_vfs_path_is_local (path) && thunar_vfs_monitor_is_excluded_path (monitor, path))) + return NULL; + /* acquire the monitor lock */ g_mutex_lock (monitor->lock); @@ -604,6 +678,9 @@ g_return_val_if_fail (callback != NULL, NULL); g_return_val_if_fail (path != NULL, NULL); + if (G_UNLIKELY (_thunar_vfs_path_is_local (path) && thunar_vfs_monitor_is_excluded_path (monitor, path))) + return NULL; + /* acquire the monitor lock */ g_mutex_lock (monitor->lock); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits