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