]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooser.h
0e08c7da6748735be01aaa40ead7e46b717f7560
[~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 } GtkFileChooserError;
65
66 GQuark gtk_file_chooser_error_quark (void);
67
68 /* Configuration
69  */
70 void                 gtk_file_chooser_set_action          (GtkFileChooser       *chooser,
71                                                            GtkFileChooserAction  action);
72 GtkFileChooserAction gtk_file_chooser_get_action          (GtkFileChooser       *chooser);
73 void                 gtk_file_chooser_set_local_only      (GtkFileChooser       *chooser,
74                                                            gboolean              local_only);
75 gboolean             gtk_file_chooser_get_local_only      (GtkFileChooser       *chooser);
76 void                 gtk_file_chooser_set_select_multiple (GtkFileChooser       *chooser,
77                                                            gboolean              select_multiple);
78 gboolean             gtk_file_chooser_get_select_multiple (GtkFileChooser       *chooser);
79 void                 gtk_file_chooser_set_show_hidden     (GtkFileChooser       *chooser,
80                                                            gboolean              show_hidden);
81 gboolean             gtk_file_chooser_get_show_hidden     (GtkFileChooser       *chooser);
82
83 void                 gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
84                                                                      gboolean        do_overwrite_confirmation);
85 gboolean             gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser);
86
87 /* Suggested name for the Save-type actions
88  */
89 void     gtk_file_chooser_set_current_name   (GtkFileChooser *chooser,
90                                               const gchar    *name);
91
92 /* Filename manipulation
93  */
94 #ifdef G_OS_WIN32
95 /* Reserve old names for DLL ABI backward compatibility */
96 #define gtk_file_chooser_get_filename gtk_file_chooser_get_filename_utf8
97 #define gtk_file_chooser_set_filename gtk_file_chooser_set_filename_utf8
98 #define gtk_file_chooser_select_filename gtk_file_chooser_select_filename_utf8
99 #define gtk_file_chooser_unselect_filename gtk_file_chooser_unselect_filename_utf8
100 #define gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames_utf8
101 #define gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder_utf8
102 #define gtk_file_chooser_get_current_folder gtk_file_chooser_get_current_folder_utf8
103 #define gtk_file_chooser_get_preview_filename gtk_file_chooser_get_preview_filename_utf8
104 #define gtk_file_chooser_add_shortcut_folder gtk_file_chooser_add_shortcut_folder_utf8
105 #define gtk_file_chooser_remove_shortcut_folder gtk_file_chooser_remove_shortcut_folder_utf8
106 #define gtk_file_chooser_list_shortcut_folders gtk_file_chooser_list_shortcut_folders_utf8
107 #endif
108
109 gchar *  gtk_file_chooser_get_filename       (GtkFileChooser *chooser);
110 gboolean gtk_file_chooser_set_filename       (GtkFileChooser *chooser,
111                                               const char     *filename);
112 gboolean gtk_file_chooser_select_filename    (GtkFileChooser *chooser,
113                                               const char     *filename);
114 void     gtk_file_chooser_unselect_filename  (GtkFileChooser *chooser,
115                                               const char     *filename);
116 void     gtk_file_chooser_select_all         (GtkFileChooser *chooser);
117 void     gtk_file_chooser_unselect_all       (GtkFileChooser *chooser);
118 GSList * gtk_file_chooser_get_filenames      (GtkFileChooser *chooser);
119 gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
120                                               const gchar    *filename);
121 gchar *  gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
122
123
124 /* URI manipulation
125  */
126 gchar *  gtk_file_chooser_get_uri                (GtkFileChooser *chooser);
127 gboolean gtk_file_chooser_set_uri                (GtkFileChooser *chooser,
128                                                   const char     *uri);
129 gboolean gtk_file_chooser_select_uri             (GtkFileChooser *chooser,
130                                                   const char     *uri);
131 void     gtk_file_chooser_unselect_uri           (GtkFileChooser *chooser,
132                                                   const char     *uri);
133 GSList * gtk_file_chooser_get_uris               (GtkFileChooser *chooser);
134 gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
135                                                   const gchar    *uri);
136 gchar *  gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
137
138 /* Preview widget
139  */
140 void       gtk_file_chooser_set_preview_widget        (GtkFileChooser *chooser,
141                                                        GtkWidget      *preview_widget);
142 GtkWidget *gtk_file_chooser_get_preview_widget        (GtkFileChooser *chooser);
143 void       gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
144                                                        gboolean        active);
145 gboolean   gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
146 void       gtk_file_chooser_set_use_preview_label     (GtkFileChooser *chooser,
147                                                        gboolean        use_label);
148 gboolean   gtk_file_chooser_get_use_preview_label     (GtkFileChooser *chooser);
149
150 char *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
151 char *gtk_file_chooser_get_preview_uri      (GtkFileChooser *chooser);
152
153 /* Extra widget
154  */
155 void       gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
156                                               GtkWidget      *extra_widget);
157 GtkWidget *gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
158
159 /* List of user selectable filters
160  */
161 void    gtk_file_chooser_add_filter    (GtkFileChooser *chooser,
162                                         GtkFileFilter  *filter);
163 void    gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
164                                         GtkFileFilter  *filter);
165 GSList *gtk_file_chooser_list_filters  (GtkFileChooser *chooser);
166
167 /* Current filter
168  */
169 void           gtk_file_chooser_set_filter (GtkFileChooser *chooser,
170                                            GtkFileFilter  *filter);
171 GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser);
172
173 /* Per-application shortcut folders */
174
175 gboolean gtk_file_chooser_add_shortcut_folder    (GtkFileChooser *chooser,
176                                                   const char     *folder,
177                                                   GError        **error);
178 gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
179                                                   const char     *folder,
180                                                   GError        **error);
181 GSList *gtk_file_chooser_list_shortcut_folders   (GtkFileChooser *chooser);
182
183 gboolean gtk_file_chooser_add_shortcut_folder_uri    (GtkFileChooser *chooser,
184                                                       const char     *uri,
185                                                       GError        **error);
186 gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
187                                                       const char     *uri,
188                                                       GError        **error);
189 GSList *gtk_file_chooser_list_shortcut_folder_uris   (GtkFileChooser *chooser);
190
191 G_END_DECLS
192
193 #endif /* __GTK_FILE_CHOOSER_H__ */