[evince] [shell] Add icons to the recent items, and always show them in menu



commit 135a545facb0df15d32f6e9e91b1c38b3b0988e3
Author: Christian Persch <chpe gnome org>
Date:   Thu Apr 29 14:26:22 2010 +0200

    [shell] Add icons to the recent items, and always show them in menu
    
    Bug #614400.

 shell/ev-window.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index e55c739..1cb21aa 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -2378,6 +2378,9 @@ ev_window_setup_recent (EvWindow *ev_window)
 		GtkAction     *action;
 		gchar         *action_name;
 		gchar         *label;
+                const gchar   *mime_type;
+                gchar         *content_type;
+                GIcon         *icon = NULL;
 
 		info = (GtkRecentInfo *) l->data;
 
@@ -2388,10 +2391,23 @@ ev_window_setup_recent (EvWindow *ev_window)
 		action_name = g_strdup_printf ("RecentFile%u", i++);
 		label = ev_window_get_recent_file_label (
 			n_items + 1, gtk_recent_info_get_display_name (info));
-		
+
+                mime_type = gtk_recent_info_get_mime_type (info);
+                content_type = g_content_type_from_mime_type (mime_type);
+                if (content_type != NULL) {
+                        icon = g_content_type_get_icon (content_type);
+                        g_free (content_type);
+                }
+
 		action = g_object_new (GTK_TYPE_ACTION,
 				       "name", action_name,
 				       "label", label,
+#if GTK_CHECK_VERSION (2, 16, 0)
+                                       "gicon", icon,
+#endif
+#if GTK_CHECK_VERSION (2, 20, 0)
+                                       "always-show-image", TRUE,
+#endif
 				       NULL);
 
 		g_object_set_data_full (G_OBJECT (action),
@@ -2416,6 +2432,8 @@ ev_window_setup_recent (EvWindow *ev_window)
 				       FALSE);
 		g_free (action_name);
 		g_free (label);
+                if (icon != NULL)
+                        g_object_unref (icon);
 
 		if (++n_items == 5)
 			break;



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