1 /* GTK - The GIMP Toolkit
2 * gtkfilechooserprivate.h: Interface definition for file selector GUIs
3 * Copyright (C) 2003, Red Hat, Inc.
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.
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.
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.
21 #ifndef __GTK_FILE_CHOOSER_PRIVATE_H__
22 #define __GTK_FILE_CHOOSER_PRIVATE_H__
24 #include "gtkfilechooser.h"
25 #include "gtkfilesystem.h"
26 #include "gtkfilesystemmodel.h"
27 #include "gtkliststore.h"
28 #include "gtkrecentmanager.h"
29 #include "gtksearchengine.h"
31 #include "gtktooltips.h"
32 #include "gtktreemodelsort.h"
33 #include "gtktreestore.h"
34 #include "gtktreeview.h"
39 #define GTK_FILE_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_CHOOSER, GtkFileChooserIface))
41 typedef struct _GtkFileChooserIface GtkFileChooserIface;
43 struct _GtkFileChooserIface
45 GTypeInterface base_iface;
49 gboolean (*set_current_folder) (GtkFileChooser *chooser,
50 const GtkFilePath *path,
52 GtkFilePath * (*get_current_folder) (GtkFileChooser *chooser);
53 void (*set_current_name) (GtkFileChooser *chooser,
55 gboolean (*select_path) (GtkFileChooser *chooser,
56 const GtkFilePath *path,
58 void (*unselect_path) (GtkFileChooser *chooser,
59 const GtkFilePath *path);
60 void (*select_all) (GtkFileChooser *chooser);
61 void (*unselect_all) (GtkFileChooser *chooser);
62 GSList * (*get_paths) (GtkFileChooser *chooser);
63 GtkFilePath * (*get_preview_path) (GtkFileChooser *chooser);
64 GtkFileSystem *(*get_file_system) (GtkFileChooser *chooser);
65 void (*add_filter) (GtkFileChooser *chooser,
66 GtkFileFilter *filter);
67 void (*remove_filter) (GtkFileChooser *chooser,
68 GtkFileFilter *filter);
69 GSList * (*list_filters) (GtkFileChooser *chooser);
70 gboolean (*add_shortcut_folder) (GtkFileChooser *chooser,
71 const GtkFilePath *path,
73 gboolean (*remove_shortcut_folder) (GtkFileChooser *chooser,
74 const GtkFilePath *path,
76 GSList * (*list_shortcut_folders) (GtkFileChooser *chooser);
80 void (*current_folder_changed) (GtkFileChooser *chooser);
81 void (*selection_changed) (GtkFileChooser *chooser);
82 void (*update_preview) (GtkFileChooser *chooser);
83 void (*file_activated) (GtkFileChooser *chooser);
84 GtkFileChooserConfirmation (*confirm_overwrite) (GtkFileChooser *chooser);
87 GtkFileSystem *_gtk_file_chooser_get_file_system (GtkFileChooser *chooser);
88 gboolean _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
89 const GtkFilePath *path,
91 GtkFilePath * _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser);
92 gboolean _gtk_file_chooser_select_path (GtkFileChooser *chooser,
93 const GtkFilePath *path,
95 void _gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
96 const GtkFilePath *path);
97 GSList * _gtk_file_chooser_get_paths (GtkFileChooser *chooser);
98 GtkFilePath * _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser);
99 gboolean _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
100 const GtkFilePath *path,
102 gboolean _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
103 const GtkFilePath *path,
106 /* GtkFileChooserDialog private */
108 struct _GtkFileChooserDialogPrivate
114 /* for use with GtkFileChooserEmbed */
117 gboolean resize_horizontally;
118 gboolean resize_vertically;
119 gboolean response_requested;
123 /* GtkFileChooserWidget private */
125 struct _GtkFileChooserWidgetPrivate
133 /* GtkFileChooserDefault private */
136 LOAD_EMPTY, /* There is no model */
137 LOAD_PRELOAD, /* Model is loading and a timer is running; model isn't inserted into the tree yet */
138 LOAD_LOADING, /* Timeout expired, model is inserted into the tree, but not fully loaded yet */
139 LOAD_FINISHED /* Model is fully loaded and inserted into the tree */
143 RELOAD_EMPTY, /* No folder has been set */
144 RELOAD_HAS_FOLDER, /* We have a folder, although it may not be completely loaded yet; no need to reload */
145 RELOAD_WAS_UNMAPPED /* We had a folder but got unmapped; reload is needed */
149 LOCATION_MODE_PATH_BAR,
150 LOCATION_MODE_FILENAME_ENTRY
154 OPERATION_MODE_BROWSE,
155 OPERATION_MODE_SEARCH,
156 OPERATION_MODE_RECENT
159 struct _GtkFileChooserDefault
161 GtkVBox parent_instance;
163 GtkFileChooserAction action;
165 GtkFileSystem *file_system;
167 /* Save mode widgets */
168 GtkWidget *save_widgets;
170 GtkWidget *save_folder_label;
171 GtkWidget *save_folder_combo;
172 GtkWidget *save_expander;
174 /* The file browsing widgets */
175 GtkWidget *browse_widgets;
176 GtkWidget *browse_shortcuts_tree_view;
177 GtkWidget *browse_shortcuts_add_button;
178 GtkWidget *browse_shortcuts_remove_button;
179 GtkWidget *browse_shortcuts_popup_menu;
180 GtkWidget *browse_shortcuts_popup_menu_remove_item;
181 GtkWidget *browse_shortcuts_popup_menu_rename_item;
182 GtkWidget *browse_files_tree_view;
183 GtkWidget *browse_files_popup_menu;
184 GtkWidget *browse_files_popup_menu_add_shortcut_item;
185 GtkWidget *browse_files_popup_menu_hidden_files_item;
186 GtkWidget *browse_new_folder_button;
187 GtkWidget *browse_path_bar_hbox;
188 GtkWidget *browse_path_bar;
190 GtkFileSystemModel *browse_files_model;
191 char *browse_files_last_selected_name;
193 /* OPERATION_MODE_SEARCH */
194 GtkWidget *search_hbox;
195 GtkWidget *search_entry;
196 GtkSearchEngine *search_engine;
197 GtkQuery *search_query;
198 GtkListStore *search_model;
199 GtkTreeModelFilter *search_model_filter;
201 /* OPERATION_MODE_RECENT */
202 GtkRecentManager *recent_manager;
203 GtkListStore *recent_model;
204 guint load_recent_id;
205 GtkTreeModelFilter *recent_model_filter;
207 GtkWidget *filter_combo_hbox;
208 GtkWidget *filter_combo;
209 GtkWidget *preview_box;
210 GtkWidget *preview_label;
211 GtkWidget *preview_widget;
212 GtkWidget *extra_align;
213 GtkWidget *extra_widget;
215 GtkWidget *location_button;
216 GtkWidget *location_entry_box;
217 GtkWidget *location_label;
218 GtkWidget *location_entry;
219 LocationMode location_mode;
221 GtkListStore *shortcuts_model;
223 /* Filter for the shortcuts pane. We filter out the "current folder" row and
224 * the separator that we use for the "Save in folder" combo.
226 GtkTreeModel *shortcuts_pane_filter_model;
228 /* Filter for the "Save in folder" combo. We filter out the Search row and
231 GtkTreeModel *shortcuts_combo_filter_model;
233 GtkTreeModelSort *sort_model;
236 GSList *loading_shortcuts;
237 GSList *reload_icon_handles;
238 GtkFileSystemHandle *file_list_drag_data_received_handle;
239 GtkFileSystemHandle *update_current_folder_handle;
240 GtkFileSystemHandle *show_and_select_paths_handle;
241 GtkFileSystemHandle *should_respond_get_info_handle;
242 GtkFileSystemHandle *file_exists_get_info_handle;
243 GtkFileSystemHandle *update_from_entry_handle;
244 GtkFileSystemHandle *shortcuts_activate_iter_handle;
245 GSList *pending_handles;
247 LoadState load_state;
248 ReloadState reload_state;
249 guint load_timeout_id;
251 OperationMode operation_mode;
253 GSList *pending_select_paths;
255 GtkFileFilter *current_filter;
258 GtkTooltips *tooltips;
264 gulong volumes_changed_id;
265 gulong bookmarks_changed_id;
267 GtkFilePath *current_volume_path;
268 GtkFilePath *current_folder;
269 GtkFilePath *preview_path;
270 char *preview_display_name;
272 GtkTreeViewColumn *list_name_column;
273 GtkCellRenderer *list_name_renderer;
274 GtkTreeViewColumn *list_mtime_column;
276 GSource *edited_idle;
277 char *edited_new_text;
279 gulong settings_signal_id;
282 gulong toplevel_set_focus_id;
283 GtkWidget *toplevel_last_focus_widget;
286 GdkDragContext *shortcuts_drag_context;
287 GSource *shortcuts_drag_outside_idle;
292 guint local_only : 1;
293 guint preview_widget_active : 1;
294 guint use_preview_label : 1;
295 guint select_multiple : 1;
296 guint show_hidden : 1;
297 guint do_overwrite_confirmation : 1;
298 guint list_sort_ascending : 1;
299 guint changing_folder : 1;
300 guint shortcuts_current_folder_active : 1;
301 guint expand_folders : 1;
303 guint has_desktop : 1;
304 guint has_search : 1;
305 guint has_recent : 1;
308 guint shortcuts_drag_outside : 1;
313 /* GtkFileSystemModel private */
315 typedef struct _FileModelNode FileModelNode;
317 struct _GtkFileSystemModel
319 GObject parent_instance;
321 GtkFileSystem *file_system;
322 GtkFileInfoType types;
323 FileModelNode *roots;
324 GtkFileFolder *root_folder;
325 GtkFilePath *root_path;
327 GtkFileSystemModelFilter filter_func;
328 gpointer filter_data;
331 GSource *idle_clear_source;
335 GSList *pending_handles;
337 guint show_hidden : 1;
338 guint show_folders : 1;
339 guint show_files : 1;
340 guint folders_only : 1;
341 guint has_editable : 1;
344 struct _FileModelNode
350 GtkFileFolder *folder;
352 FileModelNode *children;
353 FileModelNode *parent;
354 GtkFileSystemModel *model;
357 guint n_referenced_children;
363 guint is_visible : 1;
365 guint idle_clear : 1;
366 guint load_pending : 1;
372 #endif /* __GTK_FILE_CHOOSER_PRIVATE_H__ */