forked from AuroraMiddleware/gtk
tree/iconview: Use a unique drag action in drag_enter/motion callbacks
Functions already exist for providing a unique drag action for gdk_drop_finish(). Reuse these functions in the drag_enter/motion callbacks, since they require a unique action as the return value. Fixes #3187
This commit is contained in:
parent
188cb49b44
commit
d89297b152
@ -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,
|
||||
|
@ -6811,9 +6811,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,
|
||||
@ -6919,7 +6946,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);
|
||||
@ -7184,7 +7211,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;
|
||||
@ -7264,7 +7291,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);
|
||||
@ -7297,32 +7324,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