summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtkfilechooser.c31
-rw-r--r--gtk/gtkfilechooserdialog.c11
-rw-r--r--tests/testfilechooser.c26
3 files changed, 52 insertions, 16 deletions
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index f3046e75ec..0153b23d55 100644
--- a/gtk/gtkfilechooser.c
+++ b/gtk/gtkfilechooser.c
@@ -440,14 +440,14 @@ gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
* gtk_file_chooser_get_filenames:
* @chooser: a #GtkFileChooser
*
- * Lists all the files and subfolders in the current folder of
- * @chooser. The returned names are full absolute paths. If files
- * in the current folder cannot be represented as local filenames
- * they will be ignored. (See gtk_file_chooser_get_uris())
+ * Lists all the selected files and subfolders in the current folder of
+ * @chooser. The returned names are full absolute paths. If files in the current
+ * folder cannot be represented as local filenames they will be ignored. (See
+ * gtk_file_chooser_get_uris())
*
- * Return value: a #GList containing the filenames of all
+ * Return value: a #GSList containing the filenames of all selected
* files and subfolders in the current folder. Free the returned list
- * with g_lists_free(), and the filenames with g_free().
+ * with g_slist_free(), and the filenames with g_free().
**/
GSList *
gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
@@ -687,15 +687,15 @@ gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
}
/**
- * gtk_file_chooser_get_filenames:
+ * gtk_file_chooser_get_uris:
* @chooser: a #GtkFileChooser
*
- * Lists all the files and subfolders in the current folder of
+ * Lists all the selected files and subfolders in the current folder of
* @chooser. The returned names are full absolute URIs.
*
- * Return value: a #GList containing the URIs of all
+ * Return value: a #GSList containing the URIs of all selected
* files and subfolders in the current folder. Free the returned list
- * with g_lists_free(), and the filenames with g_free().
+ * with g_slist_free(), and the filenames with g_free().
**/
GSList *
gtk_file_chooser_get_uris (GtkFileChooser *chooser)
@@ -853,13 +853,12 @@ _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
* _gtk_file_chooser_get_paths:
* @chooser: a #GtkFileChooser
*
- * Lists all the files and subfolders in the current folder of
- * @chooser as #GtkFilePath. An internal function, see
- * gtk_file_chooser_get_uris().
+ * Lists all the selected files and subfolders in the current folder of @chooser
+ * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
*
- * Return value: a #GList containing a #GtkFilePath for each
- * files and subfolder in the current folder. Free the returned list
- * with g_lists_free(), and the paths with gtk_file_path_free().
+ * Return value: a #GSList containing a #GtkFilePath for each selected
+ * file and subfolder in the current folder. Free the returned list
+ * with g_slist_free(), and the paths with gtk_file_path_free().
**/
GSList *
_gtk_file_chooser_get_paths (GtkFileChooser *chooser)
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index 854783f19c..77ab450240 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -114,6 +114,14 @@ gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog)
dialog->priv = priv;
}
+/* Callback used when the user activates a file in the file chooser widget */
+static void
+file_chooser_widget_file_activated (GtkFileChooser *chooser,
+ GtkFileChooserDialog *dialog)
+{
+ gtk_window_activate_default (GTK_WINDOW (dialog));
+}
+
static GObject*
gtk_file_chooser_dialog_constructor (GType type,
guint n_construct_properties,
@@ -135,6 +143,9 @@ gtk_file_chooser_dialog_constructor (GType type,
NULL);
else
priv->widget = g_object_new (GTK_TYPE_FILE_CHOOSER_WIDGET, NULL);
+
+ g_signal_connect (priv->widget, "file-activated",
+ G_CALLBACK (file_chooser_widget_file_activated), object);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox), priv->widget, TRUE, TRUE, 0);
gtk_widget_show (priv->widget);
diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c
index 5ff9af1d2c..be1127f9db 100644
--- a/tests/testfilechooser.c
+++ b/tests/testfilechooser.c
@@ -50,6 +50,32 @@ static void
response_cb (GtkDialog *dialog,
gint response_id)
{
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ GSList *list;
+
+ list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog));
+
+ if (list)
+ {
+ GSList *l;
+
+ g_print ("Selected files:\n");
+
+ for (l = list; l; l = l->next)
+ {
+ g_print ("%s\n", (char *) l->data);
+ g_free (l->data);
+ }
+
+ g_slist_free (list);
+ }
+ else
+ g_print ("No selected files\n");
+ }
+ else
+ g_print ("Dialog was closed\n");
+
gtk_main_quit ();
}