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