Add g_app_info_launch_default_for_uri utility function. (#513256)

2008-02-01  Alexander Larsson  <alexl@redhat.com>

        * gappinfo.[ch]:
        * gio.symbols:
        Add g_app_info_launch_default_for_uri utility
	function. (#513256)


svn path=/trunk/; revision=6437
This commit is contained in:
Alexander Larsson 2008-02-01 11:21:37 +00:00 committed by Alexander Larsson
parent cebfe57343
commit a00c11f08a
4 changed files with 53 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2008-02-01 Alexander Larsson <alexl@redhat.com>
* gappinfo.[ch]:
* gio.symbols:
Add g_app_info_launch_default_for_uri utility
function. (#513256)
2008-02-01 Cosimo Cecchi <cosimoc@svn.gnome.org>
* gdesktopappinfo.c:

View File

@ -528,6 +528,47 @@ g_app_info_should_show (GAppInfo *appinfo)
return (* iface->should_show) (appinfo);
}
/**
* g_app_info_launch_default_for_uri:
* @uri: the uri to show
* @context: an optional #GAppLaunchContext.
* @error: a #GError.
*
* Utility function that launches the default application
* registered to handle the specified uri. Synchronous I/O
* is done on the uri to detext the type of the file if
* required.
*
* Returns: %TRUE on success, %FALSE on error.
**/
gboolean
g_app_info_launch_default_for_uri (const char *uri,
GAppLaunchContext *launch_context,
GError *error)
{
GAppInfo *app_info;
GFile *file;
GList l;
gboolean res;
file = g_file_new_for_uri (uri);
app_info = g_file_query_default_handler (file, NULL, error);
g_object_unref (file);
if (app_info == NULL)
return FALSE;
/* Use the uri, not the GFile, as the GFile roundtrip may
* affect the uri which we don't want (for instance for a
* mailto: uri).
*/
l.data = uri;
l.next = l.prev = NULL;
res = g_app_info_launch_uris (app_info, &l,
launch_context, error);
return res;
}
G_DEFINE_TYPE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT);
/**

View File

@ -186,6 +186,10 @@ GAppInfo *g_app_info_get_default_for_type (const char *content_type,
gboolean must_support_uris);
GAppInfo *g_app_info_get_default_for_uri_scheme (const char *uri_scheme);
gboolean g_app_info_launch_default_for_uri (const char *uri,
GAppLaunchContext *launch_context,
GError *error);
/**
* GAppLaunchContext:
* @parent_instance: The parent instance.

View File

@ -46,6 +46,7 @@ g_app_info_set_as_default_for_extension
g_app_info_add_supports_type
g_app_info_can_remove_supports_type
g_app_info_remove_supports_type
g_app_info_launch_default_for_uri
g_app_launch_context_new
g_app_launch_context_get_display
g_app_launch_context_get_startup_notify_id