]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooser.h
Add a rather specially crafted test case
[~andy/gtk] / gtk / gtkfilechooser.h
1 /* GTK - The GIMP Toolkit
2  * gtkfilechooser.h: 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 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 #error "Only <gtk/gtk.h> can be included directly."
23 #endif
24
25 #ifndef __GTK_FILE_CHOOSER_H__
26 #define __GTK_FILE_CHOOSER_H__
27
28 #include <gtk/gtkfilefilter.h>
29 #include <gtk/gtkwidget.h>
30
31 G_BEGIN_DECLS
32
33 #define GTK_TYPE_FILE_CHOOSER             (gtk_file_chooser_get_type ())
34 #define GTK_FILE_CHOOSER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
35 #define GTK_IS_FILE_CHOOSER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_CHOOSER))
36
37 typedef struct _GtkFileChooser      GtkFileChooser;
38
39 typedef enum
40 {
41   GTK_FILE_CHOOSER_ACTION_OPEN,
42   GTK_FILE_CHOOSER_ACTION_SAVE,
43   GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
44   GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
45 } GtkFileChooserAction;
46
47 typedef enum
48 {
49   GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM,
50   GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME,
51   GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN
52 } GtkFileChooserConfirmation;
53
54 GType gtk_file_chooser_get_type (void) G_GNUC_CONST;
55
56 /* GError enumeration for GtkFileChooser */
57
58 #define GTK_FILE_CHOOSER_ERROR (gtk_file_chooser_error_quark ())
59
60 typedef enum {
61   GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
62   GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
63   GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS,
64   GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME
65 } GtkFileChooserError;
66
67 GQuark gtk_file_chooser_error_quark (void);
68
69 /* Configuration
70  */
71 void                 gtk_file_chooser_set_action          (GtkFileChooser       *chooser,
72                                                            GtkFileChooserAction  action);
73 GtkFileChooserAction gtk_file_chooser_get_action          (GtkFileChooser       *chooser);
74 void                 gtk_file_chooser_set_local_only      (GtkFileChooser       *chooser,
75                                                            gboolean              local_only);
76 gboolean             gtk_file_chooser_get_local_only      (GtkFileChooser       *chooser);
77 void                 gtk_file_chooser_set_select_multiple (GtkFileChooser       *chooser,
78                                                            gboolean              select_multiple);
79 gboolean             gtk_file_chooser_get_select_multiple (GtkFileChooser       *chooser);
80 void                 gtk_file_chooser_set_show_hidden     (GtkFileChooser       *chooser,
81                                                            gboolean              show_hidden);
82 gboolean             gtk_file_chooser_get_show_hidden     (GtkFileChooser       *chooser);
83
84 void                 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
85                                                                      gboolean        do_overwrite_confirmation);
86 gboolean             gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser);
87
88 void                 gtk_file_chooser_set_create_folders  (GtkFileChooser       *chooser,
89                                                           gboolean               create_folders);
90 gboolean             gtk_file_chooser_get_create_folders (GtkFileChooser *chooser);
91
92 /* Suggested name for the Save-type actions
93  */
94 void     gtk_file_chooser_set_current_name   (GtkFileChooser *chooser,
95                                               const gchar    *name);
96
97 /* Filename manipulation
98  */
99 #ifdef G_OS_WIN32
100 /* Reserve old names for DLL ABI backward compatibility */
101 #define gtk_file_chooser_get_filename gtk_file_chooser_get_filename_utf8
102 #define gtk_file_chooser_set_filename gtk_file_chooser_set_filename_utf8
103 #define gtk_file_chooser_select_filename gtk_file_chooser_select_filename_utf8
104 #define gtk_file_chooser_unselect_filename gtk_file_chooser_unselect_filename_utf8
105 #define gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames_utf8
106 #define gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder_utf8
107 #define gtk_file_chooser_get_current_folder gtk_file_chooser_get_current_folder_utf8
108 #define gtk_file_chooser_get_preview_filename gtk_file_chooser_get_preview_filename_utf8
109 #define gtk_file_chooser_add_shortcut_folder gtk_file_chooser_add_shortcut_folder_utf8
110 #define gtk_file_chooser_remove_shortcut_folder gtk_file_chooser_remove_shortcut_folder_utf8
111 #define gtk_file_chooser_list_shortcut_folders gtk_file_chooser_list_shortcut_folders_utf8
112 #endif
113
114 gchar *  gtk_file_chooser_get_filename       (GtkFileChooser *chooser);
115 gboolean gtk_file_chooser_set_filename       (GtkFileChooser *chooser,
116                                               const char     *filename);
117 gboolean gtk_file_chooser_select_filename    (GtkFileChooser *chooser,
118                                               const char     *filename);
119 void     gtk_file_chooser_unselect_filename  (GtkFileChooser *chooser,
120                                               const char     *filename);
121 void     gtk_file_chooser_select_all         (GtkFileChooser *chooser);
122 void     gtk_file_chooser_unselect_all       (GtkFileChooser *chooser);
123 GSList * gtk_file_chooser_get_filenames      (GtkFileChooser *chooser);
124 gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
125                                               const gchar    *filename);
126 gchar *  gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
127
128
129 /* URI manipulation
130  */
131 gchar *  gtk_file_chooser_get_uri                (GtkFileChooser *chooser);
132 gboolean gtk_file_chooser_set_uri                (GtkFileChooser *chooser,
133                                                   const char     *uri);
134 gboolean gtk_file_chooser_select_uri             (GtkFileChooser *chooser,
135                                                   const char     *uri);
136 void     gtk_file_chooser_unselect_uri           (GtkFileChooser *chooser,
137                                                   const char     *uri);
138 GSList * gtk_file_chooser_get_uris               (GtkFileChooser *chooser);
139 gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
140                                                   const gchar    *uri);
141 gchar *  gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
142
143 /* GFile manipulation */
144 GFile *  gtk_file_chooser_get_file                (GtkFileChooser  *chooser);
145 gboolean gtk_file_chooser_set_file                (GtkFileChooser  *chooser,
146                                                    GFile           *file,
147                                                    GError         **error);
148 gboolean gtk_file_chooser_select_file             (GtkFileChooser  *chooser,
149                                                    GFile           *file,
150                                                    GError         **error);
151 void     gtk_file_chooser_unselect_file           (GtkFileChooser  *chooser,
152                                                    GFile           *file);
153 GSList * gtk_file_chooser_get_files               (GtkFileChooser  *chooser);
154 gboolean gtk_file_chooser_set_current_folder_file (GtkFileChooser  *chooser,
155                                                    GFile           *file,
156                                                    GError         **error);
157 GFile *  gtk_file_chooser_get_current_folder_file (GtkFileChooser  *chooser);
158
159 /* Preview widget
160  */
161 void       gtk_file_chooser_set_preview_widget        (GtkFileChooser *chooser,
162                                                        GtkWidget      *preview_widget);
163 GtkWidget *gtk_file_chooser_get_preview_widget        (GtkFileChooser *chooser);
164 void       gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
165                                                        gboolean        active);
166 gboolean   gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
167 void       gtk_file_chooser_set_use_preview_label     (GtkFileChooser *chooser,
168                                                        gboolean        use_label);
169 gboolean   gtk_file_chooser_get_use_preview_label     (GtkFileChooser *chooser);
170
171 char  *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
172 char  *gtk_file_chooser_get_preview_uri      (GtkFileChooser *chooser);
173 GFile *gtk_file_chooser_get_preview_file     (GtkFileChooser *chooser);
174
175 /* Extra widget
176  */
177 void       gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
178                                               GtkWidget      *extra_widget);
179 GtkWidget *gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
180
181 /* List of user selectable filters
182  */
183 void    gtk_file_chooser_add_filter    (GtkFileChooser *chooser,
184                                         GtkFileFilter  *filter);
185 void    gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
186                                         GtkFileFilter  *filter);
187 GSList *gtk_file_chooser_list_filters  (GtkFileChooser *chooser);
188
189 /* Current filter
190  */
191 void           gtk_file_chooser_set_filter (GtkFileChooser *chooser,
192                                            GtkFileFilter  *filter);
193 GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser);
194
195 /* Per-application shortcut folders */
196
197 gboolean gtk_file_chooser_add_shortcut_folder    (GtkFileChooser *chooser,
198                                                   const char     *folder,
199                                                   GError        **error);
200 gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
201                                                   const char     *folder,
202                                                   GError        **error);
203 GSList *gtk_file_chooser_list_shortcut_folders   (GtkFileChooser *chooser);
204
205 gboolean gtk_file_chooser_add_shortcut_folder_uri    (GtkFileChooser *chooser,
206                                                       const char     *uri,
207                                                       GError        **error);
208 gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
209                                                       const char     *uri,
210                                                       GError        **error);
211 GSList *gtk_file_chooser_list_shortcut_folder_uris   (GtkFileChooser *chooser);
212
213 G_END_DECLS
214
215 #endif /* __GTK_FILE_CHOOSER_H__ */