summaryrefslogtreecommitdiff
path: root/gdk/gdkcontentformats.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-20 03:54:42 +0100
committerBenjamin Otte <otte@redhat.com>2017-11-20 23:13:10 +0100
commitfc2ce5a9254c7678eaadde35297b8fd90c869bd4 (patch)
tree40472431d75245904fa9576b534c38b19824eb55 /gdk/gdkcontentformats.c
parent1a482ad2760b2f078605f807a13aed2877e95ef0 (diff)
downloadgtk+-fc2ce5a9254c7678eaadde35297b8fd90c869bd4.tar.gz
gdk: Make GdkContentFormats immutable
Diffstat (limited to 'gdk/gdkcontentformats.c')
-rw-r--r--gdk/gdkcontentformats.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/gdk/gdkcontentformats.c b/gdk/gdkcontentformats.c
index bb1496426c..afb6a021e3 100644
--- a/gdk/gdkcontentformats.c
+++ b/gdk/gdkcontentformats.c
@@ -207,42 +207,31 @@ gdk_content_formats_to_string (GdkContentFormats *formats)
}
/**
- * gdk_content_formats_add:
- * @formats: a #GdkContentFormats
- * @mime_type: the mime type to add
- *
- * Appends another mime_type to a #GdkContentFormats.
- **/
-void
-gdk_content_formats_add (GdkContentFormats *formats,
- const char *mime_type)
-{
- g_return_if_fail (formats != NULL);
-
- formats->formats = g_list_append (formats->formats, (gpointer) gdk_atom_intern (mime_type, FALSE));
-}
-
-/**
* gdk_content_formats_union:
- * @first: the #GdkContentFormats to merge into
- * @second: the #GtkTargeList to merge from
+ * @first: (transfer full): the #GdkContentFormats to merge into
+ * @second: (transfer none): the #GdkContentFormats to merge from
*
* Append all missing types from @second to @first, in the order
* they had in @second.
+ *
+ * Returns: a new #GdkContentFormats
*/
-void
+GdkContentFormats *
gdk_content_formats_union (GdkContentFormats *first,
const GdkContentFormats *second)
{
- GList *l;
+ GdkContentFormatsBuilder *builder;
- g_return_if_fail (first != NULL);
- g_return_if_fail (second != NULL);
+ g_return_val_if_fail (first != NULL, NULL);
+ g_return_val_if_fail (second != NULL, NULL);
- for (l = second->formats; l; l = l->next)
- {
- first->formats = g_list_append (first->formats, l->data);
- }
+ builder = gdk_content_formats_builder_new ();
+
+ gdk_content_formats_builder_add_formats (builder, first);
+ gdk_content_formats_unref (first);
+ gdk_content_formats_builder_add_formats (builder, second);
+
+ return gdk_content_formats_builder_free (builder);
}
/**
@@ -384,7 +373,7 @@ gdk_content_formats_builder_free (GdkContentFormatsBuilder *builder)
**/
void
gdk_content_formats_builder_add_formats (GdkContentFormatsBuilder *builder,
- GdkContentFormats *formats)
+ const GdkContentFormats *formats)
{
GList *l;