[glib] gosxappinfo: Special case x-scheme-handler



commit 0c4dd4a8020044fc7ba8196e0fccdd66e287fb97
Author: Patrick Griffis <tingping tingping se>
Date:   Thu Mar 30 19:49:21 2017 -0400

    gosxappinfo: Special case x-scheme-handler
    
    This is the only way they are exposed on Unix so we need to handle it
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734946

 gio/gosxappinfo.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/gio/gosxappinfo.c b/gio/gosxappinfo.c
index 62e7029..58c6697 100644
--- a/gio/gosxappinfo.c
+++ b/gio/gosxappinfo.c
@@ -600,24 +600,25 @@ g_osx_app_info_get_all_for_scheme (const char *cscheme)
 GList *
 g_app_info_get_all_for_type (const char *content_type)
 {
-  gchar *type_cstr;
+  gchar *mime_type;
   CFArrayRef bundle_list;
   CFStringRef type;
   NSBundle *bundle;
   GList *info_list = NULL;
   gint i;
 
-  if (g_str_has_prefix (content_type, "x-scheme-handler/"))
+  mime_type = g_content_type_get_mime_type (content_type);
+  if (g_str_has_prefix (mime_type, "x-scheme-handler/"))
     {
-      gchar *scheme = strchr (content_type, '/') + 1;
+      gchar *scheme = strchr (mime_type, '/') + 1;
+      GList *ret = g_osx_app_info_get_all_for_scheme (scheme);
 
-      return g_osx_app_info_get_all_for_scheme (scheme);
+      g_free (mime_type);
+      return ret;
     }
+  g_free (mime_type);
 
-  type_cstr = g_content_type_from_mime_type (content_type);
-  type = create_cfstring_from_cstr (type_cstr);
-  g_free (type_cstr);
-
+  type = create_cfstring_from_cstr (content_type);
   bundle_list = LSCopyAllRoleHandlersForContentType (type, kLSRolesAll);
   CFRelease (type);
 
@@ -657,6 +658,7 @@ GAppInfo *
 g_app_info_get_default_for_type (const char *content_type,
                                  gboolean    must_support_uris)
 {
+  gchar *mime_type;
   CFStringRef type;
   NSBundle *bundle;
 #ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
@@ -665,6 +667,17 @@ g_app_info_get_default_for_type (const char *content_type,
   CFStringRef bundle_id;
 #endif
 
+  mime_type = g_content_type_get_mime_type (content_type);
+  if (g_str_has_prefix (mime_type, "x-scheme-handler/"))
+    {
+      gchar *scheme = strchr (mime_type, '/') + 1;
+      GAppInfo *ret = g_app_info_get_default_for_uri_scheme (scheme);
+
+      g_free (mime_type);
+      return ret;
+    }
+  g_free (mime_type);
+
   type = create_cfstring_from_cstr (content_type);
 
 #ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]