diff options
author | Dan Winship <danw@gnome.org> | 2011-06-21 18:21:27 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2011-10-04 13:20:34 -0400 |
commit | 1481b7bca3c24149a2970758bc8762e1318f361e (patch) | |
tree | f2c9a026703eb65ea4ec724a385d4bff483a4f20 /gio/gvfs.c | |
parent | 38d21f6d8a761cf211c0e0ca21c394b4824d13f2 (diff) | |
download | glib-1481b7bca3c24149a2970758bc8762e1318f361e.tar.gz glib-1481b7bca3c24149a2970758bc8762e1318f361e.tar.bz2 glib-1481b7bca3c24149a2970758bc8762e1318f361e.zip |
Add _g_io_module_get_default(), use to simplify other *_get_default()s
Add _g_io_module_get_default(), which implements the
figure-out-the-best-available-module-that-is-actually-usable logic,
and use that to simplify g_proxy_resolver_get_default(),
g_settings_backend_get_default(), g_tls_backend_get_default(), and
g_vfs_get_default().
https://bugzilla.gnome.org/show_bug.cgi?id=620932
Diffstat (limited to 'gio/gvfs.c')
-rw-r--r-- | gio/gvfs.c | 53 |
1 files changed, 3 insertions, 50 deletions
diff --git a/gio/gvfs.c b/gio/gvfs.c index 697c69bb5..cbe7f2f33 100644 --- a/gio/gvfs.c +++ b/gio/gvfs.c @@ -170,53 +170,6 @@ g_vfs_parse_name (GVfs *vfs, return (* class->parse_name) (vfs, parse_name); } -static gpointer -get_default_vfs (gpointer arg) -{ - const char *use_this; - GVfs *vfs; - GList *l; - GIOExtensionPoint *ep; - GIOExtension *extension; - - - use_this = g_getenv ("GIO_USE_VFS"); - - /* Ensure vfs in modules loaded */ - _g_io_modules_ensure_loaded (); - - ep = g_io_extension_point_lookup (G_VFS_EXTENSION_POINT_NAME); - - if (use_this) - { - extension = g_io_extension_point_get_extension_by_name (ep, use_this); - if (extension) - { - vfs = g_object_new (g_io_extension_get_type (extension), NULL); - - if (g_vfs_is_active (vfs)) - return vfs; - - g_object_unref (vfs); - } - } - - for (l = g_io_extension_point_get_extensions (ep); l != NULL; l = l->next) - { - extension = l->data; - - vfs = g_object_new (g_io_extension_get_type (extension), NULL); - - if (g_vfs_is_active (vfs)) - return vfs; - - g_object_unref (vfs); - } - - - return NULL; -} - /** * g_vfs_get_default: * @@ -227,9 +180,9 @@ get_default_vfs (gpointer arg) GVfs * g_vfs_get_default (void) { - static GOnce once_init = G_ONCE_INIT; - - return g_once (&once_init, get_default_vfs, NULL); + return _g_io_module_get_default (G_VFS_EXTENSION_POINT_NAME, + "GIO_USE_VFS", + (GIOModuleVerifyFunc)g_vfs_is_active); } /** |