Added an API point about needing a way to fetch the hpaned position so we

2003-09-10  Federico Mena Quintero  <federico@ximian.com>

	* TODO: Added an API point about needing a way to fetch the hpaned
	position so we can save it.

	* gtkfilechooser.c (_gtk_file_chooser_get_paths): Fixed API docs.
	(gtk_file_chooser_get_uris): Likewise.
	(gtk_file_chooser_get_filenames): Likewise.

	* gtkfilechooserdialog.c (file_chooser_widget_file_activated): New
	callback, calls gtk_window_activate_default().

	* testfilechooser.c (response_cb): Print the selected files if the
	user clicks OK.
This commit is contained in:
Federico Mena Quintero 2003-09-11 00:56:46 +00:00 committed by Federico Mena Quintero
parent aa22566e6c
commit 9044d774bb
3 changed files with 52 additions and 16 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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 ();
}