diff options
author | TingPing <tingping@tingping.se> | 2015-03-25 18:26:50 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2017-03-11 10:29:41 -0500 |
commit | e9cb645e98c0670f3aab7108686c8b2189287131 (patch) | |
tree | fe85c88b89881a657ee210159a485ef2fcbf7034 | |
parent | 42ed4e93acef45c8a1f2f0098da27ace645e89d2 (diff) | |
download | glib-osx-appinfo.tar.gz |
Implement GAppInfo on OSXosx-appinfo
This is an implementation of most of GAppInfo using the OS X
NSBundle APIs.
Missing at this point are things that don't have equivalents
in OS X, such as hidden desktop files, last-used, manual type
associations, and g_app_info_get_all().
https://bugzilla.gnome.org/show_bug.cgi?id=734946
-rw-r--r-- | gio/Makefile.am | 14 | ||||
-rw-r--r-- | gio/giomodule.c | 8 | ||||
-rw-r--r-- | gio/gosxappinfo.c | 712 | ||||
-rw-r--r-- | gio/gosxappinfo.h | 54 | ||||
-rw-r--r-- | gio/tests/Makefile.am | 4 |
5 files changed, 783 insertions, 9 deletions
diff --git a/gio/Makefile.am b/gio/Makefile.am index fbf486991..22d4fc197 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -223,6 +223,7 @@ local_sources = \ platform_libadd = platform_deps = appinfo_sources = +appinfo_headers = contenttype_sources = if HAVE_INOTIFY @@ -253,9 +254,10 @@ if OS_UNIX if !OS_COCOA platform_libadd += xdgmime/libxdgmime.la platform_deps += xdgmime/libxdgmime.la + +appinfo_headers += gdesktopappinfo.h endif -appinfo_sources += gdesktopappinfo.c unix_sources = \ gfiledescriptorbased.c \ @@ -284,8 +286,6 @@ unix_sources = \ $(portal_sources) \ $(NULL) -appinfo_sources += $(unix_appinfo_sources) - if OS_COCOA if MAC_OS_X_9 unix_sources += gcocoanotificationbackend.c @@ -294,7 +294,6 @@ endif giounixincludedir=$(includedir)/gio-unix-2.0/gio giounixinclude_HEADERS = \ - gdesktopappinfo.h \ gfiledescriptorbased.h \ gunixconnection.h \ gunixcredentialsmessage.h \ @@ -304,6 +303,7 @@ giounixinclude_HEADERS = \ gunixinputstream.h \ gunixoutputstream.h \ gunixsocketaddress.h \ + $(appinfo_headers) \ $(NULL) if HAVE_NETLINK @@ -348,12 +348,10 @@ win32_more_sources_for_vcproj = \ win32/gwin32filemonitor.c if OS_WIN32 -win32_appinfo_sources = gwin32appinfo.c gwin32appinfo.h appinfo_sources += gwin32appinfo.c gwin32appinfo.h contenttype_sources += contenttype-win32.c platform_libadd += -lshlwapi -lws2_32 -ldnsapi -liphlpapi win32_sources = $(win32_actual_sources) -appinfo_sources += $(win32_appinfo_sources) giowin32includedir=$(includedir)/gio-win32-2.0/gio giowin32include_HEADERS = \ @@ -396,11 +394,13 @@ portal_sources = \ if OS_COCOA contenttype_sources += gosxcontenttype.c +appinfo_sources += gosxappinfo.c gosxappinfo.h endif if OS_UNIX if !OS_COCOA contenttype_sources += gcontenttype.c +appinfo_sources += gdesktopappinfo.c endif endif @@ -879,6 +879,7 @@ gdbus_LDADD = libgio-2.0.la \ $(NULL) if OS_UNIX +if !OS_COCOA # ------------------------------------------------------------------------ # gapplication(1) tool bin_PROGRAMS += gapplication @@ -889,6 +890,7 @@ gapplication_LDADD = libgio-2.0.la \ $(top_builddir)/glib/libglib-2.0.la \ $(NULL) endif +endif completiondir = $(datadir)/bash-completion/completions completion_DATA = \ diff --git a/gio/giomodule.c b/gio/giomodule.c index 3a131e129..7b9662dca 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -43,9 +43,12 @@ #endif #include <glib/gstdio.h> -#ifdef G_OS_UNIX +#if defined(G_OS_UNIX) && !defined(HAVE_COCOA) #include "gdesktopappinfo.h" #endif +#ifdef HAVE_COCOA +#include "gosxappinfo.h" +#endif #ifdef HAVE_COCOA #include <AvailabilityMacros.h> @@ -975,7 +978,7 @@ _g_io_modules_ensure_extension_points_registered (void) { registered_extensions = TRUE; -#ifdef G_OS_UNIX +#if defined(G_OS_UNIX) && !defined(HAVE_COCOA) #if !GLIB_CHECK_VERSION (3, 0, 0) ep = g_io_extension_point_register (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME); G_GNUC_BEGIN_IGNORE_DEPRECATIONS @@ -1116,6 +1119,7 @@ _g_io_modules_ensure_loaded (void) #endif #ifdef HAVE_COCOA g_type_ensure (g_nextstep_settings_backend_get_type ()); + g_type_ensure (g_osx_app_info_get_type ()); #endif #ifdef G_OS_UNIX g_type_ensure (_g_unix_volume_monitor_get_type ()); diff --git a/gio/gosxappinfo.c b/gio/gosxappinfo.c new file mode 100644 index 000000000..424f79d84 --- /dev/null +++ b/gio/gosxappinfo.c @@ -0,0 +1,712 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2014 Patrick Griffis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "config.h" + +#include "gappinfo.h" +#include "gosxappinfo.h" +#include "gcontenttype.h" +#include "gfile.h" +#include "gfileicon.h" + +#import <CoreFoundation/CoreFoundation.h> +#import <Foundation/Foundation.h> +#import <ApplicationServices/ApplicationServices.h> + +/** + * SECTION:gosxappinfo + * @title: GOsxAppInfo + * @short_description: Application information from NSBundles + * @include: gio/gosxappinfo.h + * + * #GOsxAppInfo is an implementation of #GAppInfo based on NSBundle information. + * + * Note that `<gio/gosxappinfo.h>` is unique to OSX. + */ + +static void g_osx_app_info_iface_init (GAppInfoIface *iface); +static const char *g_osx_app_info_get_id (GAppInfo *appinfo); + +/** + * GOsxAppInfo: + * + * Information about an installed application from a NSBundle. + */ +struct _GOsxAppInfo +{ + GObject parent_instance; + + NSBundle *bundle; + + /* Note that these are all NULL until first call + * to getter at which point they are cached here + */ + gchar *id; + gchar *name; + gchar *executable; + gchar *filename; + GIcon *icon; +}; + +G_DEFINE_TYPE_WITH_CODE (GOsxAppInfo, g_osx_app_info, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (G_TYPE_APP_INFO, g_osx_app_info_iface_init)) + +static GOsxAppInfo * +g_osx_app_info_new (NSBundle *bundle) +{ + GOsxAppInfo *info = g_object_new (G_TYPE_OSX_APP_INFO, NULL); + + info->bundle = [bundle retain]; + + return info; +} + +static void +g_osx_app_info_init (GOsxAppInfo *info) +{ +} + +static void +g_osx_app_info_finalize (GObject *object) +{ + GOsxAppInfo *info = G_OSX_APP_INFO (object); + + g_free (info->id); + g_free (info->name); + g_free (info->executable); + g_free (info->filename); + g_clear_object (&info->icon); + + [info->bundle release]; + + G_OBJECT_CLASS (g_osx_app_info_parent_class)->finalize (object); +} + +static void +g_osx_app_info_class_init (GOsxAppInfoClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->finalize = g_osx_app_info_finalize; +} + +static GAppInfo * +g_osx_app_info_dup (GAppInfo *appinfo) +{ + GOsxAppInfo *info; + GOsxAppInfo *new_info; + + g_return_val_if_fail (appinfo != NULL, NULL); + + info = G_OSX_APP_INFO (appinfo); + new_info = g_osx_app_info_new ([info->bundle retain]); + + return G_APP_INFO (new_info); +} + +static gboolean +g_osx_app_info_equal (GAppInfo *appinfo1, + GAppInfo *appinfo2) +{ + const gchar *str1, *str2; + + g_return_val_if_fail (appinfo1 != NULL, FALSE); + g_return_val_if_fail (appinfo2 != NULL, FALSE); + + str1 = g_osx_app_info_get_id (appinfo1); + str2 = g_osx_app_info_get_id (appinfo2); + + return (g_strcmp0 (str1, str2) == 0); +} + +/*< internal > + * get_bundle_string_value: + * @bundle: a #NSBundle + * @key: an #NSString key + * + * Returns a value from a bundles info.plist file. + * It will be utf8 encoded and it must be g_free()'d. + * + */ +static gchar * +get_bundle_string_value (NSBundle *bundle, + NSString *key) +{ + NSString *value; + const gchar *cvalue; + gchar *ret; + + g_return_val_if_fail (bundle != NULL, NULL); + + value = (NSString *)[bundle objectForInfoDictionaryKey: key]; + if (!value) + return NULL; + + cvalue = [value cStringUsingEncoding: NSUTF8StringEncoding]; + ret = g_strdup (cvalue); + + return ret; +} + +static CFStringRef +create_cfstring_from_cstr (const gchar *cstr) +{ + return CFStringCreateWithCString (NULL, cstr, kCFStringEncodingUTF8); +} + +static gchar * +create_cstr_from_cfstring (CFStringRef str) +{ + const gchar *cstr; + + if (str == NULL) + return NULL; + + cstr = CFStringGetCStringPtr (str, kCFStringEncodingUTF8); + CFRelease (str); + + return g_strdup (cstr); +} + +static char * +url_escape_hostname (const char *url) +{ + char *host_start, *ret; + + host_start = strstr (url, "://"); + if (host_start != NULL) + { + char *host_end, *scheme, *host, *hostname; + + scheme = g_strndup (url, host_start - url); + host_start += 3; + host_end = strchr (host_start, '/'); + + if (host_end != NULL) + host = g_strndup (host_start, host_end - host_start); + else + host = g_strdup (host_start); + + hostname = g_hostname_to_ascii (host_start); + + ret = g_strconcat (scheme, "://", hostname, host_end, NULL); + + g_free (scheme); + g_free (host); + g_free (hostname); + + return ret; + } + + return g_strdup (url); +} + +static CFURLRef +create_url_from_cstr (gchar *cstr, + gboolean is_file) +{ + gchar *puny_cstr; + CFStringRef str; + CFURLRef url; + + puny_cstr = url_escape_hostname (cstr); + str = CFStringCreateWithCString (NULL, puny_cstr ? puny_cstr : cstr, kCFStringEncodingUTF8); + + if (is_file) + url = CFURLCreateWithFileSystemPath (NULL, str, kCFURLPOSIXPathStyle, FALSE); + else + url = CFURLCreateWithString (NULL, str, NULL); + + if (!url) + g_debug ("Creating CFURL from %s %s failed!", cstr, is_file ? "file" : "uri"); + + g_free (puny_cstr); + CFRelease(str); + return url; +} + +static CFArrayRef +create_url_list_from_glist (GList *uris, + gboolean are_files) +{ + GList *lst; + int len = g_list_length (uris); + CFMutableArrayRef array; + + if (!len) + return NULL; + + array = CFArrayCreateMutable (NULL, len, &kCFTypeArrayCallBacks); + if (!array) + return NULL; + + for (lst = uris; lst != NULL && lst->data; lst = lst->next) + { + CFURLRef url = create_url_from_cstr ((char*)lst->data, are_files); + if (url) + CFArrayAppendValue (array, url); + } + + return (CFArrayRef)array; +} + +static LSLaunchURLSpec * +create_urlspec_for_appinfo (GOsxAppInfo *info, + GList *uris, + gboolean are_files) +{ + LSLaunchURLSpec *urlspec = g_new0 (LSLaunchURLSpec, 1); + gchar *app_cstr = g_osx_app_info_get_filename (info); + + urlspec->appURL = create_url_from_cstr (app_cstr, are_files); + urlspec->launchFlags = kLSLaunchDefaults; + urlspec->itemURLs = create_url_list_from_glist (uris, are_files); + + return urlspec; +} + +static void +free_urlspec (LSLaunchURLSpec *urlspec) +{ + if (urlspec->itemURLs) + { + CFArrayRemoveAllValues ((CFMutableArrayRef)urlspec->itemURLs); + CFRelease (urlspec->itemURLs); + } + CFRelease (urlspec->appURL); + g_free (urlspec); +} + +static NSBundle * +get_bundle_for_id (CFStringRef bundle_id) +{ + CFURLRef app_url; + NSBundle *bundle; + +#ifdef AVAILABLE_MAC_OS_VERSION_10_10_OR_LATER + CSArrayRef urls = LSCopyApplicationURLsForBundleIdentifier (bundle_id, NULL); + if (urls) + { + app_url = CFArrayGetValueAtIndex (urls, 0); + CFRetain (app_url); + CFRelease (urls); + } + else +#else + if (LSFindApplicationForInfo (kLSUnknownCreator, bundle_id, NULL, NULL, &app_url)) +#endif + { +#ifdef G_ENABLE_DEBUG /* This can fail often, no reason to alloc strings */ + gchar *id_str = create_cstr_from_cfstring (bundle_id); + g_debug ("Application not found for id \"%s\".", id_str); + g_free (id_str); +#endif + return NULL; + } + + bundle = [NSBundle bundleWithURL: (NSURL*)app_url]; + CFRelease (app_url); + + if (!bundle) + { + g_debug ("Bundle not found for url."); + return NULL; + } + + return bundle; +} + +static const char * +g_osx_app_info_get_id (GAppInfo *appinfo) +{ + GOsxAppInfo *info = G_OSX_APP_INFO (appinfo); + + if (!info->id) + info->id = get_bundle_string_value (info->bundle, @"CFBundleIdentifier"); + + return info->id; +} + +static const char * +g_osx_app_info_get_name (GAppInfo *appinfo) +{ + GOsxAppInfo *info = G_OSX_APP_INFO (appinfo); + + if (!info->name) + info->name = get_bundle_string_value (info->bundle, @"CFBundleName"); + + return info->name; +} + +static const char * +g_osx_app_info_get_display_name (GAppInfo *appinfo) +{ + return g_osx_app_info_get_name (appinfo); +} + +static const char * +g_osx_app_info_get_description (GAppInfo *appinfo) +{ + /* Bundles do not contain descriptions */ + return NULL; +} + +static const char * +g_osx_app_info_get_executable (GAppInfo *appinfo) +{ + GOsxAppInfo *info = G_OSX_APP_INFO (appinfo); + + if (!info->executable) + info->executable = get_bundle_string_value (info->bundle, @"CFBundleExecutable"); + + return info->executable; +} + +char * +g_osx_app_info_get_filename (GOsxAppInfo *info) +{ + g_return_val_if_fail (info != NULL, NULL); + + if (!info->filename) + { + info->filename = g_strconcat ("file://", [[info->bundle bundlePath] + cStringUsingEncoding: NSUTF8StringEncoding], + NULL); + } + + return info->filename; +} + +static const char * +g_osx_app_info_get_commandline (GAppInfo *appinfo) +{ + /* There isn't really a command line value */ + return NULL; +} + +static GIcon * +g_osx_app_info_get_icon (GAppInfo *appinfo) +{ + GOsxAppInfo *info = G_OSX_APP_INFO (appinfo); + + if (!info->icon) + { + gchar *icon_name, *app_uri, *icon_uri; + GFile *file; + + icon_name = get_bundle_string_value (info->bundle, @"CFBundleIconFile"); + if (!icon_name) + return NULL; + + app_uri = g_osx_app_info_get_filename (info); + icon_uri = g_strconcat (app_uri + 7, "/Contents/Resources/", icon_name, + g_str_has_suffix (icon_name, ".icns") ? NULL : ".icns", NULL); + g_free (icon_name); + + file = g_file_new_for_path (icon_uri); + info->icon = g_file_icon_new (file); + g_object_unref (file); + g_free (icon_uri); + } + + return info->icon; +} + +static gboolean +g_osx_app_info_launch_internal (GAppInfo *appinfo, + GList *uris, + gboolean are_files, + GError **error) +{ + GOsxAppInfo *info = G_OSX_APP_INFO (appinfo); + LSLaunchURLSpec *urlspec = create_urlspec_for_appinfo (info, uris, are_files); + gint ret, success = TRUE; + + if ((ret = LSOpenFromURLSpec (urlspec, NULL))) + { + /* TODO: Better error codes */ + g_set_error (error, G_IO_ERR, G_IO_ERROR_FAILED, + "Opening application failed with code %d", ret); + success = FALSE; + } + + free_urlspec (urlspec); + return success; +} + +static gboolean +g_osx_app_info_supports_uris (GAppInfo *appinfo) +{ + return TRUE; +} + +static gboolean +g_osx_app_info_supports_files (GAppInfo *appinfo) +{ + return TRUE; +} + +static gboolean +g_osx_app_info_launch (GAppInfo *appinfo, + GList *files, + GAppLaunchContext *launch_context, + GError **error) +{ + return g_osx_app_info_launch_internal (appinfo, files, TRUE, error); +} + +static gboolean +g_osx_app_info_launch_uris (GAppInfo *appinfo, + GList *uris, + GAppLaunchContext *launch_context, + GError **error) +{ + return g_osx_app_info_launch_internal (appinfo, uris, FALSE, error); +} + +static gboolean +g_osx_app_info_should_show (GAppInfo *appinfo) +{ + /* Bundles don't have hidden attribute */ + return TRUE; +} + +static gboolean +g_osx_app_info_set_as_default_for_type (GAppInfo *appinfo, + const char *content_type, + GError **error) +{ + return FALSE; +} + +static const char ** +g_osx_app_info_get_supported_types (GAppInfo *appinfo) +{ + /* TODO: get CFBundleDocumentTypes */ + return NULL; +} + +static gboolean +g_osx_app_info_set_as_last_used_for_type (GAppInfo *appinfo, + const char *content_type, + GError **error) +{ + /* Not supported. */ + return FALSE; +} + +static gboolean +g_osx_app_info_can_delete (GAppInfo *appinfo) +{ + return FALSE; +} + +static void +g_osx_app_info_iface_init (GAppInfoIface *iface) +{ + iface->dup = g_osx_app_info_dup; + iface->equal = g_osx_app_info_equal; + + iface->get_id = g_osx_app_info_get_id; + iface->get_name = g_osx_app_info_get_name; + iface->get_display_name = g_osx_app_info_get_display_name; + iface->get_description = g_osx_app_info_get_description; + iface->get_executable = g_osx_app_info_get_executable; + iface->get_commandline = g_osx_app_info_get_commandline; + iface->get_icon = g_osx_app_info_get_icon; + iface->get_supported_types = g_osx_app_info_get_supported_types; + + iface->set_as_last_used_for_type = g_osx_app_info_set_as_last_used_for_type; + iface->set_as_default_for_type = g_osx_app_info_set_as_default_for_type; + + iface->launch = g_osx_app_info_launch; + iface->launch_uris = g_osx_app_info_launch_uris; + + iface->supports_uris = g_osx_app_info_supports_uris; + iface->supports_files = g_osx_app_info_supports_files; + iface->should_show = g_osx_app_info_should_show; + iface->can_delete = g_osx_app_info_can_delete; +} + +GAppInfo * +g_app_info_create_from_commandline (const char *commandline, + const char *application_name, + GAppInfoCreateFlags flags, + GError **error) +{ + return NULL; +} + +GList * +g_osx_app_info_get_all_for_scheme (const char *cscheme) +{ + CFArrayRef bundle_list; + CFStringRef scheme; + NSBundle *bundle; + GList *info_list = NULL; + gint i; + + scheme = create_cfstring_from_cstr (cscheme); + bundle_list = LSCopyAllHandlersForURLScheme (scheme); + CFRelease (scheme); + + if (!bundle_list) + return NULL; + + for (i = 0; i < CFArrayGetCount (bundle_list); i++) + { + CFStringRef bundle_id = CFArrayGetValueAtIndex (bundle_list, i); + GAppInfo *info; + + bundle = get_bundle_for_id (bundle_id); + + if (!bundle) + continue; + + info = G_APP_INFO (g_osx_app_info_new (bundle)); + info_list = g_list_append (info_list, info); + } + + return info_list; +} + +GList * +g_app_info_get_all_for_type (const char *content_type) +{ + gchar *type_cstr; + CFArrayRef bundle_list; + CFStringRef type; + NSBundle *bundle; + GList *info_list = NULL; + gint i; + + if (g_str_has_prefix (content_type, "x-scheme-handler/")) + { + gchar *scheme = strchr (content_type, '/') + 1; + + return g_osx_app_info_get_all_for_scheme (scheme); + } + + type_cstr = g_content_type_from_mime_type (content_type); + type = create_cfstring_from_cstr (type_cstr); + g_free (type_cstr); + + bundle_list = LSCopyAllRoleHandlersForContentType (type, kLSRolesAll); + CFRelease (type); + + if (!bundle_list) + return NULL; + + for (i = 0; i < CFArrayGetCount (bundle_list); i++) + { + CFStringRef bundle_id = CFArrayGetValueAtIndex (bundle_list, i); + GAppInfo *info; + + bundle = get_bundle_for_id (bundle_id); + + if (!bundle) + continue; + + info = G_APP_INFO (g_osx_app_info_new (bundle)); + info_list = g_list_append (info_list, info); + } + + return info_list; +} + +GList * +g_app_info_get_recommended_for_type (const char *content_type) +{ + return g_app_info_get_all_for_type (content_type); +} + +GList * +g_app_info_get_fallback_for_type (const char *content_type) +{ + return g_app_info_get_all_for_type (content_type); +} + +GAppInfo * +g_app_info_get_default_for_type (const char *content_type, + gboolean must_support_uris) +{ + gchar *type_cstr; + CFStringRef type, bundle_id; + NSBundle *bundle; + + type_cstr = g_content_type_from_mime_type (content_type); + type = create_cfstring_from_cstr (type_cstr); + g_free (type_cstr); + + bundle_id = LSCopyDefaultRoleHandlerForContentType (type, kLSRolesAll); + CFRelease (type); + + if (!bundle_id) + { + g_warning ("No default handler found for mimetype '%s'.", content_type); + return NULL; + } + + bundle = get_bundle_for_id (bundle_id); + CFRelease (bundle_id); + + if (!bundle) + return NULL; + + return G_APP_INFO (g_osx_app_info_new (bundle)); +} + +GAppInfo * +g_app_info_get_default_for_uri_scheme (const char *uri_scheme) +{ + CFStringRef scheme, bundle_id; + NSBundle *bundle; + + scheme = create_cfstring_from_cstr (uri_scheme); + bundle_id = LSCopyDefaultHandlerForURLScheme (scheme); + CFRelease (scheme); + + if (!bundle_id) + { + g_warning ("No default handler found for url scheme '%s'.", uri_scheme); + return NULL; + } + + bundle = get_bundle_for_id (bundle_id); + CFRelease (bundle_id); + + if (!bundle) + return NULL; + + return G_APP_INFO (g_osx_app_info_new (bundle)); +} + +GList * +g_app_info_get_all (void) +{ + /* There is no API for this afaict + * could manually do it... + */ + return NULL; +} + +void +g_app_info_reset_type_associations (const char *content_type) +{ +} diff --git a/gio/gosxappinfo.h b/gio/gosxappinfo.h new file mode 100644 index 000000000..6a21f4dcf --- /dev/null +++ b/gio/gosxappinfo.h @@ -0,0 +1,54 @@ +/* GIO - GLib Input, Output and Streaming Library + * + * Copyright (C) 2014 Patrick Griffis + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __G_OSX_APP_INFO_H__ +#define __G_OSX_APP_INFO_H__ + +#include <gio/giotypes.h> + +G_BEGIN_DECLS + +#define G_TYPE_OSX_APP_INFO (g_osx_app_info_get_type ()) +#define G_OSX_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OSX_APP_INFO, GOsxAppInfo)) +#define G_OSX_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OSX_APP_INFO, GOsxAppInfoClass)) +#define G_IS_OSX_APP_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OSX_APP_INFO)) +#define G_IS_OSX_APP_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OSX_APP_INFO)) +#define G_OSX_APP_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OSX_APP_INFO, GOsxAppInfoClass)) + +typedef struct _GOsxAppInfo GOsxAppInfo; +typedef struct _GOsxAppInfoClass GOsxAppInfoClass; + +struct _GOsxAppInfoClass +{ + GObjectClass parent_class; +}; + +GLIB_AVAILABLE_IN_2_52 +GType g_osx_app_info_get_type (void) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_2_52 +char * g_osx_app_info_get_filename (GOsxAppInfo *info); + +GLIB_AVAILABLE_IN_2_52 +GList * g_osx_app_info_get_all_for_scheme (const gchar *scheme); + +G_END_DECLS + + +#endif /* __G_OSX_APP_INFO_H__ */ diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am index 321141da1..fe61ff994 100644 --- a/gio/tests/Makefile.am +++ b/gio/tests/Makefile.am @@ -316,17 +316,19 @@ dist_test_data += \ test_extra_programs += \ appinfo-test \ - apps \ $(NULL) uninstalled_test_extra_programs += \ gdbus-example-unix-fd-client \ $(NULL) +if !OS_COCOA +test_extra_programs += apps test_programs += mimeapps clean-local: clean-mimeapps clean-mimeapps: rm -rf xdgdatadir xdgdatahome xdgconfighome +endif uninstalled_test_programs += gsettings gschema-compile gsettings_DEPENDENCIES = test.mo |