summaryrefslogtreecommitdiff
path: root/tests/testclipboard2.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 /tests/testclipboard2.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 'tests/testclipboard2.c')
-rw-r--r--tests/testclipboard2.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index 4baabf5f86..abc4751a30 100644
--- a/tests/testclipboard2.c
+++ b/tests/testclipboard2.c
@@ -102,7 +102,26 @@ visible_child_changed_cb (GtkWidget *stack,
label);
}
}
-
+
+static GList *
+get_file_list (const char *dir)
+{
+ GFileEnumerator *enumerator;
+ GFile *file;
+ GList *list = NULL;
+
+ file = g_file_new_for_path (dir);
+ enumerator = g_file_enumerate_children (file, "standard::name", 0, NULL, NULL);
+ g_object_unref (file);
+ if (enumerator == NULL)
+ return NULL;
+
+ while (g_file_enumerator_iterate (enumerator, NULL, &file, NULL, NULL) && file != NULL)
+ list = g_list_prepend (list, g_object_ref (file));
+
+ return g_list_reverse (list);
+}
+
static void
format_list_add_row (GtkWidget *list,
const char *format_name,
@@ -271,6 +290,12 @@ get_button_list (GdkClipboard *clipboard,
"home directory");
g_value_unset (&value);
+ g_value_init (&value, GDK_TYPE_FILE_LIST);
+ g_value_take_boxed (&value, get_file_list (g_get_home_dir ()));
+ add_provider_button (box,
+ gdk_content_provider_new_for_value (&value),
+ clipboard,
+ "files in home");
return box;
}