Commit 95610f2a authored by Christian Persch's avatar Christian Persch Committed by Emmanuele Bassi

recent-chooser: Use gtk_recent_info_get_gicon()

https://bugzilla.gnome.org/show_bug.cgi?id=617174
parent b0fe3e49
......@@ -435,6 +435,7 @@ gtk_recent_chooser_default_constructor (GType type,
gtk_tree_view_column_set_resizable (impl->icon_column, FALSE);
renderer = gtk_cell_renderer_pixbuf_new ();
g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
gtk_tree_view_column_pack_start (impl->icon_column, renderer, FALSE);
gtk_tree_view_column_set_cell_data_func (impl->icon_column,
renderer,
......@@ -984,23 +985,17 @@ recent_icon_data_func (GtkTreeViewColumn *tree_column,
GtkTreeIter *iter,
gpointer user_data)
{
GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (user_data);
GtkRecentInfo *info = NULL;
GdkPixbuf *pixbuf;
gtk_tree_model_get (model, iter,
RECENT_INFO_COLUMN, &info,
-1);
GIcon *icon;
gtk_tree_model_get (model, iter, RECENT_INFO_COLUMN, &info, -1);
g_assert (info != NULL);
pixbuf = gtk_recent_info_get_icon (info, impl->icon_size);
g_object_set (cell,
"pixbuf", pixbuf,
NULL);
if (pixbuf)
g_object_unref (pixbuf);
icon = gtk_recent_info_get_gicon (info);
g_object_set (cell, "gicon", icon, NULL);
if (icon != NULL)
g_object_unref (icon);
gtk_recent_info_unref (info);
}
......
......@@ -78,9 +78,6 @@ struct _GtkRecentChooserMenuPrivate
/* the recent manager object */
GtkRecentManager *manager;
/* size of the icons of the menu items */
gint icon_size;
/* max size of the menu item label */
gint label_width;
......@@ -121,7 +118,6 @@ enum {
};
#define FALLBACK_ICON_SIZE 32
#define FALLBACK_ITEM_LIMIT 10
#define DEFAULT_LABEL_WIDTH 30
......@@ -178,8 +174,6 @@ static void set_recent_manager (GtkRecentChooserMenu *menu,
static void chooser_set_sort_type (GtkRecentChooserMenu *menu,
GtkRecentSortType sort_type);
static gint get_icon_size_for_widget (GtkWidget *widget);
static void item_activate_cb (GtkWidget *widget,
gpointer user_data);
static void manager_changed_cb (GtkRecentManager *manager,
......@@ -281,7 +275,6 @@ gtk_recent_chooser_menu_init (GtkRecentChooserMenu *menu)
priv->limit = FALLBACK_ITEM_LIMIT;
priv->sort_type = GTK_RECENT_SORT_NONE;
priv->icon_size = FALLBACK_ICON_SIZE;
priv->label_width = DEFAULT_LABEL_WIDTH;
priv->first_recent_item_pos = -1;
......@@ -817,7 +810,7 @@ gtk_recent_chooser_menu_create_item (GtkRecentChooserMenu *menu,
GtkRecentChooserMenuPrivate *priv;
gchar *text;
GtkWidget *item, *image, *label;
GdkPixbuf *icon;
GIcon *icon;
g_assert (info != NULL);
......@@ -875,11 +868,13 @@ gtk_recent_chooser_menu_create_item (GtkRecentChooserMenu *menu,
if (priv->show_icons)
{
icon = gtk_recent_info_get_icon (info, priv->icon_size);
image = gtk_image_new_from_pixbuf (icon);
icon = gtk_recent_info_get_gicon (info);
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
g_object_unref (icon);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
if (icon)
g_object_unref (icon);
}
g_signal_connect (item, "activate",
......@@ -1085,8 +1080,6 @@ gtk_recent_chooser_menu_populate (GtkRecentChooserMenu *menu)
pdata->menu = menu;
pdata->placeholder = g_object_ref (priv->placeholder);
priv->icon_size = get_icon_size_for_widget (GTK_WIDGET (menu));
/* remove our menu items first */
gtk_recent_chooser_menu_dispose_items (menu);
......@@ -1152,24 +1145,6 @@ set_recent_manager (GtkRecentChooserMenu *menu,
menu);
}
static gint
get_icon_size_for_widget (GtkWidget *widget)
{
GtkSettings *settings;
gint width, height;
if (gtk_widget_has_screen (widget))
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
else
settings = gtk_settings_get_default ();
if (gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
&width, &height))
return MAX (width, height);
return FALLBACK_ICON_SIZE;
}
static void
foreach_set_shot_tips (GtkWidget *widget,
gpointer user_data)
......
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