summaryrefslogtreecommitdiff
path: root/gdk/gdkcontentformats.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-18 05:53:25 +0100
committerBenjamin Otte <otte@redhat.com>2017-11-20 23:12:33 +0100
commitd6a209816bacff89e361a580b24e847dca0bdef5 (patch)
treea95d06515b9513c6d7f2110ddedda19badf26a2b /gdk/gdkcontentformats.c
parent9a6ec4e9591df1a8ed72bbf8793091a1f325b5ff (diff)
downloadgtk+-d6a209816bacff89e361a580b24e847dca0bdef5.tar.gz
gdkdnd: Make GdkDragContext->formats a GdkContentFormats
Instead of it being a GList of GdkAtoms.
Diffstat (limited to 'gdk/gdkcontentformats.c')
-rw-r--r--gdk/gdkcontentformats.c71
1 files changed, 53 insertions, 18 deletions
diff --git a/gdk/gdkcontentformats.c b/gdk/gdkcontentformats.c
index 78fab2ed76..c3cd9cde63 100644
--- a/gdk/gdkcontentformats.c
+++ b/gdk/gdkcontentformats.c
@@ -150,6 +150,59 @@ gdk_content_formats_unref (GdkContentFormats *formats)
}
/**
+ * gdk_content_formats_print:
+ * @formats: a #GdkContentFormats
+ * @string: a #GString to print into
+ *
+ * Prints the given @formats into a string for human consumption.
+ * This is meant for debugging and logging.
+ *
+ * The form of the representation may change at any time and is
+ * not guranteed to stay identical.
+ **/
+void
+gdk_content_formats_print (GdkContentFormats *formats,
+ GString *string)
+{
+ GList *l;
+
+ g_return_if_fail (formats != NULL);
+ g_return_if_fail (string != NULL);
+
+ g_string_append (string, "{ ");
+ for (l = formats->formats; l; l = l->next)
+ {
+ if (l != formats->formats)
+ g_string_append (string, ", ");
+ g_string_append (string, l->data);
+ }
+ g_string_append (string, " }");
+}
+
+/**
+ * gdk_content_formats_to_string:
+ * @formats: a #GdkContentFormats
+ *
+ * Prints the given @formats into a human-readable string.
+ * This is a small wrapper around gdk_content_formats_print() to help
+ * when debugging.
+ *
+ * Returns: (transfer full): a new string
+ **/
+char *
+gdk_content_formats_to_string (GdkContentFormats *formats)
+{
+ GString *string;
+
+ g_return_val_if_fail (formats != NULL, NULL);
+
+ string = g_string_new (NULL);
+ gdk_content_formats_print (formats, string);
+
+ return g_string_free (string, FALSE);
+}
+
+/**
* gdk_content_formats_add:
* @formats: a #GdkContentFormats
* @mime_type: the mime type to add
@@ -218,24 +271,6 @@ gdk_content_formats_intersects (const GdkContentFormats *first,
}
/**
- * gdk_content_formats_remove:
- * @formats: a #GdkContentFormats
- * @mime_type: the mime type
- *
- * Removes a mime type. If the mime type was not part of @formats, nothing
- * happens.
- **/
-void
-gdk_content_formats_remove (GdkContentFormats *formats,
- const char *mime_type)
-{
- g_return_if_fail (formats != NULL);
- g_return_if_fail (mime_type != NULL);
-
- formats->formats = g_list_remove (formats->formats, (gpointer) gdk_atom_intern (mime_type, FALSE));
-}
-
-/**
* gdk_content_formats_contains:
* @formats: a #GdkContentFormats
* @mime_type: the mime type to search for