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