summaryrefslogtreecommitdiff
path: root/tests/testfilechooser.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2013-06-19 13:37:40 -0500
committerFederico Mena Quintero <federico@gnome.org>2013-06-19 13:37:40 -0500
commit8b1c91886740ba08f51b709dbf831446dba09db7 (patch)
treef8b52a9ac95418e7adbea55b107f673b9de95db2 /tests/testfilechooser.c
parent84b4910b39bdd85195887437445a8f089cda621f (diff)
downloadgtk+-8b1c91886740ba08f51b709dbf831446dba09db7.tar.gz
filechooser: In testfilechooser, add buttons to get the selection and the current name
Diffstat (limited to 'tests/testfilechooser.c')
-rw-r--r--tests/testfilechooser.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c
index fdee032475..7959411ed9 100644
--- a/tests/testfilechooser.c
+++ b/tests/testfilechooser.c
@@ -397,6 +397,47 @@ set_filename_existing_nonexistent_cb (GtkButton *button,
}
static void
+get_selection_cb (GtkButton *button,
+ GtkFileChooser *chooser)
+{
+ GSList *selection;
+
+ selection = gtk_file_chooser_get_uris (chooser);
+
+ g_print ("Selection: ");
+
+ if (selection == NULL)
+ g_print ("empty\n");
+ else
+ {
+ GSList *l;
+
+ for (l = selection; l; l = l->next)
+ {
+ char *uri = l->data;
+
+ g_print ("%s\n", uri);
+
+ if (l->next)
+ g_print (" ");
+ }
+ }
+
+ g_slist_free_full (selection, g_free);
+}
+
+static void
+get_current_name_cb (GtkButton *button,
+ GtkFileChooser *chooser)
+{
+ char *name;
+
+ name = gtk_file_chooser_get_current_name (chooser);
+ g_print ("Current name: %s\n", name ? name : "NULL");
+ g_free (name);
+}
+
+static void
unmap_and_remap_cb (GtkButton *button,
GtkFileChooser *chooser)
{
@@ -682,6 +723,16 @@ main (int argc, char **argv)
g_signal_connect (button, "clicked",
G_CALLBACK (set_filename_existing_nonexistent_cb), dialog);
+ button = gtk_button_new_with_label ("Get selection");
+ gtk_container_add (GTK_CONTAINER (vbbox), button);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (get_selection_cb), dialog);
+
+ button = gtk_button_new_with_label ("Get current name");
+ gtk_container_add (GTK_CONTAINER (vbbox), button);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (get_current_name_cb), dialog);
+
button = gtk_button_new_with_label ("Unmap and remap");
gtk_container_add (GTK_CONTAINER (vbbox), button);
g_signal_connect (button, "clicked",