Handlers for activating uris and files.
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 3 Dec 2009 17:15:54 +0000 (18:15 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Fri, 4 Dec 2009 11:44:23 +0000 (12:44 +0100)
src/gtk/modest-platform.c

index a9e12cd..6f5fe28 100644 (file)
@@ -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)
 {
 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)
 {
 
 }
 
 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
 }
 
 gboolean