[gtk+/gtk-3-2] GtkRecentManager: guess mime-type from filename when file doesn't exist



commit 7b3dba726836e51b42aaa730e9dd817babc17339
Author: Siegfried-Angel Gevatter Pujals <rainct ubuntu com>
Date:   Tue Jan 24 13:59:12 2012 +0100

    GtkRecentManager: guess mime-type from filename when file doesn't exist

 gtk/gtkrecentmanager.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkrecentmanager.c b/gtk/gtkrecentmanager.c
index a674b5d..be0fc76 100644
--- a/gtk/gtkrecentmanager.c
+++ b/gtk/gtkrecentmanager.c
@@ -729,7 +729,7 @@ gtk_recent_manager_add_item_query_info (GObject      *source_object,
   GtkRecentManager *manager = user_data;
   GtkRecentData recent_data;
   GFileInfo *file_info;
-  gchar *uri;
+  gchar *uri, *basename;
 
   uri = g_file_get_uri (file);
 
@@ -753,7 +753,11 @@ gtk_recent_manager_add_item_query_info (GObject      *source_object,
       g_object_unref (file_info);
     }
   else
-    recent_data.mime_type = g_strdup (GTK_RECENT_DEFAULT_MIME); /* FIXME: maybe we should make up the MIME type from the filename's extension */
+    {
+      basename = g_file_get_basename (file);
+      recent_data.mime_type = g_content_type_guess (basename, NULL, 0, NULL);
+      g_free (basename);
+    }
 
   recent_data.app_name = g_strdup (g_get_application_name ());
   recent_data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]