return TRUE;
}
+static GdkDragAction
+gtk_icon_view_get_action (GtkWidget *widget,
+ GdkDrop *drop)
+{
+ GtkIconView *iconview = GTK_ICON_VIEW (widget);
+ GdkDrag *drag = gdk_drop_get_drag (drop);
+ GdkDragAction actions;
+
+ actions = gdk_drop_get_actions (drop);
+
+ if (drag == iconview->priv->drag &&
+ actions & GDK_ACTION_MOVE)
+ return GDK_ACTION_MOVE;
+
+ if (actions & GDK_ACTION_COPY)
+ return GDK_ACTION_COPY;
+
+ if (actions & GDK_ACTION_MOVE)
+ return GDK_ACTION_MOVE;
+
+ if (actions & GDK_ACTION_LINK)
+ return GDK_ACTION_LINK;
+
+ return 0;
+}
+
static gboolean
set_destination (GtkIconView *icon_view,
+ GdkDrop *drop,
GtkDropTargetAsync *dest,
int x,
int y,
out:
if (can_drop)
{
- *suggested_action = GDK_ACTION_ALL;
+ *suggested_action = gtk_icon_view_get_action (widget, drop);
gtk_icon_view_set_drag_dest_item (GTK_ICON_VIEW (widget),
path, pos);
gboolean empty;
GdkDragAction result;
- if (!set_destination (icon_view, dest, x, y, &suggested_action, &target))
+ if (!set_destination (icon_view, drop, dest, x, y, &suggested_action, &target))
return 0;
gtk_icon_view_get_drag_dest_item (icon_view, &path, &pos);
if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drop"))
return FALSE;
- if (!set_destination (icon_view, dest, x, y, &suggested_action, &target))
+ if (!set_destination (icon_view, drop, dest, x, y, &suggested_action, &target))
return FALSE;
path = get_logical_destination (icon_view, &drop_append_mode);
return FALSE;
}
-static GdkDragAction
-gtk_icon_view_get_action (GtkWidget *widget,
- GdkDrop *drop)
-{
- GtkIconView *iconview = GTK_ICON_VIEW (widget);
- GdkDrag *drag = gdk_drop_get_drag (drop);
- GdkDragAction actions;
-
- actions = gdk_drop_get_actions (drop);
-
- if (drag == iconview->priv->drag &&
- actions & GDK_ACTION_MOVE)
- return GDK_ACTION_MOVE;
-
- if (actions & GDK_ACTION_COPY)
- return GDK_ACTION_COPY;
-
- if (actions & GDK_ACTION_MOVE)
- return GDK_ACTION_MOVE;
-
- if (actions & GDK_ACTION_LINK)
- return GDK_ACTION_LINK;
-
- return 0;
-}
-
static void
gtk_icon_view_drag_data_received (GObject *source,
GAsyncResult *result,
return TRUE;
}
+static GdkDragAction
+gtk_tree_view_get_action (GtkWidget *widget,
+ GdkDrop *drop)
+{
+ GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
+ TreeViewDragInfo *di;
+ GdkDrag *drag = gdk_drop_get_drag (drop);
+ GdkDragAction actions;
+
+ di = get_info (tree_view);
+
+ actions = gdk_drop_get_actions (drop);
+
+ if (di && di->drag == drag &&
+ actions & GDK_ACTION_MOVE)
+ return GDK_ACTION_MOVE;
+
+ if (actions & GDK_ACTION_COPY)
+ return GDK_ACTION_COPY;
+
+ if (actions & GDK_ACTION_MOVE)
+ return GDK_ACTION_MOVE;
+
+ return 0;
+}
+
/* Returns TRUE if event should not be propagated to parent widgets */
static gboolean
set_destination_row (GtkTreeView *tree_view,
+ GdkDrop *drop,
GtkDropTargetAsync *dest,
/* coordinates relative to the widget */
int x,
out:
if (can_drop)
{
- *suggested_action = GDK_ACTION_COPY | GDK_ACTION_MOVE;
+ *suggested_action = gtk_tree_view_get_action (widget, drop);
gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (widget),
path, pos);
GdkDragAction suggested_action = 0;
GType target;
- if (!set_destination_row (tree_view, dest, x, y, &suggested_action, &target))
+ if (!set_destination_row (tree_view, drop, dest, x, y, &suggested_action, &target))
return 0;
priv->event_last_x = x;
if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag_drop"))
return FALSE;
- if (!set_destination_row (tree_view, dest, x, y, &suggested_action, &target))
+ if (!set_destination_row (tree_view, drop, dest, x, y, &suggested_action, &target))
return FALSE;
path = get_logical_dest_row (tree_view, &path_down_mode, &drop_append_mode);
return FALSE;
}
-static GdkDragAction
-gtk_tree_view_get_action (GtkWidget *widget,
- GdkDrop *drop)
-{
- GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
- TreeViewDragInfo *di;
- GdkDrag *drag = gdk_drop_get_drag (drop);
- GdkDragAction actions;
-
- di = get_info (tree_view);
-
- actions = gdk_drop_get_actions (drop);
-
- if (di && di->drag == drag &&
- actions & GDK_ACTION_MOVE)
- return GDK_ACTION_MOVE;
-
- if (actions & GDK_ACTION_COPY)
- return GDK_ACTION_COPY;
-
- if (actions & GDK_ACTION_MOVE)
- return GDK_ACTION_MOVE;
-
- return 0;
-}
-
static void
gtk_tree_view_drag_data_received (GObject *source,
GAsyncResult *result,