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