[glib/glib-2-20] Avoid unnecessary work if mount watching not specified (#585360)
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Subject: [glib/glib-2-20] Avoid unnecessary work if mount watching not specified (#585360)
- Date: Tue, 23 Jun 2009 13:06:01 -0400 (EDT)
commit 6cf974af383ed2934d0f40e9c488eb3eb5312f7d
Author: Alexander Larsson <alexl redhat com>
Date: Mon Jun 15 12:25:43 2009 +0200
Avoid unnecessary work if mount watching not specified (#585360)
If G_FILE_MONITOR_WATCH_MOUNTS isn't specified, don't do all the work
when the mtab changes.
gio/glocaldirectorymonitor.c | 29 +++++++++++++++++++++++++----
gio/glocaldirectorymonitor.h | 1 +
2 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/gio/glocaldirectorymonitor.c b/gio/glocaldirectorymonitor.c
index 42c2ce0..5160655 100644
--- a/gio/glocaldirectorymonitor.c
+++ b/gio/glocaldirectorymonitor.c
@@ -36,7 +36,8 @@
enum
{
PROP_0,
- PROP_DIRNAME
+ PROP_DIRNAME,
+ PROP_FLAGS
};
static gboolean g_local_directory_monitor_cancel (GFileMonitor *monitor);
@@ -74,6 +75,9 @@ g_local_directory_monitor_set_property (GObject *object,
case PROP_DIRNAME:
/* Do nothing */
break;
+ case PROP_FLAGS:
+ /* Do nothing */
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -89,6 +93,7 @@ g_local_directory_monitor_constructor (GType type,
GLocalDirectoryMonitorClass *klass;
GObjectClass *parent_class;
GLocalDirectoryMonitor *local_monitor;
+ GFileMonitorFlags flags = 0;
const gchar *dirname = NULL;
gint i;
@@ -106,13 +111,19 @@ g_local_directory_monitor_constructor (GType type,
{
g_warn_if_fail (G_VALUE_HOLDS_STRING (construct_properties[i].value));
dirname = g_value_get_string (construct_properties[i].value);
- break;
+ }
+ if (strcmp ("flags", g_param_spec_get_name (construct_properties[i].pspec)) == 0)
+ {
+ g_warn_if_fail (G_VALUE_HOLDS_FLAGS (construct_properties[i].value));
+ flags = g_value_get_flags (construct_properties[i].value);
}
}
local_monitor->dirname = g_strdup (dirname);
+ local_monitor->flags = flags;
- if (!klass->mount_notify)
+ if (!klass->mount_notify &&
+ (flags & G_FILE_MONITOR_WATCH_MOUNTS))
{
#ifdef G_OS_WIN32
/*claim everything was mounted */
@@ -159,6 +170,16 @@ g_local_directory_monitor_class_init (GLocalDirectoryMonitorClass* klass)
G_PARAM_CONSTRUCT_ONLY|
G_PARAM_WRITABLE|
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
+ g_object_class_install_property (gobject_class,
+ PROP_FLAGS,
+ g_param_spec_flags ("flags",
+ P_("Monitor flags"),
+ P_("Monitor flags"),
+ G_TYPE_FILE_MONITOR_FLAGS,
+ 0,
+ G_PARAM_CONSTRUCT_ONLY|
+ G_PARAM_WRITABLE|
+ G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
klass->mount_notify = FALSE;
}
@@ -268,7 +289,7 @@ _g_local_directory_monitor_new (const char *dirname,
monitor = NULL;
if (type != G_TYPE_INVALID)
- monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, NULL));
+ monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, "flags", flags, NULL));
else
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Unable to find default local directory monitor type"));
diff --git a/gio/glocaldirectorymonitor.h b/gio/glocaldirectorymonitor.h
index bf2f2b9..418634e 100644
--- a/gio/glocaldirectorymonitor.h
+++ b/gio/glocaldirectorymonitor.h
@@ -45,6 +45,7 @@ struct _GLocalDirectoryMonitor
GFileMonitor parent_instance;
gchar *dirname;
+ GFileMonitorFlags flags;
/* For mount emulation */
GUnixMountMonitor *mount_monitor;
gboolean was_mounted;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]