From fc2ce5a9254c7678eaadde35297b8fd90c869bd4 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 20 Nov 2017 03:54:42 +0100 Subject: gdk: Make GdkContentFormats immutable --- gdk/gdkcontentformats.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'gdk/gdkcontentformats.c') diff --git a/gdk/gdkcontentformats.c b/gdk/gdkcontentformats.c index bb1496426c..afb6a021e3 100644 --- a/gdk/gdkcontentformats.c +++ b/gdk/gdkcontentformats.c @@ -206,43 +206,32 @@ gdk_content_formats_to_string (GdkContentFormats *formats) return g_string_free (string, FALSE); } -/** - * 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; -- cgit v1.2.1