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