Commit 59670a59 authored by Cosimo Cecchi's avatar Cosimo Cecchi

icon-container: apply emblems from FmIconContainer

This simplifies the code a bit, and also fixes emblem sizes for
thumbnails.
parent 1004a7df
......@@ -6852,7 +6852,6 @@ static NautilusIconInfo *
nautilus_icon_container_get_icon_images (NautilusIconContainer *container,
NautilusIconData *data,
int size,
GList **emblem_icons,
char **embedded_text,
gboolean for_drag_accept,
gboolean need_large_embeddded_text,
......@@ -6864,7 +6863,7 @@ nautilus_icon_container_get_icon_images (NautilusIconContainer *container,
klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container);
g_assert (klass->get_icon_images != NULL);
return klass->get_icon_images (container, data, size, emblem_icons, embedded_text, for_drag_accept, need_large_embeddded_text, embedded_text_needs_loading, has_open_window);
return klass->get_icon_images (container, data, size, embedded_text, for_drag_accept, need_large_embeddded_text, embedded_text_needs_loading, has_open_window);
}
static void
......@@ -7023,15 +7022,12 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
int n_attach_points;
gboolean has_embedded_text_rect;
GdkPixbuf *pixbuf;
GList *emblem_icons, *l;
char *editable_text, *additional_text;
char *embedded_text;
GdkRectangle embedded_text_rect;
gboolean large_embedded_text;
gboolean embedded_text_needs_loading;
gboolean has_open_window;
GIcon *emblemed_icon;
GEmblem *emblem;
if (icon == NULL) {
return;
......@@ -7054,12 +7050,12 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
icon_size = MAX (icon_size, min_image_size);
icon_size = MIN (icon_size, max_image_size);
DEBUG ("Icon size, getting for size %d", icon_size);
/* Get the icons. */
emblem_icons = NULL;
embedded_text = NULL;
large_embedded_text = icon_size > ICON_SIZE_FOR_LARGE_EMBEDDED_TEXT;
icon_info = nautilus_icon_container_get_icon_images (container, icon->data, icon_size,
&emblem_icons,
&embedded_text,
icon == details->drop_target,
large_embedded_text, &embedded_text_needs_loading,
......@@ -7075,30 +7071,6 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
has_embedded_text_rect = nautilus_icon_info_get_embedded_rect (icon_info,
&embedded_text_rect);
/* apply emblems */
if (emblem_icons != NULL) {
l = emblem_icons;
emblem = g_emblem_new (l->data);
emblemed_icon = g_emblemed_icon_new (G_ICON (pixbuf), emblem);
g_object_unref (emblem);
for (l = l->next; l != NULL; l = l->next) {
emblem = g_emblem_new (l->data);
g_emblemed_icon_add_emblem (G_EMBLEMED_ICON (emblemed_icon),
emblem);
g_object_unref (emblem);
}
g_object_unref (icon_info);
g_object_unref (pixbuf);
icon_info = nautilus_icon_info_lookup (emblemed_icon, icon_size);
pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon_info, icon_size);
g_object_unref (emblemed_icon);
}
g_object_unref (icon_info);
if (has_embedded_text_rect && embedded_text_needs_loading) {
......@@ -7136,7 +7108,6 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
/* Let the pixbufs go. */
g_object_unref (pixbuf);
g_list_free_full (emblem_icons, g_object_unref);
g_free (editable_text);
g_free (additional_text);
......
......@@ -141,7 +141,6 @@ typedef struct {
NautilusIconInfo *(* get_icon_images) (NautilusIconContainer *container,
NautilusIconData *data,
int icon_size,
GList **emblem_icons,
char **embedded_text,
gboolean for_drag_accept,
gboolean need_large_embeddded_text,
......
......@@ -52,7 +52,6 @@ static NautilusIconInfo *
fm_icon_container_get_icon_images (NautilusIconContainer *container,
NautilusIconData *data,
int size,
GList **emblem_icons,
char **embedded_text,
gboolean for_drag_accept,
gboolean need_large_embeddded_text,
......@@ -64,6 +63,11 @@ fm_icon_container_get_icon_images (NautilusIconContainer *container,
NautilusFile *file;
gboolean use_embedding;
NautilusFileIconFlags flags;
NautilusIconInfo *icon_info;
GdkPixbuf *pixbuf;
GIcon *emblemed_icon;
GEmblem *emblem;
GList *emblem_icons, *l;
file = (NautilusFile *) data;
......@@ -77,14 +81,6 @@ fm_icon_container_get_icon_images (NautilusIconContainer *container,
use_embedding = *embedded_text != NULL;
}
if (emblem_icons != NULL) {
emblems_to_ignore = fm_directory_view_get_emblem_names_to_exclude
(FM_DIRECTORY_VIEW (icon_view));
*emblem_icons = nautilus_file_get_emblem_icons (file,
emblems_to_ignore);
g_strfreev (emblems_to_ignore);
}
*has_window_open = nautilus_file_has_open_window (file);
flags = NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM;
......@@ -102,8 +98,43 @@ fm_icon_container_get_icon_images (NautilusIconContainer *container,
if (for_drag_accept) {
flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT;
}
return nautilus_file_get_icon (file, size, flags);
emblems_to_ignore = fm_directory_view_get_emblem_names_to_exclude
(FM_DIRECTORY_VIEW (icon_view));
emblem_icons = nautilus_file_get_emblem_icons (file,
emblems_to_ignore);
g_strfreev (emblems_to_ignore);
icon_info = nautilus_file_get_icon (file, size, flags);
pixbuf = nautilus_icon_info_get_pixbuf (icon_info);
/* apply emblems */
if (emblem_icons != NULL) {
l = emblem_icons;
emblem = g_emblem_new (l->data);
emblemed_icon = g_emblemed_icon_new (G_ICON (pixbuf), emblem);
g_object_unref (emblem);
for (l = l->next; l != NULL; l = l->next) {
emblem = g_emblem_new (l->data);
g_emblemed_icon_add_emblem (G_EMBLEMED_ICON (emblemed_icon),
emblem);
g_object_unref (emblem);
}
g_clear_object (&icon_info);
icon_info = nautilus_icon_info_lookup (emblemed_icon, size);
g_object_unref (pixbuf);
g_object_unref (emblemed_icon);
}
if (emblem_icons != NULL) {
g_list_free_full (emblem_icons, g_object_unref);
}
return icon_info;
}
static char *
......
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