Commit b66052f3 authored by Benjamin Otte's avatar Benjamin Otte

gdk: Remove gdk_selection_add_targets()

It's not needed anymore, now that we can look at the content provider's
formats.

Alose remove all the API in GTK that was used to set it.
parent 65eab872
......@@ -5187,9 +5187,6 @@ gtk_css_section_get_type
GtkSelectionData
gtk_selection_owner_set
gtk_selection_owner_set_for_display
gtk_selection_add_target
gtk_selection_add_targets
gtk_selection_clear_targets
gtk_selection_convert
gtk_selection_data_set
gtk_selection_data_set_text
......
......@@ -577,8 +577,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
display_class->set_selection_owner = _gdk_broadway_display_set_selection_owner;
display_class->send_selection_notify = _gdk_broadway_display_send_selection_notify;
display_class->get_selection_property = _gdk_broadway_display_get_selection_property;
display_class->clear_selection_targets = gdk_broadway_display_clear_selection_targets;
display_class->add_selection_targets = gdk_broadway_display_add_selection_targets;
display_class->convert_selection = _gdk_broadway_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
......
......@@ -136,13 +136,6 @@ gint _gdk_broadway_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
void gdk_broadway_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection);
void gdk_broadway_display_add_selection_targets (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets);
void _gdk_broadway_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
......
......@@ -157,21 +157,6 @@ _gdk_broadway_display_get_selection_property (GdkDisplay *display,
return 0;
}
void
gdk_broadway_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection)
{
}
void
gdk_broadway_display_add_selection_targets (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets)
{
}
void
_gdk_broadway_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
......
......@@ -185,13 +185,6 @@ struct _GdkDisplayClass
guchar **data,
GdkAtom *type,
gint *format);
void (*clear_selection_targets)(GdkDisplay *display,
GdkAtom selection);
void (*add_selection_targets) (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets);
void (*convert_selection) (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
......
......@@ -330,23 +330,3 @@ gdk_utf8_to_string_target (const gchar *str)
return GDK_DISPLAY_GET_CLASS (display)->utf8_to_string_target (display, str);
}
void
gdk_selection_clear_targets (GdkDisplay *display,
GdkAtom selection)
{
}
void
gdk_selection_add_targets (GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint n_targets)
{
GdkDisplay *display;
g_return_if_fail (GDK_IS_WINDOW (window));
display = gdk_window_get_display (window);
GDK_DISPLAY_GET_CLASS (display)->add_selection_targets (display, window, selection, targets, n_targets);
}
......@@ -209,16 +209,6 @@ void gdk_selection_send_notify_for_display (GdkDisplay *display,
GdkAtom property,
guint32 time_);
GDK_AVAILABLE_IN_3_94
void gdk_selection_clear_targets (GdkDisplay *display,
GdkAtom selection);
GDK_AVAILABLE_IN_3_94
void gdk_selection_add_targets (GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint n_targets);
G_END_DECLS
#endif /* __GDK_SELECTION_H__ */
......@@ -279,8 +279,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
display_class->get_selection_owner = _gdk_quartz_display_get_selection_owner;
display_class->set_selection_owner = _gdk_quartz_display_set_selection_owner;
display_class->get_selection_property = _gdk_quartz_display_get_selection_property;
display_class->clear_selection_targets = gdk_quartz_display_clear_selection_targets;
display_class->add_selection_targets = gdk_quartz_display_add_selection_targets;
display_class->convert_selection = _gdk_quartz_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
......
......@@ -1023,8 +1023,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->set_selection_owner = _gdk_wayland_display_set_selection_owner;
display_class->send_selection_notify = _gdk_wayland_display_send_selection_notify;
display_class->get_selection_property = _gdk_wayland_display_get_selection_property;
display_class->clear_selection_targets = gdk_wayland_display_clear_selection_targets;
display_class->add_selection_targets = gdk_wayland_display_add_selection_targets;
display_class->convert_selection = _gdk_wayland_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
......
......@@ -147,13 +147,6 @@ gint _gdk_wayland_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
void gdk_wayland_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection);
void gdk_wayland_display_add_selection_targets (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets);
void _gdk_wayland_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
......
......@@ -96,8 +96,6 @@ struct _GdkWaylandSelection
/* Source-side data */
StoredSelection stored_selection;
GArray *source_targets;
GdkAtom requested_target;
struct wl_data_source *dnd_source; /* Owned by the GdkDragContext */
GdkWindow *dnd_owner;
......@@ -325,7 +323,6 @@ gdk_wayland_selection_new (void)
g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) data_offer_data_free);
selection->stored_selection.fd = -1;
selection->source_targets = g_array_new (FALSE, FALSE, sizeof (GdkAtom));
return selection;
}
......@@ -337,8 +334,6 @@ gdk_wayland_selection_free (GdkWaylandSelection *selection)
for (i = 0; i < G_N_ELEMENTS (selection->selections); i++)
g_hash_table_destroy (selection->selections[i].buffers);
g_array_unref (selection->source_targets);
g_hash_table_destroy (selection->offers);
g_free (selection->stored_selection.data);
......@@ -854,7 +849,6 @@ static void
data_source_dnd_finished (void *data,
struct wl_data_source *source)
{
GdkDisplay *display = gdk_display_get_default ();
GdkDragContext *context;
context = gdk_wayland_drag_context_lookup_by_data_source (source);
......@@ -871,7 +865,6 @@ data_source_dnd_finished (void *data,
g_signal_emit_by_name (context, "dnd-finished");
gdk_selection_owner_set (NULL, atoms[ATOM_DND], GDK_CURRENT_TIME, TRUE);
gdk_wayland_display_clear_selection_targets (display, atoms[ATOM_DND]);
}
static void
......@@ -1272,46 +1265,6 @@ _gdk_wayland_display_utf8_to_string_target (GdkDisplay *display,
return sanitize_utf8 (str, TRUE);
}
void
gdk_wayland_display_add_selection_targets (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets)
{
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
gpointer data_source;
guint i;
g_return_if_fail (GDK_IS_WINDOW (window));
data_source = gdk_wayland_selection_get_data_source (window, selection);
if (!data_source)
return;
g_array_append_vals (wayland_selection->source_targets, targets, ntargets);
for (i = 0; i < ntargets; i++)
{
gchar *mimetype = gdk_atom_name (targets[i]);
wl_data_source_offer (data_source, mimetype);
g_free (mimetype);
}
}
void
gdk_wayland_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection)
{
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
wayland_selection->requested_target = NULL;
g_array_set_size (wayland_selection->source_targets, 0);
gdk_wayland_selection_unset_data_source (display, selection);
}
gboolean
gdk_wayland_selection_set_current_offer_actions (GdkDisplay *display,
uint32_t action)
......
......@@ -1248,8 +1248,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
display_class->set_selection_owner = _gdk_win32_display_set_selection_owner;
display_class->send_selection_notify = _gdk_win32_display_send_selection_notify;
display_class->get_selection_property = _gdk_win32_display_get_selection_property;
display_class->clear_selection_targets = gdk_win32_display_clear_selection_targets;
display_class->add_selection_targets = gdk_win32_display_add_selection_targets;
display_class->convert_selection = _gdk_win32_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_win32_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_win32_display_utf8_to_string_target;
......
......@@ -397,13 +397,6 @@ gint _gdk_win32_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
void gdk_win32_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection);
void gdk_win32_display_add_selection_targets (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets);
void _gdk_win32_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
......
......@@ -2805,12 +2805,6 @@ _gdk_win32_add_target_to_selformats (GdkAtom target,
return added_count;
}
void
gdk_win32_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection)
{
}
/* This function is called from gtk_selection_add_target() and
* gtk_selection_add_targets() in gtkselection.c. It is this function
* that takes care of setting those clipboard formats for which we use
......
......@@ -3222,8 +3222,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->set_selection_owner = _gdk_x11_display_set_selection_owner;
display_class->send_selection_notify = _gdk_x11_display_send_selection_notify;
display_class->get_selection_property = _gdk_x11_display_get_selection_property;
display_class->clear_selection_targets = gdk_x11_display_clear_selection_targets;
display_class->add_selection_targets = gdk_x11_display_add_selection_targets;
display_class->convert_selection = _gdk_x11_display_convert_selection;
display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
......
......@@ -166,13 +166,6 @@ gint _gdk_x11_display_get_selection_property (GdkDisplay *display,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
void gdk_x11_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection);
void gdk_x11_display_add_selection_targets (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets);
void _gdk_x11_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
......
......@@ -311,21 +311,6 @@ _gdk_x11_display_get_selection_property (GdkDisplay *display,
return 0;
}
void
gdk_x11_display_clear_selection_targets (GdkDisplay *display,
GdkAtom selection)
{
}
void
gdk_x11_display_add_selection_targets (GdkDisplay *display,
GdkWindow *window,
GdkAtom selection,
GdkAtom *targets,
guint ntargets)
{
}
void
_gdk_x11_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
......
......@@ -551,158 +551,6 @@ gtk_selection_target_list_get (GtkWidget *widget,
return sellist->list;
}
static void
gtk_selection_target_list_add (GtkWidget *widget,
GdkAtom selection,
GdkContentFormats *formats)
{
GtkSelectionTargetList *sellist;
GList *tmp_list;
GList *lists;
lists = g_object_get_data (G_OBJECT (widget), gtk_selection_handler_key);
tmp_list = lists;
while (tmp_list)
{
sellist = tmp_list->data;
if (sellist->selection == selection)
{
sellist->list = gdk_content_formats_union (sellist->list, formats);
return;
}
tmp_list = tmp_list->next;
}
if (tmp_list == NULL)
{
sellist = g_slice_new (GtkSelectionTargetList);
sellist->selection = selection;
sellist->list = gdk_content_formats_ref (formats);
}
lists = g_list_prepend (lists, sellist);
g_object_set_data (G_OBJECT (widget), I_(gtk_selection_handler_key), lists);
}
static void
gtk_selection_target_list_remove (GtkWidget *widget)
{
GtkSelectionTargetList *sellist;
GList *tmp_list;
GList *lists;
lists = g_object_get_data (G_OBJECT (widget), gtk_selection_handler_key);
tmp_list = lists;
while (tmp_list)
{
sellist = tmp_list->data;
gdk_content_formats_unref (sellist->list);
g_slice_free (GtkSelectionTargetList, sellist);
tmp_list = tmp_list->next;
}
g_list_free (lists);
g_object_set_data (G_OBJECT (widget), I_(gtk_selection_handler_key), NULL);
}
/**
* gtk_selection_clear_targets:
* @widget: a #GtkWidget
* @selection: an atom representing a selection
*
* Remove all targets registered for the given selection for the
* widget.
**/
void
gtk_selection_clear_targets (GtkWidget *widget,
GdkAtom selection)
{
GtkSelectionTargetList *sellist;
GList *tmp_list;
GList *lists;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection != NULL);
gdk_selection_clear_targets (gtk_widget_get_display (widget), selection);
lists = g_object_get_data (G_OBJECT (widget), gtk_selection_handler_key);
tmp_list = lists;
while (tmp_list)
{
sellist = tmp_list->data;
if (sellist->selection == selection)
{
lists = g_list_delete_link (lists, tmp_list);
gdk_content_formats_unref (sellist->list);
g_slice_free (GtkSelectionTargetList, sellist);
break;
}
tmp_list = tmp_list->next;
}
g_object_set_data (G_OBJECT (widget), I_(gtk_selection_handler_key), lists);
}
/**
* gtk_selection_add_target:
* @widget: a #GtkWidget
* @selection: the selection
* @target: target to add.
*
* Appends a specified target to the list of supported targets for a
* given widget and selection.
**/
void
gtk_selection_add_target (GtkWidget *widget,
GdkAtom selection,
GdkAtom target)
{
GdkContentFormats *list;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection != NULL);
list = gdk_content_formats_new (&target, 1);
gtk_selection_add_targets (widget, selection, list);
gdk_content_formats_unref (list);
}
/**
* gtk_selection_add_targets:
* @widget: a #GtkWidget
* @selection: the selection
* @targets: the targets to add
*
* Prepends a table of targets to the list of supported targets
* for a given widget and selection.
**/
void
gtk_selection_add_targets (GtkWidget *widget,
GdkAtom selection,
GdkContentFormats *targets)
{
const char * const *mime_types;
gsize n_mime_types;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection != NULL);
g_return_if_fail (targets != NULL);
gtk_selection_target_list_add (widget, selection, targets);
mime_types = gdk_content_formats_get_mime_types (targets, &n_mime_types);
gdk_selection_add_targets (gtk_widget_get_window (widget), selection, (GdkAtom *) mime_types, n_mime_types);
}
/**
* gtk_selection_remove_all:
* @widget: a #GtkWidget
......@@ -759,9 +607,6 @@ gtk_selection_remove_all (GtkWidget *widget)
tmp_list = next;
}
/* Remove all selection lists */
gtk_selection_target_list_remove (widget);
}
......
......@@ -55,17 +55,6 @@ gboolean gtk_selection_owner_set_for_display (GdkDisplay *display,
guint32 time_);
GDK_AVAILABLE_IN_ALL
void gtk_selection_add_target (GtkWidget *widget,
GdkAtom selection,
GdkAtom target);
GDK_AVAILABLE_IN_ALL
void gtk_selection_add_targets (GtkWidget *widget,
GdkAtom selection,
GdkContentFormats *targets);
GDK_AVAILABLE_IN_ALL
void gtk_selection_clear_targets (GtkWidget *widget,
GdkAtom selection);
GDK_AVAILABLE_IN_ALL
gboolean gtk_selection_convert (GtkWidget *widget,
GdkAtom selection,
GdkAtom target,
......
......@@ -384,14 +384,6 @@ main (int argc, char *argv[])
GtkWidget *hbox;
GtkWidget *scrolled;
static const char *targetlist[] = {
"STRING",
"TEXT",
"COMPOUND_TEXT"
};
static gint ntargets = sizeof(targetlist) / sizeof(targetlist[0]);
GdkContentFormats *list;
gtk_init ();
init_atoms();
......@@ -422,10 +414,6 @@ main (int argc, char *argv[])
g_signal_connect (selection_widget, "selection_received",
G_CALLBACK (selection_received), NULL);
list = gdk_content_formats_new (targetlist, ntargets);
gtk_selection_add_targets (selection_widget, GDK_SELECTION_PRIMARY, list);
gdk_content_formats_unref (list);
g_signal_connect (selection_widget, "selection_get",
G_CALLBACK (selection_get), NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment