GdkDrop *drop,
GtkSelectionData *selection_data);
static gboolean gtk_calendar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_calendar_drag_leave (GtkWidget *widget,
GdkDrop *drop);
static gboolean gtk_calendar_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void calendar_start_spinning (GtkCalendar *calendar,
static gboolean
gtk_calendar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time)
+ gint y)
{
GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv;
GdkAtom target;
gtk_drag_highlight (widget);
}
- target = gtk_drag_dest_find_target (widget, context, NULL);
- if (target == NULL || gdk_drag_context_get_suggested_action (context) == 0)
- gdk_drag_status (context, 0, time);
- else if (get_status_pending (GDK_DROP (context)) == 0)
+ target = gtk_drag_dest_find_target (widget, drop, NULL);
+ if (target == NULL || gdk_drop_get_actions (drop) == 0)
+ gdk_drop_status (drop, 0);
+ else if (get_status_pending (drop) == 0)
{
- set_status_pending (GDK_DROP (context), gdk_drag_context_get_suggested_action (context));
- gtk_drag_get_data (widget, context, target, time);
+ set_status_pending (drop, gdk_drop_get_actions (drop));
+ gtk_drag_get_data (widget, drop, target);
}
return TRUE;
static gboolean
gtk_calendar_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time)
+ gint y)
{
GdkAtom target;
- target = gtk_drag_dest_find_target (widget, context, NULL);
+ target = gtk_drag_dest_find_target (widget, drop, NULL);
if (target != NULL)
{
- gtk_drag_get_data (widget, context,
- target,
- time);
+ gtk_drag_get_data (widget, drop, target);
return TRUE;
}
********************/
typedef struct {
- GdkDragContext *context;
+ GdkDrop *drop;
GtkWidget *widget;
const char *mime_type;
- guint time;
} GtkDragGetData;
static void
size >= 0)
g_signal_emit_by_name (data->widget,
"drag-data-received",
- data->context,
+ data->drop,
&sdata);
}
}
{
g_signal_emit_by_name (data->widget,
"drag-data-received",
- data->context,
+ data->drop,
&sdata);
}
if (site && site->flags & GTK_DEST_DEFAULT_DROP)
{
+ GdkDragAction action = site->actions & gdk_drop_get_actions (data->drop);
+
+ if (size == 0)
+ action = 0;
+
+ if (!gdk_drag_action_is_unique (action))
+ {
+ if (action & GDK_ACTION_COPY)
+ action = GDK_ACTION_COPY;
+ else if (action & GDK_ACTION_MOVE)
+ action = GDK_ACTION_MOVE;
+ }
- gdk_drag_finish (data->context,
- size > 0,
- data->time);
+ gdk_drop_finish (data->drop, action);
}
g_object_unref (data->widget);
- g_object_unref (data->context);
+ g_object_unref (data->drop);
g_slice_free (GtkDragGetData, data);
}
* gtk_drag_get_data: (method)
* @widget: the widget that will receive the
* #GtkWidget::drag-data-received signal
- * @context: the drag context
+ * @drop: the #GdkDrop
* @target: the target (form of the data) to retrieve
* @time_: a timestamp for retrieving the data. This will
* generally be the time received in a #GtkWidget::drag-motion
* drops.
*/
void
-gtk_drag_get_data (GtkWidget *widget,
- GdkDragContext *context,
- GdkAtom target,
- guint32 time_)
+gtk_drag_get_data (GtkWidget *widget,
+ GdkDrop *drop,
+ GdkAtom target)
{
GtkDragGetData *data;
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+ g_return_if_fail (GDK_IS_DROP (drop));
data = g_slice_new0 (GtkDragGetData);
data->widget = g_object_ref (widget);
- data->context = g_object_ref (context);
+ data->drop = g_object_ref (drop);
data->mime_type = target;
- data->time = time_;
- gdk_drop_read_async (GDK_DROP (context),
+ gdk_drop_read_async (drop,
(const gchar *[2]) { target, NULL },
G_PRIORITY_DEFAULT,
NULL,
}
}
- if (action && gtk_drag_dest_find_target (widget, context, NULL))
+ if (action && gtk_drag_dest_find_target (widget, GDK_DROP (context), NULL))
{
if (!site->have_drag)
{
}
g_signal_emit_by_name (widget, "drag-motion",
- context, x, y, time, &retval);
+ context, x, y, &retval);
return (site->flags & GTK_DEST_DEFAULT_MOTION) ? TRUE : retval;
}
if (site->flags & GTK_DEST_DEFAULT_DROP)
{
- GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);
+ GdkAtom target = gtk_drag_dest_find_target (widget, GDK_DROP (context), NULL);
if (target == NULL)
{
return TRUE;
}
else
- gtk_drag_get_data (widget, context, target, time);
+ gtk_drag_get_data (widget, GDK_DROP (context), target);
}
g_signal_emit_by_name (widget, "drag-drop",
- context, x, y, time, &retval);
+ context, x, y, &retval);
return (site->flags & GTK_DEST_DEFAULT_DROP) ? TRUE : retval;
}
GDK_AVAILABLE_IN_ALL
void gtk_drag_get_data (GtkWidget *widget,
- GdkDragContext *context,
- GdkAtom target,
- guint32 time_);
+ GdkDrop *drop,
+ GdkAtom target);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context);
/**
* gtk_drag_dest_find_target: (method)
* @widget: drag destination widget
- * @context: drag context
+ * @drop: #GdkDrop
* @target_list: (allow-none): list of droppable targets, or %NULL to use
* gtk_drag_dest_get_target_list (@widget).
*
- * Looks for a match between the supported targets of @context and the
+ * Looks for a match between the supported targets of @drop and the
* @dest_target_list, returning the first matching target, otherwise
* returning %NULL. @dest_target_list should usually be the return
* value from gtk_drag_dest_get_target_list(), but some widgets may
*/
const char *
gtk_drag_dest_find_target (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
GdkContentFormats *target_list)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
+ g_return_val_if_fail (GDK_IS_DROP (drop), NULL);
if (target_list == NULL)
target_list = gtk_drag_dest_get_target_list (widget);
return NULL;
return gdk_content_formats_match_mime_type (target_list,
- gdk_drag_context_get_formats (context));
+ gdk_drop_get_formats (drop));
}
GDK_AVAILABLE_IN_ALL
const char * gtk_drag_dest_find_target (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
GdkContentFormats *target_list);
GDK_AVAILABLE_IN_ALL
GdkContentFormats* gtk_drag_dest_get_target_list (GtkWidget *widget);
GdkDisplay *old_display);
static gboolean gtk_entry_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static gboolean gtk_entry_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_entry_drag_leave (GtkWidget *widget,
GdkDrop *drop);
static void gtk_entry_drag_data_received (GtkWidget *widget,
}
static gboolean
-gtk_entry_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_entry_drag_drop (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
GdkAtom target = NULL;
if (priv->editable)
- target = gtk_drag_dest_find_target (widget, context, NULL);
+ target = gtk_drag_dest_find_target (widget, drop, NULL);
if (target != NULL)
{
priv->drop_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
- gtk_drag_get_data (widget, context, target, time);
+ gtk_drag_get_data (widget, drop, target);
}
else
- gdk_drag_finish (context, FALSE, time);
+ gdk_drop_finish (drop, 0);
return TRUE;
}
static gboolean
-gtk_entry_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_entry_drag_motion (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
new_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
if (priv->editable &&
- gtk_drag_dest_find_target (widget, context, NULL) != NULL)
+ gtk_drag_dest_find_target (widget, drop, NULL) != NULL)
{
suggested_action = GDK_ACTION_COPY | GDK_ACTION_MOVE;
if (show_placeholder_text (entry))
priv->dnd_position = -1;
- gdk_drag_status (context, suggested_action, time);
+ gdk_drop_status (drop, suggested_action);
if (suggested_action == 0)
gtk_drag_unhighlight (widget);
else
static gboolean gtk_expander_focus (GtkWidget *widget,
GtkDirectionType direction);
static gboolean gtk_expander_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_expander_drag_leave (GtkWidget *widget,
GdkDrop *drop);
}
static gboolean
-gtk_expander_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_expander_drag_motion (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkExpander *expander = GTK_EXPANDER (widget);
GtkExpanderPrivate *priv = gtk_expander_get_instance_private (expander);
/* Don't do anything with the drag_drop signal */
static gboolean
file_list_drag_drop_cb (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
gint y,
- guint time_,
GtkFileChooserWidget *impl)
{
g_signal_stop_emission_by_name (widget, "drag-drop");
dropping the dragged item onto a tree item */
static gboolean
file_list_drag_motion_cb (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
gint y,
- guint time_,
GtkFileChooserWidget *impl)
{
g_signal_stop_emission_by_name (widget, "drag-motion");
static void gtk_icon_view_drag_leave (GtkWidget *widget,
GdkDrop *drop);
static gboolean gtk_icon_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static gboolean gtk_icon_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_icon_view_drag_data_received (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data);
static gboolean
set_destination (GtkIconView *icon_view,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
gint y,
GdkDragAction *suggested_action,
return FALSE; /* no longer a drop site */
}
- *target = gtk_drag_dest_find_target (widget, context,
+ *target = gtk_drag_dest_find_target (widget, drop,
gtk_drag_dest_get_target_list (widget));
if (*target == NULL)
return FALSE;
out:
if (can_drop)
{
- GtkWidget *source_widget;
-
- *suggested_action = gdk_drag_context_get_suggested_action (context);
- source_widget = gtk_drag_get_source_widget (context);
-
- if (source_widget == widget)
- {
- /* Default to MOVE, unless the user has
- * pressed ctrl or shift to affect available actions
- */
- if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0)
- *suggested_action = GDK_ACTION_MOVE;
- }
+ *suggested_action = GDK_ACTION_ALL;
gtk_icon_view_set_drag_dest_item (GTK_ICON_VIEW (widget),
path, pos);
}
static gboolean
-gtk_icon_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_icon_view_drag_motion (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkTreePath *path = NULL;
GtkIconViewDropPosition pos;
icon_view = GTK_ICON_VIEW (widget);
- if (!set_destination (icon_view, context, x, y, &suggested_action, &target))
+ if (!set_destination (icon_view, drop, x, y, &suggested_action, &target))
return FALSE;
icon_view->priv->event_last_x = x;
if (path == NULL && !empty)
{
/* Can't drop here. */
- gdk_drag_status (context, 0, time);
+ gdk_drop_status (drop, 0);
}
else
{
/* Request data so we can use the source row when
* determining whether to accept the drop
*/
- set_status_pending (GDK_DROP (context), suggested_action);
- gtk_drag_get_data (widget, context, target, time);
+ set_status_pending (drop, suggested_action);
+ gtk_drag_get_data (widget, drop, target);
}
else
{
- set_status_pending (GDK_DROP (context), 0);
- gdk_drag_status (context, suggested_action, time);
+ set_status_pending (drop, 0);
+ gdk_drop_status (drop, suggested_action);
}
}
}
static gboolean
-gtk_icon_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_icon_view_drag_drop (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkIconView *icon_view;
GtkTreePath *path;
if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag-drop"))
return FALSE;
- if (!set_destination (icon_view, context, x, y, &suggested_action, &target))
+ if (!set_destination (icon_view, drop, x, y, &suggested_action, &target))
return FALSE;
path = get_logical_destination (icon_view, &drop_append_mode);
/* in case a motion had requested drag data, change things so we
* treat drag data receives as a drop.
*/
- set_status_pending (GDK_DROP (context), 0);
- set_dest_row (GDK_DROP (context), model, path,
+ set_status_pending (drop, 0);
+ set_dest_row (drop, model, path,
icon_view->priv->empty_view_drop, drop_append_mode);
}
if (target != NULL)
{
- gtk_drag_get_data (widget, context, target, time);
+ gtk_drag_get_data (widget, drop, target);
return TRUE;
}
else
return FALSE;
}
+static GdkDragAction
+gtk_icon_view_get_action (GtkWidget *treeview,
+ GdkDrop *drop)
+{
+ GdkDragContext *drag = gdk_drop_get_drag (drop);
+ GtkWidget *source_widget = gtk_drag_get_source_widget (drag);
+ GdkDragAction actions;
+
+ actions = gdk_drop_get_actions (drop);
+
+ if (source_widget == treeview &&
+ 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 (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data)
{
GtkTreePath *path;
- gboolean accepted = FALSE;
GtkTreeModel *model;
GtkIconView *icon_view;
GtkTreePath *dest_row;
if (gtk_selection_data_get_length (selection_data) >= 0)
{
- if (gtk_tree_drag_dest_drag_data_received (GTK_TREE_DRAG_DEST (model),
- dest_row,
- selection_data))
- accepted = TRUE;
+ suggested_action = gtk_icon_view_get_action (widget, drop);
+
+ if (suggested_action &&
+ !gtk_tree_drag_dest_drag_data_received (GTK_TREE_DRAG_DEST (model),
+ dest_row,
+ selection_data))
+ suggested_action = 0;
}
- gdk_drop_finish (drop, accepted ? suggested_action : 0);
+ gdk_drop_finish (drop, suggested_action);
gtk_tree_path_free (dest_row);
BOOLEAN:ENUM,INT
BOOLEAN:OBJECT
BOOLEAN:OBJECT,UINT,FLAGS
-BOOLEAN:OBJECT,INT,INT,UINT
+BOOLEAN:OBJECT,INT,INT
BOOLEAN:OBJECT,STRING,STRING,BOXED
BOOLEAN:OBJECT,BOXED
BOOLEAN:OBJECT,OBJECT,BOXED
GdkDragContext *context,
GtkDragResult result);
static gboolean gtk_notebook_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_notebook_drag_leave (GtkWidget *widget,
GdkDrop *drop);
static gboolean gtk_notebook_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_notebook_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *data,
}
static gboolean
-gtk_notebook_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_notebook_drag_motion (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GtkNotebookPrivate *priv = notebook->priv;
{
priv->click_child = arrow;
gtk_notebook_set_scroll_timer (notebook);
- gdk_drag_status (context, 0, time);
+ gdk_drop_status (drop, 0);
retval = TRUE;
goto out;
}
stop_scrolling (notebook);
- target = gtk_drag_dest_find_target (widget, context, NULL);
+ target = gtk_drag_dest_find_target (widget, drop, NULL);
tab_target = g_intern_static_string ("GTK_NOTEBOOK_TAB");
if (target == tab_target)
retval = TRUE;
- source = GTK_NOTEBOOK (gtk_drag_get_source_widget (context));
+ source = GTK_NOTEBOOK (gtk_drag_get_source_widget (gdk_drop_get_drag (drop)));
g_assert (source->priv->cur_page != NULL);
source_child = source->priv->cur_page->child;
!(widget == source_child ||
gtk_widget_is_ancestor (widget, source_child)))
{
- gdk_drag_status (context, GDK_ACTION_MOVE, time);
+ gdk_drop_status (drop, GDK_ACTION_MOVE);
goto out;
}
else
{
/* it's a tab, but doesn't share
* ID with this notebook */
- gdk_drag_status (context, 0, time);
+ gdk_drop_status (drop, 0);
}
}
}
static gboolean
-gtk_notebook_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_notebook_drag_drop (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
GdkAtom target, tab_target;
- target = gtk_drag_dest_find_target (widget, context, NULL);
+ target = gtk_drag_dest_find_target (widget, drop, NULL);
tab_target = g_intern_static_string ("GTK_NOTEBOOK_TAB");
if (target == tab_target)
{
notebook->priv->mouse_x = x;
notebook->priv->mouse_y = y;
- gtk_drag_get_data (widget, context, target, time);
+ gtk_drag_get_data (widget, drop, target);
return TRUE;
}
static gboolean
get_drag_data (GtkWidget *list_box,
- GdkDragContext *context,
- GtkListBoxRow *row,
- guint time)
+ GdkDrop *drop,
+ GtkListBoxRow *row)
{
GdkAtom target;
- target = gtk_drag_dest_find_target (list_box, context, NULL);
+ target = gtk_drag_dest_find_target (list_box, drop, NULL);
if (target == NULL)
return FALSE;
if (row)
- g_object_set_data_full (G_OBJECT (context), "places-sidebar-row", g_object_ref (row), g_object_unref);
- gtk_drag_get_data (list_box, context, target, time);
+ g_object_set_data_full (G_OBJECT (drop), "places-sidebar-row", g_object_ref (row), g_object_unref);
+ gtk_drag_get_data (list_box, drop, target);
return TRUE;
}
}
static gboolean
-drag_motion_callback (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- gpointer user_data)
-{
- GdkDrop *drop = GDK_DROP (context);
+drag_motion_callback (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y,
+ gpointer user_data)
+{
gint action;
GtkListBoxRow *row;
GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
/* Nothing to do if no drag data */
if (!sidebar->drag_data_received &&
- !get_drag_data (sidebar->list_box, context, row, time))
+ !get_drag_data (sidebar->list_box, drop, row))
goto out;
/* Nothing to do if the target is not valid drop destination */
g_signal_stop_emission_by_name (sidebar->list_box, "drag-motion");
- gdk_drag_status (context, action, time);
+ gdk_drop_status (drop, action);
return TRUE;
}
}
static gboolean
-drag_drop_callback (GtkWidget *list_box,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- gpointer user_data)
+drag_drop_callback (GtkWidget *list_box,
+ GdkDrop *drop,
+ gint x,
+ gint y,
+ gpointer user_data)
{
gboolean retval = FALSE;
GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
row = gtk_list_box_get_row_at_y (GTK_LIST_BOX (sidebar->list_box), y);
sidebar->drop_occurred = TRUE;
- retval = get_drag_data (sidebar->list_box, context, row, time);
+ retval = get_drag_data (sidebar->list_box, drop, row);
g_signal_stop_emission_by_name (sidebar->list_box, "drag-drop");
return retval;
}
static gboolean
-gtk_stack_switcher_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_stack_switcher_drag_motion (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
GtkStackSwitcherPrivate *priv;
static void gtk_text_view_drag_leave (GtkWidget *widget,
GdkDrop *drop);
static gboolean gtk_text_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static gboolean gtk_text_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_text_view_drag_data_received (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data);
}
static gboolean
-gtk_text_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_text_view_drag_motion (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkTextIter newplace;
GtkTextView *text_view;
&newplace,
bx, by);
- target = gtk_drag_dest_find_target (widget, context,
+ target = gtk_drag_dest_find_target (widget, drop,
gtk_drag_dest_get_target_list (widget));
if (target == NULL)
if (can_accept)
{
gtk_text_mark_set_visible (priv->dnd_mark, cursor_visible (text_view));
- gdk_drag_status (context, GDK_ACTION_COPY | GDK_ACTION_MOVE, time);
+ gdk_drop_status (drop, GDK_ACTION_COPY | GDK_ACTION_MOVE);
}
else
{
- gdk_drag_status (context, 0, time);
+ gdk_drop_status (drop, 0);
gtk_text_mark_set_visible (priv->dnd_mark, FALSE);
}
}
static gboolean
-gtk_text_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
+gtk_text_view_drag_drop (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkTextView *text_view;
GtkTextViewPrivate *priv;
priv->dnd_mark);
if (gtk_text_iter_can_insert (&drop_point, priv->editable))
- target = gtk_drag_dest_find_target (widget, context, NULL);
+ target = gtk_drag_dest_find_target (widget, drop, NULL);
if (target != NULL)
- gtk_drag_get_data (widget, context, target, time);
+ gtk_drag_get_data (widget, drop, target);
else
- gdk_drag_finish (context, FALSE, time);
+ gdk_drop_finish (drop, 0);
return TRUE;
}
static void gtk_tree_view_drag_leave (GtkWidget *widget,
GdkDrop *drop);
static gboolean gtk_tree_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static gboolean gtk_tree_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time);
+ gint y);
static void gtk_tree_view_drag_data_received (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data);
/* Returns TRUE if event should not be propagated to parent widgets */
static gboolean
set_destination_row (GtkTreeView *tree_view,
- GdkDragContext *context,
+ GdkDrop *drop,
/* coordinates relative to the widget */
gint x,
gint y,
return FALSE; /* no longer a drop site */
}
- *target = gtk_drag_dest_find_target (widget, context,
+ *target = gtk_drag_dest_find_target (widget, drop,
gtk_drag_dest_get_target_list (widget));
if (*target == NULL)
{
static gboolean
-gtk_tree_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- /* coordinates relative to the widget */
- gint x,
- gint y,
- guint time)
+gtk_tree_view_drag_motion (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
gboolean empty;
GtkTreePath *path = NULL;
tree_view = GTK_TREE_VIEW (widget);
- if (!set_destination_row (tree_view, context, x, y, &suggested_action, &target))
+ if (!set_destination_row (tree_view, drop, x, y, &suggested_action, &target))
return FALSE;
tree_view->priv->event_last_x = x;
if (path == NULL && !empty)
{
/* Can't drop here. */
- gdk_drag_status (context, 0, time);
+ gdk_drop_status (drop, 0);
}
else
{
/* Request data so we can use the source row when
* determining whether to accept the drop
*/
- set_status_pending (GDK_DROP (context), suggested_action);
- gtk_drag_get_data (widget, context, target, time);
+ set_status_pending (drop, suggested_action);
+ gtk_drag_get_data (widget, drop, target);
}
else
{
- set_status_pending (GDK_DROP (context), 0);
- gdk_drag_status (context, suggested_action, time);
+ set_status_pending (drop, 0);
+ gdk_drop_status (drop, suggested_action);
}
}
static gboolean
-gtk_tree_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- /* coordinates relative to the widget */
- gint x,
- gint y,
- guint time)
+gtk_tree_view_drag_drop (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x,
+ gint y)
{
GtkTreeView *tree_view;
GtkTreePath *path;
if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag_drop"))
return FALSE;
- if (!set_destination_row (tree_view, context, x, y, &suggested_action, &target))
+ if (!set_destination_row (tree_view, drop, x, y, &suggested_action, &target))
return FALSE;
path = get_logical_dest_row (tree_view, &path_down_mode, &drop_append_mode);
/* in case a motion had requested drag data, change things so we
* treat drag data receives as a drop.
*/
- set_status_pending (GDK_DROP (context), 0);
- set_dest_row (GDK_DROP (context), model, path,
+ set_status_pending (drop, 0);
+ set_dest_row (drop, model, path,
path_down_mode, tree_view->priv->empty_view_drop,
drop_append_mode);
}
if (target != NULL)
{
- gtk_drag_get_data (widget, context, target, time);
+ gtk_drag_get_data (widget, drop, target);
return TRUE;
}
else
/**
* GtkWidget::drag-motion:
* @widget: the object which received the signal
- * @context: the drag context
+ * @drop: the #GdkDrop
* @x: the x coordinate of the current cursor position
* @y: the y coordinate of the current cursor position
- * @time: the timestamp of the motion event
*
* The ::drag-motion signal is emitted on the drop site when the user
* moves the cursor over the widget during a drag. The signal handler
* the drop site with gtk_drag_highlight().
* |[<!-- language="C" -->
* static void
- * drag_motion (GtkWidget *widget,
- * GdkDragContext *context,
- * gint x,
- * gint y,
- * guint time)
+ * drag_motion (GtkWidget *widget,
+ * GdkDrop *drop,
+ * gint x,
+ * gint y,
* {
* GdkAtom target;
*
* gtk_drag_highlight (widget);
* }
*
- * target = gtk_drag_dest_find_target (widget, context, NULL);
+ * target = gtk_drag_dest_find_target (widget, drop, NULL);
* if (target == NULL)
- * gdk_drag_status (context, 0, time);
+ * gdk_drop_status (drop, 0);
* else
* {
* private_data->pending_status
- * = gdk_drag_context_get_suggested_action (context);
- * gtk_drag_get_data (widget, context, target, time);
+ * = gdk_drop_get_actions (drop);
+ * gtk_drag_get_data (widget, drop, target);
* }
*
* return TRUE;
*
* static void
* drag_data_received (GtkWidget *widget,
- * GdkDragContext *context,
- * gint x,
- * gint y,
- * GtkSelectionData *selection_data,
- * guint info,
- * guint time)
+ * GdkDrop *drop,
+ * GtkSelectionData *selection_data)
* {
* PrivateData *private_data = GET_PRIVATE_DATA (widget);
*
*
* str = gtk_selection_data_get_text (selection_data);
* if (!data_is_acceptable (str))
- * gdk_drag_status (context, 0, time);
+ * gdk_drop_status (drop, 0);
* else
- * gdk_drag_status (context,
- * private_data->suggested_action,
- * time);
+ * gdk_drag_status (drop, GDK_ACTION_ALL);
* }
* else
* {
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_motion),
_gtk_boolean_handled_accumulator, NULL,
- _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
- G_TYPE_BOOLEAN, 4,
- GDK_TYPE_DRAG_CONTEXT,
- G_TYPE_INT,
+ _gtk_marshal_BOOLEAN__OBJECT_INT_INT,
+ G_TYPE_BOOLEAN, 3,
+ GDK_TYPE_DROP,
G_TYPE_INT,
- G_TYPE_UINT);
+ G_TYPE_INT);
/**
* GtkWidget::drag-drop:
* @widget: the object which received the signal
- * @context: the drag context
+ * @drop: the #GdkDrop
* @x: the x coordinate of the current cursor position
* @y: the y coordinate of the current cursor position
- * @time: the timestamp of the motion event
*
* The ::drag-drop signal is emitted on the drop site when the user drops
* the data onto the widget. The signal handler must determine whether
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_drop),
_gtk_boolean_handled_accumulator, NULL,
- _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
- G_TYPE_BOOLEAN, 4,
- GDK_TYPE_DRAG_CONTEXT,
- G_TYPE_INT,
+ _gtk_marshal_BOOLEAN__OBJECT_INT_INT,
+ G_TYPE_BOOLEAN, 3,
+ GDK_TYPE_DROP,
G_TYPE_INT,
- G_TYPE_UINT);
+ G_TYPE_INT);
/**
* GtkWidget::drag-data-get:
void (* drag_leave) (GtkWidget *widget,
GdkDrop *drop);
gboolean (* drag_motion) (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time_);
+ gint y);
gboolean (* drag_drop) (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time_);
+ gint y);
void (* drag_data_received) (GtkWidget *widget,
GdkDrop *drop,
GtkSelectionData *selection_data);
void
target_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
guint time)
{
g_print("leave\n");
gboolean
target_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time)
+ gint y)
{
GtkWidget *source_widget;
+ GdkDragContext *drag;
char *s;
if (!have_drag)
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_open);
}
- source_widget = gtk_drag_get_source_widget (context);
+ drag = gdk_drop_get_drag (drop);
+ source_widget = drag ? gtk_drag_get_source_widget (drag) : NULL;
g_print ("motion, source %s\n", source_widget ?
G_OBJECT_TYPE_NAME (source_widget) :
"NULL");
- s = gdk_content_formats_to_string (gdk_drag_context_get_formats (context));
+ s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
g_print ("%s\n", s);
- gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time);
+ gdk_drop_status (drop, GDK_ACTION_ALL);
return TRUE;
}
gboolean
target_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time)
+ gint y)
{
GdkContentFormats *formats;
const char *format;
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_closed);
- formats = gdk_drag_context_get_formats (context);
+ formats = gdk_drop_get_formats (drop);
format = gdk_content_formats_match_mime_type (formats, formats);
if (format)
{
- gtk_drag_get_data (widget, context,
- format,
- time);
+ gtk_drag_get_data (widget, drop, format);
return TRUE;
}
return FALSE;
}
+static GdkDragAction
+action_make_unique (GdkDragAction action)
+{
+ if (gdk_drag_action_is_unique (action))
+ return action;
+
+ if (action & GDK_ACTION_COPY)
+ return GDK_ACTION_COPY;
+
+ if (action & GDK_ACTION_MOVE)
+ return GDK_ACTION_MOVE;
+
+ if (action & GDK_ACTION_LINK)
+ return GDK_ACTION_LINK;
+
+ g_assert_not_reached ();
+ return 0;
+}
+
void
target_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+ GdkDrop *drop,
+ GtkSelectionData *selection_data)
{
if (gtk_selection_data_get_length (selection_data) >= 0 &&
gtk_selection_data_get_format (selection_data) == 8)
{
+ GdkDragAction action = gdk_drop_get_actions (drop);
g_print ("Received \"%s\" in trashcan\n", (gchar *) gtk_selection_data_get_data (selection_data));
- gdk_drag_finish (context, TRUE, time);
+ action = action_make_unique (action);
+ gdk_drop_finish (drop, action);
return;
}
- gdk_drag_finish (context, FALSE, time);
+ gdk_drop_finish (drop, 0);
}
void
label_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time)
+ GdkDrop *drop,
+ GtkSelectionData *selection_data)
{
if (gtk_selection_data_get_length (selection_data) >= 0 &&
gtk_selection_data_get_format (selection_data) == 8)
{
+ GdkDragAction action = action_make_unique (gdk_drop_get_actions (drop));
g_print ("Received \"%s\" in label\n", (gchar *) gtk_selection_data_get_data (selection_data));
- gdk_drag_finish (context, TRUE, time);
+ gdk_drop_finish (drop, action);
return;
}
- gdk_drag_finish (context, FALSE, time);
+ gdk_drop_finish (drop, 0);
}
void
gboolean
popup_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time)
+ gint y)
{
if (!in_popup)
{
void
popup_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time)
+ GdkDrop *drop)
{
if (in_popup)
{
GTK_DEST_DEFAULT_ALL,
targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
- g_signal_connect (button, "drag_motion",
+ g_signal_connect (button, "drag-motion",
G_CALLBACK (popup_motion), NULL);
- g_signal_connect (button, "drag_leave",
+ g_signal_connect (button, "drag-leave",
G_CALLBACK (popup_leave), NULL);
}
gtk_container_add (GTK_CONTAINER (popup_window), grid);
gboolean
popsite_motion (GtkWidget *widget,
- GdkDragContext *context,
+ GdkDrop *drop,
gint x,
- gint y,
- guint time)
+ gint y)
{
if (!popup_timer)
popup_timer = g_timeout_add (500, popup_cb, NULL);
void
popsite_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time)
+ GdkDrop *drop)
{
if (popup_timer)
{
gtk_widget_set_vexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
- g_signal_connect (label, "drag_motion",
+ g_signal_connect (label, "drag-motion",
G_CALLBACK (popsite_motion), NULL);
- g_signal_connect (label, "drag_leave",
+ g_signal_connect (label, "drag-leave",
G_CALLBACK (popsite_leave), NULL);
gdk_content_formats_unref (targets);
gtk_widget_set_vexpand (pixmap, TRUE);
gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
- g_signal_connect (pixmap, "drag_leave",
+ g_signal_connect (pixmap, "drag-leave",
G_CALLBACK (target_drag_leave), NULL);
- g_signal_connect (pixmap, "drag_motion",
+ g_signal_connect (pixmap, "drag-motion",
G_CALLBACK (target_drag_motion), NULL);
- g_signal_connect (pixmap, "drag_drop",
+ g_signal_connect (pixmap, "drag-drop",
G_CALLBACK (target_drag_drop), NULL);
- g_signal_connect (pixmap, "drag_data_received",
+ g_signal_connect (pixmap, "drag-data-received",
G_CALLBACK (target_drag_data_received), NULL);
/* Drag site */
gtk_widget_set_vexpand (button, TRUE);
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
- g_signal_connect (button, "drag_data_get",
+ g_signal_connect (button, "drag-data-get",
G_CALLBACK (source_drag_data_get), NULL);
- g_signal_connect (button, "drag_data_delete",
+ g_signal_connect (button, "drag-data-delete",
G_CALLBACK (source_drag_data_delete), NULL);
gtk_widget_show (window);
}
static gboolean
-toolbar_drag_drop (GtkWidget *widget, GdkDragContext *context,
- gint x, gint y, guint time, GtkWidget *label)
+toolbar_drag_drop (GtkWidget *widget,
+ GdkDrop *drop,
+ gint x, gint y,
+ GtkWidget *label)
{
gchar buf[32];
static GtkToolItem *drag_item = NULL;
static gboolean
-toolbar_drag_motion (GtkToolbar *toolbar,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- gpointer null)
+toolbar_drag_motion (GtkToolbar *toolbar,
+ GdkDrop *drop,
+ gint x,
+ gint y,
+ guint time,
+ gpointer null)
{
gint index;
g_object_ref_sink (g_object_ref (drag_item));
}
- gdk_drag_status (context, GDK_ACTION_MOVE, time);
+ gdk_drop_status (drop, GDK_ACTION_MOVE);
index = gtk_toolbar_get_drop_index (toolbar, x, y);