static void set_images (FileConflictDialogData *data) { GdkPixbuf *source_pixbuf; GdkPixbuf *destination_pixbuf; destination_pixbuf = nautilus_file_get_icon_pixbuf (data->destination, NAUTILUS_CANVAS_ICON_SIZE_SMALL, TRUE, 1, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); source_pixbuf = nautilus_file_get_icon_pixbuf (data->source, NAUTILUS_CANVAS_ICON_SIZE_SMALL, TRUE, 1, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); nautilus_file_conflict_dialog_set_images (data->dialog, destination_pixbuf, source_pixbuf); g_object_unref (destination_pixbuf); g_object_unref (source_pixbuf); }
static void file_icons_changed (NautilusFile *file, NautilusFileConflictDialog *fcd) { GdkPixbuf *pixbuf; pixbuf = nautilus_file_get_icon_pixbuf (fcd->details->destination, NAUTILUS_ICON_SIZE_LARGE, TRUE, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); gtk_image_set_from_pixbuf (GTK_IMAGE (fcd->details->dest_image), pixbuf); g_object_unref (pixbuf); pixbuf = nautilus_file_get_icon_pixbuf (fcd->details->source, NAUTILUS_ICON_SIZE_LARGE, TRUE, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); gtk_image_set_from_pixbuf (GTK_IMAGE (fcd->details->src_image), pixbuf); g_object_unref (pixbuf); }
static void fm_empty_view_add_file (FMDirectoryView *view, NautilusFile *file, NautilusDirectory *directory) { static GTimer *timer = NULL; static gdouble cumu = 0, elaps; FM_EMPTY_VIEW (view)->details->number_of_files++; GdkPixbuf *icon; if (!timer) timer = g_timer_new (); g_timer_start (timer); icon = nautilus_file_get_icon_pixbuf (file, nautilus_get_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_STANDARD), TRUE, 0); elaps = g_timer_elapsed (timer, NULL); g_timer_stop (timer); g_object_unref (icon); cumu += elaps; g_message ("entire loading: %.3f, cumulative %.3f", elaps, cumu); }
static void file_list_ready_cb (GList *files, gpointer user_data) { NautilusFileConflictDialog *fcd = user_data; NautilusFile *src, *dest, *dest_dir; time_t src_mtime, dest_mtime; gboolean source_is_dir, dest_is_dir, should_show_type; NautilusFileConflictDialogDetails *details; char *primary_text, *message, *secondary_text; const gchar *message_extra; char *dest_name, *dest_dir_name, *edit_name; char *label_text; char *size, *date, *type = NULL; GdkPixbuf *pixbuf; GtkWidget *label; GString *str; PangoAttrList *attr_list; details = fcd->details; details->handle = NULL; dest_dir = g_list_nth_data (files, 0); dest = g_list_nth_data (files, 1); src = g_list_nth_data (files, 2); src_mtime = nautilus_file_get_mtime (src); dest_mtime = nautilus_file_get_mtime (dest); dest_name = nautilus_file_get_display_name (dest); dest_dir_name = nautilus_file_get_display_name (dest_dir); source_is_dir = nautilus_file_is_directory (src); dest_is_dir = nautilus_file_is_directory (dest); type = nautilus_file_get_mime_type (dest); should_show_type = !nautilus_file_is_mime_type (src, type); g_free (type); type = NULL; /* Set up the right labels */ if (dest_is_dir) { if (source_is_dir) { primary_text = g_strdup_printf (_("Merge folder “%s”?"), dest_name); message_extra = _("Merging will ask for confirmation before replacing any files in " "the folder that conflict with the files being copied."); if (src_mtime > dest_mtime) { message = g_strdup_printf ( _("An older folder with the same name already exists in “%s”."), dest_dir_name); } else if (src_mtime < dest_mtime) { message = g_strdup_printf ( _("A newer folder with the same name already exists in “%s”."), dest_dir_name); } else { message = g_strdup_printf ( _("Another folder with the same name already exists in “%s”."), dest_dir_name); } } else { message_extra = _("Replacing it will remove all files in the folder."); primary_text = g_strdup_printf (_("Replace folder “%s”?"), dest_name); message = g_strdup_printf (_("A folder with the same name already exists in “%s”."), dest_dir_name); } } else { primary_text = g_strdup_printf (_("Replace file “%s”?"), dest_name); message_extra = _("Replacing it will overwrite its content."); if (src_mtime > dest_mtime) { message = g_strdup_printf ( _("An older file with the same name already exists in “%s”."), dest_dir_name); } else if (src_mtime < dest_mtime) { message = g_strdup_printf ( _("A newer file with the same name already exists in “%s”."), dest_dir_name); } else { message = g_strdup_printf ( _("Another file with the same name already exists in “%s”."), dest_dir_name); } } secondary_text = g_strdup_printf ("%s\n%s", message, message_extra); g_free (message); label = gtk_label_new (primary_text); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD_CHAR); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (details->titles_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); attr_list = pango_attr_list_new (); pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_LARGE)); g_object_set (label, "attributes", attr_list, NULL); pango_attr_list_unref (attr_list); label = gtk_label_new (secondary_text); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (details->titles_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (primary_text); g_free (secondary_text); /* Set up file icons */ pixbuf = nautilus_file_get_icon_pixbuf (dest, NAUTILUS_ICON_SIZE_LARGE, TRUE, gtk_widget_get_scale_factor (fcd->details->titles_vbox), NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); details->dest_image = gtk_image_new_from_pixbuf (pixbuf); gtk_box_pack_start (GTK_BOX (details->first_hbox), details->dest_image, FALSE, FALSE, 0); gtk_widget_show (details->dest_image); g_object_unref (pixbuf); pixbuf = nautilus_file_get_icon_pixbuf (src, NAUTILUS_ICON_SIZE_LARGE, TRUE, gtk_widget_get_scale_factor (fcd->details->titles_vbox), NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS); details->src_image = gtk_image_new_from_pixbuf (pixbuf); gtk_box_pack_start (GTK_BOX (details->second_hbox), details->src_image, FALSE, FALSE, 0); gtk_widget_show (details->src_image); g_object_unref (pixbuf); /* Set up labels */ label = gtk_label_new (NULL); date = nautilus_file_get_string_attribute (dest, "date_modified"); size = nautilus_file_get_string_attribute (dest, "size"); if (should_show_type) { type = nautilus_file_get_string_attribute (dest, "type"); } str = g_string_new (NULL); g_string_append_printf (str, "<b>%s</b>\n", _("Original file")); g_string_append_printf (str, "%s %s\n", _("Size:"), size); if (should_show_type) { g_string_append_printf (str, "%s %s\n", _("Type:"), type); } g_string_append_printf (str, "%s %s", _("Last modified:"), date); label_text = str->str; gtk_label_set_markup (GTK_LABEL (label), label_text); gtk_box_pack_start (GTK_BOX (details->first_hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (size); g_free (type); g_free (date); g_string_erase (str, 0, -1); /* Second label */ label = gtk_label_new (NULL); date = nautilus_file_get_string_attribute (src, "date_modified"); size = nautilus_file_get_string_attribute (src, "size"); if (should_show_type) { type = nautilus_file_get_string_attribute (src, "type"); } g_string_append_printf (str, "<b>%s</b>\n", _("Replace with")); g_string_append_printf (str, "%s %s\n", _("Size:"), size); if (should_show_type) { g_string_append_printf (str, "%s %s\n", _("Type:"), type); } g_string_append_printf (str, "%s %s", _("Last modified:"), date); label_text = g_string_free (str, FALSE); gtk_label_set_markup (GTK_LABEL (label), label_text); gtk_box_pack_start (GTK_BOX (details->second_hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (size); g_free (date); g_free (type); g_free (label_text); /* Populate the entry */ edit_name = nautilus_file_get_edit_name (dest); details->conflict_name = edit_name; gtk_entry_set_text (GTK_ENTRY (details->entry), edit_name); if (source_is_dir && dest_is_dir) { gtk_button_set_label (GTK_BUTTON (details->replace_button), _("Merge")); } nautilus_file_monitor_add (src, fcd, NAUTILUS_FILE_ATTRIBUTES_FOR_ICON); nautilus_file_monitor_add (dest, fcd, NAUTILUS_FILE_ATTRIBUTES_FOR_ICON); details->src_handler_id = g_signal_connect (src, "changed", G_CALLBACK (file_icons_changed), fcd); details->dest_handler_id = g_signal_connect (dest, "changed", G_CALLBACK (file_icons_changed), fcd); }
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 (); } } }