From: Jose Dapena Paz Date: Thu, 3 Dec 2009 17:15:54 +0000 (+0100) Subject: Handlers for activating uris and files. X-Git-Tag: jdapena-ppa-3.90.4-modest0~111 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=5018739a97d64f8ea40c4c9e4e3b2bee9d2c3ad7 Handlers for activating uris and files. --- diff --git a/src/gtk/modest-platform.c b/src/gtk/modest-platform.c index a9e12cd..6f5fe28 100644 --- a/src/gtk/modest-platform.c +++ b/src/gtk/modest-platform.c @@ -217,18 +217,46 @@ modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type, gboolean modest_platform_activate_uri (const gchar *uri) { - g_warning ("Not implemented %s", __FUNCTION__); - - return FALSE; + return g_app_info_launch_default_for_uri (uri, NULL, NULL); } gboolean modest_platform_activate_file (const gchar *path, const gchar *mime_type) { - g_warning ("Not implemented %s", __FUNCTION__); + gchar *content_type; + gboolean retval; + GAppInfo *app_info; + GList *list; + GFile *file; - return FALSE; + content_type = g_content_type_from_mime_type (mime_type); + if (!content_type) + return FALSE; + + app_info = g_app_info_get_default_for_type (content_type, FALSE); + g_free (content_type); + if (!app_info) { + content_type = g_content_type_guess (path, NULL, 0, NULL); + if (!content_type) + return FALSE; + + app_info = g_app_info_get_default_for_type (content_type, FALSE); + g_free (content_type); + + if (!app_info) + return FALSE; + + } + + file = g_file_new_for_path (path); + list = g_list_prepend (NULL, file); + retval = g_app_info_launch (app_info, list, NULL, NULL); + + g_list_free (list); + g_object_unref (file); + + return retval; } gboolean