summaryrefslogtreecommitdiff
path: root/gdk/gdkcontentdeserializer.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-29 09:37:50 +0100
committerBenjamin Otte <otte@redhat.com>2017-12-03 05:46:48 +0100
commit6b326b14c00e7b030e8f09aac94637250e506df1 (patch)
tree5c31540eab39a4236698f923397871e313eeccf7 /gdk/gdkcontentdeserializer.c
parent928c98a84efd2c72bc3ff9fe139ad5296091110a (diff)
downloadgtk+-6b326b14c00e7b030e8f09aac94637250e506df1.tar.gz
gdk: Add GDK_TYPE_FILE_LIST with serializers
This is a GSList of GFile and we want it so we can operate with lists of files and text/uri-list. I chose GSList over GList because that's what the GtkFileChooser API uses, too.
Diffstat (limited to 'gdk/gdkcontentdeserializer.c')
-rw-r--r--gdk/gdkcontentdeserializer.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/gdk/gdkcontentdeserializer.c b/gdk/gdkcontentdeserializer.c
index b9a369f2ab..22f911d319 100644
--- a/gdk/gdkcontentdeserializer.c
+++ b/gdk/gdkcontentdeserializer.c
@@ -22,7 +22,6 @@
#include "gdkcontentdeserializer.h"
#include "gdkcontentformats.h"
-#include "gdkintl.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -532,6 +531,7 @@ file_uri_deserializer_finish (GObject *source,
GOutputStream *stream = G_OUTPUT_STREAM (source);
GError *error = NULL;
gssize written;
+ GValue *value;
char *str;
char **uris;
@@ -554,17 +554,21 @@ file_uri_deserializer_finish (GObject *source,
uris = g_uri_list_extract_uris (str);
g_free (str);
- if (uris == NULL || uris[0] == NULL)
+ value = gdk_content_deserializer_get_value (deserializer);
+ if (G_VALUE_HOLDS (value, G_TYPE_FILE))
{
- error = g_error_new (G_IO_ERROR, G_IO_ERROR, _("No file given"));
- gdk_content_deserializer_return_error (deserializer, error);
+ if (uris[0] != NULL)
+ g_value_take_object (value, g_file_new_for_uri (uris[0]));
}
else
{
- GFile *file = g_file_new_for_uri (uris[0]);
+ GSList *l = NULL;
+ gsize i;
+
+ for (i = 0; uris[i] != NULL; i++)
+ l = g_slist_prepend (l, g_file_new_for_uri (uris[i]));
- g_value_take_object (gdk_content_deserializer_get_value (deserializer), file);
- gdk_content_deserializer_return_success (deserializer);
+ g_value_take_boxed (value, g_slist_reverse (l));
}
g_strfreev (uris);
}
@@ -640,6 +644,11 @@ init (void)
g_slist_free (formats);
gdk_content_register_deserializer ("text/uri-list",
+ GDK_TYPE_FILE_LIST,
+ file_uri_deserializer,
+ NULL,
+ NULL);
+ gdk_content_register_deserializer ("text/uri-list",
G_TYPE_FILE,
file_uri_deserializer,
NULL,