static NautilusIconInfo * nautilus_canvas_view_container_get_icon_images (NautilusCanvasContainer *container, NautilusCanvasIconData *data, int size, char **embedded_text, gboolean for_drag_accept, gboolean need_large_embeddded_text, gboolean *embedded_text_needs_loading, gboolean *has_window_open) { NautilusCanvasView *canvas_view; NautilusFile *file; gboolean use_embedding; NautilusFileIconFlags flags; NautilusIconInfo *icon_info; GdkPixbuf *pixbuf; GIcon *emblemed_icon; GEmblem *emblem; GList *emblem_icons, *l; file = (NautilusFile *) data; g_assert (NAUTILUS_IS_FILE (file)); canvas_view = get_canvas_view (container); g_return_val_if_fail (canvas_view != NULL, NULL); use_embedding = FALSE; if (embedded_text) { *embedded_text = nautilus_file_peek_top_left_text (file, need_large_embeddded_text, embedded_text_needs_loading); use_embedding = *embedded_text != NULL; } *has_window_open = nautilus_file_has_open_window (file); flags = NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM | NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS; if (use_embedding) { flags |= NAUTILUS_FILE_ICON_FLAGS_EMBEDDING_TEXT; } if (for_drag_accept) { flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT; } icon_info = nautilus_file_get_icon (file, size, flags); emblem_icons = nautilus_file_get_emblem_icons (file); /* apply emblems */ if (emblem_icons != NULL) { l = emblem_icons; emblem = g_emblem_new (l->data); pixbuf = nautilus_icon_info_get_pixbuf (icon_info); 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 void nautilus_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column, GValue *value) { NautilusListModel *model; FileEntry *file_entry; NautilusFile *file; char *str; GdkPixbuf *icon, *rendered_icon; GIcon *gicon, *emblemed_icon, *emblem_icon; NautilusIconInfo *icon_info; GEmblem *emblem; GList *emblem_icons, *l; int icon_size, icon_scale; NautilusZoomLevel zoom_level; NautilusFileIconFlags flags; cairo_surface_t *surface; model = (NautilusListModel *)tree_model; g_return_if_fail (model->details->stamp == iter->stamp); g_return_if_fail (!g_sequence_iter_is_end (iter->user_data)); file_entry = g_sequence_get (iter->user_data); file = file_entry->file; switch (column) { case NAUTILUS_LIST_MODEL_FILE_COLUMN: g_value_init (value, NAUTILUS_TYPE_FILE); g_value_set_object (value, file); break; case NAUTILUS_LIST_MODEL_SUBDIRECTORY_COLUMN: g_value_init (value, NAUTILUS_TYPE_DIRECTORY); g_value_set_object (value, file_entry->subdirectory); break; case NAUTILUS_LIST_MODEL_SMALLEST_ICON_COLUMN: case NAUTILUS_LIST_MODEL_SMALLER_ICON_COLUMN: case NAUTILUS_LIST_MODEL_SMALL_ICON_COLUMN: case NAUTILUS_LIST_MODEL_STANDARD_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN: case NAUTILUS_LIST_MODEL_LARGEST_ICON_COLUMN: g_value_init (value, CAIRO_GOBJECT_TYPE_SURFACE); if (file != NULL) { zoom_level = nautilus_list_model_get_zoom_level_from_column_id (column); icon_size = nautilus_get_icon_size_for_zoom_level (zoom_level); icon_scale = nautilus_list_model_get_icon_scale (model); flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS | NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE | NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM; if (model->details->drag_view != NULL) { GtkTreePath *path_a, *path_b; gtk_tree_view_get_drag_dest_row (model->details->drag_view, &path_a, NULL); if (path_a != NULL) { path_b = gtk_tree_model_get_path (tree_model, iter); if (gtk_tree_path_compare (path_a, path_b) == 0) { flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT; } gtk_tree_path_free (path_a); gtk_tree_path_free (path_b); } } gicon = G_ICON (nautilus_file_get_icon_pixbuf (file, icon_size, TRUE, icon_scale, flags)); emblem_icons = nautilus_file_get_emblem_icons (file); /* pick only the first emblem we can render for the list view */ for (l = emblem_icons; l != NULL; l = l->next) { emblem_icon = l->data; if (nautilus_icon_theme_can_render (G_THEMED_ICON (emblem_icon))) { emblem = g_emblem_new (emblem_icon); emblemed_icon = g_emblemed_icon_new (gicon, emblem); g_object_unref (gicon); g_object_unref (emblem); gicon = emblemed_icon; break; } } g_list_free_full (emblem_icons, g_object_unref); icon_info = nautilus_icon_info_lookup (gicon, icon_size, icon_scale); icon = nautilus_icon_info_get_pixbuf_at_size (icon_info, icon_size); g_object_unref (icon_info); g_object_unref (gicon); if (model->details->highlight_files != NULL && g_list_find_custom (model->details->highlight_files, file, (GCompareFunc) nautilus_file_compare_location)) { rendered_icon = eel_create_spotlight_pixbuf (icon); if (rendered_icon != NULL) { g_object_unref (icon); icon = rendered_icon; } } surface = gdk_cairo_surface_create_from_pixbuf (icon, icon_scale, NULL); g_value_take_boxed (value, surface); g_object_unref (icon); } break; case NAUTILUS_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN: g_value_init (value, G_TYPE_BOOLEAN); g_value_set_boolean (value, file != NULL && nautilus_file_can_rename (file)); break; default: if (column >= NAUTILUS_LIST_MODEL_NUM_COLUMNS || column < NAUTILUS_LIST_MODEL_NUM_COLUMNS + model->details->columns->len) { NautilusColumn *nautilus_column; GQuark attribute; nautilus_column = model->details->columns->pdata[column - NAUTILUS_LIST_MODEL_NUM_COLUMNS]; g_value_init (value, G_TYPE_STRING); g_object_get (nautilus_column, "attribute_q", &attribute, NULL); if (file != NULL) { str = nautilus_file_get_string_attribute_with_default_q (file, attribute); g_value_take_string (value, str); } else if (attribute == attribute_name_q) { if (file_entry->parent->loaded) { g_value_set_string (value, _("(Empty)")); } else { g_value_set_string (value, _("Loading…")); } } } else { g_assert_not_reached (); } } }