diff options
author | Alexander Larsson <alexl@redhat.com> | 2004-10-21 10:50:13 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2004-10-21 10:50:13 +0000 |
commit | b471662cfab3299b2959de0f71dfc6e4c6e5ac0e (patch) | |
tree | b8f045359f9586fa2ecd3f9c964bde258ecbf3f3 | |
parent | bed1ded160b645b61b6214e9d50fe63172e8d4c3 (diff) | |
download | nautilus-b471662cfab3299b2959de0f71dfc6e4c6e5ac0e.tar.gz |
Display frame when we're accepting a DnD drop.
2004-10-21 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-icon-dnd.[ch]:
(auto_scroll_timeout_callback), (drag_leave_callback),
(drag_highlight_expose), (dnd_highlight_queue_redraw),
(start_dnd_highlight), (stop_dnd_highlight),
(drag_motion_callback):
Display frame when we're accepting a DnD drop.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-dnd.c | 104 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-dnd.h | 2 |
3 files changed, 115 insertions, 0 deletions
@@ -1,3 +1,12 @@ +2004-10-21 Alexander Larsson <alexl@redhat.com> + + * libnautilus-private/nautilus-icon-dnd.[ch]: + (auto_scroll_timeout_callback), (drag_leave_callback), + (drag_highlight_expose), (dnd_highlight_queue_redraw), + (start_dnd_highlight), (stop_dnd_highlight), + (drag_motion_callback): + Display frame when we're accepting a DnD drop. + 2004-10-18 Dave Camp <dave@novell.com> * src/file-manager/fm-directory-view.c: diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c index c984c3f6f..e8aa4c5c5 100644 --- a/libnautilus-private/nautilus-icon-dnd.c +++ b/libnautilus-private/nautilus-icon-dnd.c @@ -79,6 +79,8 @@ static GtkTargetEntry drop_types [] = { /* Must be last: */ { NAUTILUS_ICON_DND_ROOTWINDOW_DROP_TYPE, 0, NAUTILUS_ICON_DND_ROOTWINDOW_DROP } }; +static void stop_dnd_highlight (GtkWidget *widget); +static void dnd_highlight_queue_redraw (GtkWidget *widget); static GtkTargetList *drop_types_list = NULL; static GtkTargetList *drop_types_list_root = NULL; @@ -653,6 +655,9 @@ auto_scroll_timeout_callback (gpointer data) return TRUE; } + /* Clear the old dnd highlight frame */ + dnd_highlight_queue_redraw (widget); + if (!nautilus_icon_container_scroll (container, (int)x_scroll_delta, (int)y_scroll_delta)) { /* the scroll value got pinned to a min or max adjustment value, * we ended up not scrolling @@ -660,6 +665,9 @@ auto_scroll_timeout_callback (gpointer data) return TRUE; } + /* Make sure the dnd highlight frame is redrawn */ + dnd_highlight_queue_redraw (widget); + /* update cached drag start offsets */ container->details->dnd_info->drag_info.start_x -= x_scroll_delta; container->details->dnd_info->drag_info.start_y -= y_scroll_delta; @@ -1206,6 +1214,8 @@ drag_leave_callback (GtkWidget *widget, if (dnd_info->shadow != NULL) eel_canvas_item_hide (dnd_info->shadow); + + stop_dnd_highlight (widget); set_drop_target (NAUTILUS_ICON_CONTAINER (widget), NULL); stop_auto_scroll (NAUTILUS_ICON_CONTAINER (widget)); @@ -1276,6 +1286,96 @@ nautilus_icon_dnd_begin_drag (NautilusIconContainer *container, } static gboolean +drag_highlight_expose (GtkWidget *widget, + GdkEventExpose *event, + gpointer data) +{ + gint x, y, width, height; + GdkWindow *window; + + x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (widget))); + y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (widget))); + gdk_drawable_get_size (widget->window, &width, &height); + + window = GTK_LAYOUT (widget)->bin_window; + + gtk_paint_shadow (widget->style, window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, widget, "dnd", + x, y, width, height); + + gdk_draw_rectangle (window, + widget->style->black_gc, + FALSE, + x, y, width - 1, height - 1); + + + return FALSE; +} + +/* Queue a redraw of the dnd highlight rect */ +static void +dnd_highlight_queue_redraw (GtkWidget *widget) +{ + NautilusIconDndInfo *dnd_info; + int width, height; + + dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + + if (!dnd_info->highlighted) { + return; + } + + width = widget->allocation.width; + height = widget->allocation.height; + + gtk_widget_queue_draw_area (widget, + 0, 0, + width, 1); + gtk_widget_queue_draw_area (widget, + 0, 0, + 1, height); + gtk_widget_queue_draw_area (widget, + 0, height - 1, + width, 1); + gtk_widget_queue_draw_area (widget, + width - 1, 0, + 1, height); +} + +static void +start_dnd_highlight (GtkWidget *widget) +{ + NautilusIconDndInfo *dnd_info; + + dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + + if (!dnd_info->highlighted) { + dnd_info->highlighted = TRUE; + g_signal_connect_after (widget, "expose_event", + G_CALLBACK (drag_highlight_expose), + NULL); + gtk_widget_queue_draw (widget); + } +} + +static void +stop_dnd_highlight (GtkWidget *widget) +{ + NautilusIconDndInfo *dnd_info; + + dnd_info = NAUTILUS_ICON_CONTAINER (widget)->details->dnd_info; + + if (dnd_info->highlighted) { + dnd_info->highlighted = FALSE; + g_signal_handlers_disconnect_by_func (widget, + drag_highlight_expose, + NULL); + gtk_widget_queue_draw (widget); + } +} + +static gboolean drag_motion_callback (GtkWidget *widget, GdkDragContext *context, int x, int y, @@ -1293,6 +1393,10 @@ drag_motion_callback (GtkWidget *widget, action = 0; nautilus_icon_container_get_drop_action (NAUTILUS_ICON_CONTAINER (widget), context, x, y, &action); + if (action != 0) { + start_dnd_highlight (widget); + } + gdk_drag_status (context, action, time); return TRUE; diff --git a/libnautilus-private/nautilus-icon-dnd.h b/libnautilus-private/nautilus-icon-dnd.h index 026089cee..15af849c0 100644 --- a/libnautilus-private/nautilus-icon-dnd.h +++ b/libnautilus-private/nautilus-icon-dnd.h @@ -36,6 +36,8 @@ typedef struct { /* inherited drag info context */ NautilusDragInfo drag_info; + gboolean highlighted; + /* Stipple for drawing icon shadows during DnD. */ GdkBitmap *stipple; |