Commit a00c11f0 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

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
parent cebfe573
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:
......
......@@ -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);
/**
......
......@@ -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.
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment