]> Pileus Git - ~andy/gtk/blob - gtk/gtkfilechooser.h
Don't do completion in the middle of an incomplete hostname
[~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 /* Suggested name for the Save-type actions
89  */
90 void     gtk_file_chooser_set_current_name   (GtkFileChooser *chooser,
91                                               const gchar    *name);
92
93 /* Filename manipulation
94  */
95 #ifdef G_OS_WIN32
96 /* Reserve old names for DLL ABI backward compatibility */
97 #define gtk_file_chooser_get_filename gtk_file_chooser_get_filename_utf8
98 #define gtk_file_chooser_set_filename gtk_file_chooser_set_filename_utf8
99 #define gtk_file_chooser_select_filename gtk_file_chooser_select_filename_utf8
100 #define gtk_file_chooser_unselect_filename gtk_file_chooser_unselect_filename_utf8
101 #define gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames_utf8
102 #define gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder_utf8
103 #define gtk_file_chooser_get_current_folder gtk_file_chooser_get_current_folder_utf8
104 #define gtk_file_chooser_get_preview_filename gtk_file_chooser_get_preview_filename_utf8
105 #define gtk_file_chooser_add_shortcut_folder gtk_file_chooser_add_shortcut_folder_utf8
106 #define gtk_file_chooser_remove_shortcut_folder gtk_file_chooser_remove_shortcut_folder_utf8
107 #define gtk_file_chooser_list_shortcut_folders gtk_file_chooser_list_shortcut_folders_utf8
108 #endif
109
110 gchar *  gtk_file_chooser_get_filename       (GtkFileChooser *chooser);
111 gboolean gtk_file_chooser_set_filename       (GtkFileChooser *chooser,
112                                               const char     *filename);
113 gboolean gtk_file_chooser_select_filename    (GtkFileChooser *chooser,
114                                               const char     *filename);
115 void     gtk_file_chooser_unselect_filename  (GtkFileChooser *chooser,
116                                               const char     *filename);
117 void     gtk_file_chooser_select_all         (GtkFileChooser *chooser);
118 void     gtk_file_chooser_unselect_all       (GtkFileChooser *chooser);
119 GSList * gtk_file_chooser_get_filenames      (GtkFileChooser *chooser);
120 gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
121                                               const gchar    *filename);
122 gchar *  gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
123
124
125 /* URI manipulation
126  */
127 gchar *  gtk_file_chooser_get_uri                (GtkFileChooser *chooser);
128 gboolean gtk_file_chooser_set_uri                (GtkFileChooser *chooser,
129                                                   const char     *uri);
130 gboolean gtk_file_chooser_select_uri             (GtkFileChooser *chooser,
131                                                   const char     *uri);
132 void     gtk_file_chooser_unselect_uri           (GtkFileChooser *chooser,
133                                                   const char     *uri);
134 GSList * gtk_file_chooser_get_uris               (GtkFileChooser *chooser);
135 gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
136                                                   const gchar    *uri);
137 gchar *  gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
138
139 /* GFile manipulation */
140 GFile *  gtk_file_chooser_get_file                (GtkFileChooser  *chooser);
141 gboolean gtk_file_chooser_set_file                (GtkFileChooser  *chooser,
142                                                    GFile           *file,
143                                                    GError         **error);
144 gboolean gtk_file_chooser_select_file             (GtkFileChooser  *chooser,
145                                                    GFile           *file,
146                                                    GError         **error);
147 void     gtk_file_chooser_unselect_file           (GtkFileChooser  *chooser,
148                                                    GFile           *file);
149 GSList * gtk_file_chooser_get_files               (GtkFileChooser  *chooser);
150 gboolean gtk_file_chooser_set_current_folder_file (GtkFileChooser  *chooser,
151                                                    GFile           *file,
152                                                    GError         **error);
153 GFile *  gtk_file_chooser_get_current_folder_file (GtkFileChooser  *chooser);
154
155 /* Preview widget
156  */
157 void       gtk_file_chooser_set_preview_widget        (GtkFileChooser *chooser,
158                                                        GtkWidget      *preview_widget);
159 GtkWidget *gtk_file_chooser_get_preview_widget        (GtkFileChooser *chooser);
160 void       gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
161                                                        gboolean        active);
162 gboolean   gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
163 void       gtk_file_chooser_set_use_preview_label     (GtkFileChooser *chooser,
164                                                        gboolean        use_label);
165 gboolean   gtk_file_chooser_get_use_preview_label     (GtkFileChooser *chooser);
166
167 char  *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
168 char  *gtk_file_chooser_get_preview_uri      (GtkFileChooser *chooser);
169 GFile *gtk_file_chooser_get_preview_file     (GtkFileChooser *chooser);
170
171 /* Extra widget
172  */
173 void       gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
174                                               GtkWidget      *extra_widget);
175 GtkWidget *gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
176
177 /* List of user selectable filters
178  */
179 void    gtk_file_chooser_add_filter    (GtkFileChooser *chooser,
180                                         GtkFileFilter  *filter);
181 void    gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
182                                         GtkFileFilter  *filter);
183 GSList *gtk_file_chooser_list_filters  (GtkFileChooser *chooser);
184
185 /* Current filter
186  */
187 void           gtk_file_chooser_set_filter (GtkFileChooser *chooser,
188                                            GtkFileFilter  *filter);
189 GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser);
190
191 /* Per-application shortcut folders */
192
193 gboolean gtk_file_chooser_add_shortcut_folder    (GtkFileChooser *chooser,
194                                                   const char     *folder,
195                                                   GError        **error);
196 gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
197                                                   const char     *folder,
198                                                   GError        **error);
199 GSList *gtk_file_chooser_list_shortcut_folders   (GtkFileChooser *chooser);
200
201 gboolean gtk_file_chooser_add_shortcut_folder_uri    (GtkFileChooser *chooser,
202                                                       const char     *uri,
203                                                       GError        **error);
204 gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
205                                                       const char     *uri,
206                                                       GError        **error);
207 GSList *gtk_file_chooser_list_shortcut_folder_uris   (GtkFileChooser *chooser);
208
209 G_END_DECLS
210
211 #endif /* __GTK_FILE_CHOOSER_H__ */