static gboolean slot_proxy_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, unsigned int time, gpointer user_data) { NautilusDragSlotProxyInfo *drag_info; NautilusWindowSlot *target_slot; GtkWidget *window; GdkAtom target; int action; char *target_uri; GFile *location; gboolean valid_text_drag; gboolean valid_xds_drag; drag_info = user_data; action = 0; valid_text_drag = FALSE; valid_xds_drag = FALSE; if (gtk_drag_get_source_widget (context) == widget) { goto out; } window = gtk_widget_get_toplevel (widget); g_assert (NAUTILUS_IS_WINDOW (window)); if (!drag_info->have_data) { target = gtk_drag_dest_find_target (widget, context, NULL); if (target == GDK_NONE) { goto out; } gtk_drag_get_data (widget, context, target, time); } target_uri = NULL; if (drag_info->target_file != NULL) { target_uri = nautilus_file_get_uri (drag_info->target_file); } else { if (drag_info->target_slot != NULL) { target_slot = drag_info->target_slot; } else { target_slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window)); } if (target_slot != NULL) { location = nautilus_window_slot_get_location (target_slot); target_uri = g_file_get_uri (location); } } if (target_uri != NULL) { NautilusFile *file; gboolean can; file = nautilus_file_get_existing_by_uri (target_uri); can = nautilus_file_can_write (file); g_object_unref (file); if (!can) { action = 0; goto out; } } if (drag_info->have_data && drag_info->have_valid_data) { if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) { nautilus_drag_default_drop_action_for_icons (context, target_uri, drag_info->data.selection_list, 0, &action); } else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) { action = nautilus_drag_default_drop_action_for_uri_list (context, target_uri); } else if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) { action = nautilus_drag_default_drop_action_for_netscape_url (context); } else if (drag_info->info == NAUTILUS_ICON_DND_TEXT) { valid_text_drag = TRUE; } else if (drag_info->info == NAUTILUS_ICON_DND_XDNDDIRECTSAVE || drag_info->info == NAUTILUS_ICON_DND_RAW) { valid_xds_drag = TRUE; } } g_free (target_uri); out: if (action != 0 || valid_text_drag || valid_xds_drag) { gtk_drag_highlight (widget); slot_proxy_check_switch_location_timer (drag_info, widget); } else { gtk_drag_unhighlight (widget); slot_proxy_remove_switch_location_timer (drag_info); } gdk_drag_status (context, action, time); return TRUE; }
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; NautilusZoomLevel zoom_level; NautilusFile *parent_file; char *emblems_to_ignore[3]; int i; NautilusFileIconFlags flags; 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, GDK_TYPE_PIXBUF); 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); 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, flags)); /* render emblems with GEmblemedIcon */ parent_file = nautilus_file_get_parent (file); i = 0; emblems_to_ignore[i++] = NAUTILUS_FILE_EMBLEM_NAME_TRASH; if (parent_file) { if (!nautilus_file_can_write (parent_file)) { emblems_to_ignore[i++] = NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE; } nautilus_file_unref (parent_file); } emblems_to_ignore[i++] = NULL; emblem_icons = nautilus_file_get_emblem_icons (file, emblems_to_ignore); /* 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 = 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; } } g_value_set_object (value, icon); 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 (); } } }