[glib] Replace "gio-desktop-app-info-lookup" extension point
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Replace "gio-desktop-app-info-lookup" extension point
- Date: Tue, 5 Oct 2010 16:15:48 +0000 (UTC)
commit 9b262f1c5fe5a6fd879f17cd7b80d8c54e33d80c
Author: Bastien Nocera <hadess hadess net>
Date: Tue Oct 5 15:02:37 2010 +0100
Replace "gio-desktop-app-info-lookup" extension point
With a native version, that looks for desktop items supporting
x-scheme-handler/foo, when looking for a handler for the "foo"
URI scheme handler.
https://bugzilla.gnome.org/show_bug.cgi?id=631410
gio/gdesktopappinfo.c | 93 ++++--------------------------------------------
gio/gdesktopappinfo.h | 36 -------------------
gio/gio.symbols | 1 -
gio/giomodule.c | 5 ---
4 files changed, 8 insertions(+), 127 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index c38726c..8047d9c 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -1838,57 +1838,18 @@ g_app_info_get_default_for_type (const char *content_type,
GAppInfo *
g_app_info_get_default_for_uri_scheme (const char *uri_scheme)
{
- static gsize lookup = 0;
-
- if (g_once_init_enter (&lookup))
- {
- gsize setup_value = 1;
- GDesktopAppInfoLookup *lookup_instance;
- const char *use_this;
- GIOExtensionPoint *ep;
- GIOExtension *extension;
- GList *l;
-
- use_this = g_getenv ("GIO_USE_URI_ASSOCIATION");
-
- /* Ensure vfs in modules loaded */
- _g_io_modules_ensure_loaded ();
-
- ep = g_io_extension_point_lookup (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME);
-
- lookup_instance = NULL;
- if (use_this)
- {
- extension = g_io_extension_point_get_extension_by_name (ep, use_this);
- if (extension)
- lookup_instance = g_object_new (g_io_extension_get_type (extension), NULL);
- }
-
- if (lookup_instance == NULL)
- {
- for (l = g_io_extension_point_get_extensions (ep); l != NULL; l = l->next)
- {
- extension = l->data;
- lookup_instance = g_object_new (g_io_extension_get_type (extension), NULL);
- if (lookup_instance != NULL)
- break;
- }
- }
+ GAppInfo *app_info;
+ char *content_type, *scheme_down;
- if (lookup_instance != NULL)
- setup_value = (gsize)lookup_instance;
-
- g_once_init_leave (&lookup, setup_value);
- }
+ scheme_down = g_ascii_strdown (uri_scheme, -1);
+ content_type = g_strdup_printf ("x-scheme-handler/%s", scheme_down);
+ g_free (scheme_down);
+ app_info = g_app_info_get_default_for_type (content_type, FALSE);
+ g_free (content_type);
- if (lookup == 1)
- return NULL;
-
- return g_desktop_app_info_lookup_get_default_for_uri_scheme (G_DESKTOP_APP_INFO_LOOKUP (lookup),
- uri_scheme);
+ return app_info;
}
-
static void
get_apps_from_dir (GHashTable *apps,
const char *dirname,
@@ -2677,41 +2638,3 @@ get_all_desktop_entries_for_mime_type (const char *base_mime_type,
return desktop_entries;
}
-/* GDesktopAppInfoLookup interface: */
-
-typedef GDesktopAppInfoLookupIface GDesktopAppInfoLookupInterface;
-G_DEFINE_INTERFACE (GDesktopAppInfoLookup, g_desktop_app_info_lookup, G_TYPE_OBJECT)
-
-static void
-g_desktop_app_info_lookup_default_init (GDesktopAppInfoLookupInterface *iface)
-{
-}
-
-/**
- * g_desktop_app_info_lookup_get_default_for_uri_scheme:
- * @lookup: a #GDesktopAppInfoLookup
- * @uri_scheme: a string containing a URI scheme.
- *
- * Gets the default application for launching applications
- * using this URI scheme for a particular GDesktopAppInfoLookup
- * implementation.
- *
- * The GDesktopAppInfoLookup interface and this function is used
- * to implement g_app_info_get_default_for_uri_scheme() backends
- * in a GIO module. There is no reason for applications to use it
- * directly. Applications should use g_app_info_get_default_for_uri_scheme().
- *
- * Returns: (transfer full): #GAppInfo for given @uri_scheme or %NULL on error.
- */
-GAppInfo *
-g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup,
- const char *uri_scheme)
-{
- GDesktopAppInfoLookupIface *iface;
-
- g_return_val_if_fail (G_IS_DESKTOP_APP_INFO_LOOKUP (lookup), NULL);
-
- iface = G_DESKTOP_APP_INFO_LOOKUP_GET_IFACE (lookup);
-
- return (* iface->get_default_for_uri_scheme) (lookup, uri_scheme);
-}
diff --git a/gio/gdesktopappinfo.h b/gio/gdesktopappinfo.h
index 48c9693..d7703f7 100644
--- a/gio/gdesktopappinfo.h
+++ b/gio/gdesktopappinfo.h
@@ -55,42 +55,6 @@ gboolean g_desktop_app_info_get_is_hidden (GDesktopAppInfo *info);
void g_desktop_app_info_set_desktop_env (const char *desktop_env);
-
-#define G_TYPE_DESKTOP_APP_INFO_LOOKUP (g_desktop_app_info_lookup_get_type ())
-#define G_DESKTOP_APP_INFO_LOOKUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_DESKTOP_APP_INFO_LOOKUP, GDesktopAppInfoLookup))
-#define G_IS_DESKTOP_APP_INFO_LOOKUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_DESKTOP_APP_INFO_LOOKUP))
-#define G_DESKTOP_APP_INFO_LOOKUP_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), G_TYPE_DESKTOP_APP_INFO_LOOKUP, GDesktopAppInfoLookupIface))
-
-/**
- * G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME:
- *
- * Extension point for default handler to URI association. See
- * <link linkend="extending-gio">Extending GIO</link>.
- */
-#define G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME "gio-desktop-app-info-lookup"
-
-/**
- * GDesktopAppInfoLookup:
- *
- * Interface that is used by backends to associate default
- * handlers with URI schemes.
- */
-typedef struct _GDesktopAppInfoLookup GDesktopAppInfoLookup;
-typedef struct _GDesktopAppInfoLookupIface GDesktopAppInfoLookupIface;
-
-struct _GDesktopAppInfoLookupIface
-{
- GTypeInterface g_iface;
-
- GAppInfo * (* get_default_for_uri_scheme) (GDesktopAppInfoLookup *lookup,
- const char *uri_scheme);
-};
-
-GType g_desktop_app_info_lookup_get_type (void) G_GNUC_CONST;
-
-GAppInfo *g_desktop_app_info_lookup_get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup,
- const char *uri_scheme);
-
G_END_DECLS
#endif /* __G_DESKTOP_APP_INFO_H__ */
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 58e457c..15212ec 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -114,7 +114,6 @@ g_desktop_app_info_get_type G_GNUC_CONST
g_desktop_app_info_get_is_hidden
g_desktop_app_info_set_desktop_env
g_desktop_app_info_lookup_get_type G_GNUC_CONST
-g_desktop_app_info_lookup_get_default_for_uri_scheme
#endif
#endif
#endif
diff --git a/gio/giomodule.c b/gio/giomodule.c
index 2c221e4..86bf25e 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -523,11 +523,6 @@ _g_io_modules_ensure_extension_points_registered (void)
{
registered_extensions = TRUE;
-#ifdef G_OS_UNIX
- ep = g_io_extension_point_register (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME);
- g_io_extension_point_set_required_type (ep, G_TYPE_DESKTOP_APP_INFO_LOOKUP);
-#endif
-
ep = g_io_extension_point_register (G_LOCAL_DIRECTORY_MONITOR_EXTENSION_POINT_NAME);
g_io_extension_point_set_required_type (ep, G_TYPE_LOCAL_DIRECTORY_MONITOR);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]