]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooser.c
Clarify the usage of this function. (gtk_file_chooser_set_uri): Likewise.
[~andy/gtk] / gtk / gtkfilechooser.c
1 /* GTK - The GIMP Toolkit
2  * gtkfilechooser.c: Abstract interface for file selector GUIs
3  * Copyright (C) 2003, Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include <config.h>
22 #include "gtkfilechooser.h"
23 #include "gtkfilechooserprivate.h"
24 #include "gtkfilesystem.h"
25 #include "gtkintl.h"
26 #include "gtktypebuiltins.h"
27 #include "gtkprivate.h"
28 #include "gtkmarshalers.h"
29 #include "gtkalias.h"
30
31 static void gtk_file_chooser_class_init (gpointer g_iface);
32
33 static GtkFilePath *gtk_file_chooser_get_path         (GtkFileChooser *chooser);
34
35 GType
36 gtk_file_chooser_get_type (void)
37 {
38   static GType file_chooser_type = 0;
39
40   if (!file_chooser_type)
41     {
42       static const GTypeInfo file_chooser_info =
43       {
44         sizeof (GtkFileChooserIface),  /* class_size */
45         NULL,                          /* base_init */
46         NULL,                          /* base_finalize */
47         (GClassInitFunc)gtk_file_chooser_class_init, /* class_init */
48       };
49
50       file_chooser_type = g_type_register_static (G_TYPE_INTERFACE,
51                                                   "GtkFileChooser",
52                                                   &file_chooser_info, 0);
53
54       g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET);
55     }
56
57   return file_chooser_type;
58 }
59
60 static gboolean
61 confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
62                                GValue                *return_accu,
63                                const GValue          *handler_return,
64                                gpointer               dummy)
65 {
66   gboolean continue_emission;
67   GtkFileChooserConfirmation conf;
68
69   conf = g_value_get_enum (handler_return);
70   g_value_set_enum (return_accu, conf);
71   continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
72
73   return continue_emission;
74 }
75
76 static void
77 gtk_file_chooser_class_init (gpointer g_iface)
78 {
79   GType iface_type = G_TYPE_FROM_INTERFACE (g_iface);
80
81   /**
82    * GtkFileChooser::current-folder-changed
83    * @chooser: the object which received the signal.
84    *
85    * This signal is emitted when the current folder in a #GtkFileChooser
86    * changes.  This can happen due to the user performing some action that
87    * changes folders, such as selecting a bookmark or visiting a folder on the
88    * file list.  It can also happen as a result of calling a function to
89    * explicitly change the current folder in a file chooser.
90    *
91    * Normally you do not need to connect to this signal, unless you need to keep
92    * track of which folder a file chooser is showing.
93    *
94    * See also:  gtk_file_chooser_set_current_folder(),
95    * gtk_file_chooser_get_current_folder(),
96    * gtk_file_chooser_set_current_folder_uri(),
97    * gtk_file_chooser_get_current_folder_uri().
98    */
99   g_signal_new ("current-folder-changed",
100                 iface_type,
101                 G_SIGNAL_RUN_LAST,
102                 G_STRUCT_OFFSET (GtkFileChooserIface, current_folder_changed),
103                 NULL, NULL,
104                 g_cclosure_marshal_VOID__VOID,
105                 G_TYPE_NONE, 0);
106
107   /**
108    * GtkFileChooser::selection-changed
109    * @chooser: the object which received the signal.
110    *
111    * This signal is emitted when there is a change in the set of selected files
112    * in a #GtkFileChooser.  This can happen when the user modifies the selection
113    * with the mouse or the keyboard, or when explicitly calling functions to
114    * change the selection.
115    *
116    * Normally you do not need to connect to this signal, as it is easier to wait
117    * for the file chooser to finish running, and then to get the list of
118    * selected files using the functions mentioned below.
119    *
120    * See also: gtk_file_chooser_select_filename(),
121    * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(),
122    * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(),
123    * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(),
124    * gtk_file_chooser_get_uris().
125    */
126   g_signal_new ("selection-changed",
127                 iface_type,
128                 G_SIGNAL_RUN_LAST,
129                 G_STRUCT_OFFSET (GtkFileChooserIface, selection_changed),
130                 NULL, NULL,
131                 g_cclosure_marshal_VOID__VOID,
132                 G_TYPE_NONE, 0);
133
134   /**
135    * GtkFileChooser::update-preview
136    * @chooser: the object which received the signal.
137    *
138    * This signal is emitted when the preview in a file chooser should be
139    * regenerated.  For example, this can happen when the currently selected file
140    * changes.  You should use this signal if you want your file chooser to have
141    * a preview widget.
142    *
143    * Once you have installed a preview widget with
144    * gtk_file_chooser_set_preview_widget(), you should update it when this
145    * signal is emitted.  You can use the functions
146    * gtk_file_chooser_get_preview_filename() or
147    * gtk_file_chooser_get_preview_uri() to get the name of the file to preview.
148    * Your widget may not be able to preview all kinds of files; your callback
149    * must call gtk_file_chooser_set_preview_wiget_active() to inform the file
150    * chooser about whether the preview was generated successfully or not.
151    *
152    * Please see the example code in <xref linkend="gtkfilechooser-preview"/>.
153    *
154    * See also: gtk_file_chooser_set_preview_widget(),
155    * gtk_file_chooser_set_preview_widget_active(),
156    * gtk_file_chooser_set_use_preview_label(),
157    * gtk_file_chooser_get_preview_filename(),
158    * gtk_file_chooser_get_preview_uri().
159    */
160   g_signal_new ("update-preview",
161                 iface_type,
162                 G_SIGNAL_RUN_LAST,
163                 G_STRUCT_OFFSET (GtkFileChooserIface, update_preview),
164                 NULL, NULL,
165                 g_cclosure_marshal_VOID__VOID,
166                 G_TYPE_NONE, 0);
167
168   /**
169    * GtkFileChooser::file-activated
170    * @chooser: the object which received the signal.
171    *
172    * This signal is emitted when the user "activates" a file in the file
173    * chooser.  This can happen by double-clicking on a file in the file list, or
174    * by pressing <keycap>Enter</keycap>.
175    *
176    * Normally you do not need to connect to this signal.  It is used internally
177    * by #GtkFileChooserDialog to know when to activate the default button in the
178    * dialog.
179    *
180    * See also: gtk_file_chooser_get_filename(),
181    * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(),
182    * gtk_file_chooser_get_uris().
183    */
184   g_signal_new ("file-activated",
185                 iface_type,
186                 G_SIGNAL_RUN_LAST,
187                 G_STRUCT_OFFSET (GtkFileChooserIface, file_activated),
188                 NULL, NULL,
189                 g_cclosure_marshal_VOID__VOID,
190                 G_TYPE_NONE, 0);
191
192   /* Documented in the docbook files */
193   g_signal_new ("confirm-overwrite",
194                 iface_type,
195                 G_SIGNAL_RUN_LAST,
196                 G_STRUCT_OFFSET (GtkFileChooserIface, confirm_overwrite),
197                 confirm_overwrite_accumulator, NULL,
198                 _gtk_marshal_ENUM__VOID,
199                 GTK_TYPE_FILE_CHOOSER_CONFIRMATION, 0);
200   
201   g_object_interface_install_property (g_iface,
202                                        g_param_spec_enum ("action",
203                                                           P_("Action"),
204                                                           P_("The type of operation that the file selector is performing"),
205                                                           GTK_TYPE_FILE_CHOOSER_ACTION,
206                                                           GTK_FILE_CHOOSER_ACTION_OPEN,
207                                                           GTK_PARAM_READWRITE));
208   g_object_interface_install_property (g_iface,
209                                        g_param_spec_string ("file-system-backend",
210                                                             P_("File System Backend"),
211                                                             P_("Name of file system backend to use"),
212                                                             NULL, 
213                                                             GTK_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
214   g_object_interface_install_property (g_iface,
215                                        g_param_spec_object ("filter",
216                                                             P_("Filter"),
217                                                             P_("The current filter for selecting which files are displayed"),
218                                                             GTK_TYPE_FILE_FILTER,
219                                                             GTK_PARAM_READWRITE));
220   g_object_interface_install_property (g_iface,
221                                        g_param_spec_boolean ("local-only",
222                                                              P_("Local Only"),
223                                                              P_("Whether the selected file(s) should be limited to local file: URLs"),
224                                                              TRUE,
225                                                              GTK_PARAM_READWRITE));
226   g_object_interface_install_property (g_iface,
227                                        g_param_spec_object ("preview-widget",
228                                                             P_("Preview widget"),
229                                                             P_("Application supplied widget for custom previews."),
230                                                             GTK_TYPE_WIDGET,
231                                                             GTK_PARAM_READWRITE));
232   g_object_interface_install_property (g_iface,
233                                        g_param_spec_boolean ("preview-widget-active",
234                                                              P_("Preview Widget Active"),
235                                                              P_("Whether the application supplied widget for custom previews should be shown."),
236                                                              TRUE,
237                                                              GTK_PARAM_READWRITE));
238   g_object_interface_install_property (g_iface,
239                                        g_param_spec_boolean ("use-preview-label",
240                                                              P_("Use Preview Label"),
241                                                              P_("Whether to display a stock label with the name of the previewed file."),
242                                                              TRUE,
243                                                              GTK_PARAM_READWRITE));
244   g_object_interface_install_property (g_iface,
245                                        g_param_spec_object ("extra-widget",
246                                                             P_("Extra widget"),
247                                                             P_("Application supplied widget for extra options."),
248                                                             GTK_TYPE_WIDGET,
249                                                             GTK_PARAM_READWRITE));
250   g_object_interface_install_property (g_iface,
251                                        g_param_spec_boolean ("select-multiple",
252                                                              P_("Select Multiple"),
253                                                              P_("Whether to allow multiple files to be selected"),
254                                                              FALSE,
255                                                              GTK_PARAM_READWRITE));
256   
257   g_object_interface_install_property (g_iface,
258                                        g_param_spec_boolean ("show-hidden",
259                                                              P_("Show Hidden"),
260                                                              P_("Whether the hidden files and folders should be displayed"),
261                                                              FALSE,
262                                                              GTK_PARAM_READWRITE));
263
264   g_object_interface_install_property (g_iface,
265                                        g_param_spec_boolean ("do-overwrite-confirmation",
266                                                              P_("Do overwrite confirmation"),
267                                                              P_("Whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE "
268                                                                 "will present an overwrite confirmation dialog if the user "
269                                                                 "selects a file name that already exists."),
270                                                              FALSE,
271                                                              GTK_PARAM_READWRITE));
272 }
273
274 /**
275  * gtk_file_chooser_error_quark:
276  *
277  * Registers an error quark for #GtkFileChooser if necessary.
278  * 
279  * Return value: The error quark used for #GtkFileChooser errors.
280  *
281  * Since: 2.4
282  **/
283 GQuark
284 gtk_file_chooser_error_quark (void)
285 {
286   static GQuark quark = 0;
287   if (quark == 0)
288     quark = g_quark_from_static_string ("gtk-file-chooser-error-quark");
289   return quark;
290 }
291
292 /**
293  * gtk_file_chooser_set_action:
294  * @chooser: a #GtkFileChooser
295  * @action: the action that the file selector is performing
296  * 
297  * Sets the type of operation that the chooser is performing; the
298  * user interface is adapted to suit the selected action. For example,
299  * an option to create a new folder might be shown if the action is
300  * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
301  * %GTK_FILE_CHOOSER_ACTION_OPEN.
302  *
303  * Since: 2.4
304  **/
305 void
306 gtk_file_chooser_set_action (GtkFileChooser       *chooser,
307                              GtkFileChooserAction  action)
308 {
309   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
310
311   g_object_set (chooser, "action", action, NULL);
312 }
313
314 /**
315  * gtk_file_chooser_get_action:
316  * @chooser: a #GtkFileChooser
317  * 
318  * Gets the type of operation that the file chooser is performing; see
319  * gtk_file_chooser_set_action().
320  * 
321  * Return value: the action that the file selector is performing
322  *
323  * Since: 2.4
324  **/
325 GtkFileChooserAction
326 gtk_file_chooser_get_action (GtkFileChooser *chooser)
327 {
328   GtkFileChooserAction action;
329   
330   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
331
332   g_object_get (chooser, "action", &action, NULL);
333
334   return action;
335 }
336
337 /**
338  * gtk_file_chooser_set_local_only:
339  * @chooser: a #GtkFileChooser
340  * @local_only: %TRUE if only local files can be selected
341  * 
342  * Sets whether only local files can be selected in the
343  * file selector. If @local_only is %TRUE (the default),
344  * then the selected file are files are guaranteed to be
345  * accessible through the operating systems native file
346  * file system and therefore the application only
347  * needs to worry about the filename functions in
348  * #GtkFileChooser, like gtk_file_chooser_get_filename(),
349  * rather than the URI functions like
350  * gtk_file_chooser_get_uri(),
351  *
352  * Since: 2.4
353  **/
354 void
355 gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
356                                  gboolean        local_only)
357 {
358   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
359
360   g_object_set (chooser, "local-only", local_only, NULL);
361 }
362
363 /**
364  * gtk_file_chooser_get_local_only:
365  * @chooser: a #GtkFileChoosre
366  * 
367  * Gets whether only local files can be selected in the
368  * file selector. See gtk_file_chooser_set_local_only()
369  * 
370  * Return value: %TRUE if only local files can be selected.
371  *
372  * Since: 2.4
373  **/
374 gboolean
375 gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
376 {
377   gboolean local_only;
378   
379   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
380
381   g_object_get (chooser, "local-only", &local_only, NULL);
382
383   return local_only;
384 }
385
386 /**
387  * gtk_file_chooser_set_select_multiple:
388  * @chooser: a #GtkFileChooser
389  * @select_multiple: %TRUE if multiple files can be selected.
390  * 
391  * Sets whether multiple files can be selected in the file selector.  This is
392  * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
393  * GTK_FILE_CHOOSER_ACTION_SAVE.  It cannot be set with either of the folder
394  * actions.
395  *
396  * Since: 2.4
397  **/
398 void
399 gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
400                                       gboolean        select_multiple)
401 {
402   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
403
404   g_object_set (chooser, "select-multiple", select_multiple, NULL);
405 }
406
407 /**
408  * gtk_file_chooser_get_select_multiple:
409  * @chooser: a #GtkFileChooser
410  * 
411  * Gets whether multiple files can be selected in the file
412  * selector. See gtk_file_chooser_set_select_multiple().
413  * 
414  * Return value: %TRUE if multiple files can be selected.
415  *
416  * Since: 2.4
417  **/
418 gboolean
419 gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
420 {
421   gboolean select_multiple;
422   
423   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
424
425   g_object_get (chooser, "select-multiple", &select_multiple, NULL);
426
427   return select_multiple;
428 }
429
430 /**
431  * gtk_file_chooser_get_filename:
432  * @chooser: a #GtkFileChooser
433  * 
434  * Gets the filename for the currently selected file in
435  * the file selector. If multiple files are selected,
436  * one of the filenames will be returned at random.
437  *
438  * If the file chooser is in folder mode, this function returns the selected
439  * folder.
440  * 
441  * Return value: The currently selected filename, or %NULL
442  *  if no file is selected, or the selected file can't
443  *  be represented with a local filename. Free with g_free().
444  *
445  * Since: 2.4
446  **/
447 gchar *
448 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
449 {
450   GtkFileSystem *file_system;
451   GtkFilePath *path;
452   gchar *result = NULL;
453   
454   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
455
456   file_system = _gtk_file_chooser_get_file_system (chooser);
457   path = gtk_file_chooser_get_path (chooser);
458   if (path)
459     {
460       result = gtk_file_system_path_to_filename (file_system, path);
461       gtk_file_path_free (path);
462     }
463
464   return result;
465 }
466
467 /**
468  * gtk_file_chooser_set_filename:
469  * @chooser: a #GtkFileChooser
470  * @filename: the filename to set as current
471  * 
472  * Sets @filename as the current filename for the file chooser, by changing
473  * to the file's parent folder and actually selecting the file in list.  If
474  * the @chooser is in #GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
475  * will also appear in the dialog's file name entry.
476  *
477  * If the file name isn't in the current folder of @chooser, then the current
478  * folder of @chooser will be changed to the folder containing @filename. This
479  * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
480  * gtk_file_chooser_select_filename().
481  *
482  * Note that the file must exist, or nothing will be done except
483  * for the directory change.
484  *
485  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
486  * should use this function if you already have a file name to which the user may save; for example,
487  * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
488  * on it.  If you don't have a file name already &mdash; for example, if the user just created
489  * a new file and is saving it for the first time, do not call this function.  Instead, use
490  * something similar to this:
491  *
492  * <programlisting>
493  * if (document_is_new)
494  *   {
495  *     /<!-- -->* the user just created a new document *<!-- -->/
496  *     gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
497  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
498  *   }
499  * else
500  *   {
501  *     /<!-- -->* the user edited an existing document *<!-- -->/ 
502  *     gtk_file_chooser_set_filename (chooser, existing_filename);
503  *   }
504  * </programlisting>
505  * 
506  * Return value: %TRUE if both the folder could be changed and the file was
507  * selected successfully, %FALSE otherwise.
508  *
509  * Since: 2.4
510  **/
511 gboolean
512 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
513                                const gchar    *filename)
514 {
515   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
516
517   gtk_file_chooser_unselect_all (chooser);
518   return gtk_file_chooser_select_filename (chooser, filename);
519 }
520
521 /**
522  * gtk_file_chooser_select_filename:
523  * @chooser: a #GtkFileChooser
524  * @filename: the filename to select
525  * 
526  * Selects a filename. If the file name isn't in the current
527  * folder of @chooser, then the current folder of @chooser will
528  * be changed to the folder containing @filename.
529  *
530  * Return value: %TRUE if both the folder could be changed and the file was
531  * selected successfully, %FALSE otherwise.
532  *
533  * Since: 2.4
534  **/
535 gboolean
536 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
537                                   const gchar    *filename)
538 {
539   GtkFileSystem *file_system;
540   GtkFilePath *path;
541   gboolean result;
542   
543   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
544   g_return_val_if_fail (filename != NULL, FALSE);
545
546   file_system = _gtk_file_chooser_get_file_system (chooser);
547
548   path = gtk_file_system_filename_to_path (file_system, filename);
549   if (path)
550     {
551       result = _gtk_file_chooser_select_path (chooser, path, NULL);
552       gtk_file_path_free (path);
553     }
554   else
555     result = FALSE;
556
557   return result;
558 }
559
560 /**
561  * gtk_file_chooser_unselect_filename:
562  * @chooser: a #GtkFileChooser
563  * @filename: the filename to unselect
564  * 
565  * Unselects a currently selected filename. If the filename
566  * is not in the current directory, does not exist, or
567  * is otherwise not currently selected, does nothing.
568  *
569  * Since: 2.4
570  **/
571 void
572 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
573                                     const char     *filename)
574 {
575   GtkFileSystem *file_system;
576   GtkFilePath *path;
577   
578   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
579   g_return_if_fail (filename != NULL);
580
581   file_system = _gtk_file_chooser_get_file_system (chooser);
582
583   path = gtk_file_system_filename_to_path (file_system, filename);
584   if (path)
585     {
586       _gtk_file_chooser_unselect_path (chooser, path);
587       gtk_file_path_free (path);
588     }
589 }
590
591 /* Converts a list of GtkFilePath* to a list of strings using the specified function */
592 static GSList *
593 file_paths_to_strings (GtkFileSystem *fs,
594                        GSList        *paths,
595                        gchar *      (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
596 {
597   GSList *strings;
598
599   strings = NULL;
600
601   for (; paths; paths = paths->next)
602     {
603       GtkFilePath *path;
604       gchar *string;
605
606       path = paths->data;
607       string = (* convert_func) (fs, path);
608
609       if (string)
610         strings = g_slist_prepend (strings, string);
611     }
612
613   return g_slist_reverse (strings);
614 }
615
616 /**
617  * gtk_file_chooser_get_filenames:
618  * @chooser: a #GtkFileChooser
619  * 
620  * Lists all the selected files and subfolders in the current folder of
621  * @chooser. The returned names are full absolute paths. If files in the current
622  * folder cannot be represented as local filenames they will be ignored. (See
623  * gtk_file_chooser_get_uris())
624  * 
625  * Return value: a #GSList containing the filenames of all selected
626  *   files and subfolders in the current folder. Free the returned list
627  *   with g_slist_free(), and the filenames with g_free().
628  *
629  * Since: 2.4
630  **/
631 GSList *
632 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
633 {
634   GtkFileSystem *file_system;
635   GSList *paths;
636   GSList *result;
637   
638   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
639
640   file_system = _gtk_file_chooser_get_file_system (chooser);
641   paths = _gtk_file_chooser_get_paths (chooser);
642
643   result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
644   gtk_file_paths_free (paths);
645   return result;
646 }
647
648 /**
649  * gtk_file_chooser_set_current_folder:
650  * @chooser: a #GtkFileChooser
651  * @filename: the full path of the new current folder
652  * 
653  * Sets the current folder for @chooser from a local filename.
654  * The user will be shown the full contents of the current folder,
655  * plus user interface elements for navigating to other folders.
656  *
657  * Return value: %TRUE if the folder could be changed successfully, %FALSE
658  * otherwise.
659  *
660  * Since: 2.4
661  **/
662 gboolean
663 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
664                                      const gchar    *filename)
665 {
666   GtkFileSystem *file_system;
667   GtkFilePath *path;
668   gboolean result;
669   
670   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
671   g_return_val_if_fail (filename != NULL, FALSE);
672
673   file_system = _gtk_file_chooser_get_file_system (chooser);
674
675   path = gtk_file_system_filename_to_path (file_system, filename);
676   if (path)
677     {
678       result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
679       gtk_file_path_free (path);
680     }
681   else
682     result = FALSE;
683
684   return result;
685 }
686
687 /**
688  * gtk_file_chooser_get_current_folder:
689  * @chooser: a #GtkFileChooser
690  * 
691  * Gets the current folder of @chooser as a local filename.
692  * See gtk_file_chooser_set_current_folder().
693  * 
694  * Return value: the full path of the current folder, or %NULL
695  *  if the current path cannot be represented as a local filename.
696  *  Free with g_free().
697  *
698  * Since: 2.4
699  **/
700 gchar *
701 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
702 {
703   GtkFileSystem *file_system;
704   GtkFilePath *path;
705   gchar *filename;
706   
707   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
708
709   file_system = _gtk_file_chooser_get_file_system (chooser);
710
711   path = _gtk_file_chooser_get_current_folder_path (chooser);
712   filename = gtk_file_system_path_to_filename (file_system, path);
713   gtk_file_path_free (path);
714
715   return filename;
716 }
717
718 /**
719  * gtk_file_chooser_set_current_name:
720  * @chooser: a #GtkFileChooser
721  * @name: the filename to use, as a UTF-8 string
722  * 
723  * Sets the current name in the file selector, as if entered
724  * by the user. Note that the name passed in here is a UTF-8
725  * string rather than a filename. This function is meant for
726  * such uses as a suggested name in a "Save As..." dialog.
727  *
728  * If you want to preselect a particular existing file, you should use
729  * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
730  * Please see the documentation for those functions for an example of using
731  * gtk_file_chooser_set_current_name() as well.
732  *
733  * Since: 2.4
734  **/
735 void
736 gtk_file_chooser_set_current_name  (GtkFileChooser *chooser,
737                                     const gchar    *name)
738 {
739   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
740   g_return_if_fail (name != NULL);
741   
742   GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_name (chooser, name);
743 }
744
745 /**
746  * gtk_file_chooser_get_uri:
747  * @chooser: a #GtkFileChooser
748  * 
749  * Gets the URI for the currently selected file in
750  * the file selector. If multiple files are selected,
751  * one of the filenames will be returned at random.
752  * 
753  * If the file chooser is in folder mode, this function returns the selected
754  * folder.
755  * 
756  * Return value: The currently selected URI, or %NULL
757  *  if no file is selected. Free with g_free()
758  *
759  * Since: 2.4
760  **/
761 gchar *
762 gtk_file_chooser_get_uri (GtkFileChooser *chooser)
763 {
764   GtkFileSystem *file_system;
765   GtkFilePath *path;
766   gchar *result = NULL;
767   
768   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
769
770   file_system = _gtk_file_chooser_get_file_system (chooser);
771   path = gtk_file_chooser_get_path (chooser);
772   if (path)
773     {
774       result = gtk_file_system_path_to_uri (file_system, path);
775       gtk_file_path_free (path);
776     }
777
778   return result;
779 }
780
781 /**
782  * gtk_file_chooser_set_uri:
783  * @chooser: a #GtkFileChooser
784  * @uri: the URI to set as current
785  * 
786  * Sets the file referred to by @uri as the current file for the file chooser,
787  * by changing to the URI's parent folder and actually selecting the URI in the
788  * list.  If the @chooser is #GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
789  * name will also appear in the dialog's file name entry.
790  *
791  * If the URI isn't in the current folder of @chooser, then the current folder
792  * of @chooser will be changed to the folder containing @uri. This is equivalent
793  * to a sequence of gtk_file_chooser_unselect_all() followed by
794  * gtk_file_chooser_select_uri().
795  *
796  * Note that the URI must exist, or nothing will be done except
797  * for the directory change.
798  * If you are implementing a <guimenuitem>File/Save As...</guimenuitem> dialog, you
799  * should use this function if you already have a file name to which the user may save; for example,
800  * when the user opens an existing file and then does <guimenuitem>File/Save As...</guimenuitem>
801  * on it.  If you don't have a file name already &mdash; for example, if the user just created
802  * a new file and is saving it for the first time, do not call this function.  Instead, use
803  * something similar to this:
804  *
805  * <programlisting>
806  * if (document_is_new)
807  *   {
808  *     /<!-- -->* the user just created a new document *<!-- -->/
809  *     gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
810  *     gtk_file_chooser_set_current_name (chooser, "Untitled document");
811  *   }
812  * else
813  *   {
814  *     /<!-- -->* the user edited an existing document *<!-- -->/ 
815  *     gtk_file_chooser_set_uri (chooser, existing_uri);
816  *   }
817  * </programlisting>
818  *
819  * Return value: %TRUE if both the folder could be changed and the URI was
820  * selected successfully, %FALSE otherwise.
821  *
822  * Since: 2.4
823  **/
824 gboolean
825 gtk_file_chooser_set_uri (GtkFileChooser *chooser,
826                           const char     *uri)
827 {
828   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
829
830   gtk_file_chooser_unselect_all (chooser);
831   return gtk_file_chooser_select_uri (chooser, uri);
832 }
833
834 /**
835  * gtk_file_chooser_select_uri:
836  * @chooser: a #GtkFileChooser
837  * @uri: the URI to select
838  * 
839  * Selects the file to by @uri. If the URI doesn't refer to a
840  * file in the current folder of @chooser, then the current folder of
841  * @chooser will be changed to the folder containing @filename.
842  *
843  * Return value: %TRUE if both the folder could be changed and the URI was
844  * selected successfully, %FALSE otherwise.
845  *
846  * Since: 2.4
847  **/
848 gboolean
849 gtk_file_chooser_select_uri (GtkFileChooser *chooser,
850                              const char     *uri)
851 {
852   GtkFileSystem *file_system;
853   GtkFilePath *path;
854   gboolean result;
855   
856   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
857   g_return_val_if_fail (uri != NULL, FALSE);
858
859   file_system = _gtk_file_chooser_get_file_system (chooser);
860
861   path = gtk_file_system_uri_to_path (file_system, uri);
862   if (path)
863     {
864       result = _gtk_file_chooser_select_path (chooser, path, NULL);
865       gtk_file_path_free (path);
866     }
867   else
868     result = FALSE;
869
870   return result;
871 }
872
873 /**
874  * gtk_file_chooser_unselect_uri:
875  * @chooser: a #GtkFileChooser
876  * @uri: the URI to unselect
877  * 
878  * Unselects the file referred to by @uri. If the file
879  * is not in the current directory, does not exist, or
880  * is otherwise not currently selected, does nothing.
881  *
882  * Since: 2.4
883  **/
884 void
885 gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
886                                const char     *uri)
887 {
888   GtkFileSystem *file_system;
889   GtkFilePath *path;
890   
891   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
892   g_return_if_fail (uri != NULL);
893
894   file_system = _gtk_file_chooser_get_file_system (chooser);
895
896   path = gtk_file_system_uri_to_path (file_system, uri);
897   if (path)
898     {
899       _gtk_file_chooser_unselect_path (chooser, path);
900       gtk_file_path_free (path);
901     }
902 }
903
904 /**
905  * gtk_file_chooser_select_all:
906  * @chooser: a #GtkFileChooser
907  * 
908  * Selects all the files in the current folder of a file chooser.
909  *
910  * Since: 2.4
911  **/
912 void
913 gtk_file_chooser_select_all (GtkFileChooser *chooser)
914 {
915   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
916   
917   GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
918 }
919
920 /**
921  * gtk_file_chooser_unselect_all:
922  * @chooser: a #GtkFileChooser
923  * 
924  * Unselects all the files in the current folder of a file chooser.
925  *
926  * Since: 2.4
927  **/
928 void
929 gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
930 {
931
932   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
933   
934   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
935 }
936
937 /**
938  * gtk_file_chooser_get_uris:
939  * @chooser: a #GtkFileChooser
940  * 
941  * Lists all the selected files and subfolders in the current folder of
942  * @chooser. The returned names are full absolute URIs.
943  * 
944  * Return value: a #GSList containing the URIs of all selected
945  *   files and subfolders in the current folder. Free the returned list
946  *   with g_slist_free(), and the filenames with g_free().
947  *
948  * Since: 2.4
949  **/
950 GSList *
951 gtk_file_chooser_get_uris (GtkFileChooser *chooser)
952 {
953   GtkFileSystem *file_system;
954   GSList *paths;
955   GSList *result;
956   
957   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
958
959   file_system = _gtk_file_chooser_get_file_system (chooser);
960   paths = _gtk_file_chooser_get_paths (chooser);
961
962   result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
963   gtk_file_paths_free (paths);
964   return result;
965 }
966
967 /**
968  * gtk_file_chooser_set_current_folder_uri:
969  * @chooser: a #GtkFileChooser
970  * @uri: the URI for the new current folder
971  * 
972  * Sets the current folder for @chooser from an URI.
973  * The user will be shown the full contents of the current folder,
974  * plus user interface elements for navigating to other folders.
975  *
976  * Return value: %TRUE if the folder could be changed successfully, %FALSE
977  * otherwise.
978  *
979  * Since: 2.4
980  **/
981 gboolean
982 gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
983                                          const gchar    *uri)
984 {
985   GtkFileSystem *file_system;
986   GtkFilePath *path;
987   gboolean result;
988   
989   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
990   g_return_val_if_fail (uri != NULL, FALSE);
991
992   file_system = _gtk_file_chooser_get_file_system (chooser);
993
994   path = gtk_file_system_uri_to_path (file_system, uri);
995   if (path)
996     {
997       result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
998       gtk_file_path_free (path);
999     }
1000   else
1001     result = FALSE;
1002
1003   return result;
1004 }
1005
1006 /**
1007  * gtk_file_chooser_get_current_folder_uri:
1008  * @chooser: a #GtkFileChooser
1009  * 
1010  * Gets the current folder of @chooser as an URI.
1011  * See gtk_file_chooser_set_current_folder_uri().
1012  * 
1013  * Return value: the URI for the current folder.
1014  *  Free with g_free().
1015  *
1016  * Since: 2.4
1017  */
1018 gchar *
1019 gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
1020 {
1021   GtkFileSystem *file_system;
1022   GtkFilePath *path;
1023   gchar *uri;
1024   
1025   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1026
1027   file_system = _gtk_file_chooser_get_file_system (chooser);
1028
1029   path = _gtk_file_chooser_get_current_folder_path (chooser);
1030   uri = gtk_file_system_path_to_uri (file_system, path);
1031   gtk_file_path_free (path);
1032
1033   return uri;
1034 }
1035
1036 /**
1037  * _gtk_file_chooser_set_current_folder_path:
1038  * @chooser: a #GtkFileChooser
1039  * @path: the #GtkFilePath for the new folder
1040  * @error: location to store error, or %NULL.
1041  * 
1042  * Sets the current folder for @chooser from a #GtkFilePath.
1043  * Internal function, see gtk_file_chooser_set_current_folder_uri().
1044  *
1045  * Return value: %TRUE if the folder could be changed successfully, %FALSE
1046  * otherwise.
1047  *
1048  * Since: 2.4
1049  **/
1050 gboolean
1051 _gtk_file_chooser_set_current_folder_path (GtkFileChooser    *chooser,
1052                                            const GtkFilePath *path,
1053                                            GError           **error)
1054 {
1055   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1056   g_return_val_if_fail (path != NULL, FALSE);
1057   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1058
1059   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error);
1060 }
1061
1062 /**
1063  * _gtk_file_chooser_get_current_folder_path:
1064  * @chooser: a #GtkFileChooser
1065  * 
1066  * Gets the current folder of @chooser as #GtkFilePath.
1067  * See gtk_file_chooser_get_current_folder_uri().
1068  * 
1069  * Return value: the #GtkFilePath for the current folder.
1070  * Free with gtk_file_path_free().
1071  *
1072  * Since: 2.4
1073  */
1074 GtkFilePath *
1075 _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
1076 {
1077   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1078
1079   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_current_folder (chooser);  
1080 }
1081
1082 /**
1083  * _gtk_file_chooser_select_path:
1084  * @chooser: a #GtkFileChooser
1085  * @path: the path to select
1086  * @error: location to store error, or %NULL
1087  * 
1088  * Selects the file referred to by @path. An internal function. See
1089  * _gtk_file_chooser_select_uri().
1090  *
1091  * Return value: %TRUE if both the folder could be changed and the path was
1092  * selected successfully, %FALSE otherwise.
1093  *
1094  * Since: 2.4
1095  **/
1096 gboolean
1097 _gtk_file_chooser_select_path (GtkFileChooser    *chooser,
1098                                const GtkFilePath *path,
1099                                GError           **error)
1100 {
1101   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1102   g_return_val_if_fail (path != NULL, FALSE);
1103   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
1104
1105   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error);
1106 }
1107
1108 /**
1109  * _gtk_file_chooser_unselect_path:
1110  * @chooser: a #GtkFileChooser
1111  * @path: the filename to path
1112  * 
1113  * Unselects the file referred to by @path. An internal
1114  * function. See _gtk_file_chooser_unselect_uri().
1115  *
1116  * Since: 2.4
1117  **/
1118 void
1119 _gtk_file_chooser_unselect_path (GtkFileChooser    *chooser,
1120                                  const GtkFilePath *path)
1121 {
1122   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1123
1124   GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path);
1125 }
1126
1127 /**
1128  * _gtk_file_chooser_get_paths:
1129  * @chooser: a #GtkFileChooser
1130  * 
1131  * Lists all the selected files and subfolders in the current folder of @chooser
1132  * as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris().
1133  * 
1134  * Return value: a #GSList containing a #GtkFilePath for each selected
1135  *   file and subfolder in the current folder.  Free the returned list
1136  *   with g_slist_free(), and the paths with gtk_file_path_free().
1137  *
1138  * Since: 2.4
1139  **/
1140 GSList *
1141 _gtk_file_chooser_get_paths (GtkFileChooser *chooser)
1142 {
1143   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1144
1145   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
1146 }
1147
1148 static GtkFilePath *
1149 gtk_file_chooser_get_path (GtkFileChooser *chooser)
1150 {
1151   GSList *list;
1152   GtkFilePath *result = NULL;
1153   
1154   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1155
1156   list = _gtk_file_chooser_get_paths (chooser);
1157   if (list)
1158     {
1159       result = list->data;
1160       list = g_slist_delete_link (list, list);
1161       gtk_file_paths_free (list);
1162     }
1163
1164   return result;
1165 }
1166
1167 /**
1168  * _gtk_file_chooser_get_file_system:
1169  * @chooser: a #GtkFileChooser
1170  * 
1171  * Gets the #GtkFileSystem of @chooser; this is an internal
1172  * implementation detail, used for conversion between paths
1173  * and filenames and URIs.
1174  * 
1175  * Return value: the file system for @chooser.
1176  *
1177  * Since: 2.4
1178  **/
1179 GtkFileSystem *
1180 _gtk_file_chooser_get_file_system (GtkFileChooser *chooser)
1181 {
1182   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1183
1184   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_file_system (chooser);
1185 }
1186
1187 /* Preview widget
1188  */
1189 /**
1190  * gtk_file_chooser_set_preview_widget:
1191  * @chooser: a #GtkFileChooser
1192  * @preview_widget: widget for displaying preview.
1193  *
1194  * Sets an application-supplied widget to use to display a custom preview
1195  * of the currently selected file. To implement a preview, after setting the
1196  * preview widget, you connect to the ::update-preview
1197  * signal, and call gtk_file_chooser_get_preview_filename() or
1198  * gtk_file_chooser_get_preview_uri() on each change. If you can
1199  * display a preview of the new file, update your widget and
1200  * set the preview active using gtk_file_chooser_set_preview_widget_active().
1201  * Otherwise, set the preview inactive.
1202  *
1203  * When there is no application-supplied preview widget, or the
1204  * application-supplied preview widget is not active, the file chooser
1205  * may display an internally generated preview of the current file or
1206  * it may display no preview at all.
1207  *
1208  * Since: 2.4
1209  **/
1210 void
1211 gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
1212                                      GtkWidget      *preview_widget)
1213 {
1214   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1215
1216   g_object_set (chooser, "preview-widget", preview_widget, NULL);
1217 }
1218
1219 /**
1220  * gtk_file_chooser_get_preview_widget:
1221  * @chooser: a #GtkFileChooser
1222  * 
1223  * Gets the current preview widget; see
1224  * gtk_file_chooser_set_preview_widget().
1225  * 
1226  * Return value: the current preview widget, or %NULL
1227  *
1228  * Since: 2.4
1229  **/
1230 GtkWidget *
1231 gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser)
1232 {
1233   GtkWidget *preview_widget;
1234   
1235   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1236
1237   g_object_get (chooser, "preview-widget", &preview_widget, NULL);
1238   
1239   /* Horrid hack; g_object_get() refs returned objects but
1240    * that contradicts the memory management conventions
1241    * for accessors.
1242    */
1243   if (preview_widget)
1244     g_object_unref (preview_widget);
1245
1246   return preview_widget;
1247 }
1248
1249 /**
1250  * gtk_file_chooser_set_preview_widget_active:
1251  * @chooser: a #GtkFileChooser
1252  * @active: whether to display the user-specified preview widget
1253  * 
1254  * Sets whether the preview widget set by
1255  * gtk_file_chooser_set_preview_widget() should be shown for the
1256  * current filename. When @active is set to false, the file chooser
1257  * may display an internally generated preview of the current file
1258  * or it may display no preview at all. See
1259  * gtk_file_chooser_set_preview_widget() for more details.
1260  *
1261  * Since: 2.4
1262  **/
1263 void
1264 gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
1265                                             gboolean        active)
1266 {
1267   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1268   
1269   g_object_set (chooser, "preview-widget-active", active, NULL);
1270 }
1271
1272 /**
1273  * gtk_file_chooser_get_preview_widget_active:
1274  * @chooser: a #GtkFileChooser
1275  * 
1276  * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1277  * should be shown for the current filename. See
1278  * gtk_file_chooser_set_preview_widget_active().
1279  * 
1280  * Return value: %TRUE if the preview widget is active for the current filename.
1281  *
1282  * Since: 2.4
1283  **/
1284 gboolean
1285 gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser)
1286 {
1287   gboolean active;
1288   
1289   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1290
1291   g_object_get (chooser, "preview-widget-active", &active, NULL);
1292
1293   return active;
1294 }
1295
1296 /**
1297  * gtk_file_chooser_set_use_preview_label:
1298  * @chooser: a #GtkFileChooser
1299  * @use_label: whether to display a stock label with the name of the previewed file
1300  * 
1301  * Sets whether the file chooser should display a stock label with the name of
1302  * the file that is being previewed; the default is %TRUE.  Applications that
1303  * want to draw the whole preview area themselves should set this to %FALSE and
1304  * display the name themselves in their preview widget.
1305  *
1306  * See also: gtk_file_chooser_set_preview_widget()
1307  *
1308  * Since: 2.4
1309  **/
1310 void
1311 gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
1312                                         gboolean        use_label)
1313 {
1314   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1315
1316   g_object_set (chooser, "use-preview-label", use_label, NULL);
1317 }
1318
1319 /**
1320  * gtk_file_chooser_get_use_preview_label:
1321  * @chooser: a #GtkFileChooser
1322  * 
1323  * Gets whether a stock label should be drawn with the name of the previewed
1324  * file.  See gtk_file_chooser_set_use_preview_label().
1325  * 
1326  * Return value: %TRUE if the file chooser is set to display a label with the
1327  * name of the previewed file, %FALSE otherwise.
1328  **/
1329 gboolean
1330 gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
1331 {
1332   gboolean use_label;
1333   
1334   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1335
1336   g_object_get (chooser, "use-preview-label", &use_label, NULL);
1337
1338   return use_label;
1339 }
1340
1341 /**
1342  * gtk_file_chooser_get_preview_filename:
1343  * @chooser: a #GtkFileChooser
1344  * 
1345  * Gets the filename that should be previewed in a custom preview
1346  * Internal function, see gtk_file_chooser_get_preview_uri().
1347  * 
1348  * Return value: the #GtkFilePath for the file to preview, or %NULL if no file
1349  *  is selected. Free with gtk_file_path_free().
1350  *
1351  * Since: 2.4
1352  **/
1353 GtkFilePath *
1354 _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
1355 {
1356   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1357
1358   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser);
1359 }
1360
1361 /**
1362  * _gtk_file_chooser_add_shortcut_folder:
1363  * @chooser: a #GtkFileChooser
1364  * @path: path of the folder to add
1365  * @error: location to store error, or %NULL
1366  * 
1367  * Adds a folder to be displayed with the shortcut folders in a file chooser.
1368  * Internal function, see gtk_file_chooser_add_shortcut_folder().
1369  * 
1370  * Return value: %TRUE if the folder could be added successfully, %FALSE
1371  * otherwise.
1372  *
1373  * Since: 2.4
1374  **/
1375 gboolean
1376 _gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
1377                                        const GtkFilePath *path,
1378                                        GError           **error)
1379 {
1380   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1381   g_return_val_if_fail (path != NULL, FALSE);
1382
1383   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1384 }
1385
1386 /**
1387  * _gtk_file_chooser_remove_shortcut_folder:
1388  * @chooser: a #GtkFileChooser
1389  * @path: path of the folder to remove
1390  * @error: location to store error, or %NULL
1391  * 
1392  * Removes a folder from the shortcut folders in a file chooser.  Internal
1393  * function, see gtk_file_chooser_remove_shortcut_folder().
1394  * 
1395  * Return value: %TRUE if the folder could be removed successfully, %FALSE
1396  * otherwise.
1397  *
1398  * Since: 2.4
1399  **/
1400 gboolean
1401 _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
1402                                           const GtkFilePath *path,
1403                                           GError           **error)
1404 {
1405   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1406   g_return_val_if_fail (path != NULL, FALSE);
1407
1408   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1409 }
1410
1411 /**
1412  * gtk_file_chooser_get_preview_filename:
1413  * @chooser: a #GtkFileChooser
1414  * 
1415  * Gets the filename that should be previewed in a custom preview
1416  * widget. See gtk_file_chooser_set_preview_widget().
1417  * 
1418  * Return value: the filename to preview, or %NULL if no file
1419  *  is selected, or if the selected file cannot be represented
1420  *  as a local filename. Free with g_free()
1421  *
1422  * Since: 2.4
1423  **/
1424 char *
1425 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
1426 {
1427   GtkFileSystem *file_system;
1428   GtkFilePath *path;
1429   gchar *result = NULL;
1430   
1431   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1432
1433   file_system = _gtk_file_chooser_get_file_system (chooser);
1434   path = _gtk_file_chooser_get_preview_path (chooser);
1435   if (path)
1436     {
1437       result = gtk_file_system_path_to_filename (file_system, path);
1438       gtk_file_path_free (path);
1439     }
1440
1441   return result;
1442 }
1443
1444 /**
1445  * gtk_file_chooser_get_preview_uri:
1446  * @chooser: a #GtkFileChooser
1447  * 
1448  * Gets the URI that should be previewed in a custom preview
1449  * widget. See gtk_file_chooser_set_preview_widget().
1450  * 
1451  * Return value: the URI for the file to preview, or %NULL if no file is
1452  * selected. Free with g_free().
1453  *
1454  * Since: 2.4
1455  **/
1456 char *
1457 gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
1458 {
1459   GtkFileSystem *file_system;
1460   GtkFilePath *path;
1461   gchar *result = NULL;
1462   
1463   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1464
1465   file_system = _gtk_file_chooser_get_file_system (chooser);
1466   path = _gtk_file_chooser_get_preview_path (chooser);
1467   if (path)
1468     {
1469       result = gtk_file_system_path_to_uri (file_system, path);
1470       gtk_file_path_free (path);
1471     }
1472
1473   return result;
1474 }
1475
1476 /**
1477  * gtk_file_chooser_set_extra_widget:
1478  * @chooser: a #GtkFileChooser
1479  * @extra_widget: widget for extra options
1480  * 
1481  * Sets an application-supplied widget to provide extra options to the user.
1482  *
1483  * Since: 2.4
1484  **/
1485 void
1486 gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
1487                                    GtkWidget      *extra_widget)
1488 {
1489   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1490
1491   g_object_set (chooser, "extra-widget", extra_widget, NULL);
1492 }
1493
1494 /**
1495  * gtk_file_chooser_get_extra_widget:
1496  * @chooser: a #GtkFileChooser
1497  * 
1498  * Gets the current preview widget; see
1499  * gtk_file_chooser_set_extra_widget().
1500  * 
1501  * Return value: the current extra widget, or %NULL
1502  *
1503  * Since: 2.4
1504  **/
1505 GtkWidget *
1506 gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
1507 {
1508   GtkWidget *extra_widget;
1509   
1510   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1511
1512   g_object_get (chooser, "extra-widget", &extra_widget, NULL);
1513   
1514   /* Horrid hack; g_object_get() refs returned objects but
1515    * that contradicts the memory management conventions
1516    * for accessors.
1517    */
1518   if (extra_widget)
1519     g_object_unref (extra_widget);
1520
1521   return extra_widget;
1522 }
1523
1524 /**
1525  * gtk_file_chooser_add_filter:
1526  * @chooser: a #GtkFileChooser
1527  * @filter: a #GtkFileFilter
1528  * 
1529  * Adds @filter to the list of filters that the user can select between.
1530  * When a filter is selected, only files that are passed by that
1531  * filter are displayed. 
1532  * 
1533  * Note that the @chooser takes ownership of the filter, so you have to 
1534  * ref and sink it if you want to keep a reference.
1535  *
1536  * Since: 2.4
1537  **/
1538 void
1539 gtk_file_chooser_add_filter (GtkFileChooser *chooser,
1540                              GtkFileFilter  *filter)
1541 {
1542   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1543
1544   GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
1545 }
1546
1547 /**
1548  * gtk_file_chooser_remove_filter:
1549  * @chooser: a #GtkFileChooser
1550  * @filter: a #GtkFileFilter
1551  * 
1552  * Removes @filter from the list of filters that the user can select between.
1553  *
1554  * Since: 2.4
1555  **/
1556 void
1557 gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
1558                                 GtkFileFilter  *filter)
1559 {
1560   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1561
1562   GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
1563 }
1564
1565 /**
1566  * gtk_file_chooser_list_filters:
1567  * @chooser: a #GtkFileChooser
1568  * 
1569  * Lists the current set of user-selectable filters; see
1570  * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1571  * 
1572  * Return value: a #GSList containing the current set of
1573  *  user selectable filters. The contents of the list are
1574  *  owned by GTK+, but you must free the list itself with
1575  *  g_slist_free() when you are done with it.
1576  *
1577  * Since: 2.4
1578  **/
1579 GSList *
1580 gtk_file_chooser_list_filters  (GtkFileChooser *chooser)
1581 {
1582   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1583
1584   return GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
1585 }
1586
1587 /**
1588  * gtk_file_chooser_set_filter:
1589  * @chooser: a #GtkFileChooser
1590  * @filter: a #GtkFileFilter
1591  * 
1592  * Sets the current filter; only the files that pass the
1593  * filter will be displayed. If the user-selectable list of filters
1594  * is non-empty, then the filter should be one of the filters
1595  * in that list. Setting the current filter when the list of
1596  * filters is empty is useful if you want to restrict the displayed
1597  * set of files without letting the user change it.
1598  *
1599  * Since: 2.4
1600  **/
1601 void
1602 gtk_file_chooser_set_filter (GtkFileChooser *chooser,
1603                              GtkFileFilter  *filter)
1604 {
1605   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1606   g_return_if_fail (GTK_IS_FILE_FILTER (filter));
1607
1608   g_object_set (chooser, "filter", filter, NULL);
1609 }
1610
1611 /**
1612  * gtk_file_chooser_get_filter:
1613  * @chooser: a #GtkFileChooser
1614  * 
1615  * Gets the current filter; see gtk_file_chooser_set_filter().
1616  * 
1617  * Return value: the current filter, or %NULL
1618  *
1619  * Since: 2.4
1620  **/
1621 GtkFileFilter *
1622 gtk_file_chooser_get_filter (GtkFileChooser *chooser)
1623 {
1624   GtkFileFilter *filter;
1625   
1626   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1627
1628   g_object_get (chooser, "filter", &filter, NULL);
1629   /* Horrid hack; g_object_get() refs returned objects but
1630    * that contradicts the memory management conventions
1631    * for accessors.
1632    */
1633   if (filter)
1634     g_object_unref (filter);
1635
1636   return filter;
1637 }
1638
1639 /**
1640  * gtk_file_chooser_add_shortcut_folder:
1641  * @chooser: a #GtkFileChooser
1642  * @folder: filename of the folder to add
1643  * @error: location to store error, or %NULL
1644  * 
1645  * Adds a folder to be displayed with the shortcut folders in a file chooser.
1646  * Note that shortcut folders do not get saved, as they are provided by the
1647  * application.  For example, you can use this to add a
1648  * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1649  * 
1650  * Return value: %TRUE if the folder could be added successfully, %FALSE
1651  * otherwise.  In the latter case, the @error will be set as appropriate.
1652  *
1653  * Since: 2.4
1654  **/
1655 gboolean
1656 gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
1657                                       const char        *folder,
1658                                       GError           **error)
1659 {
1660   GtkFilePath *path;
1661   gboolean result;
1662
1663   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1664   g_return_val_if_fail (folder != NULL, FALSE);
1665
1666   path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1667   if (!path)
1668     {
1669       g_set_error (error,
1670                    GTK_FILE_CHOOSER_ERROR,
1671                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1672                    _("Invalid filename: %s"),
1673                    folder);
1674       return FALSE;
1675     }
1676
1677   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1678
1679   gtk_file_path_free (path);
1680
1681   return result;
1682 }
1683
1684 /**
1685  * gtk_file_chooser_remove_shortcut_folder:
1686  * @chooser: a #GtkFileChooser
1687  * @folder: filename of the folder to remove
1688  * @error: location to store error, or %NULL
1689  * 
1690  * Removes a folder from a file chooser's list of shortcut folders.
1691  * 
1692  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
1693  * In the latter case, the @error will be set as appropriate.
1694  *
1695  * See also: gtk_file_chooser_add_shortcut_folder()
1696  *
1697  * Since: 2.4
1698  **/
1699 gboolean
1700 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
1701                                          const char        *folder,
1702                                          GError           **error)
1703 {
1704   GtkFilePath *path;
1705   gboolean result;
1706
1707   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1708   g_return_val_if_fail (folder != NULL, FALSE);
1709
1710   path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
1711   if (!path)
1712     {
1713       g_set_error (error,
1714                    GTK_FILE_CHOOSER_ERROR,
1715                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1716                    _("Invalid filename: %s"),
1717                    folder);
1718       return FALSE;
1719     }
1720
1721   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1722
1723   gtk_file_path_free (path);
1724
1725   return result;
1726 }
1727
1728 /**
1729  * gtk_file_chooser_list_shortcut_folders:
1730  * @chooser: a #GtkFileChooser
1731  * 
1732  * Queries the list of shortcut folders in the file chooser, as set by
1733  * gtk_file_chooser_add_shortcut_folder().
1734  * 
1735  * Return value: A list of folder filenames, or %NULL if there are no shortcut
1736  * folders.  Free the returned list with g_slist_free(), and the filenames with
1737  * g_free().
1738  *
1739  * Since: 2.4
1740  **/
1741 GSList *
1742 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
1743 {
1744   GSList *folders;
1745   GSList *result;
1746
1747   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1748
1749   folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1750
1751   result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1752                                   folders,
1753                                   gtk_file_system_path_to_filename);
1754   gtk_file_paths_free (folders);
1755   return result;
1756 }
1757
1758 /**
1759  * gtk_file_chooser_add_shortcut_folder_uri:
1760  * @chooser: a #GtkFileChooser
1761  * @uri: URI of the folder to add
1762  * @error: location to store error, or %NULL
1763  * 
1764  * Adds a folder URI to be displayed with the shortcut folders in a file
1765  * chooser.  Note that shortcut folders do not get saved, as they are provided
1766  * by the application.  For example, you can use this to add a
1767  * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1768  * 
1769  * Return value: %TRUE if the folder could be added successfully, %FALSE
1770  * otherwise.  In the latter case, the @error will be set as appropriate.
1771  *
1772  * Since: 2.4
1773  **/
1774 gboolean
1775 gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser    *chooser,
1776                                           const char        *uri,
1777                                           GError           **error)
1778 {
1779   GtkFilePath *path;
1780   gboolean result;
1781
1782   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1783   g_return_val_if_fail (uri != NULL, FALSE);
1784
1785   path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1786   if (!path)
1787     {
1788       g_set_error (error,
1789                    GTK_FILE_CHOOSER_ERROR,
1790                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1791                    _("Invalid filename: %s"),
1792                    uri);
1793       return FALSE;
1794     }
1795
1796   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
1797
1798   gtk_file_path_free (path);
1799
1800   return result;
1801 }
1802
1803 /**
1804  * gtk_file_chooser_remove_shortcut_folder_uri:
1805  * @chooser: a #GtkFileChooser
1806  * @uri: URI of the folder to remove
1807  * @error: location to store error, or %NULL
1808  * 
1809  * Removes a folder URI from a file chooser's list of shortcut folders.
1810  * 
1811  * Return value: %TRUE if the operation succeeds, %FALSE otherwise.  
1812  * In the latter case, the @error will be set as appropriate.
1813  *
1814  * See also: gtk_file_chooser_add_shortcut_folder_uri()
1815  *
1816  * Since: 2.4
1817  **/
1818 gboolean
1819 gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser    *chooser,
1820                                              const char        *uri,
1821                                              GError           **error)
1822 {
1823   GtkFilePath *path;
1824   gboolean result;
1825
1826   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1827   g_return_val_if_fail (uri != NULL, FALSE);
1828
1829   path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
1830   if (!path)
1831     {
1832       g_set_error (error,
1833                    GTK_FILE_CHOOSER_ERROR,
1834                    GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
1835                    _("Invalid filename: %s"),
1836                    uri);
1837       return FALSE;
1838     }
1839
1840   result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
1841
1842   gtk_file_path_free (path);
1843
1844   return result;
1845 }
1846
1847 /**
1848  * gtk_file_chooser_list_shortcut_folder_uris:
1849  * @chooser: a #GtkFileChooser
1850  * 
1851  * Queries the list of shortcut folders in the file chooser, as set by
1852  * gtk_file_chooser_add_shortcut_folder_uri().
1853  * 
1854  * Return value: A list of folder URIs, or %NULL if there are no shortcut
1855  * folders.  Free the returned list with g_slist_free(), and the URIs with
1856  * g_free().
1857  *
1858  * Since: 2.4
1859  **/
1860 GSList *
1861 gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
1862 {
1863   GSList *folders;
1864   GSList *result;
1865
1866   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
1867
1868   folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
1869
1870   result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
1871                                   folders,
1872                                   gtk_file_system_path_to_uri);
1873   gtk_file_paths_free (folders);
1874   return result;
1875 }
1876
1877
1878 /**
1879  * gtk_file_chooser_set_show_hidden:
1880  * @chooser: a #GtkFileChooser
1881  * @show_hidden: %TRUE if hidden files and folders should be displayed.
1882  * 
1883  * Sets whether hidden files and folders are displayed in the file selector.  
1884  *
1885  * Since: 2.6
1886  **/
1887 void
1888 gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
1889                                   gboolean        show_hidden)
1890 {
1891   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1892
1893   g_object_set (chooser, "show-hidden", show_hidden, NULL);
1894 }
1895
1896 /**
1897  * gtk_file_chooser_get_show_hidden:
1898  * @chooser: a #GtkFileChooser
1899  * 
1900  * Gets whether hidden files and folders are displayed in the file selector.   
1901  * See gtk_file_chooser_set_show_hidden().
1902  * 
1903  * Return value: %TRUE if hidden files and folders are displayed.
1904  *
1905  * Since: 2.6
1906  **/
1907 gboolean
1908 gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser)
1909 {
1910   gboolean show_hidden;
1911   
1912   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1913
1914   g_object_get (chooser, "show-hidden", &show_hidden, NULL);
1915
1916   return show_hidden;
1917 }
1918
1919 /**
1920  * gtk_file_chooser_set_do_overwrite_confirmation:
1921  * @chooser: a #GtkFileChooser
1922  * @do_overwrite_confirmation: whether to confirm overwriting in save mode
1923  * 
1924  * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
1925  * a confirmation dialog if the user types a file name that already exists.  This
1926  * is %FALSE by default.
1927  *
1928  * Regardless of this setting, the @chooser will emit the "confirm-overwrite"
1929  * signal when appropriate.
1930  *
1931  * If all you need is the stock confirmation dialog, set this property to %TRUE.
1932  * You can override the way confirmation is done by actually handling the
1933  * "confirm-overwrite" signal; please refer to its documentation for the
1934  * details.
1935  *
1936  * Since: 2.8
1937  **/
1938 void
1939 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
1940                                                 gboolean        do_overwrite_confirmation)
1941 {
1942   g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
1943
1944   g_object_set (chooser, "do-overwrite-confirmation", do_overwrite_confirmation, NULL);
1945 }
1946
1947 /**
1948  * gtk_file_chooser_get_do_overwrite_confirmation:
1949  * @chooser: a #GtkFileChooser
1950  * 
1951  * Queries whether a file chooser is set to confirm for overwriting when the user
1952  * types a file name that already exists.
1953  * 
1954  * Return value: %TRUE if the file chooser will present a confirmation dialog;
1955  * %FALSE otherwise.
1956  *
1957  * Since: 2.8
1958  **/
1959 gboolean
1960 gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
1961 {
1962   gboolean do_overwrite_confirmation;
1963
1964   g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
1965
1966   g_object_get (chooser, "do-overwrite-confirmation", &do_overwrite_confirmation, NULL);
1967
1968   return do_overwrite_confirmation;
1969 }
1970
1971 #ifdef G_OS_WIN32
1972
1973 /* DLL ABI stability backward compatibility versions */
1974
1975 #undef gtk_file_chooser_get_filename
1976
1977 gchar *
1978 gtk_file_chooser_get_filename (GtkFileChooser *chooser)
1979 {
1980   gchar *utf8_filename = gtk_file_chooser_get_filename_utf8 (chooser);
1981   gchar *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
1982
1983   g_free (utf8_filename);
1984
1985   return retval;
1986 }
1987
1988 #undef gtk_file_chooser_set_filename
1989
1990 gboolean
1991 gtk_file_chooser_set_filename (GtkFileChooser *chooser,
1992                                const gchar    *filename)
1993 {
1994   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
1995   gboolean retval = gtk_file_chooser_set_filename_utf8 (chooser, utf8_filename);
1996
1997   g_free (utf8_filename);
1998
1999   return retval;
2000 }
2001
2002 #undef gtk_file_chooser_select_filename
2003
2004 gboolean
2005 gtk_file_chooser_select_filename (GtkFileChooser *chooser,
2006                                   const gchar    *filename)
2007 {
2008   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2009   gboolean retval = gtk_file_chooser_select_filename_utf8 (chooser, utf8_filename);
2010
2011   g_free (utf8_filename);
2012
2013   return retval;
2014 }
2015
2016 #undef gtk_file_chooser_unselect_filename
2017
2018 void
2019 gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
2020                                     const char     *filename)
2021 {
2022   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2023
2024   gtk_file_chooser_unselect_filename_utf8 (chooser, utf8_filename);
2025   g_free (utf8_filename);
2026 }
2027
2028 #undef gtk_file_chooser_get_filenames
2029
2030 GSList *
2031 gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
2032 {
2033   GSList *list = gtk_file_chooser_get_filenames_utf8 (chooser);
2034   GSList *rover = list;
2035   
2036   while (rover)
2037     {
2038       gchar *tem = (gchar *) rover->data;
2039       rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2040       g_free (tem);
2041       rover = rover->next;
2042     }
2043
2044   return list;
2045 }
2046
2047 #undef gtk_file_chooser_set_current_folder
2048
2049 gboolean
2050 gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
2051                                      const gchar    *filename)
2052 {
2053   gchar *utf8_filename = g_locale_to_utf8 (filename, -1, NULL, NULL, NULL);
2054   gboolean retval = gtk_file_chooser_set_current_folder_utf8 (chooser, utf8_filename);
2055
2056   g_free (utf8_filename);
2057
2058   return retval;
2059 }
2060
2061 #undef gtk_file_chooser_get_current_folder
2062
2063 gchar *
2064 gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
2065 {
2066   gchar *utf8_folder = gtk_file_chooser_get_current_folder_utf8 (chooser);
2067   gchar *retval = g_locale_from_utf8 (utf8_folder, -1, NULL, NULL, NULL);
2068
2069   g_free (utf8_folder);
2070
2071   return retval;
2072 }
2073
2074 #undef gtk_file_chooser_get_preview_filename
2075
2076 char *
2077 gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
2078 {
2079   char *utf8_filename = gtk_file_chooser_get_preview_filename_utf8 (chooser);
2080   char *retval = g_locale_from_utf8 (utf8_filename, -1, NULL, NULL, NULL);
2081
2082   g_free (utf8_filename);
2083
2084   return retval;
2085 }
2086
2087 #undef gtk_file_chooser_add_shortcut_folder
2088
2089 gboolean
2090 gtk_file_chooser_add_shortcut_folder (GtkFileChooser    *chooser,
2091                                       const char        *folder,
2092                                       GError           **error)
2093 {
2094   char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2095   gboolean retval =
2096     gtk_file_chooser_add_shortcut_folder_utf8 (chooser, utf8_folder, error);
2097
2098   g_free (utf8_folder);
2099
2100   return retval;
2101 }
2102
2103 #undef gtk_file_chooser_remove_shortcut_folder
2104
2105 gboolean
2106 gtk_file_chooser_remove_shortcut_folder (GtkFileChooser    *chooser,
2107                                          const char        *folder,
2108                                          GError           **error)
2109 {
2110   char *utf8_folder = g_locale_to_utf8 (folder, -1, NULL, NULL, NULL);
2111   gboolean retval =
2112     gtk_file_chooser_remove_shortcut_folder_utf8 (chooser, utf8_folder, error);
2113
2114   g_free (utf8_folder);
2115
2116   return retval;
2117 }
2118
2119 #undef gtk_file_chooser_list_shortcut_folders
2120
2121 GSList *
2122 gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
2123 {
2124   GSList *list = gtk_file_chooser_list_shortcut_folders_utf8 (chooser);
2125   GSList *rover = list;
2126   
2127   while (rover)
2128     {
2129       gchar *tem = (gchar *) rover->data;
2130       rover->data = g_locale_from_utf8 ((gchar *) rover->data, -1, NULL, NULL, NULL);
2131       g_free (tem);
2132       rover = rover->next;
2133     }
2134
2135   return list;
2136 }
2137
2138 #endif
2139
2140 #define __GTK_FILE_CHOOSER_C__
2141 #include "gtkaliasdef.c"