forked from AuroraMiddleware/gtk
Merge branch 'drag-action' into 'main'
tree/iconview: Use a unique drag action in drag_enter/motion callbacks Closes #3187 See merge request GNOME/gtk!4882
This commit is contained in:
commit
b165028e86
@ -5692,8 +5692,35 @@ drag_scroll_timeout (gpointer data)
|
||||
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,
|
||||
@ -5780,7 +5807,7 @@ set_destination (GtkIconView *icon_view,
|
||||
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);
|
||||
@ -6020,7 +6047,7 @@ gtk_icon_view_drag_motion (GtkDropTargetAsync *dest,
|
||||
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);
|
||||
@ -6085,7 +6112,7 @@ gtk_icon_view_drag_drop (GtkDropTargetAsync *dest,
|
||||
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);
|
||||
@ -6115,32 +6142,6 @@ gtk_icon_view_drag_drop (GtkDropTargetAsync *dest,
|
||||
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,
|
||||
|
@ -6818,9 +6818,36 @@ scroll_row_timeout (gpointer data)
|
||||
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,
|
||||
@ -6926,7 +6953,7 @@ set_destination_row (GtkTreeView *tree_view,
|
||||
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);
|
||||
@ -7191,7 +7218,7 @@ gtk_tree_view_drag_motion (GtkDropTargetAsync *dest,
|
||||
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;
|
||||
@ -7271,7 +7298,7 @@ gtk_tree_view_drag_drop (GtkDropTargetAsync *dest,
|
||||
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);
|
||||
@ -7304,32 +7331,6 @@ gtk_tree_view_drag_drop (GtkDropTargetAsync *dest,
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user