[gtk/dnd-gestures-2: 61/150] Remove gdk_drag_get_data
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 61/150] Remove gdk_drag_get_data
- Date: Tue, 7 Jan 2020 06:57:03 +0000 (UTC)
commit 65c19bc286b8a92e18a9a205735f1dea23300085
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 3 16:26:15 2020 -0500
Remove gdk_drag_get_data
This is not used anymore, so we can remove it,
and the GtkDropTarget::drag-data-received signal
that it emits.
gtk/gtkdnd.c | 185 +-----------------------------------------------------
gtk/gtkdnd.h | 5 --
gtk/gtkdragdest.c | 22 -------
gtk/gtkdragdest.h | 9 +--
4 files changed, 3 insertions(+), 218 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 2b0366c5b7..788e46513d 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -107,168 +107,6 @@ static GtkDragDestInfo * gtk_drag_get_dest_info (GdkDrop *drop,
gboolean create);
-/********************
- * Destination side *
- ********************/
-
-
-typedef struct {
- GdkDrop *drop;
- GtkWidget *widget;
- const char *mime_type;
-} GtkDragGetData;
-
-static void
-gtk_drag_get_data_finish (GtkDragGetData *data,
- guchar *bytes,
- gsize size)
-{
- GtkDragDestSite *site;
- GtkSelectionData sdata;
- GdkContentFormats *target_list = NULL;
- GdkDragAction actions = 0;
- GtkDestDefaults flags = 0;
-
- site = g_object_get_data (G_OBJECT (data->widget), "gtk-drag-dest");
-
- sdata.target = data->mime_type;
- sdata.type = data->mime_type;
- sdata.format = 8;
- sdata.length = size;
- sdata.data = bytes ? bytes : (guchar *)g_strdup ("");
- sdata.display = gtk_widget_get_display (data->widget);
-
- if (site)
- {
- target_list = gtk_drop_target_get_formats (site->dest);
- actions = gtk_drop_target_get_actions (site->dest);
- flags = gtk_drop_target_get_defaults (site->dest);
- }
-
- if (target_list)
- {
- if (gdk_content_formats_contain_mime_type (target_list, data->mime_type))
- {
- if (!(flags & GTK_DEST_DEFAULT_DROP) || size >= 0)
- gtk_drop_target_emit_drag_data_received (site->dest, data->drop, &sdata);
- }
- }
- else
- {
- gtk_drop_target_emit_drag_data_received (site->dest, data->drop, &sdata);
- }
-
- if (flags & GTK_DEST_DEFAULT_DROP)
- {
- GdkDragAction action = 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_drop_finish (data->drop, action);
- }
-
- g_object_unref (data->widget);
- g_object_unref (data->drop);
- g_slice_free (GtkDragGetData, data);
-}
-
-static void
-gtk_drag_get_data_got_data (GObject *source,
- GAsyncResult *result,
- gpointer data)
-{
- gssize written;
-
- written = g_output_stream_splice_finish (G_OUTPUT_STREAM (source), result, NULL);
- if (written < 0)
- {
- gtk_drag_get_data_finish (data, NULL, 0);
- }
- else
- {
- gtk_drag_get_data_finish (data,
- g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (source)),
- g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (source)));
- }
-}
-
-static void
-gtk_drag_get_data_got_stream (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
-{
- GtkDragGetData *data = user_data;
- GInputStream *input_stream;
- GOutputStream *output_stream;
-
- input_stream = gdk_drop_read_finish (GDK_DROP (source), result, &data->mime_type, NULL);
- if (input_stream == NULL)
- {
- gtk_drag_get_data_finish (data, NULL, 0);
- return;
- }
-
- output_stream = g_memory_output_stream_new_resizable ();
- g_output_stream_splice_async (output_stream,
- input_stream,
- G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- G_PRIORITY_DEFAULT,
- NULL,
- gtk_drag_get_data_got_data,
- data);
- g_object_unref (output_stream);
- g_object_unref (input_stream);
-
-}
-
-/**
- * gtk_drag_get_data: (method)
- * @widget: the widget that will receive the
- * #GtkWidget::drag-data-received signal
- * @drop: the #GdkDrop
- * @target: the target (form of the data) to retrieve
- *
- * Gets the data associated with a drag. When the data
- * is received or the retrieval fails, GTK+ will emit a
- * #GtkWidget::drag-data-received signal. Failure of the retrieval
- * is indicated by the length field of the @selection_data
- * signal parameter being negative. However, when gtk_drag_get_data()
- * is called implicitely because the %GTK_DEST_DEFAULT_DROP was set,
- * then the widget will not receive notification of failed
- * drops.
- */
-void
-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_DROP (drop));
-
- data = g_slice_new0 (GtkDragGetData);
- data->widget = g_object_ref (widget);
- data->drop = g_object_ref (drop);
- data->mime_type = target;
-
- gdk_drop_read_async (drop,
- (const gchar *[2]) { target, NULL },
- G_PRIORITY_DEFAULT,
- NULL,
- gtk_drag_get_data_got_stream,
- data);
-}
-
/*
* _gtk_drag_dest_handle_event:
* @toplevel: Toplevel widget that received the event
@@ -591,33 +429,12 @@ gtk_drag_dest_drop (GtkWidget *widget,
{
GtkDragDestSite *site;
GtkDragDestInfo *info;
- GtkDestDefaults flags;
- gboolean retval;
site = g_object_get_data (G_OBJECT (widget), "gtk-drag-dest");
g_return_val_if_fail (site != NULL, FALSE);
- flags = gtk_drop_target_get_defaults (site->dest);
-
info = gtk_drag_get_dest_info (drop, FALSE);
g_return_val_if_fail (info != NULL, FALSE);
- if (flags & GTK_DEST_DEFAULT_DROP)
- {
- GdkAtom target;
-
- target = gtk_drop_target_match (site->dest, drop);
-
- if (target == NULL)
- {
- gdk_drop_finish (drop, 0);
- return TRUE;
- }
- else
- gtk_drag_get_data (widget, drop, target);
- }
-
- retval = gtk_drop_target_emit_drag_drop (site->dest, drop, x, y);
-
- return (flags & GTK_DEST_DEFAULT_DROP) ? TRUE : retval;
+ return gtk_drop_target_emit_drag_drop (site->dest, drop, x, y);
}
diff --git a/gtk/gtkdnd.h b/gtk/gtkdnd.h
index 28f60e3d3b..1fab2f4a92 100644
--- a/gtk/gtkdnd.h
+++ b/gtk/gtkdnd.h
@@ -39,11 +39,6 @@ G_BEGIN_DECLS
/* Destination side */
-GDK_AVAILABLE_IN_ALL
-void gtk_drag_get_data (GtkWidget *widget,
- GdkDrop *drop,
- GdkAtom target);
-
G_END_DECLS
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index 22e7519537..00cb19e6cc 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -391,19 +391,6 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
NULL,
G_TYPE_BOOLEAN, 2,
G_TYPE_INT, G_TYPE_INT);
-
- signals[DRAG_DATA_RECEIVED] =
- g_signal_new (I_("drag-data-received"),
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _gtk_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE);
- g_signal_set_va_marshaller (signals[DRAG_DATA_RECEIVED],
- G_TYPE_FROM_CLASS (class),
- _gtk_marshal_VOID__BOXEDv);
}
/**
@@ -756,15 +743,6 @@ gtk_drop_target_emit_drag_drop (GtkDropTarget *dest,
return result;
}
-void
-gtk_drop_target_emit_drag_data_received (GtkDropTarget *dest,
- GdkDrop *drop,
- GtkSelectionData *sdata)
-{
- set_drop (dest, drop);
- g_signal_emit (dest, signals[DRAG_DATA_RECEIVED], 0, sdata);
-}
-
/**
* gtk_drag_highlight: (method)
* @widget: a widget to highlight
diff --git a/gtk/gtkdragdest.h b/gtk/gtkdragdest.h
index 24190d8120..e28d5b3aa9 100644
--- a/gtk/gtkdragdest.h
+++ b/gtk/gtkdragdest.h
@@ -48,12 +48,7 @@ typedef struct _GtkDropTarget GtkDropTarget;
* @GTK_DEST_DEFAULT_HIGHLIGHT: If set for a widget, GTK+ will draw a highlight on
* this widget as long as a drag is over this widget and the widget drag format
* and action are acceptable.
- * @GTK_DEST_DEFAULT_OP: If set for a widget, when a drop occurs, GTK+ will
- * will check if the drag matches this widget’s list of possible formats and
- * actions. If so, GTK+ will call gtk_drag_get_data() on behalf of the widget.
- * Whether or not the drop is successful, GTK+ will call gdk_drag_finish(). If
- * the action was a move, then if the drag was successful, then %TRUE will be
- * passed for the @delete parameter to gdk_drag_finish().
+ * @GTK_DEST_DEFAULT_DROP: Does not do anything now.
* @GTK_DEST_DEFAULT_ALL: If set, specifies that all default actions should
* be taken.
*
@@ -65,7 +60,7 @@ typedef enum {
GTK_DEST_DEFAULT_MOTION = 1 << 0,
GTK_DEST_DEFAULT_HIGHLIGHT = 1 << 1,
GTK_DEST_DEFAULT_DROP = 1 << 2,
- GTK_DEST_DEFAULT_ALL = 0x07
+ GTK_DEST_DEFAULT_ALL = 0x7
} GtkDestDefaults;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]