mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
gosxappinfo: Fix get_default_for_type() on 10.10+
https://bugzilla.gnome.org/show_bug.cgi?id=734946
This commit is contained in:
parent
d4bfee1e7a
commit
fac83e09d6
@ -294,6 +294,20 @@ free_urlspec (LSLaunchURLSpec *urlspec)
|
|||||||
g_free (urlspec);
|
g_free (urlspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSBundle *
|
||||||
|
get_bundle_for_url (CFURLRef app_url)
|
||||||
|
{
|
||||||
|
NSBundle *bundle = [NSBundle bundleWithURL: (NSURL*)app_url];
|
||||||
|
|
||||||
|
if (!bundle)
|
||||||
|
{
|
||||||
|
g_debug ("Bundle not found for url.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
static NSBundle *
|
static NSBundle *
|
||||||
get_bundle_for_id (CFStringRef bundle_id)
|
get_bundle_for_id (CFStringRef bundle_id)
|
||||||
{
|
{
|
||||||
@ -324,15 +338,8 @@ get_bundle_for_id (CFStringRef bundle_id)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle = [NSBundle bundleWithURL: (NSURL*)app_url];
|
bundle = get_bundle_for_url (app_url);
|
||||||
CFRelease (app_url);
|
CFRelease (app_url);
|
||||||
|
|
||||||
if (!bundle)
|
|
||||||
{
|
|
||||||
g_debug ("Bundle not found for url.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,24 +657,34 @@ GAppInfo *
|
|||||||
g_app_info_get_default_for_type (const char *content_type,
|
g_app_info_get_default_for_type (const char *content_type,
|
||||||
gboolean must_support_uris)
|
gboolean must_support_uris)
|
||||||
{
|
{
|
||||||
gchar *type_cstr;
|
CFStringRef type;
|
||||||
CFStringRef type, bundle_id;
|
|
||||||
NSBundle *bundle;
|
NSBundle *bundle;
|
||||||
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
|
||||||
|
CFURLRef bundle_id;
|
||||||
|
#else
|
||||||
|
CFStringRef bundle_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
type_cstr = g_content_type_from_mime_type (content_type);
|
type = create_cfstring_from_cstr (content_type);
|
||||||
type = create_cfstring_from_cstr (type_cstr);
|
|
||||||
g_free (type_cstr);
|
|
||||||
|
|
||||||
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
|
||||||
|
bundle_id = LSCopyDefaultApplicationURLForContentType (type, kLSRolesAll, NULL);
|
||||||
|
#else
|
||||||
bundle_id = LSCopyDefaultRoleHandlerForContentType (type, kLSRolesAll);
|
bundle_id = LSCopyDefaultRoleHandlerForContentType (type, kLSRolesAll);
|
||||||
|
#endif
|
||||||
CFRelease (type);
|
CFRelease (type);
|
||||||
|
|
||||||
if (!bundle_id)
|
if (!bundle_id)
|
||||||
{
|
{
|
||||||
g_warning ("No default handler found for mimetype '%s'.", content_type);
|
g_warning ("No default handler found for content type '%s'.", content_type);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
|
||||||
|
bundle = get_bundle_for_url (bundle_id);
|
||||||
|
#else
|
||||||
bundle = get_bundle_for_id (bundle_id);
|
bundle = get_bundle_for_id (bundle_id);
|
||||||
|
#endif
|
||||||
CFRelease (bundle_id);
|
CFRelease (bundle_id);
|
||||||
|
|
||||||
if (!bundle)
|
if (!bundle)
|
||||||
|
Loading…
Reference in New Issue
Block a user