diff options
author | Alexander Larsson <alexl@redhat.com> | 2005-07-13 08:17:29 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2005-07-13 08:17:29 +0000 |
commit | 412aa180dd998865512bedee99595d6d74bccce6 (patch) | |
tree | 87ddee750b109390115fdde7a9170f56c88e5591 /libnautilus-private/nautilus-icon-dnd.c | |
parent | 97617974455557291fd711c251ef430611d9de38 (diff) | |
download | nautilus-412aa180dd998865512bedee99595d6d74bccce6.tar.gz |
Set dnd icon in drag_begin (#307943) patch from Matthias Clasen
2005-07-13 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-icon-dnd.c:
Set dnd icon in drag_begin (#307943)
patch from Matthias Clasen
Diffstat (limited to 'libnautilus-private/nautilus-icon-dnd.c')
-rw-r--r-- | libnautilus-private/nautilus-icon-dnd.c | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c index eb8149570..3929bf4b9 100644 --- a/libnautilus-private/nautilus-icon-dnd.c +++ b/libnautilus-private/nautilus-icon-dnd.c @@ -1257,6 +1257,44 @@ drag_leave_callback (GtkWidget *widget, nautilus_icon_container_free_drag_data(NAUTILUS_ICON_CONTAINER (widget)); } +static void +drag_begin_callback (GtkWidget *widget, + GdkDragContext *context, + gpointer data) +{ + NautilusIconContainer *container; + GdkPixmap *pixmap; + GdkBitmap *mask; + double x1, y1, x2, y2, winx, winy; + int x_offset, y_offset; + int start_x, start_y; + + container = NAUTILUS_ICON_CONTAINER (widget); + + start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); + start_y = container->details->dnd_info->drag_info.start_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); + + /* create a pixmap and mask to drag with */ + pixmap = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item, &mask); + + /* we want to drag semi-transparent pixbufs, but X is too slow dealing with + stippled masks, so we had to remove the code; this comment is left as a memorial + to it, with the hope that we get it back someday as X Windows improves */ + + /* compute the image's offset */ + eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (container->details->drag_icon->item), + &x1, &y1, &x2, &y2); + eel_canvas_world_to_window (EEL_CANVAS (container), + x1, y1, &winx, &winy); + x_offset = start_x - winx; + y_offset = start_y - winy; + + gtk_drag_set_icon_pixmap (context, + gtk_widget_get_colormap (GTK_WIDGET (container)), + pixmap, mask, + x_offset, y_offset); +} + void nautilus_icon_dnd_begin_drag (NautilusIconContainer *container, GdkDragAction actions, @@ -1266,12 +1304,7 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container, int start_y) { NautilusIconDndInfo *dnd_info; - EelCanvas *canvas; GdkDragContext *context; - GdkPixmap *pixmap; - GdkBitmap *mask; - int x_offset, y_offset; - double x1, y1, x2, y2, winx, winy; g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); g_return_if_fail (event != NULL); @@ -1282,38 +1315,15 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container, /* Notice that the event is in bin_window coordinates, because of the way the canvas handles events. */ - canvas = EEL_CANVAS (container); - dnd_info->drag_info.start_x = start_x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))); - dnd_info->drag_info.start_y = start_y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))); + dnd_info->drag_info.start_x = start_x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); + dnd_info->drag_info.start_y = start_y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); - /* create a pixmap and mask to drag with */ - pixmap = nautilus_icon_canvas_item_get_image (container->details->drag_icon->item, &mask); - - /* we want to drag semi-transparent pixbufs, but X is too slow dealing with - stippled masks, so we had to remove the code; this comment is left as a memorial - to it, with the hope that we get it back someday as X Windows improves */ - - /* compute the image's offset */ - eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (container->details->drag_icon->item), - &x1, &y1, &x2, &y2); - eel_canvas_world_to_window (canvas, x1, y1, &winx, &winy); - x_offset = start_x - winx; - y_offset = start_y - winy; - /* start the drag */ context = gtk_drag_begin (GTK_WIDGET (container), dnd_info->drag_info.target_list, actions, button, (GdkEvent *) event); - - if (context) { - /* set the icon for dragging */ - gtk_drag_set_icon_pixmap (context, - gtk_widget_get_colormap (GTK_WIDGET (container)), - pixmap, mask, - x_offset, y_offset); - } } static gboolean @@ -1726,7 +1736,10 @@ nautilus_icon_dnd_init (NautilusIconContainer *container, targets = gtk_drag_dest_get_target_list (GTK_WIDGET (container)); gtk_target_list_add_text_targets (targets, NAUTILUS_ICON_DND_TEXT); + /* Messages for outgoing drag. */ + g_signal_connect (container, "drag_begin", + G_CALLBACK (drag_begin_callback), NULL); g_signal_connect (container, "drag_data_get", G_CALLBACK (drag_data_get_callback), NULL); g_signal_connect (container, "drag_end", |