Commit 423b5c48 authored by Darin Adler's avatar Darin Adler

Reworked the canvas item class used by the icon

	container. Straightened out the use of various coordinate systems
	and bounds calculations and removed much unused code inherited
	from the GdkPixbuf canvas item class that Andy cloned our code
	from. Changed the class so it doesn't scale icons any more -- we
	leave that to the icon factory so the scaled icons can be cached.

	* libnautilus/gnome-icon-container-dnd.c:
	* libnautilus/gnome-icon-container-private.h:
	* libnautilus/gnome-icon-container.c:
	* libnautilus/nautilus-icons-view-icon-item.c:
	* libnautilus/nautilus-icons-view-icon-item.h:
	Made extensive changes to the icon item class, including getting
	rid of the "x", "y", "width", and "height" attributes, adding a
	new "font" attribute, changing the "label" attribute name to "text"
	to be more consistent with other canvas items, simplifying the
	update logic for now (we can recomplicate it later if need be),
	changing the pixbuf to have a fixed size in pixels instead of being
	scaled with the pixels_per_unit and changing the pixbuf when we change
	zoom levels, and other misc. cleanup.
	(nautilus_icons_view_icon_item_get_arg):
	Fixed bug for "label" which would return a non-strdup'd	piece of text.
	(draw_or_measure_text_box):
	Fixed bug where width of the selection box would be based on the
	length of the last line of text, not the widest, and extra GCs would
	be created for each line of text.

	* libnautilus/nautilus-icons-controller.h:
	* libnautilus/nautilus-icons-controller.c:
	(nautilus_icons_controller_get_icon_image):
	* src/file-manager/fm-icons-controller.c:
	(fm_icons_controller_get_icon_image):
	Changed the interface so that the icons controller specifies the icon
	as a NautilusScalableIcon instead of a GdkPixbuf. This lets the icon
	container get the appropriate icon for size as it zooms.

	* libnautilus/gdk-extensions.h:
	* libnautilus/gdk-extensions.c:
	(nautilus_gdk_font_equal):
	Added a version of gdk_font_equal that works with NULL for the font.
	Maybe we need a naming scheme for these NULL-tolerant variations on
	basic calls.

	* src/ntl-uri-map.c: (nautilus_navinfo_free):
	* src/ntl-window-msgs.c: (nautilus_window_change_location_2):
	Fixed a NULL dereference that would happen when @navi was NULL.

	* libnautilus/nautilus-directory.c:
	(nautilus_directory_try_to_read_metafile):
	Fixed error handling for case when gnome_vfs_read fails.  Fixed
	error handling for case where metafile_info.size won't fit into a
	size_t.  Switched back to g_malloc instead of g_alloca, since the
	size of a file might be too big for the stack. In the long run, we
	will feed the file data directly to the XML code, so this is a bit
	temporary.  Removed the assert that Elliot added to help track
	down the giant files sizes coming from gnome-vfs; the failure in
	g_malloc will be easy to debug, unlike the failure in
	g_alloca. (The assert was added without a ChangeLog entry.)
parent d3954cb9
...@@ -393,6 +393,24 @@ nautilus_gdk_color_parse_with_white_default (const char *color_spec, ...@@ -393,6 +393,24 @@ nautilus_gdk_color_parse_with_white_default (const char *color_spec,
} }
} }
/**
* nautilus_gdk_font_equal
* @font_a_null_allowed: A font or NULL.
* @font_b_null_allowed: A font or NULL.
*
* Calls gdk_font_equal, unless one of the fonts is NULL.
*/
gboolean
nautilus_gdk_font_equal (GdkFont *font_a_null_allowed,
GdkFont *font_b_null_allowed)
{
if (font_a_null_allowed == NULL)
return font_b_null_allowed == NULL;
if (font_b_null_allowed == NULL)
return FALSE;
return gdk_font_equal (font_a_null_allowed, font_b_null_allowed);
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK) #if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char * static char *
......
...@@ -81,4 +81,7 @@ void nautilus_interpolate_color (gdouble ratio, ...@@ -81,4 +81,7 @@ void nautilus_interpolate_color (gdouble ratio,
const GdkColor *end_color, const GdkColor *end_color,
GdkColor *interpolated_color); GdkColor *interpolated_color);
gboolean nautilus_gdk_font_equal (GdkFont *font_a_null_allowed,
GdkFont *font_b_null_allowed);
#endif /* GDK_EXTENSIONS_H */ #endif /* GDK_EXTENSIONS_H */
...@@ -26,17 +26,15 @@ ...@@ -26,17 +26,15 @@
#include <config.h> #include <config.h>
#include "gnome-icon-container-dnd.h" #include "gnome-icon-container-dnd.h"
#include "gnome-icon-container-private.h"
#include "nautilus-icons-view-icon-item.h"
#include "nautilus-background.h"
#include "nautilus-gtk-extensions.h"
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "nautilus-glib-extensions.h"
#include <gtk/gtksignal.h> #include <gtk/gtksignal.h>
#include "nautilus-gtk-extensions.h"
#include "nautilus-background.h"
#include "gnome-icon-container-private.h"
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
typedef struct { typedef struct {
char *uri; char *uri;
...@@ -50,7 +48,6 @@ static GtkTargetEntry drag_types [] = { ...@@ -50,7 +48,6 @@ static GtkTargetEntry drag_types [] = {
{ GNOME_ICON_CONTAINER_DND_URI_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_URI_LIST }, { GNOME_ICON_CONTAINER_DND_URI_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_URI_LIST },
{ GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL } { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL }
}; };
static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
static GtkTargetEntry drop_types [] = { static GtkTargetEntry drop_types [] = {
{ GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST }, { GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST_TYPE, 0, GNOME_ICON_CONTAINER_DND_GNOME_ICON_LIST },
...@@ -58,7 +55,6 @@ static GtkTargetEntry drop_types [] = { ...@@ -58,7 +55,6 @@ static GtkTargetEntry drop_types [] = {
{ GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL }, { GNOME_ICON_CONTAINER_DND_URL_TYPE, 0, GNOME_ICON_CONTAINER_DND_URL },
{ GNOME_ICON_CONTAINER_DND_COLOR_TYPE, 0, GNOME_ICON_CONTAINER_DND_COLOR } { GNOME_ICON_CONTAINER_DND_COLOR_TYPE, 0, GNOME_ICON_CONTAINER_DND_COLOR }
}; };
static const int num_drop_types = sizeof (drop_types) / sizeof (drop_types[0]);
static GnomeCanvasItem * static GnomeCanvasItem *
create_selection_shadow (GnomeIconContainer *container, create_selection_shadow (GnomeIconContainer *container,
...@@ -70,6 +66,7 @@ create_selection_shadow (GnomeIconContainer *container, ...@@ -70,6 +66,7 @@ create_selection_shadow (GnomeIconContainer *container,
int max_x, max_y; int max_x, max_y;
int min_x, min_y; int min_x, min_y;
GList *p; GList *p;
double pixels_per_unit;
if (list == NULL) if (list == NULL)
return NULL; return NULL;
...@@ -83,6 +80,7 @@ create_selection_shadow (GnomeIconContainer *container, ...@@ -83,6 +80,7 @@ create_selection_shadow (GnomeIconContainer *container,
we try to be smart and only create the maximum number of rectangles we try to be smart and only create the maximum number of rectangles
that we will need, in the vertical/horizontal directions. */ that we will need, in the vertical/horizontal directions. */
/* FIXME: Does this work properly if the window is scrolled? */
max_x = GTK_WIDGET (container)->allocation.width; max_x = GTK_WIDGET (container)->allocation.width;
min_x = -max_x; min_x = -max_x;
...@@ -96,10 +94,10 @@ create_selection_shadow (GnomeIconContainer *container, ...@@ -96,10 +94,10 @@ create_selection_shadow (GnomeIconContainer *container,
gnome_canvas_group_get_type (), gnome_canvas_group_get_type (),
NULL)); NULL));
pixels_per_unit = canvas->pixels_per_unit;
for (p = list; p != NULL; p = p->next) { for (p = list; p != NULL; p = p->next) {
DndSelectionItem *item; DndSelectionItem *item;
int x1, y1; int x1, y1, x2, y2;
int x2, y2;
item = p->data; item = p->data;
...@@ -111,32 +109,29 @@ create_selection_shadow (GnomeIconContainer *container, ...@@ -111,32 +109,29 @@ create_selection_shadow (GnomeIconContainer *container,
x2 = x1 + item->icon_width; x2 = x1 + item->icon_width;
y2 = y1 + item->icon_height; y2 = y1 + item->icon_height;
if (x2 >= min_x && x1 <= max_x && y2 >= min_y && y1 <= max_y) { if (x2 >= min_x && x1 <= max_x && y2 >= min_y && y1 <= max_y)
GnomeCanvasItem *rect; gnome_canvas_item_new
rect = gnome_canvas_item_new
(group, (group,
gnome_canvas_rect_get_type (), gnome_canvas_rect_get_type (),
"x1", (double) x1, "y1", (double) y1, "x1", (double) x1 / pixels_per_unit,
"x2", (double) x2, "y2", (double) y2, "y1", (double) y1 / pixels_per_unit,
"x2", (double) x2 / pixels_per_unit,
"y2", (double) y2 / pixels_per_unit,
"outline_color", "black", "outline_color", "black",
"outline_stipple", stipple, "outline_stipple", stipple,
"width_pixels", 1, "width_pixels", 1,
NULL); NULL);
} }
}
return GNOME_CANVAS_ITEM (group); return GNOME_CANVAS_ITEM (group);
} }
/* This is a workaround for a gnome-canvas bug: with the current (1.0.18) /* Set the affine instead of the x and y position.
gnome-libs, setting the x/y values for an existing group fails at updating * Simple, and setting x and y was broken at one point.
the bounds of the group. So, instead of setting the x/y values to the */
current position at initialization time, we set them to (0,0) and then use a
simple affine transform. */
static void static void
set_shadow_position (GnomeCanvasItem *shadow, set_shadow_position (GnomeCanvasItem *shadow,
gdouble x, gdouble y) double x, double y)
{ {
double affine[6]; double affine[6];
...@@ -151,6 +146,7 @@ set_shadow_position (GnomeCanvasItem *shadow, ...@@ -151,6 +146,7 @@ set_shadow_position (GnomeCanvasItem *shadow,
} }
/* Functions to deal with DndSelectionItems. */ /* Functions to deal with DndSelectionItems. */
static DndSelectionItem * static DndSelectionItem *
...@@ -195,7 +191,6 @@ set_gnome_icon_list_selection (GnomeIconContainer *container, ...@@ -195,7 +191,6 @@ set_gnome_icon_list_selection (GnomeIconContainer *container,
GtkSelectionData *selection_data) GtkSelectionData *selection_data)
{ {
GnomeIconContainerDetails *details; GnomeIconContainerDetails *details;
GnomeCanvas* canvas = GNOME_CANVAS(container);
GList *p; GList *p;
GString *data; GString *data;
...@@ -204,30 +199,27 @@ set_gnome_icon_list_selection (GnomeIconContainer *container, ...@@ -204,30 +199,27 @@ set_gnome_icon_list_selection (GnomeIconContainer *container,
data = g_string_new (NULL); data = g_string_new (NULL);
for (p = details->icons; p != NULL; p = p->next) { for (p = details->icons; p != NULL; p = p->next) {
GnomeIconContainerIcon *icon; GnomeIconContainerIcon *icon;
gint center_offset; ArtIRect rect;
char *uri; char *uri;
char *s; char *s;
GdkPixbuf *pixbuf;
int icon_x, icon_y;
icon = p->data; icon = p->data;
if (!icon->is_selected) if (!icon->is_selected)
continue; continue;
center_offset = nautilus_icons_view_icon_item_center_offset nautilus_icons_view_icon_item_get_icon_window_rectangle
(NAUTILUS_ICONS_VIEW_ICON_ITEM (icon->item)); (icon->item, &rect);
uri = nautilus_icons_controller_get_icon_uri
/* Corner of the icon relative to the cursor. */ (details->controller, icon->data);
icon_x = icon->x - details->dnd_info->start_x + floor(center_offset / canvas->pixels_per_unit);
icon_y = icon->y - details->dnd_info->start_y;
uri = nautilus_icons_controller_get_icon_uri (details->controller, icon->data); s = g_strdup_printf ("%s\r%d:%d:%hu:%hu\r\n",
pixbuf = nautilus_icons_controller_get_icon_image(details->controller, icon->data); uri,
(int) (rect.x0 - details->dnd_info->start_x),
(int) (rect.y0 - details->dnd_info->start_y),
rect.x1 - rect.x0,
rect.y1 - rect.y0);
s = g_strdup_printf ("%s\r%d:%d:%d:%d\r\n",
uri, icon_x, icon_y, pixbuf->art_pixbuf->width, pixbuf->art_pixbuf->height);
g_free (uri); g_free (uri);
gdk_pixbuf_unref(pixbuf);
g_string_append (data, s); g_string_append (data, s);
g_free (s); g_free (s);
...@@ -312,7 +304,7 @@ get_gnome_icon_list_selection (GnomeIconContainer *container, ...@@ -312,7 +304,7 @@ get_gnome_icon_list_selection (GnomeIconContainer *container,
{ {
GnomeIconContainerDndInfo *dnd_info; GnomeIconContainerDndInfo *dnd_info;
const guchar *p, *oldp; const guchar *p, *oldp;
gint size; int size;
dnd_info = container->details->dnd_info; dnd_info = container->details->dnd_info;
...@@ -401,8 +393,8 @@ gnome_icon_container_position_shadow (GnomeIconContainer *container, ...@@ -401,8 +393,8 @@ gnome_icon_container_position_shadow (GnomeIconContainer *container,
gnome_canvas_window_to_world (GNOME_CANVAS (container), gnome_canvas_window_to_world (GNOME_CANVAS (container),
x, y, &world_x, &world_y); x, y, &world_x, &world_y);
gnome_canvas_item_show (shadow);
set_shadow_position (shadow, world_x, world_y); set_shadow_position (shadow, world_x, world_y);
gnome_canvas_item_show (shadow);
} }
static void static void
...@@ -412,44 +404,31 @@ gnome_icon_container_dropped_icon_feedback (GtkWidget *widget, ...@@ -412,44 +404,31 @@ gnome_icon_container_dropped_icon_feedback (GtkWidget *widget,
{ {
GnomeIconContainer *container; GnomeIconContainer *container;
GnomeIconContainerDndInfo *dnd_info; GnomeIconContainerDndInfo *dnd_info;
GnomeCanvasItem *shadow;
double world_x, world_y;
container = GNOME_ICON_CONTAINER (widget); container = GNOME_ICON_CONTAINER (widget);
dnd_info = container->details->dnd_info; dnd_info = container->details->dnd_info;
/* delete old selection list if any */ /* Delete old selection list if any. */
if (dnd_info->selection_list != NULL) { if (dnd_info->selection_list != NULL) {
destroy_selection_list (dnd_info->selection_list); destroy_selection_list (dnd_info->selection_list);
dnd_info->selection_list = NULL; dnd_info->selection_list = NULL;
} }
/* build the selection list from the drag data */ /* Delete old shadow if any. */
get_gnome_icon_list_selection (container, data);
shadow = create_selection_shadow (container, dnd_info->selection_list);
gnome_canvas_item_set (shadow, "x", (gdouble) 0, "y", (gdouble) 0,
NULL);
gnome_canvas_window_to_world (GNOME_CANVAS (widget),
x, y, &world_x, &world_y);
set_shadow_position (shadow, world_x, world_y);
gnome_canvas_item_show (shadow);
if (dnd_info->shadow != NULL) if (dnd_info->shadow != NULL)
gtk_object_destroy (GTK_OBJECT (dnd_info->shadow)); gtk_object_destroy (GTK_OBJECT (dnd_info->shadow));
dnd_info->shadow = shadow;
/* Build the selection list and the shadow. */
get_gnome_icon_list_selection (container, data);
dnd_info->shadow = create_selection_shadow (container, dnd_info->selection_list);
gnome_icon_container_position_shadow (container, x, y);
} }
static void static void
drag_data_received_cb (GtkWidget *widget, drag_data_received_cb (GtkWidget *widget,
GdkDragContext *context, GdkDragContext *context,
gint x, int x,
gint y, int y,
GtkSelectionData *data, GtkSelectionData *data,
guint info, guint info,
guint32 time, guint32 time,
...@@ -535,30 +514,13 @@ gnome_icon_container_receive_dropped_icons (GnomeIconContainer *container, ...@@ -535,30 +514,13 @@ gnome_icon_container_receive_dropped_icons (GnomeIconContainer *container,
if (dnd_info->selection_list == NULL) if (dnd_info->selection_list == NULL)
return; return;
/* Move files in same window. /* Move files. */
if (context->action != GDK_ACTION_MOVE) {
FIXME: This won't work between windows for two reasons. /* FIXME: We want to copy files here, I think. */
g_warning ("non-move action not implemented yet");
First, we have to figure out whether we need to actually } else {
move or copy some files. For directory views this is based
on the URIs, but that should be done by the controller, not
here in the view.
Second, the start_x and start_y values are only good for
this window. To make dragging between multiple windows work,
we need to communicate the offset between the mouse and the
corner of the selection along with the other selection info
so we can position the icons correctly in the window they
are dropped in. The geometry that's currently included along
with the selection is not sufficient.
*/
if (context->action == GDK_ACTION_MOVE) {
double world_x, world_y;
GList *icons_to_select; GList *icons_to_select;
gnome_canvas_window_to_world (GNOME_CANVAS (container),
x, y, &world_x, &world_y);
icons_to_select = NULL; icons_to_select = NULL;
for (p = dnd_info->selection_list; p != NULL; p = p->next) { for (p = dnd_info->selection_list; p != NULL; p = p->next) {
DndSelectionItem *item; DndSelectionItem *item;
...@@ -569,21 +531,22 @@ gnome_icon_container_receive_dropped_icons (GnomeIconContainer *container, ...@@ -569,21 +531,22 @@ gnome_icon_container_receive_dropped_icons (GnomeIconContainer *container,
(container, item->uri); (container, item->uri);
if (icon == NULL) { if (icon == NULL) {
/* FIXME: Do we ever get a MOVE between windows?
* If so, we need to move files here.
*/
g_warning ("drag between containers not implemented yet"); g_warning ("drag between containers not implemented yet");
continue; continue;
} }
if (item->got_icon_position) { if (item->got_icon_position) {
int icon_x, icon_y; double world_x, world_y;
double scale = icon->item->canvas->pixels_per_unit;
int center_offset = nautilus_icons_view_icon_item_center_offset
(NAUTILUS_ICONS_VIEW_ICON_ITEM (icon->item));
icon_x = (int) world_x + item->icon_x - (center_offset / scale);
icon_y = (int) world_y + item->icon_y;
gnome_canvas_window_to_world (GNOME_CANVAS (container),
x + item->icon_x,
y + item->icon_y,
&world_x, &world_y);
gnome_icon_container_move_icon gnome_icon_container_move_icon
(container, icon, icon_x, icon_y, TRUE); (container, icon, world_x, world_y, TRUE);
} }
icons_to_select = g_list_prepend (icons_to_select, icon); icons_to_select = g_list_prepend (icons_to_select, icon);
...@@ -621,8 +584,8 @@ gnome_icon_container_free_drag_data (GnomeIconContainer *container) ...@@ -621,8 +584,8 @@ gnome_icon_container_free_drag_data (GnomeIconContainer *container)
static gboolean static gboolean
drag_drop_cb (GtkWidget *widget, drag_drop_cb (GtkWidget *widget,
GdkDragContext *context, GdkDragContext *context,
gint x, int x,
gint y, int y,
guint32 time, guint32 time,
gpointer data) gpointer data)
{ {
...@@ -680,7 +643,7 @@ gnome_icon_container_dnd_init (GnomeIconContainer *container, ...@@ -680,7 +643,7 @@ gnome_icon_container_dnd_init (GnomeIconContainer *container,
dnd_info = g_new0 (GnomeIconContainerDndInfo, 1); dnd_info = g_new0 (GnomeIconContainerDndInfo, 1);
dnd_info->target_list = gtk_target_list_new (drag_types, dnd_info->target_list = gtk_target_list_new (drag_types,
num_drag_types); NAUTILUS_N_ELEMENTS (drag_types));
dnd_info->stipple = gdk_bitmap_ref (stipple); dnd_info->stipple = gdk_bitmap_ref (stipple);
...@@ -691,7 +654,7 @@ gnome_icon_container_dnd_init (GnomeIconContainer *container, ...@@ -691,7 +654,7 @@ gnome_icon_container_dnd_init (GnomeIconContainer *container,
gtk_drag_dest_set (GTK_WIDGET (container), gtk_drag_dest_set (GTK_WIDGET (container),
0, 0,
drop_types, num_drop_types, drop_types, NAUTILUS_N_ELEMENTS (drop_types),
GDK_ACTION_COPY | GDK_ACTION_MOVE); GDK_ACTION_COPY | GDK_ACTION_MOVE);
/* Messages for outgoing drag. */ /* Messages for outgoing drag. */
...@@ -740,30 +703,33 @@ gnome_icon_container_dnd_fini (GnomeIconContainer *container) ...@@ -740,30 +703,33 @@ gnome_icon_container_dnd_fini (GnomeIconContainer *container)
void void
gnome_icon_container_dnd_begin_drag (GnomeIconContainer *container, gnome_icon_container_dnd_begin_drag (GnomeIconContainer *container,
GdkDragAction actions, GdkDragAction actions,
gint button, int button,
GdkEventMotion *event) GdkEventMotion *event)
{ {
GtkArg pixbuf_args[1];
GnomeIconContainerDndInfo *dnd_info; GnomeIconContainerDndInfo *dnd_info;
GdkDragContext *context;
GnomeCanvasItem *pixbuf_item;
GnomeCanvas *canvas; GnomeCanvas *canvas;
GdkPixbuf *temp_pixbuf, *scaled_pixbuf; GdkDragContext *context;
GtkArg pixbuf_arg;
GnomeCanvasItem *item;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap_for_dragged_file; GdkPixmap *pixmap_for_dragged_file;
GdkBitmap *mask_for_dragged_file; GdkBitmap *mask_for_dragged_file;
gint x_offset, y_offset, center_offset; int x_offset, y_offset;
ArtIRect rect;
g_return_if_fail (container != NULL);
g_return_if_fail (GNOME_IS_ICON_CONTAINER (container)); g_return_if_fail (GNOME_IS_ICON_CONTAINER (container));
g_return_if_fail (event != NULL); g_return_if_fail (event != NULL);
dnd_info = container->details->dnd_info; dnd_info = container->details->dnd_info;
g_return_if_fail (dnd_info != NULL); g_return_if_fail (dnd_info != NULL);
/* Notice that the event is already in world coordinates, because of /* Notice that the event is in world coordinates, because of
the way the canvas handles events! */ the way the canvas handles events.
dnd_info->start_x = event->x; */
dnd_info->start_y = event->y; canvas = GNOME_CANVAS (container);
gnome_canvas_world_to_window (canvas,
event->x, event->y,
&dnd_info->start_x, &dnd_info->start_y);
/* start the drag */ /* start the drag */
context = gtk_drag_begin (GTK_WIDGET (container), context = gtk_drag_begin (GTK_WIDGET (container),
...@@ -773,45 +739,20 @@ gnome_icon_container_dnd_begin_drag (GnomeIconContainer *container, ...@@ -773,45 +739,20 @@ gnome_icon_container_dnd_begin_drag (GnomeIconContainer *container,
(GdkEvent *) event); (GdkEvent *) event);
/* create a pixmap and mask to drag with */ /* create a pixmap and mask to drag with */
pixbuf_item = GNOME_CANVAS_ITEM (container->details->drag_icon->item); item = GNOME_CANVAS_ITEM (container->details->drag_icon->item);
pixbuf_args[0].name = "NautilusIconsViewIconItem::pixbuf"; pixbuf_arg.name = "NautilusIconsViewIconItem::pixbuf";
gtk_object_getv (GTK_OBJECT (pixbuf_item), 1, pixbuf_args); gtk_object_getv (GTK_OBJECT (item), 1, &pixbuf_arg);
temp_pixbuf = (GdkPixbuf *) GTK_VALUE_OBJECT (pixbuf_args[0]); pixbuf = GTK_VALUE_BOXED (pixbuf_arg);
gdk_pixbuf_render_pixmap_and_mask (pixbuf,
&pixmap_for_dragged_file,
&mask_for_dragged_file,
128);
/* compute the image's offset */ /* compute the image's offset */
canvas = GNOME_CANVAS (container); nautilus_icons_view_icon_item_get_icon_window_rectangle
(container->details->drag_icon->item, &rect);
x_offset = floor (event->x - pixbuf_item->x1 + .5); x_offset = dnd_info->start_x - rect.x0;
y_offset = floor (event->y - pixbuf_item->y1 + .5); y_offset = dnd_info->start_y - rect.y0;
center_offset = nautilus_icons_view_icon_item_center_offset
(NAUTILUS_ICONS_VIEW_ICON_ITEM (container->details->drag_icon->item));
x_offset -= center_offset;
/* if the scale factor isn't 1.0, we have to scale the pixmap */
/* FIXME: eventually need to get the size, if any, from the metadata here */
scaled_pixbuf = NULL;
if (container->details->zoom_level != NAUTILUS_ZOOM_LEVEL_STANDARD) {
gint old_width, old_height;