selection: Remove the info uint

Instead of allowing people to pass a uint user-data, insist on them
comparing mime types.

The user data was a uint instead of a pointer anyway, so uniqueness
could not be guaranteed and it caused more issues than it was worth.
And that's ignoring the fact that it basically wasn't used.
This commit is contained in:
Benjamin Otte 2017-11-16 22:50:37 +01:00
parent 5da3059175
commit 3f5178dc21
45 changed files with 178 additions and 378 deletions

View File

@ -121,7 +121,6 @@ drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint32 time,
gpointer data)
{

View File

@ -166,7 +166,6 @@ palette_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time,
gpointer data)
{
@ -210,7 +209,6 @@ passive_canvas_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time,
gpointer data)
{
@ -285,7 +283,6 @@ interactive_canvas_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection,
guint info,
guint time,
gpointer data)
@ -566,8 +563,8 @@ do_toolpalette (GtkWidget *do_widget)
contents = gtk_drawing_area_new ();
g_object_connect (contents,
"signal::draw", canvas_draw, NULL,
"signal::drag-data-received", passive_canvas_drag_data_received, NULL,
"draw", canvas_draw, NULL,
"drag-data-received", passive_canvas_drag_data_received, NULL,
NULL);
gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette),
@ -592,11 +589,11 @@ do_toolpalette (GtkWidget *do_widget)
contents = gtk_drawing_area_new ();
g_object_connect (contents,
"signal::draw", canvas_draw, NULL,
"signal::drag-motion", interactive_canvas_drag_motion, NULL,
"signal::drag-data-received", interactive_canvas_drag_data_received, NULL,
"signal::drag-leave", interactive_canvas_drag_leave, contents,
"signal::drag-drop", interactive_canvas_drag_drop, NULL,
"draw", canvas_draw, NULL,
"drag-motion", interactive_canvas_drag_motion, NULL,
"drag-data-received", interactive_canvas_drag_data_received, NULL,
"drag-leave", interactive_canvas_drag_leave, contents,
"drag-drop", interactive_canvas_drag_drop, NULL,
NULL);
gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette),

View File

@ -6,7 +6,7 @@
/* Drag 'n Drop */
static GtkTargetEntry target_table[] = {
{ "text/uri-list", 0, 0 },
{ "text/uri-list", 0 },
};
typedef struct
@ -459,7 +459,7 @@ icon_browser_window_init (IconBrowserWindow *win)
gtk_widget_init_template (GTK_WIDGET (win));
list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (list, 0);
gtk_target_list_add_text_targets (list);
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
GDK_BUTTON1_MASK,
list,

View File

@ -304,14 +304,12 @@ static gboolean gtk_calendar_query_tooltip (GtkWidget *widget,
static void gtk_calendar_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time);
static void gtk_calendar_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time);
static gboolean gtk_calendar_drag_motion (GtkWidget *widget,
GdkDragContext *context,
@ -2650,7 +2648,7 @@ gtk_calendar_motion_notify (GtkWidget *widget,
{
GdkDragContext *context;
GtkTargetList *target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (target_list, 0);
gtk_target_list_add_text_targets (target_list);
context = gtk_drag_begin_with_coordinates (widget, target_list, GDK_ACTION_COPY,
1, (GdkEvent *)event,
priv->drag_start_x, priv->drag_start_y);
@ -2883,7 +2881,6 @@ static void
gtk_calendar_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkCalendar *calendar = GTK_CALENDAR (widget);
@ -2986,7 +2983,6 @@ gtk_calendar_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkCalendar *calendar = GTK_CALENDAR (widget);

View File

@ -189,14 +189,6 @@ static GtkClipboard *clipboard_peek (GdkDisplay *display,
static GtkWidget * get_clipboard_widget (GdkDisplay *display);
enum {
TARGET_STRING,
TARGET_TEXT,
TARGET_COMPOUND_TEXT,
TARGET_UTF8_STRING,
TARGET_SAVE_TARGETS
};
static const gchar request_contents_key[] = "gtk-request-contents";
static GQuark request_contents_key_id = 0;
@ -399,7 +391,6 @@ gtk_clipboard_get_default (GdkDisplay *display)
static void
selection_get_cb (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkClipboard *clipboard;
@ -408,7 +399,7 @@ selection_get_cb (GtkWidget *widget,
gtk_selection_data_get_selection (selection_data));
if (clipboard && clipboard->get_func)
clipboard->get_func (clipboard, selection_data, info, clipboard->user_data);
clipboard->get_func (clipboard, selection_data, clipboard->user_data);
}
static gboolean
@ -811,7 +802,6 @@ gtk_clipboard_real_clear (GtkClipboard *clipboard)
static void
text_get_func (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer data)
{
gtk_selection_data_set_text (selection_data, data, -1);
@ -848,7 +838,7 @@ gtk_clipboard_set_text (GtkClipboard *clipboard,
g_return_if_fail (text != NULL);
targets = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (targets, 0);
gtk_target_list_add_text_targets (targets);
if (len < 0)
len = strlen (text);
@ -865,7 +855,6 @@ gtk_clipboard_set_text (GtkClipboard *clipboard,
static void
pixbuf_get_func (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer data)
{
gtk_selection_data_set_pixbuf (selection_data, data);
@ -900,7 +889,7 @@ gtk_clipboard_set_image (GtkClipboard *clipboard,
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
targets = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (targets, 0, TRUE);
gtk_target_list_add_image_targets (targets, TRUE);
gtk_clipboard_set_with_data (clipboard,
targets,
@ -2155,8 +2144,7 @@ gtk_clipboard_real_set_can_store (GtkClipboard *clipboard,
{
gtk_selection_add_target (clipboard_widget,
clipboard->selection,
gdk_atom_intern_static_string ("SAVE_TARGETS"),
TARGET_SAVE_TARGETS);
gdk_atom_intern_static_string ("SAVE_TARGETS"));
/* Ref the owner so it won't go away */
if (clipboard->have_owner)

View File

@ -146,9 +146,6 @@ typedef void (* GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard,
* @clipboard: the #GtkClipboard
* @selection_data: a #GtkSelectionData argument in which the requested
* data should be stored.
* @info: the info field corresponding to the requested target from the
* #GtkTargetEntry array passed to gtk_clipboard_set_with_data() or
* gtk_clipboard_set_with_owner().
* @user_data_or_owner: the @user_data argument passed to
* gtk_clipboard_set_with_data(), or the @owner argument passed to
* gtk_clipboard_set_with_owner()
@ -164,7 +161,6 @@ typedef void (* GtkClipboardTargetsReceivedFunc) (GtkClipboard *clipboard,
*/
typedef void (* GtkClipboardGetFunc) (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer user_data_or_owner);
/**

View File

@ -114,7 +114,6 @@ static void gtk_color_button_drag_begin (GtkWidget *widget,
static void gtk_color_button_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
GtkColorButton *button);
@ -124,14 +123,13 @@ static void gtk_color_button_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint32 time,
GtkColorButton *button);
static guint color_button_signals[LAST_SIGNAL] = { 0 };
static const GtkTargetEntry drop_types[] = { { (char *) "application/x-color", 0, 0 } };
static const GtkTargetEntry drop_types[] = { { (char *) "application/x-color", 0 } };
static void gtk_color_button_iface_init (GtkColorChooserInterface *iface);
@ -292,7 +290,6 @@ gtk_color_button_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint32 time,
GtkColorButton *button)
{
@ -364,7 +361,6 @@ static void
gtk_color_button_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
GtkColorButton *button)
{

View File

@ -191,7 +191,6 @@ static void
swatch_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
@ -216,7 +215,6 @@ swatch_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
gint length;

View File

@ -110,7 +110,6 @@ struct _GtkDragFindData
@implementation GtkDragSourceOwner
-(void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
{
guint target_info;
GtkSelectionData selection_data;
selection_data.selection = NULL;
@ -120,13 +119,11 @@ struct _GtkDragFindData
selection_data.display = gdk_display_get_default ();
if (gtk_target_list_find (info->target_list,
selection_data.target,
&target_info))
selection_data.target))
{
g_signal_emit_by_name (info->widget, "drag-data-get",
info->context,
&selection_data,
target_info,
time);
if (selection_data.length >= 0)

View File

@ -134,12 +134,6 @@ typedef gboolean (* GtkDragDestCallback) (GtkWidget *widget,
gint y,
guint32 time);
/* Enumeration for some targets we handle internally */
enum {
TARGET_DELETE = 0x40000002
};
/* Forward declarations */
static void gtk_drag_get_event_actions (const GdkEvent *event,
gint button,
@ -203,7 +197,6 @@ static void gtk_drag_cancel_internal (GtkDragSourceInfo *info,
static void gtk_drag_selection_get (GtkWidget *widget,
GtkSelectionData *selection_data,
guint sel_info,
guint32 time,
gpointer data);
static void gtk_drag_remove_icon (GtkDragSourceInfo *info);
@ -823,11 +816,8 @@ gtk_drag_selection_received (GtkWidget *widget,
if (site && site->target_list)
{
guint target_info;
if (gtk_target_list_find (site->target_list,
target,
&target_info))
target))
{
if (!(site->flags & GTK_DEST_DEFAULT_DROP) ||
gtk_selection_data_get_length (selection_data) >= 0)
@ -835,7 +825,7 @@ gtk_drag_selection_received (GtkWidget *widget,
"drag-data-received",
context, info->drop_x, info->drop_y,
selection_data,
target_info, time);
time);
}
}
else
@ -844,7 +834,7 @@ gtk_drag_selection_received (GtkWidget *widget,
"drag-data-received",
context, info->drop_x, info->drop_y,
selection_data,
0, time);
time);
}
if (site && site->flags & GTK_DEST_DEFAULT_DROP)
@ -1810,15 +1800,13 @@ gtk_drag_source_check_selection (GtkDragSourceInfo *info,
gtk_selection_add_target (info->ipc_widget,
selection,
pair->target,
pair->info);
pair->target);
tmp_list = tmp_list->next;
}
gtk_selection_add_target (info->ipc_widget,
selection,
gdk_atom_intern_static_string ("DELETE"),
TARGET_DELETE);
gdk_atom_intern_static_string ("DELETE"));
}
@ -1889,7 +1877,6 @@ gtk_drag_drop (GtkDragSourceInfo *info,
g_signal_emit_by_name (info->widget, "drag-data-get",
info->context, &selection_data,
pair->info,
time);
/* FIXME: Should we check for length >= 0 here? */
@ -1921,37 +1908,29 @@ gtk_drag_drop (GtkDragSourceInfo *info,
static void
gtk_drag_selection_get (GtkWidget *widget,
GtkSelectionData *selection_data,
guint sel_info,
guint32 time,
gpointer data)
{
GtkDragSourceInfo *info = data;
static GdkAtom null_atom = NULL;
guint target_info;
if (!null_atom)
null_atom = gdk_atom_intern_static_string ("NULL");
switch (sel_info)
if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("DELETE"))
{
case TARGET_DELETE:
g_signal_emit_by_name (info->widget,
"drag-data-delete",
info->context);
gtk_selection_data_set (selection_data, null_atom, 8, NULL, 0);
break;
default:
if (gtk_target_list_find (info->target_list,
gtk_selection_data_get_target (selection_data),
&target_info))
{
g_signal_emit_by_name (info->widget, "drag-data-get",
info->context,
selection_data,
target_info,
time);
}
break;
}
else if (gtk_target_list_find (info->target_list,
gtk_selection_data_get_target (selection_data)))
{
g_signal_emit_by_name (info->widget, "drag-data-get",
info->context,
selection_data,
time);
}
}

View File

@ -273,7 +273,7 @@ gtk_drag_dest_add_text_targets (GtkWidget *widget)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (target_list, 0);
gtk_target_list_add_text_targets (target_list);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
@ -300,7 +300,7 @@ gtk_drag_dest_add_image_targets (GtkWidget *widget)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (target_list, 0, FALSE);
gtk_target_list_add_image_targets (target_list, FALSE);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
@ -327,7 +327,7 @@ gtk_drag_dest_add_uri_targets (GtkWidget *widget)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_uri_targets (target_list, 0);
gtk_target_list_add_uri_targets (target_list);
gtk_drag_dest_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}

View File

@ -290,7 +290,7 @@ gtk_drag_source_add_text_targets (GtkWidget *widget)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (target_list, 0);
gtk_target_list_add_text_targets (target_list);
gtk_drag_source_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
@ -317,7 +317,7 @@ gtk_drag_source_add_image_targets (GtkWidget *widget)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (target_list, 0, TRUE);
gtk_target_list_add_image_targets (target_list, TRUE);
gtk_drag_source_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}
@ -344,7 +344,7 @@ gtk_drag_source_add_uri_targets (GtkWidget *widget)
gtk_target_list_ref (target_list);
else
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_uri_targets (target_list, 0);
gtk_target_list_add_uri_targets (target_list);
gtk_drag_source_set_target_list (widget, target_list);
gtk_target_list_unref (target_list);
}

View File

@ -454,12 +454,10 @@ static void gtk_entry_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time);
static void gtk_entry_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time);
static void gtk_entry_drag_data_delete (GtkWidget *widget,
GdkDragContext *context);
@ -3882,7 +3880,7 @@ gtk_entry_drag_gesture_update (GtkGestureDrag *gesture,
guint actions = priv->editable ? GDK_ACTION_COPY | GDK_ACTION_MOVE : GDK_ACTION_COPY;
guint button;
gtk_target_list_add_text_targets (target_list, 0);
gtk_target_list_add_text_targets (target_list);
gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
@ -6529,7 +6527,6 @@ gtk_entry_paste (GtkEntry *entry,
static void
primary_get_cb (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer data)
{
GtkEntry *entry = GTK_ENTRY (data);
@ -6564,7 +6561,7 @@ gtk_entry_update_primary_selection (GtkEntry *entry)
return;
list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (list, 0);
gtk_target_list_add_text_targets (list);
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (entry), GDK_SELECTION_PRIMARY);
@ -8945,7 +8942,6 @@ gtk_entry_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkEntry *entry = GTK_ENTRY (widget);
@ -8995,7 +8991,6 @@ static void
gtk_entry_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkEntry *entry = GTK_ENTRY (widget);

View File

@ -213,17 +213,6 @@ struct _GtkFileChooserButtonPrivate
};
/* ************* *
* DnD Support *
* ************* */
enum
{
TEXT_PLAIN,
TEXT_URI_LIST
};
/* ********************* *
* Function Prototypes *
* ********************* */
@ -267,7 +256,6 @@ static void gtk_file_chooser_button_drag_data_received (GtkWidget *wi
gint x,
gint y,
GtkSelectionData *data,
guint type,
guint drag_time);
static void gtk_file_chooser_button_show (GtkWidget *widget);
static void gtk_file_chooser_button_hide (GtkWidget *widget);
@ -551,8 +539,8 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
/* DnD */
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_uri_targets (target_list, TEXT_URI_LIST);
gtk_target_list_add_text_targets (target_list, TEXT_PLAIN);
gtk_target_list_add_uri_targets (target_list);
gtk_target_list_add_text_targets (target_list);
gtk_drag_dest_set (GTK_WIDGET (button),
(GTK_DEST_DEFAULT_ALL),
target_list,
@ -1227,7 +1215,6 @@ gtk_file_chooser_button_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *data,
guint type,
guint drag_time)
{
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (widget);
@ -1239,55 +1226,48 @@ gtk_file_chooser_button_drag_data_received (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->drag_data_received (widget,
context,
x, y,
data, type,
data,
drag_time);
if (widget == NULL || context == NULL || data == NULL || gtk_selection_data_get_length (data) < 0)
return;
switch (type)
if (gtk_selection_data_targets_include_uri (data))
{
case TEXT_URI_LIST:
{
gchar **uris;
struct DndSelectFolderData *info;
gchar **uris;
struct DndSelectFolderData *info;
uris = gtk_selection_data_get_uris (data);
uris = gtk_selection_data_get_uris (data);
if (uris == NULL)
break;
if (uris != NULL)
{
info = g_new0 (struct DndSelectFolderData, 1);
info->button = g_object_ref (button);
info->i = 0;
info->uris = uris;
info->selected = FALSE;
info->file_system = priv->fs;
g_object_get (priv->chooser, "action", &info->action, NULL);
info = g_new0 (struct DndSelectFolderData, 1);
info->button = g_object_ref (button);
info->i = 0;
info->uris = uris;
info->selected = FALSE;
info->file_system = priv->fs;
g_object_get (priv->chooser, "action", &info->action, NULL);
info->file = g_file_new_for_uri (info->uris[info->i]);
info->file = g_file_new_for_uri (info->uris[info->i]);
if (priv->dnd_select_folder_cancellable)
g_cancellable_cancel (priv->dnd_select_folder_cancellable);
if (priv->dnd_select_folder_cancellable)
g_cancellable_cancel (priv->dnd_select_folder_cancellable);
priv->dnd_select_folder_cancellable =
_gtk_file_system_get_info (priv->fs, info->file,
"standard::type",
dnd_select_folder_get_info_cb, info);
}
break;
case TEXT_PLAIN:
priv->dnd_select_folder_cancellable =
_gtk_file_system_get_info (priv->fs, info->file,
"standard::type",
dnd_select_folder_get_info_cb, info);
}
}
else if (gtk_selection_data_targets_include_text (data))
{
text = (char*) gtk_selection_data_get_text (data);
file = g_file_new_for_uri (text);
gtk_file_chooser_select_file (GTK_FILE_CHOOSER (priv->chooser), file, NULL);
g_object_unref (file);
g_free (text);
g_signal_emit (button, file_chooser_button_signals[FILE_SET], 0);
break;
default:
break;
}
gtk_drag_finish (context, TRUE, FALSE, drag_time);

View File

@ -107,11 +107,6 @@
* GtkFileChooserWidget has a single CSS node with name filechooser.
*/
/* Values for GtkSelection-related "info" fields */
#define SELECTION_TEXT 0
#define SELECTION_URI 1
/* 150 mseconds of delay */
#define LOCATION_CHANGED_TIMEOUT 150
@ -1664,7 +1659,6 @@ rename_file_cb (GSimpleAction *action,
static void
copy_file_get_cb (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer data)
{
GSList *selected_files = data;
@ -1685,7 +1679,7 @@ copy_file_get_cb (GtkClipboard *clipboard,
{
GFile *file = (GFile *) l->data;
if (info == SELECTION_URI)
if (gtk_selection_data_targets_include_uri (selection_data))
uris[i] = g_file_get_uri (file);
else /* if (info == SELECTION_TEXT) - let this be the fallback */
uris[i] = g_file_get_parse_name (file);
@ -1693,7 +1687,7 @@ copy_file_get_cb (GtkClipboard *clipboard,
i++;
}
if (info == SELECTION_URI)
if (gtk_selection_data_targets_include_uri (selection_data))
gtk_selection_data_set_uris (selection_data, uris);
else /* if (info == SELECTION_TEXT) - let this be the fallback */
{
@ -1735,8 +1729,8 @@ copy_file_location_cb (GSimpleAction *action,
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (impl), GDK_SELECTION_CLIPBOARD);
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (target_list, SELECTION_TEXT);
gtk_target_list_add_uri_targets (target_list, SELECTION_URI);
gtk_target_list_add_text_targets (target_list);
gtk_target_list_add_uri_targets (target_list);
gtk_clipboard_set_with_data (clipboard, target_list,
copy_file_get_cb,
@ -2003,7 +1997,6 @@ file_list_drag_data_received_cb (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time_,
gpointer user_data)
{

View File

@ -279,7 +279,6 @@ static void gtk_icon_view_drag_end (GtkWidget *widget,
static void gtk_icon_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time);
static void gtk_icon_view_drag_data_delete (GtkWidget *widget,
GdkDragContext *context);
@ -303,7 +302,6 @@ static void gtk_icon_view_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time);
static gboolean gtk_icon_view_maybe_begin_drag (GtkIconView *icon_view,
GdkEventMotion *event);
@ -6257,7 +6255,6 @@ static void
gtk_icon_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkIconView *icon_view;
@ -6470,7 +6467,6 @@ gtk_icon_view_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkTreePath *path;
@ -6900,7 +6896,7 @@ gtk_icon_view_get_reorderable (GtkIconView *icon_view)
}
static const GtkTargetEntry item_targets[] = {
{ (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
{ (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET }
};

View File

@ -471,7 +471,6 @@ static void gtk_label_setup_mnemonic (GtkLabel *label,
static void gtk_label_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time);
static void gtk_label_buildable_interface_init (GtkBuildableIface *iface);
@ -4779,7 +4778,7 @@ gtk_label_drag_gesture_update (GtkGestureDrag *gesture,
const GdkEvent *event;
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
gtk_target_list_add_text_targets (target_list, 0);
gtk_target_list_add_text_targets (target_list);
g_signal_connect (widget, "drag-begin",
G_CALLBACK (drag_begin_cb), NULL);
@ -5113,7 +5112,6 @@ static void
gtk_label_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
gtk_label_set_selection_text (GTK_LABEL (widget), selection_data);
@ -5122,7 +5120,6 @@ gtk_label_drag_data_get (GtkWidget *widget,
static void
get_text_callback (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer user_data_or_owner)
{
gtk_label_set_selection_text (GTK_LABEL (user_data_or_owner), selection_data);
@ -5232,7 +5229,7 @@ gtk_label_select_region_index (GtkLabel *label,
GtkTargetList *list;
list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (list, 0);
gtk_target_list_add_text_targets (list);
if (clipboard)
gtk_clipboard_set_with_owner (clipboard,

View File

@ -109,7 +109,6 @@ static gboolean gtk_link_button_popup_menu (GtkWidget *widget);
static void gtk_link_button_drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection,
guint _info,
guint _time,
gpointer user_data);
static gboolean gtk_link_button_query_tooltip_cb (GtkWidget *widget,
@ -130,8 +129,8 @@ static void set_hand_cursor (GtkWidget *widget,
gboolean show_hand);
static const GtkTargetEntry link_drop_types[] = {
{ (char *) "text/uri-list", 0, 0 },
{ (char *) "_NETSCAPE_URL", 0, 0 }
{ (char *) "text/uri-list", 0 },
{ (char *) "_NETSCAPE_URL", 0 }
};
static guint link_signals[LAST_SIGNAL] = { 0, };
@ -452,7 +451,6 @@ static void
gtk_link_button_drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection,
guint _info,
guint _time,
gpointer user_data)
{

View File

@ -59,7 +59,6 @@ VOID:BOXED,OBJECT
VOID:BOXED,STRING,INT
VOID:BOXED,UINT
VOID:BOXED,UINT,FLAGS
VOID:BOXED,UINT,UINT
VOID:ENUM,BOOLEAN
VOID:ENUM,ENUM
VOID:ENUM,FLOAT
@ -75,14 +74,14 @@ VOID:INT,INT,BOXED
VOID:INT,INT,INT
VOID:OBJECT,BOOLEAN
VOID:OBJECT,BOXED,BOXED
VOID:OBJECT,BOXED,UINT,UINT
VOID:OBJECT,BOXED,UINT
VOID:OBJECT,BOXED,BOOLEAN,BOOLEAN
VOID:OBJECT,ENUM
VOID:OBJECT,FLAGS
VOID:OBJECT,INT
VOID:OBJECT,INT,OBJECT
VOID:OBJECT,INT,INT
VOID:OBJECT,INT,INT,BOXED,UINT,UINT
VOID:OBJECT,INT,INT,BOXED,UINT
VOID:OBJECT,OBJECT
VOID:OBJECT,POINTER
VOID:OBJECT,POINTER,INT

View File

@ -309,12 +309,12 @@ struct _GtkNotebookPage
};
static const GtkTargetEntry src_notebook_targets [] = {
{ (char *) "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
{ (char *) "application/x-rootwindow-drop", 0, 0 },
{ (char *) "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP },
{ (char *) "application/x-rootwindow-drop", 0 },
};
static const GtkTargetEntry dst_notebook_targets [] = {
{ (char *) "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
{ (char *) "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP },
};
/*** GtkNotebook Methods ***/
@ -402,14 +402,12 @@ static gboolean gtk_notebook_drag_drop (GtkWidget *widget,
static void gtk_notebook_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *data,
guint info,
guint time);
static void gtk_notebook_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time);
static void gtk_notebook_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
@ -3274,7 +3272,6 @@ static void
gtk_notebook_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *data,
guint info,
guint time)
{
GtkNotebook *notebook = GTK_NOTEBOOK (widget);
@ -3304,7 +3301,6 @@ gtk_notebook_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time)
{
GtkNotebook *notebook;
@ -7137,7 +7133,6 @@ gtk_notebook_get_tab_detachable (GtkNotebook *notebook,
* gint x,
* gint y,
* GtkSelectionData *data,
* guint info,
* guint time,
* gpointer user_data)
* {

View File

@ -1474,7 +1474,6 @@ static void
button_drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time_,
gpointer data)
{

View File

@ -313,12 +313,12 @@ enum {
/* Target types for dragging from the shortcuts list */
static const GtkTargetEntry dnd_source_targets[] = {
{ (char *) "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_GTK_SIDEBAR_ROW }
{ (char *) "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET }
};
/* Target types for dropping into the shortcuts list */
static const GtkTargetEntry dnd_drop_targets [] = {
{ (char *) "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_GTK_SIDEBAR_ROW }
{ (char *) "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET }
};
G_DEFINE_TYPE (GtkPlacesSidebar, gtk_places_sidebar, GTK_TYPE_SCROLLED_WINDOW);
@ -1972,8 +1972,6 @@ static void
drag_data_get_callback (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *data,
guint info,
guint time,
gpointer user_data)
{
GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
@ -1995,7 +1993,6 @@ drag_data_received_callback (GtkWidget *list_box,
int x,
int y,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer user_data)
{
@ -2009,8 +2006,7 @@ drag_data_received_callback (GtkWidget *list_box,
if (!sidebar->drag_data_received)
{
if (gtk_selection_data_get_target (selection_data) != NULL &&
info == DND_TEXT_URI_LIST)
if (gtk_selection_data_targets_include_uri (selection_data))
{
gchar **uris;
@ -2020,13 +2016,15 @@ drag_data_received_callback (GtkWidget *list_box,
g_list_free_full (sidebar->drag_list, g_object_unref);
sidebar->drag_list = build_file_list_from_uris ((const char **) uris);
g_strfreev (uris);
sidebar->drag_data_info = DND_TEXT_URI_LIST;
}
else
{
sidebar->drag_list = NULL;
if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("DND_GTK_SIDEBAR_ROW"))
sidebar->drag_data_info = DND_GTK_SIDEBAR_ROW;
}
sidebar->drag_data_received = TRUE;
sidebar->drag_data_info = info;
}
g_signal_stop_emission_by_name (list_box, "drag-data-received");
@ -4075,11 +4073,11 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
NULL,
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
target_list = gtk_target_list_new (dnd_drop_targets, G_N_ELEMENTS (dnd_drop_targets));
gtk_target_list_add_uri_targets (target_list, DND_TEXT_URI_LIST);
gtk_target_list_add_uri_targets (target_list);
gtk_drag_dest_set_target_list (sidebar->list_box, target_list);
gtk_target_list_unref (target_list);
sidebar->source_targets = gtk_target_list_new (dnd_source_targets, G_N_ELEMENTS (dnd_source_targets));
gtk_target_list_add_text_targets (sidebar->source_targets, 0);
gtk_target_list_add_text_targets (sidebar->source_targets);
g_signal_connect (sidebar->list_box, "motion-notify-event",
G_CALLBACK (on_motion_notify_event), sidebar);

View File

@ -295,15 +295,13 @@ gtk_target_list_unref (GtkTargetList *list)
* @list: a #GtkTargetList
* @target: the interned atom representing the target
* @flags: the flags for this target
* @info: an ID that will be passed back to the application
*
* Appends another target to a #GtkTargetList.
**/
void
gtk_target_list_add (GtkTargetList *list,
GdkAtom target,
guint flags,
guint info)
guint flags)
{
GtkTargetPair *pair;
@ -312,7 +310,6 @@ gtk_target_list_add (GtkTargetList *list,
pair = g_slice_new (GtkTargetPair);
pair->target = target;
pair->flags = flags;
pair->info = info;
list->list = g_list_append (list->list, pair);
}
@ -350,7 +347,6 @@ init_atoms (void)
/**
* gtk_target_list_add_text_targets:
* @list: a #GtkTargetList
* @info: an ID that will be passed back to the application
*
* Appends the text targets supported by #GtkSelectionData to
* the target list. All targets are added with the same @info.
@ -358,8 +354,7 @@ init_atoms (void)
* Since: 2.6
**/
void
gtk_target_list_add_text_targets (GtkTargetList *list,
guint info)
gtk_target_list_add_text_targets (GtkTargetList *list)
{
g_return_if_fail (list != NULL);
@ -367,20 +362,19 @@ gtk_target_list_add_text_targets (GtkTargetList *list,
/* Keep in sync with gtk_selection_data_targets_include_text()
*/
gtk_target_list_add (list, utf8_atom, 0, info);
gtk_target_list_add (list, ctext_atom, 0, info);
gtk_target_list_add (list, text_atom, 0, info);
gtk_target_list_add (list, GDK_TARGET_STRING, 0, info);
gtk_target_list_add (list, text_plain_utf8_atom, 0, info);
gtk_target_list_add (list, utf8_atom, 0);
gtk_target_list_add (list, ctext_atom, 0);
gtk_target_list_add (list, text_atom, 0);
gtk_target_list_add (list, GDK_TARGET_STRING, 0);
gtk_target_list_add (list, text_plain_utf8_atom, 0);
if (!g_get_charset (NULL))
gtk_target_list_add (list, text_plain_locale_atom, 0, info);
gtk_target_list_add (list, text_plain_atom, 0, info);
gtk_target_list_add (list, text_plain_locale_atom, 0);
gtk_target_list_add (list, text_plain_atom, 0);
}
/**
* gtk_target_list_add_rich_text_targets:
* @list: a #GtkTargetList
* @info: an ID that will be passed back to the application
* @deserializable: if %TRUE, then deserializable rich text formats
* will be added, serializable formats otherwise.
* @buffer: a #GtkTextBuffer.
@ -394,7 +388,6 @@ gtk_target_list_add_text_targets (GtkTargetList *list,
**/
void
gtk_target_list_add_rich_text_targets (GtkTargetList *list,
guint info,
gboolean deserializable,
GtkTextBuffer *buffer)
{
@ -411,7 +404,7 @@ gtk_target_list_add_rich_text_targets (GtkTargetList *list,
atoms = gtk_text_buffer_get_serialize_formats (buffer, &n_atoms);
for (i = 0; i < n_atoms; i++)
gtk_target_list_add (list, atoms[i], 0, info);
gtk_target_list_add (list, atoms[i], 0);
g_free (atoms);
}
@ -419,7 +412,6 @@ gtk_target_list_add_rich_text_targets (GtkTargetList *list,
/**
* gtk_target_list_add_image_targets:
* @list: a #GtkTargetList
* @info: an ID that will be passed back to the application
* @writable: whether to add only targets for which GTK+ knows
* how to convert a pixbuf into the format
*
@ -430,7 +422,6 @@ gtk_target_list_add_rich_text_targets (GtkTargetList *list,
**/
void
gtk_target_list_add_image_targets (GtkTargetList *list,
guint info,
gboolean writable)
{
GSList *formats, *f;
@ -472,7 +463,7 @@ gtk_target_list_add_image_targets (GtkTargetList *list,
for (m = mimes; *m; m++)
{
atom = gdk_atom_intern (*m, FALSE);
gtk_target_list_add (list, atom, 0, info);
gtk_target_list_add (list, atom, 0);
}
g_strfreev (mimes);
}
@ -491,14 +482,13 @@ gtk_target_list_add_image_targets (GtkTargetList *list,
* Since: 2.6
**/
void
gtk_target_list_add_uri_targets (GtkTargetList *list,
guint info)
gtk_target_list_add_uri_targets (GtkTargetList *list)
{
g_return_if_fail (list != NULL);
init_atoms ();
gtk_target_list_add (list, text_uri_list_atom, 0, info);
gtk_target_list_add (list, text_uri_list_atom, 0);
}
/**
@ -543,7 +533,6 @@ gtk_target_list_add_table (GtkTargetList *list,
GtkTargetPair *pair = g_slice_new (GtkTargetPair);
pair->target = gdk_atom_intern (targets[i].target, FALSE);
pair->flags = targets[i].flags;
pair->info = targets[i].info;
list->list = g_list_prepend (list->list, pair);
}
@ -587,8 +576,6 @@ gtk_target_list_remove (GtkTargetList *list,
* gtk_target_list_find:
* @list: a #GtkTargetList
* @target: an interned atom representing the target to search for
* @info: (out) (allow-none): a pointer to the location to store
* application info for target, or %NULL
*
* Looks up a given target in a #GtkTargetList.
*
@ -596,8 +583,7 @@ gtk_target_list_remove (GtkTargetList *list,
**/
gboolean
gtk_target_list_find (GtkTargetList *list,
GdkAtom target,
guint *info)
GdkAtom target)
{
GList *tmp_list;
@ -609,12 +595,7 @@ gtk_target_list_find (GtkTargetList *list,
GtkTargetPair *pair = tmp_list->data;
if (pair->target == target)
{
if (info)
*info = pair->info;
return TRUE;
}
return TRUE;
tmp_list = tmp_list->next;
}
@ -885,7 +866,6 @@ gtk_selection_clear_targets (GtkWidget *widget,
* @widget: a #GtkWidget
* @selection: the selection
* @target: target to add.
* @info: A unsigned integer which will be passed back to the application.
*
* Appends a specified target to the list of supported targets for a
* given widget and selection.
@ -893,8 +873,7 @@ gtk_selection_clear_targets (GtkWidget *widget,
void
gtk_selection_add_target (GtkWidget *widget,
GdkAtom selection,
GdkAtom target,
guint info)
GdkAtom target)
{
GtkTargetList *list;
@ -902,7 +881,7 @@ gtk_selection_add_target (GtkWidget *widget,
g_return_if_fail (selection != NULL);
list = gtk_selection_target_list_get (widget, selection);
gtk_target_list_add (list, target, 0, info);
gtk_target_list_add (list, target, 0);
gdk_selection_add_targets (gtk_widget_get_window (widget), selection, &target, 1);
}
@ -2118,7 +2097,7 @@ gtk_targets_include_image (GdkAtom *targets,
g_return_val_if_fail (targets != NULL || n_targets == 0, FALSE);
list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (list, 0, writable);
gtk_target_list_add_image_targets (list, writable);
for (i = 0; i < n_targets && !result; i++)
{
for (l = list->list; l; l = l->next)
@ -3080,20 +3059,18 @@ gtk_selection_invoke_handler (GtkWidget *widget,
guint time)
{
GtkTargetList *target_list;
guint info;
g_return_if_fail (widget != NULL);
target_list = gtk_selection_target_list_get (widget, data->selection);
if (data->target != gtk_selection_atoms[SAVE_TARGETS] &&
target_list &&
gtk_target_list_find (target_list, data->target, &info))
gtk_target_list_find (target_list, data->target))
{
g_signal_emit_by_name (widget,
"selection-get",
data,
info, time);
time);
}
else
gtk_selection_default_handler (widget, data);

View File

@ -53,7 +53,6 @@ struct _GtkTargetPair
{
GdkAtom target;
guint flags;
guint info;
};
/**
@ -107,7 +106,6 @@ struct _GtkTargetEntry
{
gchar *target;
guint flags;
guint info;
};
GDK_AVAILABLE_IN_ALL
@ -125,23 +123,18 @@ void gtk_target_list_merge (GtkTargetList *target,
GDK_AVAILABLE_IN_ALL
void gtk_target_list_add (GtkTargetList *list,
GdkAtom target,
guint flags,
guint info);
guint flags);
GDK_AVAILABLE_IN_ALL
void gtk_target_list_add_text_targets (GtkTargetList *list,
guint info);
void gtk_target_list_add_text_targets (GtkTargetList *list);
GDK_AVAILABLE_IN_ALL
void gtk_target_list_add_rich_text_targets (GtkTargetList *list,
guint info,
gboolean deserializable,
GtkTextBuffer *buffer);
GDK_AVAILABLE_IN_ALL
void gtk_target_list_add_image_targets (GtkTargetList *list,
guint info,
gboolean writable);
GDK_AVAILABLE_IN_ALL
void gtk_target_list_add_uri_targets (GtkTargetList *list,
guint info);
void gtk_target_list_add_uri_targets (GtkTargetList *list);
GDK_AVAILABLE_IN_ALL
void gtk_target_list_add_table (GtkTargetList *list,
const GtkTargetEntry *targets,
@ -151,8 +144,7 @@ void gtk_target_list_remove (GtkTargetList *list,
GdkAtom target);
GDK_AVAILABLE_IN_ALL
gboolean gtk_target_list_find (GtkTargetList *list,
GdkAtom target,
guint *info);
GdkAtom target);
GDK_AVAILABLE_IN_ALL
gboolean gtk_selection_owner_set (GtkWidget *widget,
@ -167,8 +159,7 @@ gboolean gtk_selection_owner_set_for_display (GdkDisplay *display,
GDK_AVAILABLE_IN_ALL
void gtk_selection_add_target (GtkWidget *widget,
GdkAtom selection,
GdkAtom target,
guint info);
GdkAtom target);
GDK_AVAILABLE_IN_ALL
void gtk_selection_add_targets (GtkWidget *widget,
GdkAtom selection,

View File

@ -3204,7 +3204,6 @@ clipboard_clear_selection_cb (GtkClipboard *clipboard,
static void
clipboard_get_selection_cb (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer data)
{
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (data);
@ -3212,7 +3211,7 @@ clipboard_get_selection_cb (GtkClipboard *clipboard,
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
{
if (info == GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS)
if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"))
{
/* Provide the address of the buffer; this will only be
* used within-process
@ -3223,7 +3222,7 @@ clipboard_get_selection_cb (GtkClipboard *clipboard,
(void*)&buffer,
sizeof (buffer));
}
else if (info == GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT)
else if (gtk_selection_data_targets_include_rich_text (selection_data, buffer))
{
guint8 *str;
gsize len;
@ -3238,7 +3237,7 @@ clipboard_get_selection_cb (GtkClipboard *clipboard,
str, len);
g_free (str);
}
else
else if (gtk_selection_data_targets_include_text (selection_data))
{
gchar *str;
@ -3275,14 +3274,13 @@ create_clipboard_contents_buffer (GtkTextBuffer *buffer)
static void
clipboard_get_contents_cb (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer data)
{
GtkTextBuffer *contents = GTK_TEXT_BUFFER (data);
g_assert (contents); /* This should never be called unless we own the clipboard */
if (info == GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS)
if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"))
{
/* Provide the address of the clipboard buffer; this will only
* be used within-process. OK to supply a NULL value for contents.
@ -3293,7 +3291,7 @@ clipboard_get_contents_cb (GtkClipboard *clipboard,
(void*)&contents,
sizeof (contents));
}
else if (info == GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT)
else if (gtk_selection_data_targets_include_rich_text (selection_data, contents))
{
GtkTextBuffer *clipboard_source_buffer;
GtkTextIter start, end;
@ -4014,16 +4012,13 @@ gtk_text_buffer_get_target_list (GtkTextBuffer *buffer,
if (include_local)
gtk_target_list_add (target_list,
gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"),
GTK_TARGET_SAME_APP,
GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS);
GTK_TARGET_SAME_APP);
gtk_target_list_add_rich_text_targets (target_list,
GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT,
deserializable,
buffer);
gtk_target_list_add_text_targets (target_list,
GTK_TEXT_BUFFER_TARGET_INFO_TEXT);
gtk_target_list_add_text_targets (target_list);
return target_list;
}

View File

@ -436,7 +436,6 @@ static void gtk_text_view_drag_end (GtkWidget *widget,
static void gtk_text_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time);
static void gtk_text_view_drag_data_delete (GtkWidget *widget,
GdkDragContext *context);
@ -460,7 +459,6 @@ static void gtk_text_view_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time);
static gboolean gtk_text_view_popup_menu (GtkWidget *widget);
@ -7840,13 +7838,12 @@ static void
gtk_text_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
GtkTextBuffer *buffer = gtk_text_view_get_buffer (text_view);
if (info == GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS)
if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"))
{
gtk_selection_data_set (selection_data,
gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"),
@ -7854,7 +7851,7 @@ gtk_text_view_drag_data_get (GtkWidget *widget,
(void*)&buffer,
sizeof (buffer));
}
else if (info == GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT)
else if (gtk_selection_data_targets_include_rich_text (selection_data, buffer))
{
GtkTextIter start;
GtkTextIter end;
@ -8103,7 +8100,6 @@ gtk_text_view_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkTextIter drop_point;
@ -8131,7 +8127,7 @@ gtk_text_view_drag_data_received (GtkWidget *widget,
gtk_text_buffer_begin_user_action (buffer);
if (info == GTK_TEXT_BUFFER_TARGET_INFO_BUFFER_CONTENTS)
if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"))
{
GtkTextBuffer *src_buffer = NULL;
GtkTextIter start, end;
@ -8205,7 +8201,7 @@ gtk_text_view_drag_data_received (GtkWidget *widget,
}
}
else if (gtk_selection_data_get_length (selection_data) > 0 &&
info == GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT)
gtk_selection_data_targets_include_rich_text (selection_data, buffer))
{
gboolean retval;
GError *error = NULL;

View File

@ -181,8 +181,8 @@ static GdkAtom dnd_target_atom_group = NULL;
static const GtkTargetEntry dnd_targets[] =
{
{ (char *) "application/x-gtk-tool-palette-item", GTK_TARGET_SAME_APP, 0 },
{ (char *) "application/x-gtk-tool-palette-group", GTK_TARGET_SAME_APP, 0 },
{ (char *) "application/x-gtk-tool-palette-item", GTK_TARGET_SAME_APP },
{ (char *) "application/x-gtk-tool-palette-group", GTK_TARGET_SAME_APP },
};
static void gtk_tool_palette_set_hadjustment (GtkToolPalette *palette,
@ -1519,7 +1519,6 @@ static void
gtk_tool_palette_item_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection,
guint info,
guint time,
gpointer data)
{

View File

@ -634,7 +634,6 @@ static void gtk_tree_view_drag_end (GtkWidget *widget,
static void gtk_tree_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time);
static void gtk_tree_view_drag_data_delete (GtkWidget *widget,
GdkDragContext *context);
@ -658,7 +657,6 @@ static void gtk_tree_view_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time);
/* tree_model signals */
@ -7572,7 +7570,6 @@ static void
gtk_tree_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkTreeView *tree_view;
@ -7816,7 +7813,6 @@ gtk_tree_view_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time)
{
GtkTreePath *path;
@ -12547,7 +12543,7 @@ gtk_tree_view_set_reorderable (GtkTreeView *tree_view,
if (reorderable)
{
const GtkTargetEntry row_targets[] = {
{ (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
{ (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET }
};
GtkTargetList *targets;

View File

@ -2532,10 +2532,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, selection_get),
NULL, NULL,
_gtk_marshal_VOID__BOXED_UINT_UINT,
G_TYPE_NONE, 3,
_gtk_marshal_VOID__BOXED_UINT,
G_TYPE_NONE, 2,
GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_UINT,
G_TYPE_UINT);
/**
@ -2871,11 +2870,10 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_get),
NULL, NULL,
_gtk_marshal_VOID__OBJECT_BOXED_UINT_UINT,
G_TYPE_NONE, 4,
_gtk_marshal_VOID__OBJECT_BOXED_UINT,
G_TYPE_NONE, 3,
GDK_TYPE_DRAG_CONTEXT,
GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_UINT,
G_TYPE_UINT);
/**
@ -2885,8 +2883,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
* @x: where the drop happened
* @y: where the drop happened
* @data: the received data
* @info: the info that has been registered with the target in the
* #GtkTargetList
* @time: the timestamp at which the data was received
*
* The ::drag-data-received signal is emitted on the drop site when the
@ -2956,13 +2952,12 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkWidgetClass, drag_data_received),
NULL, NULL,
_gtk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT_UINT,
G_TYPE_NONE, 6,
_gtk_marshal_VOID__OBJECT_INT_INT_BOXED_UINT,
G_TYPE_NONE, 5,
GDK_TYPE_DRAG_CONTEXT,
G_TYPE_INT,
G_TYPE_INT,
GTK_TYPE_SELECTION_DATA | G_SIGNAL_TYPE_STATIC_SCOPE,
G_TYPE_UINT,
G_TYPE_UINT);
/**

View File

@ -392,7 +392,6 @@ struct _GtkWidgetClass
/* selection */
void (* selection_get) (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time_);
void (* selection_received) (GtkWidget *widget,
GtkSelectionData *selection_data,
@ -406,7 +405,6 @@ struct _GtkWidgetClass
void (* drag_data_get) (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time_);
void (* drag_data_delete) (GtkWidget *widget,
GdkDragContext *context);
@ -430,7 +428,6 @@ struct _GtkWidgetClass
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint time_);
gboolean (* drag_failed) (GtkWidget *widget,
GdkDragContext *context,

View File

@ -278,7 +278,7 @@ struct _GtkWindowPrivate
};
static const GtkTargetEntry dnd_dest_targets [] = {
{ (char *) "application/x-rootwindow-drop", 0, 0 },
{ (char *) "application/x-rootwindow-drop", 0 },
};
enum {

View File

@ -289,15 +289,10 @@ GdkPixbuf *trashcan_closed;
gboolean have_drag;
enum {
TARGET_STRING,
TARGET_ROOTWIN
};
static GtkTargetEntry target_table[] = {
{ "STRING", 0, TARGET_STRING },
{ "text/plain", 0, TARGET_STRING },
{ "application/x-rootwindow-drop", 0, TARGET_ROOTWIN }
{ "STRING", 0 },
{ "text/plain", 0 },
{ "application/x-rootwindow-drop", 0 }
};
static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
@ -415,11 +410,10 @@ void
source_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
if (info == TARGET_ROOTWIN)
if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("application/x-rootwindow-drop"))
g_print ("I was dropped on the rootwin\n");
else
gtk_selection_data_set (selection_data,

View File

@ -27,11 +27,6 @@ get_image_surface (GtkImage *image,
}
}
enum {
TARGET_IMAGE,
TARGET_TEXT
};
enum {
TOP_LEFT,
CENTER,
@ -129,9 +124,9 @@ update_source_target_list (GtkWidget *image)
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (target_list, TARGET_IMAGE, FALSE);
gtk_target_list_add_image_targets (target_list, FALSE);
if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME)
gtk_target_list_add_text_targets (target_list, TARGET_TEXT);
gtk_target_list_add_text_targets (target_list);
gtk_drag_source_set_target_list (image, target_list);
@ -145,8 +140,8 @@ update_dest_target_list (GtkWidget *image)
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_image_targets (target_list, TARGET_IMAGE, FALSE);
gtk_target_list_add_text_targets (target_list, TARGET_TEXT);
gtk_target_list_add_image_targets (target_list, FALSE);
gtk_target_list_add_text_targets (target_list);
gtk_drag_dest_set_target_list (image, target_list);
@ -157,7 +152,6 @@ void
image_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
@ -165,20 +159,21 @@ image_drag_data_get (GtkWidget *widget,
const gchar *name;
int size;
switch (info)
if (gtk_selection_data_targets_include_image (selection_data, TRUE))
{
case TARGET_IMAGE:
surface = get_image_surface (GTK_IMAGE (data), &size);
gtk_selection_data_set_surface (selection_data, surface);
break;
case TARGET_TEXT:
}
else if (gtk_selection_data_targets_include_text (selection_data))
{
if (gtk_image_get_storage_type (GTK_IMAGE (data)) == GTK_IMAGE_ICON_NAME)
name = gtk_image_get_icon_name (GTK_IMAGE (data));
else
name = "Boo!";
gtk_selection_data_set_text (selection_data, name, -1);
break;
default:
}
else
{
g_assert_not_reached ();
}
}
@ -189,7 +184,6 @@ image_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint32 time,
gpointer data)
{
@ -199,19 +193,20 @@ image_drag_data_received (GtkWidget *widget,
if (gtk_selection_data_get_length (selection_data) == 0)
return;
switch (info)
if (gtk_selection_data_targets_include_image (selection_data, FALSE))
{
case TARGET_IMAGE:
surface = gtk_selection_data_get_surface (selection_data);
gtk_image_set_from_surface (GTK_IMAGE (data), surface);
cairo_surface_destroy (surface);
break;
case TARGET_TEXT:
}
else if (gtk_selection_data_targets_include_text (selection_data))
{
text = (gchar *)gtk_selection_data_get_text (selection_data);
gtk_image_set_from_icon_name (GTK_IMAGE (data), text);
g_free (text);
break;
default:
}
else
{
g_assert_not_reached ();
}
}
@ -312,7 +307,6 @@ void
spinner_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{

View File

@ -24,7 +24,6 @@ static void
drag_data_get_cb (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *data,
guint info,
guint time,
gpointer user_data)
{
@ -168,7 +167,7 @@ main (int argc, char **argv)
GTK_ENTRY_ICON_PRIMARY,
"Save a file");
tlist = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (tlist, 0);
gtk_target_list_add_text_targets (tlist);
gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
tlist, GDK_ACTION_COPY);

View File

@ -412,7 +412,7 @@ popup_menu_handler (GtkWidget *widget)
}
static const GtkTargetEntry item_targets[] = {
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, 0 }
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP }
};
gint

View File

@ -34,7 +34,6 @@ void
drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{

View File

@ -1,13 +1,8 @@
#include <gtk/gtk.h>
enum
{
TARGET_GTK_TREE_MODEL_ROW
};
static GtkTargetEntry row_targets[] =
{
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, TARGET_GTK_TREE_MODEL_ROW }
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP }
};
static void

View File

@ -1,7 +1,7 @@
#include <gtk/gtk.h>
static GtkTargetEntry entries[] = {
{ "GTK_LIST_BOX_ROW", GTK_TARGET_SAME_APP, 0 }
{ "GTK_LIST_BOX_ROW", GTK_TARGET_SAME_APP }
};
static void
@ -37,7 +37,6 @@ void
drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
@ -55,7 +54,6 @@ drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *selection_data,
guint info,
guint32 time,
gpointer data)
{

View File

@ -56,7 +56,7 @@ gchar *tabs4 [] = {
};
static const GtkTargetEntry button_targets[] = {
{ "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
{ "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP },
};
static GtkNotebook*
@ -126,7 +126,6 @@ on_button_drag_data_received (GtkWidget *widget,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time,
gpointer user_data)
{

View File

@ -161,13 +161,11 @@ selection_toggled (GtkWidget *widget)
void
selection_get (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time,
gpointer data)
{
guchar *buffer;
gint len;
GdkAtom type = NULL;
if (!selection_string)
{
@ -180,18 +178,9 @@ selection_get (GtkWidget *widget,
len = selection_string->len;
}
switch (info)
{
case COMPOUND_TEXT:
case TEXT:
type = seltypes[COMPOUND_TEXT];
break;
case STRING:
type = seltypes[STRING];
break;
}
gtk_selection_data_set (selection_data, type, 8, buffer, len);
gtk_selection_data_set (selection_data,
gtk_selection_data_get_target (selection_data),
8, buffer, len);
}
gint
@ -396,9 +385,9 @@ main (int argc, char *argv[])
GtkWidget *scrolled;
static GtkTargetEntry targetlist[] = {
{ "STRING", 0, STRING },
{ "TEXT", 0, TEXT },
{ "COMPOUND_TEXT", 0, COMPOUND_TEXT }
{ "STRING", 0 },
{ "TEXT", 0 },
{ "COMPOUND_TEXT", 0 }
};
static gint ntargets = sizeof(targetlist) / sizeof(targetlist[0]);
GtkTargetList *list;

View File

@ -306,7 +306,7 @@ toolbar_drag_drop (GtkWidget *widget, GdkDragContext *context,
}
static GtkTargetEntry target_table[] = {
{ "application/x-toolbar-item", 0, 0 }
{ "application/x-toolbar-item", 0 }
};
static void

View File

@ -704,7 +704,7 @@ selection_changed (GtkTreeSelection *selection, GtkWidget *button)
}
static GtkTargetEntry row_targets[] = {
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP, 0}
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP }
};
int

View File

@ -64,7 +64,7 @@ get_model (void)
}
static GtkTargetEntry entries[] = {
{ "text/plain", 0, 0 }
{ "text/plain", 0 }
};
static GtkWidget *
@ -89,12 +89,12 @@ get_dragsource (void)
}
static void
data_received (GtkWidget *widget,
GdkDragContext *context,
gint x, gint y,
GtkSelectionData *selda,
guint info, guint time,
gpointer dada)
drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x, gint y,
GtkSelectionData *selda,
guint time,
gpointer dada)
{
gchar *text;
@ -112,7 +112,7 @@ get_droptarget (void)
label = gtk_label_new ("Drop here");
targets = gtk_target_list_new (entries, G_N_ELEMENTS (entries));
gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_COPY);
g_signal_connect (label, "drag-data-received", G_CALLBACK (data_received), NULL);
g_signal_connect (label, "drag-data-received", G_CALLBACK (drag_data_received), NULL);
gtk_target_list_unref (targets);
return label;

View File

@ -641,14 +641,8 @@ on_row_activated (GtkTreeView *tree_view,
g_print ("Row activated\n");
}
enum
{
TARGET_GTK_TREE_MODEL_ROW
};
static GtkTargetEntry row_targets[] = {
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP,
TARGET_GTK_TREE_MODEL_ROW }
{ "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_APP }
};
int

View File

@ -42,13 +42,10 @@ test_text (void)
static void
test_with_data_get (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
guint info,
gpointer user_data_or_owner)
{
gboolean success;
g_assert_cmpuint (info, ==, 42);
success = gtk_selection_data_set_text (selection_data, SOME_TEXT, -1);
g_assert (success);
}
@ -69,7 +66,7 @@ static void
test_with_data (void)
{
GtkClipboard *clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (), GDK_SELECTION_CLIPBOARD);
GtkTargetEntry entries[] = { { .target = TARGET_TEXT, .info = 42 } };
GtkTargetEntry entries[] = { { .target = TARGET_TEXT } };
GtkTargetList *targets;
targets = gtk_target_list_new (entries, G_N_ELEMENTS(entries));