summaryrefslogtreecommitdiff
path: root/gio/glocalfilemonitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'gio/glocalfilemonitor.c')
-rw-r--r--gio/glocalfilemonitor.c60
1 files changed, 4 insertions, 56 deletions
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index 91d524f5e..a8925c04f 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -150,75 +150,23 @@ static void g_local_file_monitor_class_init (GLocalFileMonitorClass *klass)
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
}
-static gpointer
-get_default_local_file_monitor (gpointer data)
-{
- GLocalFileMonitorClass *chosen_class;
- GLocalFileMonitorClass **ret = data;
- GIOExtensionPoint *ep;
- GList *extensions, *l;
-
- _g_io_modules_ensure_loaded ();
-
- ep = g_io_extension_point_lookup (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME);
-
- extensions = g_io_extension_point_get_extensions (ep);
-
- chosen_class = NULL;
- for (l = extensions; l != NULL; l = l->next)
- {
- GIOExtension *extension = l->data;
- GLocalFileMonitorClass *klass;
-
- klass = G_LOCAL_FILE_MONITOR_CLASS (g_io_extension_ref_class (extension));
-
- if (klass->is_supported ())
- {
- chosen_class = klass;
- break;
- }
- else
- g_type_class_unref (klass);
- }
-
- if (chosen_class)
- {
- *ret = chosen_class;
- return (gpointer)G_TYPE_FROM_CLASS (chosen_class);
- }
- else
- return (gpointer)G_TYPE_INVALID;
-}
-
GFileMonitor*
_g_local_file_monitor_new (const char *pathname,
GFileMonitorFlags flags,
GError **error)
{
- static GOnce once_init = G_ONCE_INIT;
- GTypeClass *type_class;
- GFileMonitor *monitor;
+ GFileMonitor *monitor = NULL;
GType type;
- type_class = NULL;
- g_once (&once_init, get_default_local_file_monitor, &type_class);
- type = (GType)once_init.retval;
+ type = _g_io_module_get_default_type (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME,
+ "GIO_USE_FILE_MONITOR",
+ G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
- monitor = NULL;
if (type != G_TYPE_INVALID)
monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, "flags", flags, NULL));
else
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Unable to find default local file monitor type"));
- /* This is non-null on first pass here. Unref the class now.
- * This is to avoid unloading the module and then loading it
- * again which would happen if we unrefed the class
- * before creating the monitor.
- */
-
- if (type_class)
- g_type_class_unref (type_class);
-
return monitor;
}