summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-20 04:42:43 +0100
committerBenjamin Otte <otte@redhat.com>2017-11-20 23:15:11 +0100
commit1a70ca75e8128cfa4c1a9225301b42b50bdc17bc (patch)
tree2022982aeb22f1384199d7c90cea2613d80e8671 /gtk
parentfc2ce5a9254c7678eaadde35297b8fd90c869bd4 (diff)
downloadgtk+-1a70ca75e8128cfa4c1a9225301b42b50bdc17bc.tar.gz
gdk: Sanitize GdkContentFormats API
Make sure the API reflects the idea that GdkContentFormats is a set containing mime types. In particular, treat the object itself as a plural - it's named content format`S' after all - and therefor use the correct verb form. Also make GdkContentFormats keep an array instead of a list, now that it's immutable.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkclipboard.c9
-rw-r--r--gtk/gtkdnd.c10
-rw-r--r--gtk/gtkdragdest.c4
-rw-r--r--gtk/gtkselection.c22
-rw-r--r--gtk/gtktextview.c2
5 files changed, 24 insertions, 23 deletions
diff --git a/gtk/gtkclipboard.c b/gtk/gtkclipboard.c
index 68d8b15c73..65b770d028 100644
--- a/gtk/gtkclipboard.c
+++ b/gtk/gtkclipboard.c
@@ -2090,7 +2090,6 @@ gtk_clipboard_real_set_can_store (GtkClipboard *clipboard,
GdkContentFormats *formats)
{
GtkWidget *clipboard_widget;
- guint n_atoms;
if (clipboard->selection != GDK_SELECTION_CLIPBOARD)
return;
@@ -2117,8 +2116,12 @@ gtk_clipboard_real_set_can_store (GtkClipboard *clipboard,
if (formats)
{
- clipboard->storable_formats = gdk_content_formats_get_atoms (formats, &n_atoms);
- clipboard->n_storable_formats = n_atoms;
+ const char * const *mime_types;
+ gsize n_mime_types;
+
+ mime_types = gdk_content_formats_get_mime_types (formats, &n_mime_types);
+ clipboard->storable_formats = g_memdup (mime_types, sizeof (char *) * n_mime_types);
+ clipboard->n_storable_formats = n_mime_types;
}
else
{
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 2e8af5a8c3..4015e2245e 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -818,7 +818,7 @@ gtk_drag_selection_received (GtkWidget *widget,
if (site && site->target_list)
{
- if (gdk_content_formats_contains (site->target_list, target))
+ if (gdk_content_formats_contain_mime_type (site->target_list, target))
{
if (!(site->flags & GTK_DEST_DEFAULT_DROP) ||
gtk_selection_data_get_length (selection_data) >= 0)
@@ -1842,9 +1842,9 @@ gtk_drag_drop (GtkDragSourceInfo *info,
/* GTK+ traditionally has used application/x-rootwin-drop, but the
* XDND spec specifies x-rootwindow-drop.
*/
- if (gdk_content_formats_contains (info->target_list, "application/x-rootwindow-drop"))
+ if (gdk_content_formats_contain_mime_type (info->target_list, "application/x-rootwindow-drop"))
found = gdk_atom_intern ("application/x-rootwindow-drop", FALSE);
- if (gdk_content_formats_contains (info->target_list, "application/x-rootwin-drop"))
+ if (gdk_content_formats_contain_mime_type (info->target_list, "application/x-rootwin-drop"))
found = gdk_atom_intern ("application/x-rootwin-drop", FALSE);
else found = NULL;
@@ -1903,8 +1903,8 @@ gtk_drag_selection_get (GtkWidget *widget,
info->context);
gtk_selection_data_set (selection_data, null_atom, 8, NULL, 0);
}
- else if (gdk_content_formats_contains (info->target_list,
- gtk_selection_data_get_target (selection_data)))
+ else if (gdk_content_formats_contain_mime_type (info->target_list,
+ gtk_selection_data_get_target (selection_data)))
{
g_signal_emit_by_name (info->widget, "drag-data-get",
info->context,
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index fabbe27a4e..9c37569fb1 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -422,8 +422,8 @@ gtk_drag_dest_find_target (GtkWidget *widget,
if (target_list == NULL)
return NULL;
- result = gdk_content_formats_intersects (target_list,
- gdk_drag_context_get_formats (context));
+ result = gdk_content_formats_match (target_list,
+ gdk_drag_context_get_formats (context));
return result;
}
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index 8d6c1ec4ec..1d7a8485e7 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -734,8 +734,8 @@ gtk_selection_add_targets (GtkWidget *widget,
GdkAtom selection,
GdkContentFormats *targets)
{
- GdkAtom *atoms;
- guint n_targets;
+ const char * const *mime_types;
+ gsize n_mime_types;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (selection != NULL);
@@ -743,9 +743,8 @@ gtk_selection_add_targets (GtkWidget *widget,
gtk_selection_target_list_add (widget, selection, targets);
- atoms = gdk_content_formats_get_atoms (targets, &n_targets);
- gdk_selection_add_targets (gtk_widget_get_window (widget), selection, atoms, n_targets);
- g_free (atoms);
+ 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);
}
@@ -1932,7 +1931,7 @@ gtk_targets_include_image (GdkAtom *targets,
list = gtk_content_formats_add_image_targets (list, writable);
for (i = 0; i < n_targets && !result; i++)
{
- if (gdk_content_formats_contains (list, targets[i]))
+ if (gdk_content_formats_contain_mime_type (list, targets[i]))
{
result = TRUE;
break;
@@ -2908,7 +2907,7 @@ gtk_selection_invoke_handler (GtkWidget *widget,
target_list = gtk_selection_target_list_get (widget, data->selection);
if (data->target != gtk_selection_atoms[SAVE_TARGETS] &&
target_list &&
- gdk_content_formats_contains (target_list, data->target))
+ gdk_content_formats_contain_mime_type (target_list, data->target))
{
g_signal_emit_by_name (widget,
"selection-get",
@@ -2967,13 +2966,14 @@ gtk_selection_default_handler (GtkWidget *widget,
else if (data->target == gtk_selection_atoms[TARGETS])
{
/* List of all targets supported for this widget/selection pair */
- GdkAtom *p, *atoms;
- guint count, i;
+ GdkAtom *p;
+ const char * const *atoms;
+ gsize count, i;
GdkContentFormats *target_list;
target_list = gtk_selection_target_list_get (widget,
data->selection);
- atoms = gdk_content_formats_get_atoms (target_list, &count);
+ atoms = gdk_content_formats_get_mime_types (target_list, &count);
data->type = GDK_SELECTION_TYPE_ATOM;
data->format = 32;
@@ -2991,8 +2991,6 @@ gtk_selection_default_handler (GtkWidget *widget,
for (i = 0; i < count; i++)
*p++ = atoms[i];
-
- g_free (atoms);
}
else if (data->target == gtk_selection_atoms[SAVE_TARGETS])
{
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 8bf79a9094..a4bf36d5d6 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -8158,7 +8158,7 @@ gtk_text_view_drag_data_received (GtkWidget *widget,
buffer_formats = gdk_content_formats_new (atoms, n_atoms);
dnd_formats = gdk_drag_context_get_formats (context);
- target = gdk_content_formats_intersects (dnd_formats, buffer_formats);
+ target = gdk_content_formats_match (dnd_formats, buffer_formats);
gdk_content_formats_unref (buffer_formats);
g_free (atoms);