File: | src/file-manager/fm-directory-view.c |
Warning: | line 4733, column 2 Value stored to 'num_applications' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
2 | |
3 | /* fm-directory-view.c |
4 | * |
5 | * Copyright (C) 1999, 2000 Free Software Foundation |
6 | * Copyright (C) 2000, 2001 Eazel, Inc. |
7 | * |
8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of the |
11 | * License, or (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public |
19 | * License along with this program; if not, write to the |
20 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
21 | * Boston, MA 02110-1301, USA. |
22 | * |
23 | * Authors: Ettore Perazzoli, |
24 | * John Sullivan <sullivan@eazel.com>, |
25 | * Darin Adler <darin@bentspoon.com>, |
26 | * Pavel Cisler <pavel@eazel.com>, |
27 | * David Emory Watson <dwatson@cs.ucr.edu> |
28 | */ |
29 | |
30 | #include <config.h> |
31 | #include <math.h> |
32 | |
33 | #include <cdk/cdkkeysyms.h> |
34 | #include <cdk/cdkx.h> |
35 | #include <ctk/ctk.h> |
36 | #include <glib/gi18n.h> |
37 | #include <glib/gstdio.h> |
38 | #include <gio/gio.h> |
39 | |
40 | #define CAFE_DESKTOP_USE_UNSTABLE_API |
41 | #include <libcafe-desktop/cafe-desktop-utils.h> |
42 | |
43 | #include <eel/eel-background.h> |
44 | #include <eel/eel-glib-extensions.h> |
45 | #include <eel/eel-cafe-extensions.h> |
46 | #include <eel/eel-ctk-extensions.h> |
47 | #include <eel/eel-ctk-macros.h> |
48 | #include <eel/eel-stock-dialogs.h> |
49 | #include <eel/eel-string.h> |
50 | #include <eel/eel-vfs-extensions.h> |
51 | |
52 | #include <libbaul-private/baul-recent.h> |
53 | #include <libbaul-extension/baul-menu-provider.h> |
54 | #include <libbaul-private/baul-clipboard.h> |
55 | #include <libbaul-private/baul-clipboard-monitor.h> |
56 | #include <libbaul-private/baul-debug-log.h> |
57 | #include <libbaul-private/baul-desktop-icon-file.h> |
58 | #include <libbaul-private/baul-desktop-directory.h> |
59 | #include <libbaul-private/baul-extensions.h> |
60 | #include <libbaul-private/baul-search-directory.h> |
61 | #include <libbaul-private/baul-directory-background.h> |
62 | #include <libbaul-private/baul-directory.h> |
63 | #include <libbaul-private/baul-dnd.h> |
64 | #include <libbaul-private/baul-file-attributes.h> |
65 | #include <libbaul-private/baul-file-changes-queue.h> |
66 | #include <libbaul-private/baul-file-dnd.h> |
67 | #include <libbaul-private/baul-file-operations.h> |
68 | #include <libbaul-private/baul-file-utilities.h> |
69 | #include <libbaul-private/baul-file-private.h> /* for baul_file_get_existing_by_uri */ |
70 | #include <libbaul-private/baul-global-preferences.h> |
71 | #include <libbaul-private/baul-link.h> |
72 | #include <libbaul-private/baul-metadata.h> |
73 | #include <libbaul-private/baul-mime-actions.h> |
74 | #include <libbaul-private/baul-module.h> |
75 | #include <libbaul-private/baul-program-choosing.h> |
76 | #include <libbaul-private/baul-trash-monitor.h> |
77 | #include <libbaul-private/baul-ui-utilities.h> |
78 | #include <libbaul-private/baul-signaller.h> |
79 | #include <libbaul-private/baul-autorun.h> |
80 | #include <libbaul-private/baul-icon-names.h> |
81 | #include <libbaul-private/baul-undostack-manager.h> |
82 | |
83 | #include "fm-directory-view.h" |
84 | #include "fm-list-view.h" |
85 | #include "fm-desktop-icon-view.h" |
86 | #include "fm-actions.h" |
87 | #include "fm-error-reporting.h" |
88 | #include "fm-marshal.h" |
89 | #include "fm-properties-window.h" |
90 | #include "libbaul-private/baul-open-with-dialog.h" |
91 | |
92 | /* Minimum starting update inverval */ |
93 | #define UPDATE_INTERVAL_MIN100 100 |
94 | /* Maximum update interval */ |
95 | #define UPDATE_INTERVAL_MAX2000 2000 |
96 | /* Amount of miliseconds the update interval is increased */ |
97 | #define UPDATE_INTERVAL_INC250 250 |
98 | /* Interval at which the update interval is increased */ |
99 | #define UPDATE_INTERVAL_TIMEOUT_INTERVAL250 250 |
100 | /* Milliseconds that have to pass without a change to reset the update interval */ |
101 | #define UPDATE_INTERVAL_RESET1000 1000 |
102 | |
103 | #define SILENT_WINDOW_OPEN_LIMIT5 5 |
104 | |
105 | #define DUPLICATE_HORIZONTAL_ICON_OFFSET70 70 |
106 | #define DUPLICATE_VERTICAL_ICON_OFFSET30 30 |
107 | |
108 | #define MAX_QUEUED_UPDATES500 500 |
109 | |
110 | #define FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER"/MenuBar/File/Open Placeholder/Open With/Applications Placeholder" "/MenuBar/File/Open Placeholder/Open With/Applications Placeholder" |
111 | #define FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER"/MenuBar/File/Open Placeholder/Applications Placeholder" "/MenuBar/File/Open Placeholder/Applications Placeholder" |
112 | #define FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER"/MenuBar/File/Open Placeholder/Scripts/Scripts Placeholder" "/MenuBar/File/Open Placeholder/Scripts/Scripts Placeholder" |
113 | #define FM_DIRECTORY_VIEW_MENU_PATH_EXTENSION_ACTIONS_PLACEHOLDER"/MenuBar/Edit/Extension Actions" "/MenuBar/Edit/Extension Actions" |
114 | #define FM_DIRECTORY_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER"/MenuBar/File/New Items Placeholder/New Documents/New Documents Placeholder" "/MenuBar/File/New Items Placeholder/New Documents/New Documents Placeholder" |
115 | #define FM_DIRECTORY_VIEW_MENU_PATH_OPEN"/MenuBar/File/Open Placeholder/Open" "/MenuBar/File/Open Placeholder/Open" |
116 | |
117 | #define FM_DIRECTORY_VIEW_POPUP_PATH_SELECTION"/selection" "/selection" |
118 | #define FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER"/selection/Open Placeholder/Open With/Applications Placeholder" "/selection/Open Placeholder/Open With/Applications Placeholder" |
119 | #define FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER"/selection/Open Placeholder/Applications Placeholder" "/selection/Open Placeholder/Applications Placeholder" |
120 | #define FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER"/selection/Open Placeholder/Scripts/Scripts Placeholder" "/selection/Open Placeholder/Scripts/Scripts Placeholder" |
121 | #define FM_DIRECTORY_VIEW_POPUP_PATH_EXTENSION_ACTIONS"/selection/Extension Actions" "/selection/Extension Actions" |
122 | #define FM_DIRECTORY_VIEW_POPUP_PATH_OPEN"/selection/Open Placeholder/Open" "/selection/Open Placeholder/Open" |
123 | |
124 | #define FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND"/background" "/background" |
125 | #define FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_SCRIPTS_PLACEHOLDER"/background/Before Zoom Items/New Object Items/Scripts/Scripts Placeholder" "/background/Before Zoom Items/New Object Items/Scripts/Scripts Placeholder" |
126 | #define FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_NEW_DOCUMENTS_PLACEHOLDER"/background/Before Zoom Items/New Object Items/New Documents/New Documents Placeholder" "/background/Before Zoom Items/New Object Items/New Documents/New Documents Placeholder" |
127 | |
128 | #define FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION"/location" "/location" |
129 | |
130 | #define MAX_MENU_LEVELS5 5 |
131 | #define TEMPLATE_LIMIT30 30 |
132 | |
133 | enum { |
134 | ADD_FILE, |
135 | BEGIN_FILE_CHANGES, |
136 | BEGIN_LOADING, |
137 | CLEAR, |
138 | END_FILE_CHANGES, |
139 | FLUSH_ADDED_FILES, |
140 | END_LOADING, |
141 | FILE_CHANGED, |
142 | LOAD_ERROR, |
143 | MOVE_COPY_ITEMS, |
144 | REMOVE_FILE, |
145 | TRASH, |
146 | DELETE, |
147 | LAST_SIGNAL |
148 | }; |
149 | |
150 | enum |
151 | { |
152 | PROP_0, |
153 | PROP_WINDOW_SLOT |
154 | }; |
155 | |
156 | |
157 | static guint signals[LAST_SIGNAL] = { 0 }; |
158 | |
159 | static CdkAtom copied_files_atom; |
160 | |
161 | static char *scripts_directory_uri; |
162 | static int scripts_directory_uri_length; |
163 | |
164 | struct FMDirectoryViewDetails |
165 | { |
166 | BaulWindowInfo *window; |
167 | BaulWindowSlotInfo *slot; |
168 | BaulDirectory *model; |
169 | BaulFile *directory_as_file; |
170 | BaulFile *location_popup_directory_as_file; |
171 | CdkEventButton *location_popup_event; |
172 | CtkActionGroup *dir_action_group; |
173 | guint dir_merge_id; |
174 | |
175 | GList *scripts_directory_list; |
176 | CtkActionGroup *scripts_action_group; |
177 | guint scripts_merge_id; |
178 | |
179 | GList *templates_directory_list; |
180 | CtkActionGroup *templates_action_group; |
181 | guint templates_merge_id; |
182 | |
183 | CtkActionGroup *extensions_menu_action_group; |
184 | guint extensions_menu_merge_id; |
185 | |
186 | guint display_selection_idle_id; |
187 | guint update_menus_timeout_id; |
188 | guint update_status_idle_id; |
189 | guint reveal_selection_idle_id; |
190 | |
191 | guint display_pending_source_id; |
192 | guint changes_timeout_id; |
193 | |
194 | guint update_interval; |
195 | guint64 last_queued; |
196 | |
197 | guint files_added_handler_id; |
198 | guint files_changed_handler_id; |
199 | guint load_error_handler_id; |
200 | guint done_loading_handler_id; |
201 | guint file_changed_handler_id; |
202 | |
203 | guint delayed_rename_file_id; |
204 | |
205 | GList *new_added_files; |
206 | GList *new_changed_files; |
207 | |
208 | GHashTable *non_ready_files; |
209 | |
210 | GList *old_added_files; |
211 | GList *old_changed_files; |
212 | |
213 | GList *pending_locations_selected; |
214 | |
215 | /* whether we are in the active slot */ |
216 | gboolean active; |
217 | |
218 | /* loading indicates whether this view has begun loading a directory. |
219 | * This flag should need not be set inside subclasses. FMDirectoryView automatically |
220 | * sets 'loading' to TRUE before it begins loading a directory's contents and to FALSE |
221 | * after it finishes loading the directory and its view. |
222 | */ |
223 | gboolean loading; |
224 | gboolean menu_states_untrustworthy; |
225 | gboolean scripts_invalid; |
226 | gboolean templates_invalid; |
227 | gboolean reported_load_error; |
228 | |
229 | /* flag to indicate that no file updates should be dispatched to subclasses. |
230 | * This is a workaround for bug #87701 that prevents the list view from |
231 | * losing focus when the underlying CtkTreeView is updated. |
232 | */ |
233 | gboolean updates_frozen; |
234 | guint updates_queued; |
235 | gboolean needs_reload; |
236 | |
237 | gboolean sort_directories_first; |
238 | |
239 | gboolean show_foreign_files; |
240 | gboolean show_hidden_files; |
241 | gboolean ignore_hidden_file_preferences; |
242 | |
243 | gboolean show_backup_files; |
244 | |
245 | gboolean batching_selection_level; |
246 | gboolean selection_changed_while_batched; |
247 | |
248 | gboolean selection_was_removed; |
249 | |
250 | gboolean metadata_for_directory_as_file_pending; |
251 | gboolean metadata_for_files_in_directory_pending; |
252 | |
253 | gboolean selection_change_is_due_to_shell; |
254 | gboolean send_selection_change_to_shell; |
255 | |
256 | CtkActionGroup *open_with_action_group; |
257 | guint open_with_merge_id; |
258 | |
259 | GList *subdirectory_list; |
260 | |
261 | gboolean allow_moves; |
262 | |
263 | CdkPoint context_menu_position; |
264 | |
265 | gboolean undo_active; |
266 | gboolean redo_active; |
267 | gchar* undo_action_description; |
268 | gchar* undo_action_label; |
269 | gchar* redo_action_description; |
270 | gchar* redo_action_label; |
271 | }; |
272 | |
273 | typedef struct { |
274 | BaulFile *file; |
275 | BaulDirectory *directory; |
276 | } FileAndDirectory; |
277 | |
278 | /* forward declarations */ |
279 | |
280 | static gboolean display_selection_info_idle_callback (gpointer data); |
281 | static void fm_directory_view_class_init (FMDirectoryViewClass *klass); |
282 | static void fm_directory_view_init (FMDirectoryView *view); |
283 | static void fm_directory_view_duplicate_selection (FMDirectoryView *view, |
284 | GList *files, |
285 | GArray *item_locations); |
286 | static void fm_directory_view_create_links_for_files (FMDirectoryView *view, |
287 | GList *files, |
288 | GArray *item_locations); |
289 | static void trash_or_delete_files (CtkWindow *parent_window, |
290 | const GList *files, |
291 | gboolean delete_if_all_already_in_trash, |
292 | FMDirectoryView *view); |
293 | static void load_directory (FMDirectoryView *view, |
294 | BaulDirectory *directory); |
295 | static void fm_directory_view_merge_menus (FMDirectoryView *view); |
296 | static void fm_directory_view_unmerge_menus (FMDirectoryView *view); |
297 | static void fm_directory_view_init_show_hidden_files (FMDirectoryView *view); |
298 | static void fm_directory_view_init_show_backup_files (FMDirectoryView *view); |
299 | static void fm_directory_view_load_location (BaulView *baul_view, |
300 | const char *location); |
301 | static void fm_directory_view_stop_loading (BaulView *baul_view); |
302 | static void fm_directory_view_drop_proxy_received_uris (FMDirectoryView *view, |
303 | const GList *source_uri_list, |
304 | const char *target_uri, |
305 | CdkDragAction action); |
306 | static void fm_directory_view_drop_proxy_received_netscape_url (FMDirectoryView *view, |
307 | const char *netscape_url, |
308 | const char *target_uri, |
309 | CdkDragAction action); |
310 | static void clipboard_changed_callback (BaulClipboardMonitor *monitor, |
311 | FMDirectoryView *view); |
312 | static void open_one_in_new_window (gpointer data, |
313 | gpointer callback_data); |
314 | static void open_one_in_folder_window (gpointer data, |
315 | gpointer callback_data); |
316 | static void schedule_update_menus (FMDirectoryView *view); |
317 | static void schedule_update_menus_callback (gpointer callback_data); |
318 | static void remove_update_menus_timeout_callback (FMDirectoryView *view); |
319 | static void schedule_update_status (FMDirectoryView *view); |
320 | static void remove_update_status_idle_callback (FMDirectoryView *view); |
321 | static void reset_update_interval (FMDirectoryView *view); |
322 | static void schedule_idle_display_of_pending_files (FMDirectoryView *view); |
323 | static void unschedule_display_of_pending_files (FMDirectoryView *view); |
324 | static void disconnect_model_handlers (FMDirectoryView *view); |
325 | static void metadata_for_directory_as_file_ready_callback (BaulFile *file, |
326 | gpointer callback_data); |
327 | static void metadata_for_files_in_directory_ready_callback (BaulDirectory *directory, |
328 | GList *files, |
329 | gpointer callback_data); |
330 | static void fm_directory_view_trash_state_changed_callback (BaulTrashMonitor *trash, |
331 | gboolean state, |
332 | gpointer callback_data); |
333 | static void fm_directory_view_select_file (FMDirectoryView *view, |
334 | BaulFile *file); |
335 | |
336 | static CdkDragAction ask_link_action (FMDirectoryView *view); |
337 | static void update_templates_directory (FMDirectoryView *view); |
338 | static void user_dirs_changed (FMDirectoryView *view); |
339 | static void fm_directory_view_set_is_active (FMDirectoryView *view, |
340 | gboolean is_active); |
341 | |
342 | static gboolean file_list_all_are_folders (GList *file_list); |
343 | |
344 | static void action_open_scripts_folder_callback (CtkAction *action, |
345 | gpointer callback_data); |
346 | static void action_cut_files_callback (CtkAction *action, |
347 | gpointer callback_data); |
348 | static void action_copy_files_callback (CtkAction *action, |
349 | gpointer callback_data); |
350 | static void action_paste_files_callback (CtkAction *action, |
351 | gpointer callback_data); |
352 | static void action_copy_to_next_pane_callback (CtkAction *action, |
353 | gpointer callback_data); |
354 | static void action_move_to_next_pane_callback (CtkAction *action, |
355 | gpointer callback_data); |
356 | static void action_rename_callback (CtkAction *action, |
357 | gpointer callback_data); |
358 | static void action_rename_select_all_callback (CtkAction *action, |
359 | gpointer callback_data); |
360 | static void action_paste_files_into_callback (CtkAction *action, |
361 | gpointer callback_data); |
362 | static void action_connect_to_server_link_callback (CtkAction *action, |
363 | gpointer data); |
364 | static void action_mount_volume_callback (CtkAction *action, |
365 | gpointer data); |
366 | static void action_unmount_volume_callback (CtkAction *action, |
367 | gpointer data); |
368 | static void action_format_volume_callback (CtkAction *action, |
369 | gpointer data); |
370 | static void action_start_volume_callback (CtkAction *action, |
371 | gpointer data); |
372 | static void action_stop_volume_callback (CtkAction *action, |
373 | gpointer data); |
374 | static void action_detect_media_callback (CtkAction *action, |
375 | gpointer data); |
376 | |
377 | /* location popup-related actions */ |
378 | |
379 | static void action_location_open_alternate_callback (CtkAction *action, |
380 | gpointer callback_data); |
381 | static void action_location_open_folder_window_callback (CtkAction *action, |
382 | gpointer callback_data); |
383 | |
384 | static void action_location_cut_callback (CtkAction *action, |
385 | gpointer callback_data); |
386 | static void action_location_copy_callback (CtkAction *action, |
387 | gpointer callback_data); |
388 | static void action_location_trash_callback (CtkAction *action, |
389 | gpointer callback_data); |
390 | static void action_location_delete_callback (CtkAction *action, |
391 | gpointer callback_data); |
392 | static void action_location_properties_callback (CtkAction *action, |
393 | gpointer callback_data); |
394 | |
395 | static void unschedule_pop_up_location_context_menu (FMDirectoryView *view); |
396 | |
397 | static inline void fm_directory_view_widget_to_file_operation_position (FMDirectoryView *view, |
398 | CdkPoint *position); |
399 | static void fm_directory_view_widget_to_file_operation_position_xy (FMDirectoryView *view, |
400 | int *x, int *y); |
401 | |
402 | /* undo-related actions */ |
403 | |
404 | static void undo_redo_menu_update_callback (BaulUndoStackManager* manager, gpointer arg1, gpointer data); |
405 | |
406 | static void undo_update_menu (FMDirectoryView *view); |
407 | |
408 | static void finish_undoredo_callback (gpointer data); |
409 | |
410 | static void real_action_undo (FMDirectoryView *view); |
411 | |
412 | static void real_action_redo (FMDirectoryView *view); |
413 | |
414 | static void action_undo_callback (CtkAction *action, gpointer callback_data); |
415 | |
416 | static void action_redo_callback (CtkAction *action, gpointer callback_data); |
417 | |
418 | EEL_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, CTK_TYPE_SCROLLED_WINDOW)static gpointer parent_class; GType fm_directory_view_get_type (void) { GType parent_type; static GType type; if (type == 0 ) { static GTypeInfo info = { sizeof (FMDirectoryViewClass), ( (void*)0), ((void*)0), (GClassInitFunc) fm_directory_view_class_init , ((void*)0), ((void*)0), sizeof (FMDirectoryView), 0, (GInstanceInitFunc ) fm_directory_view_init, ((void*)0) }; parent_type = ((ctk_scrolled_window_get_type ())); type = g_type_register_static (parent_type, "FMDirectoryView" , &info, 0); parent_class = g_type_class_ref (parent_type ); } return type; } |
419 | |
420 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_file)static void fm_directory_view_unimplemented_add_file (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "add_file"); } |
421 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, bump_zoom_level)static void fm_directory_view_unimplemented_bump_zoom_level ( void) { g_warning ("failed to override signal " "fm_directory_view" "->" "bump_zoom_level"); } |
422 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, can_zoom_in)static void fm_directory_view_unimplemented_can_zoom_in (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "can_zoom_in"); } |
423 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, can_zoom_out)static void fm_directory_view_unimplemented_can_zoom_out (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "can_zoom_out"); } |
424 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, clear)static void fm_directory_view_unimplemented_clear (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "clear" ); } |
425 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, file_changed)static void fm_directory_view_unimplemented_file_changed (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "file_changed"); } |
426 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_background_widget)static void fm_directory_view_unimplemented_get_background_widget (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "get_background_widget"); } |
427 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_selection)static void fm_directory_view_unimplemented_get_selection (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "get_selection"); } |
428 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_selection_for_file_transfer)static void fm_directory_view_unimplemented_get_selection_for_file_transfer (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "get_selection_for_file_transfer"); } |
429 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_item_count)static void fm_directory_view_unimplemented_get_item_count (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "get_item_count"); } |
430 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, is_empty)static void fm_directory_view_unimplemented_is_empty (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "is_empty"); } |
431 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, reset_to_defaults)static void fm_directory_view_unimplemented_reset_to_defaults (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "reset_to_defaults"); } |
432 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, restore_default_zoom_level)static void fm_directory_view_unimplemented_restore_default_zoom_level (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "restore_default_zoom_level"); } |
433 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, select_all)static void fm_directory_view_unimplemented_select_all (void) { g_warning ("failed to override signal " "fm_directory_view" "->" "select_all"); } |
434 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, set_selection)static void fm_directory_view_unimplemented_set_selection (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "set_selection"); } |
435 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, zoom_to_level)static void fm_directory_view_unimplemented_zoom_to_level (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "zoom_to_level"); } |
436 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_zoom_level)static void fm_directory_view_unimplemented_get_zoom_level (void ) { g_warning ("failed to override signal " "fm_directory_view" "->" "get_zoom_level"); } |
437 | EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, invert_selection)static void fm_directory_view_unimplemented_invert_selection ( void) { g_warning ("failed to override signal " "fm_directory_view" "->" "invert_selection"); } |
438 | |
439 | typedef struct { |
440 | GAppInfo *application; |
441 | GList *files; |
442 | FMDirectoryView *directory_view; |
443 | } ApplicationLaunchParameters; |
444 | |
445 | typedef struct { |
446 | BaulFile *file; |
447 | FMDirectoryView *directory_view; |
448 | } ScriptLaunchParameters; |
449 | |
450 | typedef struct { |
451 | BaulFile *file; |
452 | FMDirectoryView *directory_view; |
453 | } CreateTemplateParameters; |
454 | |
455 | static ApplicationLaunchParameters * |
456 | application_launch_parameters_new (GAppInfo *application, |
457 | GList *files, |
458 | FMDirectoryView *directory_view) |
459 | { |
460 | ApplicationLaunchParameters *result; |
461 | |
462 | result = g_new0 (ApplicationLaunchParameters, 1)((ApplicationLaunchParameters *) g_malloc0_n ((1), sizeof (ApplicationLaunchParameters ))); |
463 | result->application = g_object_ref (application)((__typeof__ (application)) (g_object_ref) (application)); |
464 | result->files = baul_file_list_copy (files); |
465 | |
466 | if (directory_view != NULL((void*)0)) { |
467 | g_object_ref (directory_view)((__typeof__ (directory_view)) (g_object_ref) (directory_view )); |
468 | result->directory_view = directory_view; |
469 | } |
470 | |
471 | return result; |
472 | } |
473 | |
474 | static void |
475 | application_launch_parameters_free (ApplicationLaunchParameters *parameters) |
476 | { |
477 | g_object_unref (parameters->application); |
478 | baul_file_list_free (parameters->files); |
479 | |
480 | if (parameters->directory_view != NULL((void*)0)) { |
481 | g_object_unref (parameters->directory_view); |
482 | } |
483 | |
484 | g_free (parameters); |
485 | } |
486 | |
487 | static GList * |
488 | file_and_directory_list_to_files (GList *fad_list) |
489 | { |
490 | GList *res, *l; |
491 | FileAndDirectory *fad = NULL((void*)0); |
492 | |
493 | res = NULL((void*)0); |
494 | for (l = fad_list; l != NULL((void*)0); l = l->next) { |
495 | fad = l->data; |
496 | res = g_list_prepend (res, baul_file_ref (fad->file)); |
497 | } |
498 | return g_list_reverse (res); |
499 | } |
500 | |
501 | |
502 | static GList * |
503 | file_and_directory_list_from_files (BaulDirectory *directory, GList *files) |
504 | { |
505 | GList *res, *l; |
506 | FileAndDirectory *fad = NULL((void*)0); |
507 | |
508 | res = NULL((void*)0); |
509 | for (l = files; l != NULL((void*)0); l = l->next) { |
510 | fad = g_new0 (FileAndDirectory, 1)((FileAndDirectory *) g_malloc0_n ((1), sizeof (FileAndDirectory ))); |
511 | fad->directory = baul_directory_ref (directory); |
512 | fad->file = baul_file_ref (l->data); |
513 | res = g_list_prepend (res, fad); |
514 | } |
515 | return g_list_reverse (res); |
516 | } |
517 | |
518 | static void |
519 | file_and_directory_free (FileAndDirectory *fad) |
520 | { |
521 | baul_directory_unref (fad->directory); |
522 | baul_file_unref (fad->file); |
523 | g_free (fad); |
524 | } |
525 | |
526 | |
527 | static void |
528 | file_and_directory_list_free (GList *list) |
529 | { |
530 | GList *l; |
531 | |
532 | for (l = list; l != NULL((void*)0); l = l->next) { |
533 | file_and_directory_free (l->data); |
534 | } |
535 | |
536 | g_list_free (list); |
537 | } |
538 | |
539 | static gboolean |
540 | file_and_directory_equal (gconstpointer v1, |
541 | gconstpointer v2) |
542 | { |
543 | const FileAndDirectory *fad1, *fad2; |
544 | fad1 = v1; |
545 | fad2 = v2; |
546 | |
547 | return (fad1->file == fad2->file && |
548 | fad1->directory == fad2->directory); |
549 | } |
550 | |
551 | static guint |
552 | file_and_directory_hash (gconstpointer v) |
553 | { |
554 | const FileAndDirectory *fad; |
555 | |
556 | fad = v; |
557 | return GPOINTER_TO_UINT (fad->file)((guint) (gulong) (fad->file)) ^ GPOINTER_TO_UINT (fad->directory)((guint) (gulong) (fad->directory)); |
558 | } |
559 | |
560 | |
561 | |
562 | |
563 | static ScriptLaunchParameters * |
564 | script_launch_parameters_new (BaulFile *file, |
565 | FMDirectoryView *directory_view) |
566 | { |
567 | ScriptLaunchParameters *result; |
568 | |
569 | result = g_new0 (ScriptLaunchParameters, 1)((ScriptLaunchParameters *) g_malloc0_n ((1), sizeof (ScriptLaunchParameters ))); |
570 | g_object_ref (directory_view)((__typeof__ (directory_view)) (g_object_ref) (directory_view )); |
571 | result->directory_view = directory_view; |
572 | baul_file_ref (file); |
573 | result->file = file; |
574 | |
575 | return result; |
576 | } |
577 | |
578 | static void |
579 | script_launch_parameters_free (ScriptLaunchParameters *parameters) |
580 | { |
581 | g_object_unref (parameters->directory_view); |
582 | baul_file_unref (parameters->file); |
583 | g_free (parameters); |
584 | } |
585 | |
586 | static CreateTemplateParameters * |
587 | create_template_parameters_new (BaulFile *file, |
588 | FMDirectoryView *directory_view) |
589 | { |
590 | CreateTemplateParameters *result; |
591 | |
592 | result = g_new0 (CreateTemplateParameters, 1)((CreateTemplateParameters *) g_malloc0_n ((1), sizeof (CreateTemplateParameters ))); |
593 | g_object_ref (directory_view)((__typeof__ (directory_view)) (g_object_ref) (directory_view )); |
594 | result->directory_view = directory_view; |
595 | baul_file_ref (file); |
596 | result->file = file; |
597 | |
598 | return result; |
599 | } |
600 | |
601 | static void |
602 | create_templates_parameters_free (CreateTemplateParameters *parameters) |
603 | { |
604 | g_object_unref (parameters->directory_view); |
605 | baul_file_unref (parameters->file); |
606 | g_free (parameters); |
607 | } |
608 | |
609 | BaulWindowInfo * |
610 | fm_directory_view_get_baul_window (FMDirectoryView *view) |
611 | { |
612 | g_assert (view->details->window != NULL)do { if (view->details->window != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 612, ((const char*) (__func__ )), "view->details->window != NULL"); } while (0); |
613 | |
614 | return view->details->window; |
615 | } |
616 | |
617 | BaulWindowSlotInfo * |
618 | fm_directory_view_get_baul_window_slot (FMDirectoryView *view) |
619 | { |
620 | g_assert (view->details->slot != NULL)do { if (view->details->slot != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 620, ((const char*) (__func__ )), "view->details->slot != NULL"); } while (0); |
621 | |
622 | return view->details->slot; |
623 | } |
624 | |
625 | /* Returns the CtkWindow that this directory view occupies, or NULL |
626 | * if at the moment this directory view is not in a CtkWindow or the |
627 | * CtkWindow cannot be determined. Primarily used for parenting dialogs. |
628 | */ |
629 | CtkWindow * |
630 | fm_directory_view_get_containing_window (FMDirectoryView *view) |
631 | { |
632 | CtkWidget *window; |
633 | |
634 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 634, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
635 | |
636 | window = ctk_widget_get_ancestor (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), CTK_TYPE_WINDOW(ctk_window_get_type ())); |
637 | if (window == NULL((void*)0)) { |
638 | return NULL((void*)0); |
639 | } |
640 | |
641 | return CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))); |
642 | } |
643 | |
644 | static gboolean |
645 | fm_directory_view_confirm_multiple (CtkWindow *parent_window, |
646 | int count, |
647 | gboolean tabs) |
648 | { |
649 | CtkDialog *dialog; |
650 | char *prompt; |
651 | char *detail; |
652 | int response; |
653 | |
654 | if (count <= SILENT_WINDOW_OPEN_LIMIT5) { |
655 | return TRUE(!(0)); |
656 | } |
657 | |
658 | prompt = _("Are you sure you want to open all files?")gettext ("Are you sure you want to open all files?"); |
659 | if (tabs) { |
660 | detail = g_strdup_printf (ngettext("This will open %'d separate tab.", |
661 | "This will open %'d separate tabs.", count), count); |
662 | } else { |
663 | detail = g_strdup_printf (ngettext("This will open %'d separate window.", |
664 | "This will open %'d separate windows.", count), count); |
665 | } |
666 | dialog = eel_show_yes_no_dialog (prompt, detail, |
667 | "ctk-ok", "process-stop", |
668 | parent_window); |
669 | g_free (detail); |
670 | |
671 | response = ctk_dialog_run (dialog); |
672 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
673 | |
674 | return response == CTK_RESPONSE_YES; |
675 | } |
676 | |
677 | static gboolean |
678 | selection_contains_one_item_in_menu_callback (FMDirectoryView *view, GList *selection) |
679 | { |
680 | if (eel_g_list_exactly_one_item (selection)) { |
681 | return TRUE(!(0)); |
682 | } |
683 | |
684 | /* If we've requested a menu update that hasn't yet occurred, then |
685 | * the mismatch here doesn't surprise us, and we won't complain. |
686 | * Otherwise, we will complain. |
687 | */ |
688 | if (!view->details->menu_states_untrustworthy) { |
689 | g_warning ("Expected one selected item, found %'d. No action will be performed.", |
690 | g_list_length (selection)); |
691 | } |
692 | |
693 | return FALSE(0); |
694 | } |
695 | |
696 | static gboolean |
697 | selection_not_empty_in_menu_callback (FMDirectoryView *view, GList *selection) |
698 | { |
699 | if (selection != NULL((void*)0)) { |
700 | return TRUE(!(0)); |
701 | } |
702 | |
703 | /* If we've requested a menu update that hasn't yet occurred, then |
704 | * the mismatch here doesn't surprise us, and we won't complain. |
705 | * Otherwise, we will complain. |
706 | */ |
707 | if (!view->details->menu_states_untrustworthy) { |
708 | g_warning ("Empty selection found when selection was expected. No action will be performed."); |
709 | } |
710 | |
711 | return FALSE(0); |
712 | } |
713 | |
714 | static char * |
715 | get_view_directory (FMDirectoryView *view) |
716 | { |
717 | char *uri, *path; |
718 | GFile *f; |
719 | |
720 | uri = baul_directory_get_uri (view->details->model); |
721 | if (eel_uri_is_desktop (uri)) { |
722 | g_free (uri); |
723 | uri = baul_get_desktop_directory_uri (); |
724 | |
725 | } |
726 | f = g_file_new_for_uri (uri); |
727 | path = g_file_get_path (f); |
728 | g_object_unref (f); |
729 | g_free (uri); |
730 | |
731 | return path; |
732 | } |
733 | |
734 | void |
735 | fm_directory_view_activate_files (FMDirectoryView *view, |
736 | GList *files, |
737 | BaulWindowOpenMode mode, |
738 | BaulWindowOpenFlags flags, |
739 | gboolean confirm_multiple) |
740 | { |
741 | char *path; |
742 | |
743 | path = get_view_directory (view); |
744 | baul_mime_activate_files (fm_directory_view_get_containing_window (view), |
745 | view->details->slot, |
746 | files, |
747 | path, |
748 | mode, |
749 | flags, |
750 | confirm_multiple); |
751 | |
752 | g_free (path); |
753 | } |
754 | |
755 | void |
756 | fm_directory_view_activate_file (FMDirectoryView *view, |
757 | BaulFile *file, |
758 | BaulWindowOpenMode mode, |
759 | BaulWindowOpenFlags flags) |
760 | { |
761 | char *path; |
762 | |
763 | path = get_view_directory (view); |
764 | baul_mime_activate_file (fm_directory_view_get_containing_window (view), |
765 | view->details->slot, |
766 | file, |
767 | path, |
768 | mode, |
769 | flags); |
770 | |
771 | g_free (path); |
772 | } |
773 | |
774 | static void |
775 | action_open_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
776 | gpointer callback_data) |
777 | { |
778 | GList *selection; |
779 | FMDirectoryView *view; |
780 | |
781 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
782 | |
783 | selection = fm_directory_view_get_selection (view); |
784 | fm_directory_view_activate_files (view, |
785 | selection, |
786 | BAUL_WINDOW_OPEN_ACCORDING_TO_MODE, |
787 | 0, |
788 | TRUE(!(0))); |
789 | baul_file_list_free (selection); |
790 | } |
791 | |
792 | static void |
793 | action_open_close_parent_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
794 | gpointer callback_data) |
795 | { |
796 | GList *selection; |
797 | FMDirectoryView *view; |
798 | |
799 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
800 | |
801 | selection = fm_directory_view_get_selection (view); |
802 | fm_directory_view_activate_files (view, |
803 | selection, |
804 | BAUL_WINDOW_OPEN_ACCORDING_TO_MODE, |
805 | BAUL_WINDOW_OPEN_FLAG_CLOSE_BEHIND, |
806 | TRUE(!(0))); |
807 | baul_file_list_free (selection); |
808 | } |
809 | |
810 | |
811 | static void |
812 | action_open_alternate_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
813 | gpointer callback_data) |
814 | { |
815 | FMDirectoryView *view; |
816 | GList *selection; |
817 | CtkWindow *window; |
818 | |
819 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
820 | selection = fm_directory_view_get_selection (view); |
821 | |
822 | window = fm_directory_view_get_containing_window (view); |
823 | |
824 | if (fm_directory_view_confirm_multiple (window, g_list_length (selection), FALSE(0))) { |
825 | g_list_foreach (selection, open_one_in_new_window, view); |
826 | } |
827 | |
828 | baul_file_list_free (selection); |
829 | } |
830 | |
831 | static void |
832 | action_open_new_tab_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
833 | gpointer callback_data) |
834 | { |
835 | FMDirectoryView *view; |
836 | GList *selection; |
837 | CtkWindow *window; |
838 | |
839 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
840 | selection = fm_directory_view_get_selection (view); |
841 | |
842 | window = fm_directory_view_get_containing_window (view); |
843 | |
844 | if (fm_directory_view_confirm_multiple (window, g_list_length (selection), TRUE(!(0)))) { |
845 | fm_directory_view_activate_files (view, |
846 | selection, |
847 | BAUL_WINDOW_OPEN_ACCORDING_TO_MODE, |
848 | BAUL_WINDOW_OPEN_FLAG_NEW_TAB, |
849 | FALSE(0)); |
850 | } |
851 | |
852 | baul_file_list_free (selection); |
853 | } |
854 | |
855 | static void |
856 | action_open_folder_window_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
857 | gpointer callback_data) |
858 | { |
859 | FMDirectoryView *view; |
860 | GList *selection; |
861 | CtkWindow *window; |
862 | |
863 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
864 | selection = fm_directory_view_get_selection (view); |
865 | |
866 | window = fm_directory_view_get_containing_window (view); |
867 | |
868 | if (fm_directory_view_confirm_multiple (window, g_list_length (selection), FALSE(0))) { |
869 | g_list_foreach (selection, open_one_in_folder_window, view); |
870 | } |
871 | |
872 | baul_file_list_free (selection); |
873 | } |
874 | |
875 | static void |
876 | open_location (FMDirectoryView *directory_view, |
877 | const char *new_uri, |
878 | BaulWindowOpenMode mode, |
879 | BaulWindowOpenFlags flags) |
880 | { |
881 | CtkWindow *window; |
882 | GFile *location; |
883 | |
884 | g_assert (FM_IS_DIRECTORY_VIEW (directory_view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((directory_view)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 884, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (directory_view)" ); } while (0); |
885 | g_assert (new_uri != NULL)do { if (new_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 885, ((const char*) (__func__ )), "new_uri != NULL"); } while (0); |
886 | |
887 | window = fm_directory_view_get_containing_window (directory_view); |
888 | baul_debug_log (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER", |
889 | "directory view open_location window=%p: %s", window, new_uri); |
890 | location = g_file_new_for_uri (new_uri); |
891 | baul_window_slot_info_open_location (directory_view->details->slot,baul_window_slot_info_open_location_full(directory_view->details ->slot, location, mode, flags, ((void*)0), ((void*)0), ((void *)0)) |
892 | location, mode, flags, NULL)baul_window_slot_info_open_location_full(directory_view->details ->slot, location, mode, flags, ((void*)0), ((void*)0), ((void *)0)); |
893 | g_object_unref (location); |
894 | } |
895 | |
896 | static void |
897 | application_selected_cb (BaulOpenWithDialog *dialog, |
898 | GAppInfo *app, |
899 | gpointer user_data) |
900 | { |
901 | CtkWindow *parent_window; |
902 | BaulFile *file; |
903 | GList files; |
904 | |
905 | parent_window = CTK_WINDOW (user_data)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_window_get_type ())))))); |
906 | |
907 | file = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "directory-view:file"); |
908 | |
909 | files.next = NULL((void*)0); |
910 | files.prev = NULL((void*)0); |
911 | files.data = file; |
912 | baul_launch_application (app, &files, parent_window); |
913 | } |
914 | |
915 | static void |
916 | choose_program (FMDirectoryView *view, |
917 | BaulFile *file) |
918 | { |
919 | CtkWidget *dialog; |
920 | char *uri; |
921 | char *mime_type; |
922 | |
923 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 923, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
924 | g_assert (BAUL_IS_FILE (file))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((file)); GType __t = (baul_file_get_type()); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 924, ((const char*) (__func__)), "BAUL_IS_FILE (file)"); } while (0); |
925 | |
926 | baul_file_ref (file); |
927 | uri = baul_file_get_uri (file); |
928 | mime_type = baul_file_get_mime_type (file); |
929 | |
930 | dialog = baul_open_with_dialog_new (uri, mime_type, NULL((void*)0)); |
931 | g_object_set_data_full (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), |
932 | "directory-view:file", |
933 | g_object_ref (file)((__typeof__ (file)) (g_object_ref) (file)), |
934 | (GDestroyNotify)g_object_unref); |
935 | |
936 | ctk_window_set_screen (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), |
937 | ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))))); |
938 | ctk_widget_show (dialog); |
939 | |
940 | g_signal_connect_object (dialog, |
941 | "application_selected", |
942 | G_CALLBACK (application_selected_cb)((GCallback) (application_selected_cb)), |
943 | fm_directory_view_get_containing_window (view), |
944 | 0); |
945 | |
946 | g_free (uri); |
947 | g_free (mime_type); |
948 | baul_file_unref (file); |
949 | } |
950 | |
951 | static void |
952 | open_with_other_program (FMDirectoryView *view) |
953 | { |
954 | GList *selection; |
955 | |
956 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 956, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
957 | |
958 | selection = fm_directory_view_get_selection (view); |
959 | |
960 | if (selection_contains_one_item_in_menu_callback (view, selection)) { |
961 | choose_program (view, BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type())))))); |
962 | } |
963 | |
964 | baul_file_list_free (selection); |
965 | } |
966 | |
967 | static void |
968 | action_other_application_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
969 | gpointer callback_data) |
970 | { |
971 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 971, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
972 | |
973 | open_with_other_program (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type())))))); |
974 | } |
975 | |
976 | static void |
977 | trash_or_delete_selected_files (FMDirectoryView *view) |
978 | { |
979 | /* This might be rapidly called multiple times for the same selection |
980 | * when using keybindings. So we remember if the current selection |
981 | * was already removed (but the view doesn't know about it yet). |
982 | */ |
983 | if (!view->details->selection_was_removed) { |
984 | GList *selection; |
985 | |
986 | selection = fm_directory_view_get_selection_for_file_transfer (view); |
987 | trash_or_delete_files (fm_directory_view_get_containing_window (view), |
988 | selection, TRUE(!(0)), |
989 | view); |
990 | baul_file_list_free (selection); |
991 | view->details->selection_was_removed = TRUE(!(0)); |
992 | } |
993 | } |
994 | |
995 | static gboolean |
996 | real_trash (FMDirectoryView *view) |
997 | { |
998 | CtkAction *action; |
999 | |
1000 | action = ctk_action_group_get_action (view->details->dir_action_group, |
1001 | FM_ACTION_TRASH"Trash"); |
1002 | if (ctk_action_get_sensitive (action) && |
1003 | ctk_action_get_visible (action)) { |
1004 | trash_or_delete_selected_files (view); |
1005 | return TRUE(!(0)); |
1006 | } |
1007 | return FALSE(0); |
1008 | } |
1009 | |
1010 | static void |
1011 | action_trash_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1012 | gpointer callback_data) |
1013 | { |
1014 | trash_or_delete_selected_files (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type())))))); |
1015 | } |
1016 | |
1017 | static void |
1018 | delete_selected_files (FMDirectoryView *view) |
1019 | { |
1020 | GList *selection; |
1021 | GList *node; |
1022 | GList *locations; |
1023 | |
1024 | selection = fm_directory_view_get_selection_for_file_transfer (view); |
1025 | if (selection == NULL((void*)0)) { |
1026 | return; |
1027 | } |
1028 | |
1029 | locations = NULL((void*)0); |
1030 | for (node = selection; node != NULL((void*)0); node = node->next) { |
1031 | locations = g_list_prepend (locations, |
1032 | baul_file_get_location ((BaulFile *) node->data)); |
1033 | } |
1034 | locations = g_list_reverse (locations); |
1035 | |
1036 | baul_file_operations_delete (locations, fm_directory_view_get_containing_window (view), NULL((void*)0), NULL((void*)0)); |
1037 | |
1038 | g_list_free_full (locations, g_object_unref); |
1039 | baul_file_list_free (selection); |
1040 | } |
1041 | |
1042 | static void |
1043 | action_delete_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1044 | gpointer callback_data) |
1045 | { |
1046 | delete_selected_files (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type())))))); |
1047 | } |
1048 | |
1049 | static void |
1050 | action_restore_from_trash_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1051 | gpointer callback_data) |
1052 | { |
1053 | FMDirectoryView *view; |
1054 | GList *selection; |
1055 | |
1056 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1057 | |
1058 | selection = fm_directory_view_get_selection_for_file_transfer (view); |
1059 | baul_restore_files_from_trash (selection, |
1060 | fm_directory_view_get_containing_window (view)); |
1061 | |
1062 | baul_file_list_free (selection); |
1063 | |
1064 | } |
1065 | |
1066 | static gboolean |
1067 | real_delete (FMDirectoryView *view) |
1068 | { |
1069 | CtkAction *action; |
1070 | |
1071 | action = ctk_action_group_get_action (view->details->dir_action_group, |
1072 | FM_ACTION_TRASH"Trash"); |
1073 | if (ctk_action_get_sensitive (action) && |
1074 | ctk_action_get_visible (action)) { |
1075 | delete_selected_files (view); |
1076 | return TRUE(!(0)); |
1077 | } |
1078 | return FALSE(0); |
1079 | } |
1080 | |
1081 | static void |
1082 | action_duplicate_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1083 | gpointer callback_data) |
1084 | { |
1085 | FMDirectoryView *view; |
1086 | GList *selection; |
1087 | |
1088 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1089 | selection = fm_directory_view_get_selection_for_file_transfer (view); |
1090 | if (selection_not_empty_in_menu_callback (view, selection)) { |
1091 | GArray *selected_item_locations; |
1092 | |
1093 | /* FIXME bugzilla.gnome.org 45061: |
1094 | * should change things here so that we use a get_icon_locations (view, selection). |
1095 | * Not a problem in this case but in other places the selection may change by |
1096 | * the time we go and retrieve the icon positions, relying on the selection |
1097 | * staying intact to ensure the right sequence and count of positions is fragile. |
1098 | */ |
1099 | selected_item_locations = fm_directory_view_get_selected_icon_locations (view); |
1100 | fm_directory_view_duplicate_selection (view, selection, selected_item_locations); |
1101 | g_array_free (selected_item_locations, TRUE(!(0))); |
1102 | } |
1103 | |
1104 | baul_file_list_free (selection); |
1105 | } |
1106 | |
1107 | static void |
1108 | action_create_link_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1109 | gpointer callback_data) |
1110 | { |
1111 | FMDirectoryView *view; |
1112 | GList *selection; |
1113 | |
1114 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1114, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1115 | |
1116 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1117 | selection = fm_directory_view_get_selection (view); |
1118 | if (selection_not_empty_in_menu_callback (view, selection)) { |
1119 | GArray *selected_item_locations; |
1120 | |
1121 | selected_item_locations = fm_directory_view_get_selected_icon_locations (view); |
1122 | fm_directory_view_create_links_for_files (view, selection, selected_item_locations); |
1123 | g_array_free (selected_item_locations, TRUE(!(0))); |
1124 | } |
1125 | |
1126 | baul_file_list_free (selection); |
1127 | } |
1128 | |
1129 | static void |
1130 | action_select_all_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1131 | gpointer callback_data) |
1132 | { |
1133 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1133, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1134 | |
1135 | fm_directory_view_select_all (callback_data); |
1136 | } |
1137 | |
1138 | static void |
1139 | action_invert_selection_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1140 | gpointer callback_data) |
1141 | { |
1142 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1142, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1143 | |
1144 | fm_directory_view_invert_selection (callback_data); |
1145 | } |
1146 | |
1147 | |
1148 | static void |
1149 | pattern_select_response_cb (CtkWidget *dialog, int response, gpointer user_data) |
1150 | { |
1151 | FMDirectoryView *view; |
1152 | BaulDirectory *directory; |
1153 | CtkWidget *entry; |
1154 | GList *selection; |
1155 | GError *error; |
1156 | |
1157 | view = FM_DIRECTORY_VIEW (user_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), (fm_directory_view_get_type()))))); |
1158 | |
1159 | switch (response) { |
1160 | case CTK_RESPONSE_OK : |
1161 | entry = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "entry"); |
1162 | directory = fm_directory_view_get_model (view); |
1163 | selection = baul_directory_match_pattern (directory, |
1164 | ctk_entry_get_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))))); |
1165 | |
1166 | if (selection) { |
1167 | fm_directory_view_set_selection (view, selection); |
1168 | baul_file_list_free (selection); |
1169 | |
1170 | fm_directory_view_reveal_selection(view); |
1171 | } |
1172 | /* fall through */ |
1173 | case CTK_RESPONSE_NONE : |
1174 | case CTK_RESPONSE_DELETE_EVENT : |
1175 | case CTK_RESPONSE_CANCEL : |
1176 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
1177 | break; |
1178 | case CTK_RESPONSE_HELP : |
1179 | error = NULL((void*)0); |
1180 | ctk_show_uri_on_window (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), |
1181 | "help:cafe-user-guide/baul-select-pattern", |
1182 | ctk_get_current_event_time (), &error); |
1183 | if (error) { |
1184 | eel_show_error_dialog (_("There was an error displaying help.")gettext ("There was an error displaying help."), error->message, |
1185 | CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ()))))))); |
1186 | g_error_free (error); |
1187 | } |
1188 | break; |
1189 | default : |
1190 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1190, ((const char*) (__func__)), ((void*)0)); } while (0); |
1191 | } |
1192 | } |
1193 | |
1194 | static void |
1195 | select_pattern (FMDirectoryView *view) |
1196 | { |
1197 | CtkWidget *dialog; |
1198 | CtkWidget *label; |
1199 | CtkWidget *example; |
1200 | CtkWidget *grid; |
1201 | CtkWidget *entry; |
1202 | char *example_pattern; |
1203 | |
1204 | dialog = ctk_dialog_new (); |
1205 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), _("Select Items Matching")gettext ("Select Items Matching")); |
1206 | ctk_window_set_transient_for (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), fm_directory_view_get_containing_window (view)); |
1207 | ctk_window_set_destroy_with_parent (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); |
1208 | |
1209 | eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
1210 | _("_Help")gettext ("_Help"), |
1211 | "help-browser", |
1212 | CTK_RESPONSE_HELP); |
1213 | |
1214 | eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
1215 | _("_Cancel")gettext ("_Cancel"), |
1216 | "process-stop", |
1217 | CTK_RESPONSE_CANCEL); |
1218 | |
1219 | eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
1220 | _("_OK")gettext ("_OK"), |
1221 | "ctk-ok", |
1222 | CTK_RESPONSE_OK); |
1223 | |
1224 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
1225 | CTK_RESPONSE_OK); |
1226 | ctk_container_set_border_width (CTK_CONTAINER (dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_container_get_type ())))))), 5); |
1227 | ctk_box_set_spacing (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_box_get_type ())))))), 2); |
1228 | |
1229 | label = ctk_label_new_with_mnemonic (_("_Pattern:")gettext ("_Pattern:")); |
1230 | |
1231 | ctk_widget_set_halign (label, CTK_ALIGN_START); |
1232 | |
1233 | example = ctk_label_new (NULL((void*)0)); |
1234 | ctk_widget_set_halign (example, CTK_ALIGN_START); |
1235 | example_pattern = g_strdup_printf ("<b>%s</b><i>%s</i>", |
1236 | _("Examples: ")gettext ("Examples: "), |
1237 | "*.png, file\?\?.txt, pict*.\?\?\?"); |
1238 | ctk_label_set_markup (CTK_LABEL (example)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((example)), ((ctk_label_get_type ())))))), example_pattern); |
1239 | g_free (example_pattern); |
1240 | ctk_widget_set_halign (example, CTK_ALIGN_START); |
1241 | |
1242 | entry = ctk_entry_new (); |
1243 | ctk_entry_set_activates_default (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), TRUE(!(0))); |
1244 | ctk_widget_set_hexpand (entry, TRUE(!(0))); |
1245 | |
1246 | grid = ctk_grid_new (); |
1247 | g_object_set (grid, |
1248 | "orientation", CTK_ORIENTATION_VERTICAL, |
1249 | "border-width", 6, |
1250 | "row-spacing", 6, |
1251 | "column-spacing", 12, |
1252 | NULL((void*)0)); |
1253 | |
1254 | ctk_container_add (CTK_CONTAINER (grid)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_container_get_type ())))))), label); |
1255 | ctk_grid_attach_next_to (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), entry, label, |
1256 | CTK_POS_RIGHT, 1, 1); |
1257 | ctk_grid_attach_next_to (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), example, entry, |
1258 | CTK_POS_BOTTOM, 1, 1); |
1259 | |
1260 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), entry); |
1261 | ctk_widget_show_all (grid); |
1262 | ctk_container_add (CTK_CONTAINER (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_container_get_type ())))))), grid); |
1263 | |
1264 | g_object_set_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "entry", entry); |
1265 | g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) ( pattern_select_response_cb))), (view), ((void*)0), (GConnectFlags ) 0) |
1266 | G_CALLBACK (pattern_select_response_cb),g_signal_connect_data ((dialog), ("response"), (((GCallback) ( pattern_select_response_cb))), (view), ((void*)0), (GConnectFlags ) 0) |
1267 | view)g_signal_connect_data ((dialog), ("response"), (((GCallback) ( pattern_select_response_cb))), (view), ((void*)0), (GConnectFlags ) 0); |
1268 | ctk_widget_show_all (dialog); |
1269 | } |
1270 | |
1271 | static void |
1272 | action_select_pattern_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1273 | gpointer callback_data) |
1274 | { |
1275 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1275, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1276 | |
1277 | select_pattern(callback_data); |
1278 | } |
1279 | |
1280 | static void |
1281 | action_reset_to_defaults_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1282 | gpointer callback_data) |
1283 | { |
1284 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1284, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1285 | |
1286 | fm_directory_view_reset_to_defaults (callback_data); |
1287 | } |
1288 | |
1289 | |
1290 | static void |
1291 | hidden_files_mode_changed (BaulWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), |
1292 | gpointer callback_data) |
1293 | { |
1294 | FMDirectoryView *directory_view; |
1295 | |
1296 | directory_view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1297 | |
1298 | fm_directory_view_init_show_hidden_files (directory_view); |
1299 | } |
1300 | |
1301 | static void |
1302 | backup_files_mode_changed (BaulWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), |
1303 | gpointer callback_data) |
1304 | { |
1305 | FMDirectoryView *directory_view; |
1306 | |
1307 | directory_view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1308 | |
1309 | fm_directory_view_init_show_backup_files (directory_view); |
1310 | } |
1311 | |
1312 | static void |
1313 | action_save_search_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1314 | gpointer callback_data) |
1315 | { |
1316 | FMDirectoryView *directory_view; |
1317 | |
1318 | directory_view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1319 | |
1320 | if (directory_view->details->model && |
1321 | BAUL_IS_SEARCH_DIRECTORY (directory_view->details->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (directory_view->details->model)); GType __t = (baul_search_directory_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
1322 | BaulSearchDirectory *search; |
1323 | |
1324 | search = BAUL_SEARCH_DIRECTORY (directory_view->details->model)((((BaulSearchDirectory*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((directory_view->details->model)), ( baul_search_directory_get_type()))))); |
1325 | baul_search_directory_save_search (search); |
1326 | |
1327 | /* Save search is disabled */ |
1328 | schedule_update_menus (directory_view); |
1329 | } |
1330 | } |
1331 | |
1332 | static void |
1333 | query_name_entry_changed_cb (CtkWidget *entry, CtkWidget *button) |
1334 | { |
1335 | const char *text; |
1336 | gboolean sensitive; |
1337 | |
1338 | text = ctk_entry_get_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ()))))))); |
1339 | |
1340 | sensitive = (text != NULL((void*)0)) && (*text != 0); |
1341 | |
1342 | ctk_widget_set_sensitive (button, sensitive); |
1343 | } |
1344 | |
1345 | |
1346 | static void |
1347 | action_save_search_as_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1348 | gpointer callback_data) |
1349 | { |
1350 | FMDirectoryView *directory_view; |
1351 | |
1352 | directory_view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1353 | |
1354 | if (directory_view->details->model && |
1355 | BAUL_IS_SEARCH_DIRECTORY (directory_view->details->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (directory_view->details->model)); GType __t = (baul_search_directory_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
1356 | BaulSearchDirectory *search; |
1357 | CtkWidget *dialog, *grid, *label, *entry, *chooser, *save_button; |
1358 | |
1359 | search = BAUL_SEARCH_DIRECTORY (directory_view->details->model)((((BaulSearchDirectory*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((directory_view->details->model)), ( baul_search_directory_get_type()))))); |
1360 | |
1361 | dialog = ctk_dialog_new (); |
1362 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), _("Save Search as")gettext ("Save Search as")); |
1363 | ctk_window_set_transient_for (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), fm_directory_view_get_containing_window (directory_view)); |
1364 | |
1365 | eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
1366 | _("_Cancel")gettext ("_Cancel"), |
1367 | "process-stop", |
1368 | CTK_RESPONSE_CANCEL); |
1369 | |
1370 | save_button = eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), _("_Save")gettext ("_Save"), |
1371 | "document-save", CTK_RESPONSE_OK); |
1372 | |
1373 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
1374 | CTK_RESPONSE_OK); |
1375 | ctk_container_set_border_width (CTK_CONTAINER (dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_container_get_type ())))))), 5); |
1376 | ctk_box_set_spacing (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_box_get_type ())))))), 2); |
1377 | ctk_window_set_resizable (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), FALSE(0)); |
1378 | |
1379 | grid = ctk_grid_new (); |
1380 | g_object_set (grid, |
1381 | "orientation", CTK_ORIENTATION_VERTICAL, |
1382 | "border-width", 5, |
1383 | "row-spacing", 6, |
1384 | "column-spacing", 12, |
1385 | NULL((void*)0)); |
1386 | ctk_box_pack_start (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_box_get_type ())))))), grid, TRUE(!(0)), TRUE(!(0)), 0); |
1387 | ctk_widget_show (grid); |
1388 | |
1389 | label = ctk_label_new_with_mnemonic (_("Search _name:")gettext ("Search _name:")); |
1390 | ctk_label_set_xalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), 0.0); |
1391 | ctk_container_add (CTK_CONTAINER (grid)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_container_get_type ())))))), label); |
1392 | ctk_widget_show (label); |
1393 | entry = ctk_entry_new (); |
1394 | ctk_widget_set_hexpand (entry, TRUE(!(0))); |
1395 | ctk_grid_attach_next_to (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), entry, label, |
1396 | CTK_POS_RIGHT, 1, 1); |
1397 | ctk_entry_set_activates_default (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), TRUE(!(0))); |
1398 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), entry); |
1399 | |
1400 | ctk_widget_set_sensitive (save_button, FALSE(0)); |
1401 | g_signal_connect (entry, "changed",g_signal_connect_data ((entry), ("changed"), (((GCallback) (query_name_entry_changed_cb ))), (save_button), ((void*)0), (GConnectFlags) 0) |
1402 | G_CALLBACK (query_name_entry_changed_cb), save_button)g_signal_connect_data ((entry), ("changed"), (((GCallback) (query_name_entry_changed_cb ))), (save_button), ((void*)0), (GConnectFlags) 0); |
1403 | |
1404 | ctk_widget_show (entry); |
1405 | label = ctk_label_new_with_mnemonic (_("_Folder:")gettext ("_Folder:")); |
1406 | ctk_label_set_xalign (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), 0.0); |
1407 | ctk_container_add (CTK_CONTAINER (grid)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_container_get_type ())))))), label); |
1408 | ctk_widget_show (label); |
1409 | |
1410 | chooser = ctk_file_chooser_button_new (_("Select Folder to Save Search In")gettext ("Select Folder to Save Search In"), |
1411 | CTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); |
1412 | ctk_widget_set_hexpand (chooser, TRUE(!(0))); |
1413 | ctk_grid_attach_next_to (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), chooser, label, |
1414 | CTK_POS_RIGHT, 1, 1); |
1415 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), chooser); |
1416 | ctk_widget_show (chooser); |
1417 | |
1418 | ctk_file_chooser_set_local_only (CTK_FILE_CHOOSER (chooser)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_file_chooser_get_type ())))))), TRUE(!(0))); |
1419 | |
1420 | ctk_file_chooser_set_current_folder (CTK_FILE_CHOOSER (chooser)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_file_chooser_get_type ())))))), |
1421 | g_get_home_dir ()); |
1422 | |
1423 | if (ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))) == CTK_RESPONSE_OK) { |
1424 | const char *entry_text; |
1425 | char *filename, *filename_utf8, *dirname, *path, *uri; |
1426 | GFile *location; |
1427 | |
1428 | entry_text = ctk_entry_get_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ()))))))); |
1429 | if (g_str_has_suffix (entry_text, BAUL_SAVED_SEARCH_EXTENSION)(__builtin_constant_p (".savedSearch")? __extension__ ({ const char * const __str = (entry_text); const char * const __suffix = (".savedSearch"); gboolean __result = (0); if (__str == (( void*)0) || __suffix == ((void*)0)) __result = (g_str_has_suffix ) (__str, __suffix); else { const size_t __str_len = strlen ( ((__str) + !(__str))); const size_t __suffix_len = strlen ((( __suffix) + !(__suffix))); if (__str_len >= __suffix_len) __result = memcmp (__str + __str_len - __suffix_len, ((__suffix) + !( __suffix)), __suffix_len) == 0; } __result; }) : (g_str_has_suffix ) (entry_text, ".savedSearch") )) { |
1430 | filename_utf8 = g_strdup (entry_text)g_strdup_inline (entry_text); |
1431 | } else { |
1432 | filename_utf8 = g_strconcat (entry_text, BAUL_SAVED_SEARCH_EXTENSION".savedSearch", NULL((void*)0)); |
1433 | } |
1434 | |
1435 | filename = g_filename_from_utf8 (filename_utf8, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
1436 | g_free (filename_utf8); |
1437 | |
1438 | dirname = ctk_file_chooser_get_filename (CTK_FILE_CHOOSER (chooser)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_file_chooser_get_type ()))))))); |
1439 | |
1440 | path = g_build_filename (dirname, filename, NULL((void*)0)); |
1441 | g_free (filename); |
1442 | g_free (dirname); |
1443 | |
1444 | uri = g_filename_to_uri (path, NULL((void*)0), NULL((void*)0)); |
1445 | g_free (path); |
1446 | |
1447 | baul_search_directory_save_to_file (search, uri); |
1448 | location = g_file_new_for_uri (uri); |
1449 | baul_file_changes_queue_file_added (location); |
1450 | g_object_unref (location); |
1451 | baul_file_changes_consume_changes (TRUE(!(0))); |
1452 | g_free (uri); |
1453 | } |
1454 | |
1455 | ctk_widget_destroy (dialog); |
1456 | } |
1457 | } |
1458 | |
1459 | |
1460 | static void |
1461 | action_empty_trash_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1462 | gpointer callback_data) |
1463 | { |
1464 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1464, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1465 | |
1466 | baul_file_operations_empty_trash (CTK_WIDGET (callback_data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), ((ctk_widget_get_type ()))))))); |
1467 | } |
1468 | |
1469 | static void |
1470 | action_new_folder_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1471 | gpointer callback_data) |
1472 | { |
1473 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1473, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1474 | |
1475 | fm_directory_view_new_folder (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type())))))); |
1476 | } |
1477 | |
1478 | static void |
1479 | action_new_empty_file_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1480 | gpointer callback_data) |
1481 | { |
1482 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1482, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1483 | |
1484 | fm_directory_view_new_file (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))), NULL((void*)0), NULL((void*)0)); |
1485 | } |
1486 | |
1487 | static void |
1488 | action_new_launcher_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1489 | gpointer callback_data) |
1490 | { |
1491 | char *parent_uri; |
1492 | FMDirectoryView *view; |
1493 | CtkWindow *window; |
1494 | |
1495 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1495, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1496 | |
1497 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1498 | |
1499 | parent_uri = fm_directory_view_get_backing_uri (view); |
1500 | |
1501 | window = fm_directory_view_get_containing_window (view); |
1502 | baul_debug_log (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER", |
1503 | "directory view create new launcher in window=%p: %s", window, parent_uri); |
1504 | baul_launch_application_from_command (ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))), |
1505 | "cafe-desktop-item-edit", |
1506 | "cafe-desktop-item-edit", |
1507 | FALSE(0), |
1508 | "--create-new", parent_uri, NULL((void*)0)); |
1509 | |
1510 | g_free (parent_uri); |
1511 | } |
1512 | |
1513 | static void |
1514 | action_properties_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1515 | gpointer callback_data) |
1516 | { |
1517 | FMDirectoryView *view; |
1518 | GList *selection; |
1519 | |
1520 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1520, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1521 | |
1522 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1523 | selection = fm_directory_view_get_selection (view); |
1524 | if (g_list_length (selection) == 0) { |
1525 | if (view->details->directory_as_file != NULL((void*)0)) { |
1526 | GList *files; |
1527 | |
1528 | files = g_list_append (NULL((void*)0), baul_file_ref (view->details->directory_as_file)); |
1529 | |
1530 | fm_properties_window_present (files, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
1531 | |
1532 | baul_file_list_free (files); |
1533 | } |
1534 | } else { |
1535 | fm_properties_window_present (selection, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
1536 | } |
1537 | baul_file_list_free (selection); |
1538 | } |
1539 | |
1540 | static void |
1541 | action_location_properties_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
1542 | gpointer callback_data) |
1543 | { |
1544 | FMDirectoryView *view; |
1545 | GList *files; |
1546 | |
1547 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1547, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
1548 | |
1549 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1550 | g_assert (BAUL_IS_FILE (view->details->location_popup_directory_as_file))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view->details->location_popup_directory_as_file)); GType __t = (baul_file_get_type()); gboolean __r; if (!__inst ) __r = (0); else if (__inst->g_class && __inst-> g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr ( ((gchar*) 0), "fm-directory-view.c", 1550, ((const char*) (__func__ )), "BAUL_IS_FILE (view->details->location_popup_directory_as_file)" ); } while (0); |
1551 | |
1552 | files = g_list_append (NULL((void*)0), baul_file_ref (view->details->location_popup_directory_as_file)); |
1553 | |
1554 | fm_properties_window_present (files, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
1555 | |
1556 | baul_file_list_free (files); |
1557 | } |
1558 | |
1559 | static gboolean |
1560 | all_files_in_trash (GList *files) |
1561 | { |
1562 | GList *node; |
1563 | |
1564 | /* Result is ambiguous if called on NULL, so disallow. */ |
1565 | g_return_val_if_fail (files != NULL, FALSE)do { if ((files != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "files != NULL"); return ((0)); } } while (0); |
1566 | |
1567 | for (node = files; node != NULL((void*)0); node = node->next) { |
1568 | if (!baul_file_is_in_trash (BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), (baul_file_get_type()))))))) { |
1569 | return FALSE(0); |
1570 | } |
1571 | } |
1572 | |
1573 | return TRUE(!(0)); |
1574 | } |
1575 | |
1576 | static gboolean |
1577 | all_selected_items_in_trash (FMDirectoryView *view) |
1578 | { |
1579 | GList *selection; |
1580 | gboolean result; |
1581 | |
1582 | /* If the contents share a parent directory, we need only |
1583 | * check that parent directory. Otherwise we have to inspect |
1584 | * each selected item. |
1585 | */ |
1586 | selection = fm_directory_view_get_selection (view); |
1587 | result = (selection == NULL((void*)0)) ? FALSE(0) : all_files_in_trash (selection); |
1588 | baul_file_list_free (selection); |
1589 | |
1590 | return result; |
1591 | } |
1592 | |
1593 | static gboolean |
1594 | we_are_in_vfolder_desktop_dir (FMDirectoryView *view) |
1595 | { |
1596 | BaulFile *file; |
1597 | char *mime_type; |
1598 | |
1599 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
1600 | |
1601 | if (view->details->model == NULL((void*)0)) { |
1602 | return FALSE(0); |
1603 | } |
1604 | |
1605 | file = baul_directory_get_corresponding_file (view->details->model); |
1606 | mime_type = baul_file_get_mime_type (file); |
1607 | baul_file_unref (file); |
1608 | |
1609 | if (mime_type != NULL((void*)0) |
1610 | && strcmp (mime_type, "x-directory/vfolder-desktop") == 0) { |
1611 | g_free (mime_type); |
1612 | return TRUE(!(0)); |
1613 | } else { |
1614 | g_free (mime_type); |
1615 | return FALSE(0); |
1616 | } |
1617 | } |
1618 | |
1619 | /* Preferences changed callbacks */ |
1620 | static void |
1621 | text_attribute_names_changed_callback (gpointer callback_data) |
1622 | { |
1623 | FMDirectoryView *view; |
1624 | |
1625 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1626 | |
1627 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> text_attribute_names_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->text_attribute_names_changed) (view); } } while ( 0) |
1628 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> text_attribute_names_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->text_attribute_names_changed) (view); } } while ( 0) |
1629 | text_attribute_names_changed, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> text_attribute_names_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->text_attribute_names_changed) (view); } } while ( 0); |
1630 | } |
1631 | |
1632 | static void |
1633 | image_display_policy_changed_callback (gpointer callback_data) |
1634 | { |
1635 | FMDirectoryView *view; |
1636 | |
1637 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1638 | |
1639 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> image_display_policy_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->image_display_policy_changed) (view); } } while ( 0) |
1640 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> image_display_policy_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->image_display_policy_changed) (view); } } while ( 0) |
1641 | image_display_policy_changed, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> image_display_policy_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->image_display_policy_changed) (view); } } while ( 0); |
1642 | } |
1643 | |
1644 | static void |
1645 | click_policy_changed_callback (gpointer callback_data) |
1646 | { |
1647 | FMDirectoryView *view; |
1648 | |
1649 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1650 | |
1651 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> click_policy_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->click_policy_changed) (view); } } while (0) |
1652 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> click_policy_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->click_policy_changed) (view); } } while (0) |
1653 | click_policy_changed, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> click_policy_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->click_policy_changed) (view); } } while (0); |
1654 | } |
1655 | |
1656 | gboolean |
1657 | fm_directory_view_should_sort_directories_first (FMDirectoryView *view) |
1658 | { |
1659 | return view->details->sort_directories_first; |
1660 | } |
1661 | |
1662 | static void |
1663 | sort_directories_first_changed_callback (gpointer callback_data) |
1664 | { |
1665 | FMDirectoryView *view; |
1666 | gboolean preference_value; |
1667 | |
1668 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1669 | |
1670 | preference_value = |
1671 | g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_SORT_DIRECTORIES_FIRST"sort-directories-first"); |
1672 | |
1673 | if (preference_value != view->details->sort_directories_first) { |
1674 | view->details->sort_directories_first = preference_value; |
1675 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> sort_directories_first_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->sort_directories_first_changed) (view); } } while (0) |
1676 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> sort_directories_first_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->sort_directories_first_changed) (view); } } while (0) |
1677 | sort_directories_first_changed, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> sort_directories_first_changed != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->sort_directories_first_changed) (view); } } while (0); |
1678 | } |
1679 | } |
1680 | |
1681 | static void set_up_scripts_directory_global(void) |
1682 | { |
1683 | if (scripts_directory_uri != NULL((void*)0)) |
1684 | { |
1685 | return; |
1686 | } |
1687 | |
1688 | char* scripts_directory_path; |
1689 | scripts_directory_path = g_build_filename (g_get_user_config_dir (), "baul", "scripts", NULL((void*)0)); |
1690 | |
1691 | if (g_mkdir_with_parents(scripts_directory_path, 0755) == 0) |
1692 | { |
1693 | scripts_directory_uri = g_filename_to_uri(scripts_directory_path, NULL((void*)0), NULL((void*)0)); |
1694 | scripts_directory_uri_length = strlen(scripts_directory_uri); |
1695 | |
1696 | /* Support for GNOME Nautilus scripts |
1697 | */ |
1698 | char* nautilus_scripts_path = g_build_filename(g_get_home_dir(), ".gnome2", "nautilus-scripts", NULL((void*)0)); |
1699 | |
1700 | if (g_file_test(nautilus_scripts_path, G_FILE_TEST_IS_DIR) == TRUE(!(0))) |
1701 | { |
1702 | char* nautilus_syslink = g_build_filename(g_get_user_config_dir(), "baul", "scripts", "nautilus", NULL((void*)0)); |
1703 | /* If link already exists, or also any other kind of file/dir with same name, ignore it */ |
1704 | if (g_file_test(nautilus_syslink, G_FILE_TEST_IS_SYMLINK) == FALSE(0) && |
1705 | g_file_test(nautilus_syslink, G_FILE_TEST_EXISTS) == FALSE(0) && |
1706 | g_file_test(nautilus_syslink, G_FILE_TEST_IS_DIR) == FALSE(0)) |
1707 | { |
1708 | /* Check if we need to create a link */ |
1709 | GDir* dir = g_dir_open(nautilus_scripts_path, 0, NULL((void*)0)); |
1710 | |
1711 | if (dir) |
1712 | { |
1713 | /* If directory contains files, we can create the link */ |
1714 | int count = 0; |
1715 | |
1716 | while (g_dir_read_name(dir) != NULL((void*)0)) |
1717 | { |
1718 | count++; |
1719 | } |
1720 | |
1721 | if (count > 0) |
1722 | { |
1723 | /* Create link to nautilus folder */ |
1724 | int res = symlink (nautilus_scripts_path, nautilus_syslink); |
1725 | if (res != 0) |
1726 | g_warning ("Can't create symlink to nautilus scripts folder"); |
1727 | } |
1728 | |
1729 | g_dir_close(dir); |
1730 | } |
1731 | } |
1732 | |
1733 | g_free(nautilus_syslink); |
1734 | } |
1735 | |
1736 | g_free(nautilus_scripts_path); |
1737 | } |
1738 | |
1739 | g_free(scripts_directory_path); |
1740 | } |
1741 | |
1742 | static void |
1743 | scripts_added_or_changed_callback (BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
1744 | GList *files G_GNUC_UNUSED__attribute__ ((__unused__)), |
1745 | gpointer callback_data) |
1746 | { |
1747 | FMDirectoryView *view; |
1748 | |
1749 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1750 | |
1751 | view->details->scripts_invalid = TRUE(!(0)); |
1752 | if (view->details->active) { |
1753 | schedule_update_menus (view); |
1754 | } |
1755 | } |
1756 | |
1757 | static void |
1758 | templates_added_or_changed_callback (BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
1759 | GList *files G_GNUC_UNUSED__attribute__ ((__unused__)), |
1760 | gpointer callback_data) |
1761 | { |
1762 | FMDirectoryView *view; |
1763 | |
1764 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
1765 | |
1766 | view->details->templates_invalid = TRUE(!(0)); |
1767 | if (view->details->active) { |
1768 | schedule_update_menus (view); |
1769 | } |
1770 | } |
1771 | |
1772 | static void |
1773 | add_directory_to_directory_list (FMDirectoryView *view, |
1774 | BaulDirectory *directory, |
1775 | GList **directory_list, |
1776 | GCallback changed_callback) |
1777 | { |
1778 | BaulFileAttributes attributes; |
1779 | |
1780 | if (g_list_find (*directory_list, directory) == NULL((void*)0)) { |
1781 | baul_directory_ref (directory); |
1782 | |
1783 | attributes = |
1784 | BAUL_FILE_ATTRIBUTES_FOR_ICON(BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_LINK_INFO | BAUL_FILE_ATTRIBUTE_THUMBNAIL ) | |
1785 | BAUL_FILE_ATTRIBUTE_INFO | |
1786 | BAUL_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT; |
1787 | |
1788 | baul_directory_file_monitor_add (directory, directory_list, |
1789 | FALSE(0), attributes, |
1790 | (BaulDirectoryCallback)changed_callback, view); |
1791 | |
1792 | g_signal_connect_object (directory, "files_added", |
1793 | G_CALLBACK (changed_callback)((GCallback) (changed_callback)), view, 0); |
1794 | g_signal_connect_object (directory, "files_changed", |
1795 | G_CALLBACK (changed_callback)((GCallback) (changed_callback)), view, 0); |
1796 | |
1797 | *directory_list = g_list_append (*directory_list, directory); |
1798 | } |
1799 | } |
1800 | |
1801 | static void |
1802 | remove_directory_from_directory_list (FMDirectoryView *view, |
1803 | BaulDirectory *directory, |
1804 | GList **directory_list, |
1805 | GCallback changed_callback) |
1806 | { |
1807 | *directory_list = g_list_remove (*directory_list, directory); |
1808 | |
1809 | g_signal_handlers_disconnect_by_func (directory,g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (changed_callback))), (view)) |
1810 | G_CALLBACK (changed_callback),g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (changed_callback))), (view)) |
1811 | view)g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (changed_callback))), (view)); |
1812 | |
1813 | baul_directory_file_monitor_remove (directory, directory_list); |
1814 | |
1815 | baul_directory_unref (directory); |
1816 | } |
1817 | |
1818 | |
1819 | static void |
1820 | add_directory_to_scripts_directory_list (FMDirectoryView *view, |
1821 | BaulDirectory *directory) |
1822 | { |
1823 | add_directory_to_directory_list (view, directory, |
1824 | &view->details->scripts_directory_list, |
1825 | G_CALLBACK (scripts_added_or_changed_callback)((GCallback) (scripts_added_or_changed_callback))); |
1826 | } |
1827 | |
1828 | static void |
1829 | remove_directory_from_scripts_directory_list (FMDirectoryView *view, |
1830 | BaulDirectory *directory) |
1831 | { |
1832 | remove_directory_from_directory_list (view, directory, |
1833 | &view->details->scripts_directory_list, |
1834 | G_CALLBACK (scripts_added_or_changed_callback)((GCallback) (scripts_added_or_changed_callback))); |
1835 | } |
1836 | |
1837 | static void |
1838 | add_directory_to_templates_directory_list (FMDirectoryView *view, |
1839 | BaulDirectory *directory) |
1840 | { |
1841 | add_directory_to_directory_list (view, directory, |
1842 | &view->details->templates_directory_list, |
1843 | G_CALLBACK (templates_added_or_changed_callback)((GCallback) (templates_added_or_changed_callback))); |
1844 | } |
1845 | |
1846 | static void |
1847 | remove_directory_from_templates_directory_list (FMDirectoryView *view, |
1848 | BaulDirectory *directory) |
1849 | { |
1850 | remove_directory_from_directory_list (view, directory, |
1851 | &view->details->templates_directory_list, |
1852 | G_CALLBACK (templates_added_or_changed_callback)((GCallback) (templates_added_or_changed_callback))); |
1853 | } |
1854 | |
1855 | static void |
1856 | slot_active (BaulWindowSlot *slot G_GNUC_UNUSED__attribute__ ((__unused__)), |
1857 | FMDirectoryView *view) |
1858 | { |
1859 | g_assert (!view->details->active)do { if (!view->details->active) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 1859, ((const char*) ( __func__)), "!view->details->active"); } while (0); |
1860 | view->details->active = TRUE(!(0)); |
1861 | |
1862 | fm_directory_view_merge_menus (view); |
1863 | schedule_update_menus (view); |
1864 | } |
1865 | |
1866 | static void |
1867 | slot_inactive (BaulWindowSlot *slot G_GNUC_UNUSED__attribute__ ((__unused__)), |
1868 | FMDirectoryView *view) |
1869 | { |
1870 | g_assert (view->details->active ||do { if (view->details->active || ctk_widget_get_parent (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))) == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1871, ((const char*) (__func__)), "view->details->active || ctk_widget_get_parent (CTK_WIDGET (view)) == NULL" ); } while (0) |
1871 | ctk_widget_get_parent (CTK_WIDGET (view)) == NULL)do { if (view->details->active || ctk_widget_get_parent (((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))) == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 1871, ((const char*) (__func__)), "view->details->active || ctk_widget_get_parent (CTK_WIDGET (view)) == NULL" ); } while (0); |
1872 | view->details->active = FALSE(0); |
1873 | |
1874 | fm_directory_view_unmerge_menus (view); |
1875 | remove_update_menus_timeout_callback (view); |
1876 | } |
1877 | |
1878 | static void |
1879 | fm_directory_view_grab_focus (BaulView *view) |
1880 | { |
1881 | /* focus the child of the scrolled window if it exists */ |
1882 | CtkWidget *child; |
1883 | child = ctk_bin_get_child (CTK_BIN (view)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_bin_get_type ()))))))); |
1884 | if (child) { |
1885 | ctk_widget_grab_focus (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((child)), ((ctk_widget_get_type ()))))))); |
1886 | } |
1887 | } |
1888 | |
1889 | static void |
1890 | view_iface_update_menus (BaulView *view) |
1891 | { |
1892 | fm_directory_view_update_menus (FM_DIRECTORY_VIEW (view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (fm_directory_view_get_type())))))); |
1893 | } |
1894 | |
1895 | static CtkWidget * |
1896 | fm_directory_view_get_widget (BaulView *view) |
1897 | { |
1898 | return CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))); |
1899 | } |
1900 | |
1901 | static int |
1902 | fm_directory_view_get_selection_count (BaulView *view) |
1903 | { |
1904 | /* FIXME: This could be faster if we special cased it in subclasses */ |
1905 | GList *files; |
1906 | int len; |
1907 | |
1908 | files = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (fm_directory_view_get_type())))))); |
1909 | len = g_list_length (files); |
1910 | baul_file_list_free (files); |
1911 | |
1912 | return len; |
1913 | } |
1914 | |
1915 | static GList * |
1916 | fm_directory_view_get_selection_locations (BaulView *view) |
1917 | { |
1918 | GList *files; |
1919 | GList *locations; |
1920 | GList *l; |
1921 | GFile *location = NULL((void*)0); |
1922 | |
1923 | files = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (fm_directory_view_get_type())))))); |
1924 | locations = NULL((void*)0); |
1925 | for (l = files; l != NULL((void*)0); l = l->next) { |
1926 | location = baul_file_get_location (BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type())))))); |
1927 | locations = g_list_prepend (locations, location); |
1928 | } |
1929 | baul_file_list_free (files); |
1930 | |
1931 | return g_list_reverse (locations); |
1932 | } |
1933 | |
1934 | static GList * |
1935 | file_list_from_location_list (const GList *uri_list) |
1936 | { |
1937 | GList *file_list; |
1938 | const GList *node; |
1939 | |
1940 | file_list = NULL((void*)0); |
1941 | for (node = uri_list; node != NULL((void*)0); node = node->next) { |
1942 | file_list = g_list_prepend |
1943 | (file_list, |
1944 | baul_file_get (node->data)); |
1945 | } |
1946 | return g_list_reverse (file_list); |
1947 | } |
1948 | |
1949 | static void |
1950 | fm_directory_view_set_selection_locations (BaulView *baul_view, |
1951 | GList *selection_locations) |
1952 | { |
1953 | FMDirectoryView *view; |
1954 | |
1955 | view = FM_DIRECTORY_VIEW (baul_view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baul_view)), (fm_directory_view_get_type()))))); |
1956 | |
1957 | if (!view->details->loading) { |
1958 | GList *selection; |
1959 | |
1960 | /* If we aren't still loading, set the selection right now, |
1961 | * and reveal the new selection. |
1962 | */ |
1963 | selection = file_list_from_location_list (selection_locations); |
1964 | view->details->selection_change_is_due_to_shell = TRUE(!(0)); |
1965 | fm_directory_view_set_selection (view, selection); |
1966 | view->details->selection_change_is_due_to_shell = FALSE(0); |
1967 | fm_directory_view_reveal_selection (view); |
1968 | baul_file_list_free (selection); |
1969 | } else { |
1970 | /* If we are still loading, set the list of pending URIs instead. |
1971 | * done_loading() will eventually select the pending URIs and reveal them. |
1972 | */ |
1973 | g_list_free_full (view->details->pending_locations_selected, g_object_unref); |
1974 | view->details->pending_locations_selected = |
1975 | g_list_copy_deep (selection_locations, (GCopyFunc) g_object_ref, NULL((void*)0)); |
1976 | } |
1977 | } |
1978 | |
1979 | |
1980 | void |
1981 | fm_directory_view_init_view_iface (BaulViewIface *iface) |
1982 | { |
1983 | iface->grab_focus = fm_directory_view_grab_focus; |
1984 | iface->update_menus = view_iface_update_menus; |
1985 | |
1986 | iface->get_widget = fm_directory_view_get_widget; |
1987 | iface->load_location = fm_directory_view_load_location; |
1988 | iface->stop_loading = fm_directory_view_stop_loading; |
1989 | |
1990 | iface->get_selection_count = fm_directory_view_get_selection_count; |
1991 | iface->get_selection = fm_directory_view_get_selection_locations; |
1992 | iface->set_selection = fm_directory_view_set_selection_locations; |
1993 | iface->set_is_active = (gpointer)fm_directory_view_set_is_active; |
1994 | |
1995 | iface->supports_zooming = (gpointer)fm_directory_view_supports_zooming; |
1996 | iface->bump_zoom_level = (gpointer)fm_directory_view_bump_zoom_level; |
1997 | iface->zoom_to_level = (gpointer)fm_directory_view_zoom_to_level; |
1998 | iface->restore_default_zoom_level = (gpointer)fm_directory_view_restore_default_zoom_level; |
1999 | iface->can_zoom_in = (gpointer)fm_directory_view_can_zoom_in; |
2000 | iface->can_zoom_out = (gpointer)fm_directory_view_can_zoom_out; |
2001 | iface->get_zoom_level = (gpointer)fm_directory_view_get_zoom_level; |
2002 | |
2003 | iface->pop_up_location_context_menu = (gpointer)fm_directory_view_pop_up_location_context_menu; |
2004 | iface->drop_proxy_received_uris = (gpointer)fm_directory_view_drop_proxy_received_uris; |
2005 | iface->drop_proxy_received_netscape_url = (gpointer)fm_directory_view_drop_proxy_received_netscape_url; |
2006 | } |
2007 | |
2008 | static void |
2009 | fm_directory_view_init (FMDirectoryView *view) |
2010 | { |
2011 | BaulDirectory *scripts_directory; |
2012 | |
2013 | view->details = g_new0 (FMDirectoryViewDetails, 1)((FMDirectoryViewDetails *) g_malloc0_n ((1), sizeof (FMDirectoryViewDetails ))); |
2014 | |
2015 | /* Default to true; desktop-icon-view sets to false */ |
2016 | view->details->show_foreign_files = TRUE(!(0)); |
2017 | |
2018 | view->details->non_ready_files = |
2019 | g_hash_table_new_full (file_and_directory_hash, |
2020 | file_and_directory_equal, |
2021 | (GDestroyNotify)file_and_directory_free, |
2022 | NULL((void*)0)); |
2023 | |
2024 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (view)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((view)), ((ctk_scrolled_window_get_type ()) ))))), |
2025 | CTK_POLICY_AUTOMATIC, |
2026 | CTK_POLICY_AUTOMATIC); |
2027 | ctk_scrolled_window_set_hadjustment (CTK_SCROLLED_WINDOW (view)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((view)), ((ctk_scrolled_window_get_type ()) ))))), NULL((void*)0)); |
2028 | ctk_scrolled_window_set_vadjustment (CTK_SCROLLED_WINDOW (view)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((view)), ((ctk_scrolled_window_get_type ()) ))))), NULL((void*)0)); |
2029 | ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (view)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((view)), ((ctk_scrolled_window_get_type ()) ))))), CTK_SHADOW_ETCHED_IN); |
2030 | ctk_scrolled_window_set_overlay_scrolling (CTK_SCROLLED_WINDOW (view)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((view)), ((ctk_scrolled_window_get_type ()) ))))), FALSE(0)); |
2031 | |
2032 | set_up_scripts_directory_global (); |
2033 | scripts_directory = baul_directory_get_by_uri (scripts_directory_uri); |
2034 | add_directory_to_scripts_directory_list (view, scripts_directory); |
2035 | baul_directory_unref (scripts_directory); |
2036 | |
2037 | if (baul_should_use_templates_directory ()) { |
2038 | BaulDirectory *templates_directory; |
2039 | char *templates_uri; |
2040 | |
2041 | templates_uri = baul_get_templates_directory_uri (); |
2042 | templates_directory = baul_directory_get_by_uri (templates_uri); |
2043 | g_free (templates_uri); |
2044 | add_directory_to_templates_directory_list (view, templates_directory); |
2045 | baul_directory_unref (templates_directory); |
2046 | } |
2047 | update_templates_directory (view); |
2048 | g_signal_connect_object (baul_signaller_get_current (), |
2049 | "user_dirs_changed", |
2050 | G_CALLBACK (user_dirs_changed)((GCallback) (user_dirs_changed)), |
2051 | view, G_CONNECT_SWAPPED); |
2052 | |
2053 | view->details->sort_directories_first = |
2054 | g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_SORT_DIRECTORIES_FIRST"sort-directories-first"); |
2055 | |
2056 | g_signal_connect_object (baul_trash_monitor_get (), "trash_state_changed", |
2057 | G_CALLBACK (fm_directory_view_trash_state_changed_callback)((GCallback) (fm_directory_view_trash_state_changed_callback) ), view, 0); |
2058 | |
2059 | /* React to clipboard changes */ |
2060 | g_signal_connect_object (baul_clipboard_monitor_get (), "clipboard_changed", |
2061 | G_CALLBACK (clipboard_changed_callback)((GCallback) (clipboard_changed_callback)), view, 0); |
2062 | |
2063 | /* Register to menu provider extension signal managing menu updates */ |
2064 | g_signal_connect_object (baul_signaller_get_current (), "popup_menu_changed", |
2065 | G_CALLBACK (fm_directory_view_update_menus)((GCallback) (fm_directory_view_update_menus)), view, G_CONNECT_SWAPPED); |
2066 | |
2067 | ctk_widget_show (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
2068 | |
2069 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "enable-delete" ), (((GCallback) (schedule_update_menus_callback))), (view), ( (void*)0), G_CONNECT_SWAPPED) |
2070 | "changed::" BAUL_PREFERENCES_ENABLE_DELETE,g_signal_connect_data ((baul_preferences), ("changed::" "enable-delete" ), (((GCallback) (schedule_update_menus_callback))), (view), ( (void*)0), G_CONNECT_SWAPPED) |
2071 | G_CALLBACK (schedule_update_menus_callback), view)g_signal_connect_data ((baul_preferences), ("changed::" "enable-delete" ), (((GCallback) (schedule_update_menus_callback))), (view), ( (void*)0), G_CONNECT_SWAPPED); |
2072 | g_signal_connect_swapped (baul_icon_view_preferences,g_signal_connect_data ((baul_icon_view_preferences), ("changed::" "captions"), (((GCallback) (text_attribute_names_changed_callback ))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2073 | "changed::" BAUL_PREFERENCES_ICON_VIEW_CAPTIONS,g_signal_connect_data ((baul_icon_view_preferences), ("changed::" "captions"), (((GCallback) (text_attribute_names_changed_callback ))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2074 | G_CALLBACK(text_attribute_names_changed_callback),g_signal_connect_data ((baul_icon_view_preferences), ("changed::" "captions"), (((GCallback) (text_attribute_names_changed_callback ))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2075 | view)g_signal_connect_data ((baul_icon_view_preferences), ("changed::" "captions"), (((GCallback) (text_attribute_names_changed_callback ))), (view), ((void*)0), G_CONNECT_SWAPPED); |
2076 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "show-image-thumbnails" ), (((GCallback) (image_display_policy_changed_callback))), ( view), ((void*)0), G_CONNECT_SWAPPED) |
2077 | "changed::" BAUL_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,g_signal_connect_data ((baul_preferences), ("changed::" "show-image-thumbnails" ), (((GCallback) (image_display_policy_changed_callback))), ( view), ((void*)0), G_CONNECT_SWAPPED) |
2078 | G_CALLBACK (image_display_policy_changed_callback),g_signal_connect_data ((baul_preferences), ("changed::" "show-image-thumbnails" ), (((GCallback) (image_display_policy_changed_callback))), ( view), ((void*)0), G_CONNECT_SWAPPED) |
2079 | view)g_signal_connect_data ((baul_preferences), ("changed::" "show-image-thumbnails" ), (((GCallback) (image_display_policy_changed_callback))), ( view), ((void*)0), G_CONNECT_SWAPPED); |
2080 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "click-policy" ), (((GCallback) (click_policy_changed_callback))), (view), ( (void*)0), G_CONNECT_SWAPPED) |
2081 | "changed::" BAUL_PREFERENCES_CLICK_POLICY,g_signal_connect_data ((baul_preferences), ("changed::" "click-policy" ), (((GCallback) (click_policy_changed_callback))), (view), ( (void*)0), G_CONNECT_SWAPPED) |
2082 | G_CALLBACK(click_policy_changed_callback),g_signal_connect_data ((baul_preferences), ("changed::" "click-policy" ), (((GCallback) (click_policy_changed_callback))), (view), ( (void*)0), G_CONNECT_SWAPPED) |
2083 | view)g_signal_connect_data ((baul_preferences), ("changed::" "click-policy" ), (((GCallback) (click_policy_changed_callback))), (view), ( (void*)0), G_CONNECT_SWAPPED); |
2084 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "sort-directories-first" ), (((GCallback) (sort_directories_first_changed_callback))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2085 | "changed::" BAUL_PREFERENCES_SORT_DIRECTORIES_FIRST,g_signal_connect_data ((baul_preferences), ("changed::" "sort-directories-first" ), (((GCallback) (sort_directories_first_changed_callback))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2086 | G_CALLBACK(sort_directories_first_changed_callback),g_signal_connect_data ((baul_preferences), ("changed::" "sort-directories-first" ), (((GCallback) (sort_directories_first_changed_callback))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2087 | view)g_signal_connect_data ((baul_preferences), ("changed::" "sort-directories-first" ), (((GCallback) (sort_directories_first_changed_callback))), (view), ((void*)0), G_CONNECT_SWAPPED); |
2088 | g_signal_connect_swapped (cafe_lockdown_preferences,g_signal_connect_data ((cafe_lockdown_preferences), ("changed::" "disable-command-line"), (((GCallback) (schedule_update_menus ))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2089 | "changed::" BAUL_PREFERENCES_LOCKDOWN_COMMAND_LINE,g_signal_connect_data ((cafe_lockdown_preferences), ("changed::" "disable-command-line"), (((GCallback) (schedule_update_menus ))), (view), ((void*)0), G_CONNECT_SWAPPED) |
2090 | G_CALLBACK (schedule_update_menus), view)g_signal_connect_data ((cafe_lockdown_preferences), ("changed::" "disable-command-line"), (((GCallback) (schedule_update_menus ))), (view), ((void*)0), G_CONNECT_SWAPPED); |
2091 | |
2092 | /* Update undo actions stuff and connect signals from the undostack manager */ |
2093 | view->details->undo_active = FALSE(0); |
2094 | view->details->redo_active = FALSE(0); |
2095 | view->details->undo_action_description = NULL((void*)0); |
2096 | view->details->undo_action_label = NULL((void*)0); |
2097 | view->details->redo_action_description = NULL((void*)0); |
2098 | view->details->redo_action_label = NULL((void*)0); |
2099 | |
2100 | BaulUndoStackManager* manager = baul_undostack_manager_instance (); |
2101 | |
2102 | g_signal_connect_object (G_OBJECT(manager)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((manager)), (((GType) ((20) << (2)))))))), "request-menu-update", |
2103 | G_CALLBACK(undo_redo_menu_update_callback)((GCallback) (undo_redo_menu_update_callback)), view, 0); |
2104 | |
2105 | baul_undostack_manager_request_menu_update (baul_undostack_manager_instance()); |
2106 | } |
2107 | |
2108 | static void |
2109 | real_unmerge_menus (FMDirectoryView *view) |
2110 | { |
2111 | CtkUIManager *ui_manager; |
2112 | |
2113 | if (view->details->window == NULL((void*)0)) { |
2114 | return; |
2115 | } |
2116 | |
2117 | ui_manager = baul_window_info_get_ui_manager (view->details->window); |
2118 | |
2119 | baul_ui_unmerge_ui (ui_manager, |
2120 | &view->details->dir_merge_id, |
2121 | &view->details->dir_action_group); |
2122 | baul_ui_unmerge_ui (ui_manager, |
2123 | &view->details->extensions_menu_merge_id, |
2124 | &view->details->extensions_menu_action_group); |
2125 | baul_ui_unmerge_ui (ui_manager, |
2126 | &view->details->open_with_merge_id, |
2127 | &view->details->open_with_action_group); |
2128 | baul_ui_unmerge_ui (ui_manager, |
2129 | &view->details->scripts_merge_id, |
2130 | &view->details->scripts_action_group); |
2131 | baul_ui_unmerge_ui (ui_manager, |
2132 | &view->details->templates_merge_id, |
2133 | &view->details->templates_action_group); |
2134 | } |
2135 | |
2136 | static void |
2137 | fm_directory_view_destroy (CtkWidget *object) |
2138 | { |
2139 | FMDirectoryView *view; |
2140 | GList *node, *next; |
2141 | |
2142 | view = FM_DIRECTORY_VIEW (object)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), (fm_directory_view_get_type()))))); |
2143 | |
2144 | disconnect_model_handlers (view); |
2145 | |
2146 | fm_directory_view_unmerge_menus (view); |
2147 | |
2148 | /* We don't own the window, so no unref */ |
2149 | view->details->slot = NULL((void*)0); |
2150 | view->details->window = NULL((void*)0); |
2151 | |
2152 | fm_directory_view_stop (view); |
2153 | fm_directory_view_clear (view); |
2154 | |
2155 | for (node = view->details->scripts_directory_list; node != NULL((void*)0); node = next) { |
2156 | next = node->next; |
2157 | remove_directory_from_scripts_directory_list (view, node->data); |
2158 | } |
2159 | |
2160 | for (node = view->details->templates_directory_list; node != NULL((void*)0); node = next) { |
2161 | next = node->next; |
2162 | remove_directory_from_templates_directory_list (view, node->data); |
2163 | } |
2164 | |
2165 | while (view->details->subdirectory_list != NULL((void*)0)) { |
2166 | fm_directory_view_remove_subdirectory (view, |
2167 | view->details->subdirectory_list->data); |
2168 | } |
2169 | |
2170 | remove_update_menus_timeout_callback (view); |
2171 | remove_update_status_idle_callback (view); |
2172 | |
2173 | if (view->details->display_selection_idle_id != 0) { |
2174 | g_source_remove (view->details->display_selection_idle_id); |
2175 | view->details->display_selection_idle_id = 0; |
2176 | } |
2177 | |
2178 | if (view->details->reveal_selection_idle_id != 0) { |
2179 | g_source_remove (view->details->reveal_selection_idle_id); |
2180 | view->details->reveal_selection_idle_id = 0; |
2181 | } |
2182 | |
2183 | if (view->details->delayed_rename_file_id != 0) { |
2184 | g_source_remove (view->details->delayed_rename_file_id); |
2185 | view->details->delayed_rename_file_id = 0; |
2186 | } |
2187 | |
2188 | if (view->details->model) { |
2189 | baul_directory_unref (view->details->model); |
2190 | view->details->model = NULL((void*)0); |
2191 | } |
2192 | |
2193 | if (view->details->directory_as_file) { |
2194 | baul_file_unref (view->details->directory_as_file); |
2195 | view->details->directory_as_file = NULL((void*)0); |
2196 | } |
2197 | |
2198 | EEL_CALL_PARENT (CTK_WIDGET_CLASS, destroy, (object))do { if (((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((parent_class)), ((ctk_widget_get_type ()))) )))->destroy != ((void*)0)) { (* ((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((parent_class)), ( (ctk_widget_get_type ()))))))->destroy) (object); } } while (0); |
2199 | } |
2200 | |
2201 | static void |
2202 | fm_directory_view_finalize (GObject *object) |
2203 | { |
2204 | FMDirectoryView *view; |
2205 | |
2206 | view = FM_DIRECTORY_VIEW (object)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), (fm_directory_view_get_type()))))); |
2207 | |
2208 | g_signal_handlers_disconnect_by_func (baul_preferences,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (schedule_update_menus_callback), (view)) |
2209 | schedule_update_menus_callback, view)g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (schedule_update_menus_callback), (view)); |
2210 | g_signal_handlers_disconnect_by_func (baul_icon_view_preferences,g_signal_handlers_disconnect_matched ((baul_icon_view_preferences ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (text_attribute_names_changed_callback), (view)) |
2211 | text_attribute_names_changed_callback, view)g_signal_handlers_disconnect_matched ((baul_icon_view_preferences ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (text_attribute_names_changed_callback), (view)); |
2212 | g_signal_handlers_disconnect_by_func (baul_preferences,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (image_display_policy_changed_callback), (view)) |
2213 | image_display_policy_changed_callback, view)g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (image_display_policy_changed_callback), (view)); |
2214 | g_signal_handlers_disconnect_by_func (baul_preferences,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (click_policy_changed_callback), (view)) |
2215 | click_policy_changed_callback, view)g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (click_policy_changed_callback), (view)); |
2216 | g_signal_handlers_disconnect_by_func (baul_preferences,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (sort_directories_first_changed_callback), (view)) |
2217 | sort_directories_first_changed_callback, view)g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (sort_directories_first_changed_callback), (view)); |
2218 | g_signal_handlers_disconnect_by_func (cafe_lockdown_preferences,g_signal_handlers_disconnect_matched ((cafe_lockdown_preferences ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (schedule_update_menus), (view)) |
2219 | schedule_update_menus, view)g_signal_handlers_disconnect_matched ((cafe_lockdown_preferences ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (schedule_update_menus), (view)); |
2220 | |
2221 | unschedule_pop_up_location_context_menu (view); |
2222 | if (view->details->location_popup_event != NULL((void*)0)) { |
2223 | cdk_event_free ((CdkEvent *) view->details->location_popup_event); |
2224 | } |
2225 | |
2226 | g_hash_table_destroy (view->details->non_ready_files); |
2227 | |
2228 | g_free (view->details); |
2229 | |
2230 | EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object))do { if (((((GObjectClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((parent_class)), (((GType) ((20) << (2)) ))))))->finalize != ((void*)0)) { (* ((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((parent_class)), ( ((GType) ((20) << (2))))))))->finalize) (object); } } while (0); |
2231 | } |
2232 | |
2233 | /** |
2234 | * fm_directory_view_display_selection_info: |
2235 | * |
2236 | * Display information about the current selection, and notify the view frame of the changed selection. |
2237 | * @view: FMDirectoryView for which to display selection info. |
2238 | * |
2239 | **/ |
2240 | void |
2241 | fm_directory_view_display_selection_info (FMDirectoryView *view) |
2242 | { |
2243 | GList *selection; |
2244 | goffset non_folder_size; |
2245 | gboolean non_folder_size_known; |
2246 | guint non_folder_count, folder_count, folder_item_count; |
2247 | gboolean folder_item_count_known; |
2248 | guint file_item_count; |
2249 | GList *p; |
2250 | char *first_item_name; |
2251 | char *non_folder_str; |
2252 | char *folder_count_str; |
2253 | char *folder_item_count_str; |
2254 | char *status_string; |
2255 | char *free_space_str; |
2256 | char *obj_selected_free_space_str; |
2257 | BaulFile *file = NULL((void*)0); |
2258 | |
2259 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
2260 | |
2261 | selection = fm_directory_view_get_selection (view); |
2262 | |
2263 | folder_item_count_known = TRUE(!(0)); |
2264 | folder_count = 0; |
2265 | folder_item_count = 0; |
2266 | non_folder_count = 0; |
2267 | non_folder_size_known = FALSE(0); |
2268 | non_folder_size = 0; |
2269 | first_item_name = NULL((void*)0); |
2270 | folder_count_str = NULL((void*)0); |
2271 | non_folder_str = NULL((void*)0); |
2272 | folder_item_count_str = NULL((void*)0); |
2273 | free_space_str = NULL((void*)0); |
2274 | obj_selected_free_space_str = NULL((void*)0); |
2275 | |
2276 | for (p = selection; p != NULL((void*)0); p = p->next) { |
2277 | file = p->data; |
2278 | if (baul_file_is_directory (file)) { |
2279 | folder_count++; |
2280 | if (baul_file_get_directory_item_count (file, &file_item_count, NULL((void*)0))) { |
2281 | folder_item_count += file_item_count; |
2282 | } else { |
2283 | folder_item_count_known = FALSE(0); |
2284 | } |
2285 | } else { |
2286 | non_folder_count++; |
2287 | if (!baul_file_can_get_size (file)) { |
2288 | non_folder_size_known = TRUE(!(0)); |
2289 | non_folder_size += baul_file_get_size (file); |
2290 | } |
2291 | } |
2292 | |
2293 | if (first_item_name == NULL((void*)0)) { |
2294 | first_item_name = baul_file_get_display_name (file); |
2295 | } |
2296 | } |
2297 | |
2298 | baul_file_list_free (selection); |
2299 | |
2300 | /* Break out cases for localization's sake. But note that there are still pieces |
2301 | * being assembled in a particular order, which may be a problem for some localizers. |
2302 | */ |
2303 | |
2304 | if (folder_count != 0) { |
2305 | if (folder_count == 1 && non_folder_count == 0) { |
2306 | folder_count_str = g_strdup_printf (_("\"%s\" selected")gettext ("\"%s\" selected"), first_item_name); |
2307 | } else { |
2308 | folder_count_str = g_strdup_printf (ngettext("%'d folder selected", |
2309 | "%'d folders selected", |
2310 | folder_count), |
2311 | folder_count); |
2312 | } |
2313 | |
2314 | if (folder_count == 1) { |
2315 | if (!folder_item_count_known) { |
2316 | folder_item_count_str = g_strdup ("")g_strdup_inline (""); |
2317 | } else { |
2318 | folder_item_count_str = g_strdup_printf (ngettext(" (containing %'d item)", |
2319 | " (containing %'d items)", |
2320 | folder_item_count), |
2321 | folder_item_count); |
2322 | } |
2323 | } |
2324 | else { |
2325 | if (!folder_item_count_known) { |
2326 | folder_item_count_str = g_strdup ("")g_strdup_inline (""); |
2327 | } else { |
2328 | /* Translators: this is preceded with a string of form 'N folders' (N more than 1) */ |
2329 | folder_item_count_str = g_strdup_printf (ngettext(" (containing a total of %'d item)", |
2330 | " (containing a total of %'d items)", |
2331 | folder_item_count), |
2332 | folder_item_count); |
2333 | } |
2334 | |
2335 | } |
2336 | } |
2337 | |
2338 | if (non_folder_count != 0) { |
2339 | char *items_string; |
2340 | |
2341 | if (folder_count == 0) { |
2342 | if (non_folder_count == 1) { |
2343 | items_string = g_strdup_printf (_("\"%s\" selected")gettext ("\"%s\" selected"), |
2344 | first_item_name); |
2345 | } else { |
2346 | items_string = g_strdup_printf (ngettext("%'d item selected", |
2347 | "%'d items selected", |
2348 | non_folder_count), |
2349 | non_folder_count); |
2350 | } |
2351 | } else { |
2352 | /* Folders selected also, use "other" terminology */ |
2353 | items_string = g_strdup_printf (ngettext("%'d other item selected", |
2354 | "%'d other items selected", |
2355 | non_folder_count), |
2356 | non_folder_count); |
2357 | } |
2358 | |
2359 | if (non_folder_size_known) { |
2360 | char *size_string; |
2361 | |
2362 | if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_USE_IEC_UNITS"use-iec-units")) |
2363 | size_string = g_format_size_full (non_folder_size, G_FORMAT_SIZE_IEC_UNITS); |
2364 | else |
2365 | size_string = g_format_size(non_folder_size); |
2366 | |
2367 | /* Translators: This is marked for translation in case a localiser |
2368 | * needs to use something other than parentheses. The |
2369 | * first message gives the number of items selected; |
2370 | * the message in parentheses the size of those items. |
2371 | */ |
2372 | non_folder_str = g_strdup_printf (_("%s (%s)")gettext ("%s (%s)"), |
2373 | items_string, |
2374 | size_string); |
2375 | |
2376 | g_free (size_string); |
2377 | g_free (items_string); |
2378 | } else { |
2379 | non_folder_str = items_string; |
2380 | } |
2381 | } |
2382 | |
2383 | free_space_str = baul_file_get_volume_free_space (view->details->directory_as_file); |
2384 | if (free_space_str != NULL((void*)0)) { |
2385 | obj_selected_free_space_str = g_strdup_printf (_("Free space: %s")gettext ("Free space: %s"), free_space_str); |
2386 | } |
2387 | if (folder_count == 0 && non_folder_count == 0) { |
2388 | char *item_count_str; |
2389 | guint item_count; |
2390 | |
2391 | item_count = fm_directory_view_get_item_count (view); |
2392 | |
2393 | item_count_str = g_strdup_printf (ngettext ("%'u item", "%'u items", item_count), item_count); |
2394 | |
2395 | if (free_space_str != NULL((void*)0)) { |
2396 | status_string = g_strdup_printf (_("%s, Free space: %s")gettext ("%s, Free space: %s"), item_count_str, free_space_str); |
2397 | g_free (item_count_str); |
2398 | } else { |
2399 | status_string = item_count_str; |
2400 | } |
2401 | |
2402 | } else if (folder_count == 0) { |
2403 | if (free_space_str == NULL((void*)0)) { |
2404 | status_string = g_strdup (non_folder_str)g_strdup_inline (non_folder_str); |
2405 | } else { |
2406 | /* Marking this for translation, since you |
2407 | * might want to change "," to something else. |
2408 | * After the comma the amount of free space will |
2409 | * be shown. |
2410 | */ |
2411 | status_string = g_strdup_printf (_("%s, %s")gettext ("%s, %s"), |
2412 | non_folder_str, |
2413 | obj_selected_free_space_str); |
2414 | } |
2415 | } else if (non_folder_count == 0) { |
2416 | if (free_space_str == NULL((void*)0)) { |
2417 | /* No use marking this for translation, since you |
2418 | * can't reorder the strings, which is the main thing |
2419 | * you'd want to do. |
2420 | */ |
2421 | status_string = g_strdup_printf ("%s%s", |
2422 | folder_count_str, |
2423 | folder_item_count_str); |
2424 | } else { |
2425 | /* Marking this for translation, since you |
2426 | * might want to change "," to something else. |
2427 | * After the comma the amount of free space will |
2428 | * be shown. |
2429 | */ |
2430 | status_string = g_strdup_printf (_("%s%s, %s")gettext ("%s%s, %s"), |
2431 | folder_count_str, |
2432 | folder_item_count_str, |
2433 | obj_selected_free_space_str); |
2434 | } |
2435 | } else { |
2436 | if (obj_selected_free_space_str == NULL((void*)0)) { |
2437 | /* This is marked for translation in case a localizer |
2438 | * needs to change ", " to something else. The comma |
2439 | * is between the message about the number of folders |
2440 | * and the number of items in those folders and the |
2441 | * message about the number of other items and the |
2442 | * total size of those items. |
2443 | */ |
2444 | status_string = g_strdup_printf (_("%s%s, %s")gettext ("%s%s, %s"), |
2445 | folder_count_str, |
2446 | folder_item_count_str, |
2447 | non_folder_str); |
2448 | } else { |
2449 | /* This is marked for translation in case a localizer |
2450 | * needs to change ", " to something else. The first comma |
2451 | * is between the message about the number of folders |
2452 | * and the number of items in those folders and the |
2453 | * message about the number of other items and the |
2454 | * total size of those items. After the second comma |
2455 | * the free space is written. |
2456 | */ |
2457 | status_string = g_strdup_printf (_("%s%s, %s, %s")gettext ("%s%s, %s, %s"), |
2458 | folder_count_str, |
2459 | folder_item_count_str, |
2460 | non_folder_str, |
2461 | obj_selected_free_space_str); |
2462 | } |
2463 | } |
2464 | |
2465 | g_free (free_space_str); |
2466 | g_free (obj_selected_free_space_str); |
2467 | g_free (first_item_name); |
2468 | g_free (folder_count_str); |
2469 | g_free (folder_item_count_str); |
2470 | g_free (non_folder_str); |
2471 | |
2472 | baul_window_slot_info_set_status (view->details->slot, |
2473 | status_string); |
2474 | g_free (status_string); |
2475 | } |
2476 | |
2477 | void |
2478 | fm_directory_view_send_selection_change (FMDirectoryView *view) |
2479 | { |
2480 | baul_window_info_report_selection_changed (view->details->window); |
2481 | |
2482 | view->details->send_selection_change_to_shell = FALSE(0); |
2483 | } |
2484 | |
2485 | gboolean |
2486 | fm_directory_view_get_allow_moves (FMDirectoryView *view) |
2487 | { |
2488 | return view->details->allow_moves; |
2489 | } |
2490 | |
2491 | static void |
2492 | fm_directory_view_load_location (BaulView *baul_view, |
2493 | const char *location) |
2494 | { |
2495 | BaulDirectory *directory; |
2496 | FMDirectoryView *directory_view; |
2497 | |
2498 | directory_view = FM_DIRECTORY_VIEW (baul_view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baul_view)), (fm_directory_view_get_type()))))); |
2499 | |
2500 | if (eel_uri_is_search (location)) { |
2501 | directory_view->details->allow_moves = FALSE(0); |
2502 | } else { |
2503 | directory_view->details->allow_moves = TRUE(!(0)); |
2504 | } |
2505 | |
2506 | directory = baul_directory_get_by_uri (location); |
2507 | load_directory (directory_view, directory); |
2508 | baul_directory_unref (directory); |
2509 | } |
2510 | |
2511 | static void |
2512 | fm_directory_view_stop_loading (BaulView *baul_view) |
2513 | { |
2514 | fm_directory_view_stop (FM_DIRECTORY_VIEW (baul_view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baul_view)), (fm_directory_view_get_type())))))); |
2515 | } |
2516 | |
2517 | static gboolean |
2518 | reveal_selection_idle_callback (gpointer data) |
2519 | { |
2520 | FMDirectoryView *view; |
2521 | |
2522 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
2523 | |
2524 | view->details->reveal_selection_idle_id = 0; |
2525 | fm_directory_view_reveal_selection (view); |
2526 | |
2527 | return FALSE(0); |
2528 | } |
2529 | |
2530 | static void |
2531 | done_loading (FMDirectoryView *view, |
2532 | gboolean all_files_seen) |
2533 | { |
2534 | if (!view->details->loading) { |
2535 | return; |
2536 | } |
2537 | |
2538 | /* This can be called during destruction, in which case there |
2539 | * is no BaulWindowInfo any more. |
2540 | */ |
2541 | if (view->details->window != NULL((void*)0)) { |
2542 | GList *locations_selected; |
2543 | |
2544 | if (all_files_seen) { |
2545 | baul_window_info_report_load_complete (view->details->window, BAUL_VIEW (view)((((BaulView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((baul_view_get_type ()))))))); |
2546 | } |
2547 | |
2548 | schedule_update_menus (view); |
2549 | schedule_update_status (view); |
2550 | reset_update_interval (view); |
2551 | |
2552 | locations_selected = view->details->pending_locations_selected; |
2553 | |
2554 | if (locations_selected != NULL((void*)0) && all_files_seen) { |
2555 | GList *selection; |
2556 | |
2557 | view->details->pending_locations_selected = NULL((void*)0); |
2558 | |
2559 | selection = file_list_from_location_list (locations_selected); |
2560 | |
2561 | view->details->selection_change_is_due_to_shell = TRUE(!(0)); |
2562 | fm_directory_view_set_selection (view, selection); |
2563 | view->details->selection_change_is_due_to_shell = FALSE(0); |
2564 | baul_file_list_free (selection); |
2565 | |
2566 | if (FM_IS_LIST_VIEW (view)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (view)); GType __t = (fm_list_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
2567 | /* HACK: We should be able to directly call reveal_selection here, |
2568 | * but at this point the CtkTreeView hasn't allocated the new nodes |
2569 | * yet, and it has a bug in the scroll calculation dealing with this |
2570 | * special case. It would always make the selection the top row, even |
2571 | * if no scrolling would be neccessary to reveal it. So we let it |
2572 | * allocate before revealing. |
2573 | */ |
2574 | if (view->details->reveal_selection_idle_id != 0) { |
2575 | g_source_remove (view->details->reveal_selection_idle_id); |
2576 | } |
2577 | view->details->reveal_selection_idle_id = |
2578 | g_idle_add (reveal_selection_idle_callback, view); |
2579 | } else { |
2580 | fm_directory_view_reveal_selection (view); |
2581 | } |
2582 | } |
2583 | g_list_free_full (locations_selected, g_object_unref); |
2584 | fm_directory_view_display_selection_info (view); |
2585 | } |
2586 | |
2587 | fm_directory_view_end_loading (view, all_files_seen); |
2588 | |
2589 | view->details->loading = FALSE(0); |
2590 | } |
2591 | |
2592 | |
2593 | typedef struct { |
2594 | GHashTable *debuting_files; |
2595 | GList *added_files; |
2596 | } DebutingFilesData; |
2597 | |
2598 | static void |
2599 | debuting_files_data_free (DebutingFilesData *data) |
2600 | { |
2601 | g_hash_table_unref (data->debuting_files); |
2602 | baul_file_list_free (data->added_files); |
2603 | g_free (data); |
2604 | } |
2605 | |
2606 | /* This signal handler watch for the arrival of the icons created |
2607 | * as the result of a file operation. Once the last one is detected |
2608 | * it selects and reveals them all. |
2609 | */ |
2610 | static void |
2611 | debuting_files_add_file_callback (FMDirectoryView *view, |
2612 | BaulFile *new_file, |
2613 | BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
2614 | DebutingFilesData *data) |
2615 | { |
2616 | GFile *location; |
2617 | |
2618 | location = baul_file_get_location (new_file); |
2619 | |
2620 | if (g_hash_table_remove (data->debuting_files, location)) { |
2621 | baul_file_ref (new_file); |
2622 | data->added_files = g_list_prepend (data->added_files, new_file); |
2623 | |
2624 | if (g_hash_table_size (data->debuting_files) == 0) { |
2625 | fm_directory_view_set_selection (view, data->added_files); |
2626 | fm_directory_view_reveal_selection (view); |
2627 | g_signal_handlers_disconnect_by_func (view,g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (debuting_files_add_file_callback))), (data )) |
2628 | G_CALLBACK (debuting_files_add_file_callback),g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (debuting_files_add_file_callback))), (data )) |
2629 | data)g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (debuting_files_add_file_callback))), (data )); |
2630 | } |
2631 | } |
2632 | |
2633 | g_object_unref (location); |
2634 | } |
2635 | |
2636 | typedef struct { |
2637 | GList *added_files; |
2638 | FMDirectoryView *directory_view; |
2639 | } CopyMoveDoneData; |
2640 | |
2641 | static void |
2642 | copy_move_done_data_free (CopyMoveDoneData *data) |
2643 | { |
2644 | g_assert (data != NULL)do { if (data != ((void*)0)) ; else g_assertion_message_expr ( ((gchar*) 0), "fm-directory-view.c", 2644, ((const char*) (__func__ )), "data != NULL"); } while (0); |
2645 | |
2646 | eel_remove_weak_pointer (&data->directory_view); |
2647 | baul_file_list_free (data->added_files); |
2648 | g_free (data); |
2649 | } |
2650 | |
2651 | static void |
2652 | pre_copy_move_add_file_callback (FMDirectoryView *view G_GNUC_UNUSED__attribute__ ((__unused__)), |
2653 | BaulFile *new_file, |
2654 | BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
2655 | CopyMoveDoneData *data) |
2656 | { |
2657 | baul_file_ref (new_file); |
2658 | data->added_files = g_list_prepend (data->added_files, new_file); |
2659 | } |
2660 | |
2661 | /* This needs to be called prior to baul_file_operations_copy_move. |
2662 | * It hooks up a signal handler to catch any icons that get added before |
2663 | * the copy_done_callback is invoked. The return value should be passed |
2664 | * as the data for uri_copy_move_done_callback. |
2665 | */ |
2666 | static CopyMoveDoneData * |
2667 | pre_copy_move (FMDirectoryView *directory_view) |
2668 | { |
2669 | CopyMoveDoneData *copy_move_done_data; |
2670 | |
2671 | copy_move_done_data = g_new0 (CopyMoveDoneData, 1)((CopyMoveDoneData *) g_malloc0_n ((1), sizeof (CopyMoveDoneData ))); |
2672 | copy_move_done_data->directory_view = directory_view; |
2673 | |
2674 | eel_add_weak_pointer (©_move_done_data->directory_view); |
2675 | |
2676 | /* We need to run after the default handler adds the folder we want to |
2677 | * operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we |
2678 | * must use connect_after. |
2679 | */ |
2680 | g_signal_connect (directory_view, "add_file",g_signal_connect_data ((directory_view), ("add_file"), (((GCallback ) (pre_copy_move_add_file_callback))), (copy_move_done_data), ((void*)0), (GConnectFlags) 0) |
2681 | G_CALLBACK (pre_copy_move_add_file_callback), copy_move_done_data)g_signal_connect_data ((directory_view), ("add_file"), (((GCallback ) (pre_copy_move_add_file_callback))), (copy_move_done_data), ((void*)0), (GConnectFlags) 0); |
2682 | |
2683 | return copy_move_done_data; |
2684 | } |
2685 | |
2686 | /* This function is used to pull out any debuting uris that were added |
2687 | * and (as a side effect) remove them from the debuting uri hash table. |
2688 | */ |
2689 | static gboolean |
2690 | copy_move_done_partition_func (gpointer data, gpointer callback_data) |
2691 | { |
2692 | GFile *location; |
2693 | gboolean result; |
2694 | |
2695 | location = baul_file_get_location (BAUL_FILE (data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (baul_file_get_type())))))); |
2696 | result = g_hash_table_remove ((GHashTable *) callback_data, location); |
2697 | g_object_unref (location); |
2698 | |
2699 | return result; |
2700 | } |
2701 | |
2702 | static gboolean |
2703 | remove_not_really_moved_files (gpointer key, |
2704 | gpointer value, |
2705 | gpointer callback_data) |
2706 | { |
2707 | GList **added_files; |
2708 | GFile *loc; |
2709 | |
2710 | loc = key; |
2711 | |
2712 | if (GPOINTER_TO_INT (value)((gint) (glong) (value))) { |
2713 | return FALSE(0); |
2714 | } |
2715 | |
2716 | added_files = callback_data; |
2717 | *added_files = g_list_prepend (*added_files, |
2718 | baul_file_get (loc)); |
2719 | return TRUE(!(0)); |
2720 | } |
2721 | |
2722 | |
2723 | /* When this function is invoked, the file operation is over, but all |
2724 | * the icons may not have been added to the directory view yet, so |
2725 | * we can't select them yet. |
2726 | * |
2727 | * We're passed a hash table of the uri's to look out for, we hook |
2728 | * up a signal handler to await their arrival. |
2729 | */ |
2730 | static void |
2731 | copy_move_done_callback (GHashTable *debuting_files, gpointer data) |
2732 | { |
2733 | FMDirectoryView *directory_view; |
2734 | CopyMoveDoneData *copy_move_done_data; |
2735 | DebutingFilesData *debuting_files_data; |
2736 | |
2737 | copy_move_done_data = (CopyMoveDoneData *) data; |
2738 | directory_view = copy_move_done_data->directory_view; |
2739 | |
2740 | if (directory_view != NULL((void*)0)) { |
2741 | g_assert (FM_IS_DIRECTORY_VIEW (directory_view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((directory_view)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 2741, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (directory_view)" ); } while (0); |
2742 | |
2743 | debuting_files_data = g_new (DebutingFilesData, 1)((DebutingFilesData *) g_malloc_n ((1), sizeof (DebutingFilesData ))); |
2744 | debuting_files_data->debuting_files = g_hash_table_ref (debuting_files); |
2745 | debuting_files_data->added_files = eel_g_list_partition |
2746 | (copy_move_done_data->added_files, |
2747 | copy_move_done_partition_func, |
2748 | debuting_files, |
2749 | ©_move_done_data->added_files); |
2750 | |
2751 | /* We're passed the same data used by pre_copy_move_add_file_callback, so disconnecting |
2752 | * it will free data. We've already siphoned off the added_files we need, and stashed the |
2753 | * directory_view pointer. |
2754 | */ |
2755 | g_signal_handlers_disconnect_by_func (directory_view,g_signal_handlers_disconnect_matched ((directory_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (pre_copy_move_add_file_callback))), (data) ) |
2756 | G_CALLBACK (pre_copy_move_add_file_callback),g_signal_handlers_disconnect_matched ((directory_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (pre_copy_move_add_file_callback))), (data) ) |
2757 | data)g_signal_handlers_disconnect_matched ((directory_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (pre_copy_move_add_file_callback))), (data) ); |
2758 | |
2759 | /* Any items in the debuting_files hash table that have |
2760 | * "FALSE" as their value aren't really being copied |
2761 | * or moved, so we can't wait for an add_file signal |
2762 | * to come in for those. |
2763 | */ |
2764 | g_hash_table_foreach_remove (debuting_files, |
2765 | remove_not_really_moved_files, |
2766 | &debuting_files_data->added_files); |
2767 | |
2768 | if (g_hash_table_size (debuting_files) == 0) { |
2769 | /* on the off-chance that all the icons have already been added */ |
2770 | if (debuting_files_data->added_files != NULL((void*)0)) { |
2771 | fm_directory_view_set_selection (directory_view, |
2772 | debuting_files_data->added_files); |
2773 | fm_directory_view_reveal_selection (directory_view); |
2774 | } |
2775 | debuting_files_data_free (debuting_files_data); |
2776 | } else { |
2777 | /* We need to run after the default handler adds the folder we want to |
2778 | * operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we |
2779 | * must use connect_after. |
2780 | */ |
2781 | g_signal_connect_data (directory_view, |
2782 | "add_file", |
2783 | G_CALLBACK (debuting_files_add_file_callback)((GCallback) (debuting_files_add_file_callback)), |
2784 | debuting_files_data, |
2785 | (GClosureNotify) debuting_files_data_free, |
2786 | G_CONNECT_AFTER); |
2787 | } |
2788 | |
2789 | /* Schedule menu update for undo items */ |
2790 | schedule_update_menus (directory_view); |
2791 | |
2792 | } |
2793 | |
2794 | copy_move_done_data_free (copy_move_done_data); |
2795 | } |
2796 | |
2797 | static gboolean |
2798 | real_file_still_belongs (FMDirectoryView *view, BaulFile *file, BaulDirectory *directory) |
2799 | { |
2800 | if (view->details->model != directory && |
2801 | g_list_find (view->details->subdirectory_list, directory) == NULL((void*)0)) { |
2802 | return FALSE(0); |
2803 | } |
2804 | |
2805 | return baul_directory_contains_file (directory, file); |
2806 | } |
2807 | |
2808 | static gboolean |
2809 | still_should_show_file (FMDirectoryView *view, BaulFile *file, BaulDirectory *directory) |
2810 | { |
2811 | return fm_directory_view_should_show_file (view, file) |
2812 | && EEL_INVOKE_METHOD (FM_DIRECTORY_VIEW_CLASS, view, file_still_belongs, (view, file, directory))((* (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> file_still_belongs)) (view, file, directory)); |
2813 | } |
2814 | |
2815 | static gboolean |
2816 | ready_to_load (BaulFile *file) |
2817 | { |
2818 | return baul_file_check_if_ready (file, |
2819 | BAUL_FILE_ATTRIBUTES_FOR_ICON(BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_LINK_INFO | BAUL_FILE_ATTRIBUTE_THUMBNAIL )); |
2820 | } |
2821 | |
2822 | static int |
2823 | compare_files_cover (gconstpointer a, gconstpointer b, gpointer callback_data) |
2824 | { |
2825 | const FileAndDirectory *fad1, *fad2; |
2826 | FMDirectoryView *view; |
2827 | |
2828 | view = callback_data; |
2829 | fad1 = a; fad2 = b; |
2830 | |
2831 | if (fad1->directory < fad2->directory) { |
2832 | return -1; |
2833 | } else if (fad1->directory > fad2->directory) { |
2834 | return 1; |
2835 | } else { |
2836 | return EEL_INVOKE_METHOD (FM_DIRECTORY_VIEW_CLASS, view, compare_files,((* (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> compare_files)) (view, fad1->file, fad2->file)) |
2837 | (view, fad1->file, fad2->file))((* (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> compare_files)) (view, fad1->file, fad2->file)); |
2838 | } |
2839 | } |
2840 | static void |
2841 | sort_files (FMDirectoryView *view, GList **list) |
2842 | { |
2843 | *list = g_list_sort_with_data (*list, compare_files_cover, view); |
2844 | |
2845 | } |
2846 | |
2847 | /* Go through all the new added and changed files. |
2848 | * Put any that are not ready to load in the non_ready_files hash table. |
2849 | * Add all the rest to the old_added_files and old_changed_files lists. |
2850 | * Sort the old_*_files lists if anything was added to them. |
2851 | */ |
2852 | static void |
2853 | process_new_files (FMDirectoryView *view) |
2854 | { |
2855 | GList *new_added_files, *new_changed_files, *old_added_files, *old_changed_files; |
2856 | GHashTable *non_ready_files; |
2857 | GList *node, *next; |
2858 | FileAndDirectory *pending; |
2859 | gboolean in_non_ready; |
2860 | |
2861 | new_added_files = view->details->new_added_files; |
2862 | view->details->new_added_files = NULL((void*)0); |
2863 | new_changed_files = view->details->new_changed_files; |
2864 | view->details->new_changed_files = NULL((void*)0); |
2865 | |
2866 | non_ready_files = view->details->non_ready_files; |
2867 | |
2868 | old_added_files = view->details->old_added_files; |
2869 | old_changed_files = view->details->old_changed_files; |
2870 | |
2871 | /* Newly added files go into the old_added_files list if they're |
2872 | * ready, and into the hash table if they're not. |
2873 | */ |
2874 | for (node = new_added_files; node != NULL((void*)0); node = next) { |
2875 | next = node->next; |
2876 | pending = (FileAndDirectory *)node->data; |
2877 | in_non_ready = g_hash_table_lookup (non_ready_files, pending) != NULL((void*)0); |
2878 | if (fm_directory_view_should_show_file (view, pending->file)) { |
2879 | if (ready_to_load (pending->file)) { |
2880 | if (in_non_ready) { |
2881 | g_hash_table_remove (non_ready_files, pending); |
2882 | } |
2883 | new_added_files = g_list_delete_link (new_added_files, node); |
2884 | old_added_files = g_list_prepend (old_added_files, pending); |
2885 | } else { |
2886 | if (!in_non_ready) { |
2887 | new_added_files = g_list_delete_link (new_added_files, node); |
2888 | g_hash_table_insert (non_ready_files, pending, pending); |
2889 | } |
2890 | } |
2891 | } |
2892 | } |
2893 | file_and_directory_list_free (new_added_files); |
2894 | |
2895 | /* Newly changed files go into the old_added_files list if they're ready |
2896 | * and were seen non-ready in the past, into the old_changed_files list |
2897 | * if they are read and were not seen non-ready in the past, and into |
2898 | * the hash table if they're not ready. |
2899 | */ |
2900 | for (node = new_changed_files; node != NULL((void*)0); node = next) { |
2901 | next = node->next; |
2902 | pending = (FileAndDirectory *)node->data; |
2903 | if (!still_should_show_file (view, pending->file, pending->directory) || ready_to_load (pending->file)) { |
2904 | if (g_hash_table_lookup (non_ready_files, pending) != NULL((void*)0)) { |
2905 | g_hash_table_remove (non_ready_files, pending); |
2906 | if (still_should_show_file (view, pending->file, pending->directory)) { |
2907 | new_changed_files = g_list_delete_link (new_changed_files, node); |
2908 | old_added_files = g_list_prepend (old_added_files, pending); |
2909 | } |
2910 | } else if (fm_directory_view_should_show_file (view, pending->file)) { |
2911 | new_changed_files = g_list_delete_link (new_changed_files, node); |
2912 | old_changed_files = g_list_prepend (old_changed_files, pending); |
2913 | } |
2914 | } |
2915 | } |
2916 | file_and_directory_list_free (new_changed_files); |
2917 | |
2918 | /* If any files were added to old_added_files, then resort it. */ |
2919 | if (old_added_files != view->details->old_added_files) { |
2920 | view->details->old_added_files = old_added_files; |
2921 | sort_files (view, &view->details->old_added_files); |
2922 | } |
2923 | |
2924 | /* Resort old_changed_files too, since file attributes |
2925 | * relevant to sorting could have changed. |
2926 | */ |
2927 | if (old_changed_files != view->details->old_changed_files) { |
2928 | view->details->old_changed_files = old_changed_files; |
2929 | sort_files (view, &view->details->old_changed_files); |
2930 | } |
2931 | |
2932 | } |
2933 | |
2934 | static void |
2935 | process_old_files (FMDirectoryView *view) |
2936 | { |
2937 | GList *files_added, *files_changed, *node; |
2938 | GList *selection, *files; |
2939 | gboolean send_selection_change; |
2940 | |
2941 | files_added = view->details->old_added_files; |
2942 | files_changed = view->details->old_changed_files; |
2943 | |
2944 | send_selection_change = FALSE(0); |
2945 | |
2946 | if (files_added != NULL((void*)0) || files_changed != NULL((void*)0)) { |
2947 | FileAndDirectory *pending = NULL((void*)0); |
2948 | |
2949 | g_signal_emit (view, signals[BEGIN_FILE_CHANGES], 0); |
2950 | |
2951 | for (node = files_added; node != NULL((void*)0); node = node->next) { |
2952 | pending = node->data; |
2953 | g_signal_emit (view, |
2954 | signals[ADD_FILE], 0, pending->file, pending->directory); |
2955 | } |
2956 | |
2957 | for (node = files_changed; node != NULL((void*)0); node = node->next) { |
2958 | pending = node->data; |
2959 | g_signal_emit (view, |
2960 | signals[still_should_show_file (view, pending->file, pending->directory) |
2961 | ? FILE_CHANGED : REMOVE_FILE], 0, |
2962 | pending->file, pending->directory); |
2963 | } |
2964 | |
2965 | g_signal_emit (view, signals[END_FILE_CHANGES], 0); |
2966 | |
2967 | if (files_changed != NULL((void*)0)) { |
2968 | selection = fm_directory_view_get_selection (view); |
2969 | files = file_and_directory_list_to_files (files_changed); |
2970 | send_selection_change = eel_g_lists_sort_and_check_for_intersection |
2971 | (&files, &selection); |
2972 | baul_file_list_free (files); |
2973 | baul_file_list_free (selection); |
2974 | } |
2975 | |
2976 | file_and_directory_list_free (view->details->old_added_files); |
2977 | view->details->old_added_files = NULL((void*)0); |
2978 | |
2979 | file_and_directory_list_free (view->details->old_changed_files); |
2980 | view->details->old_changed_files = NULL((void*)0); |
2981 | } |
2982 | |
2983 | if (send_selection_change) { |
2984 | /* Send a selection change since some file names could |
2985 | * have changed. |
2986 | */ |
2987 | fm_directory_view_send_selection_change (view); |
2988 | } |
2989 | } |
2990 | |
2991 | static void |
2992 | display_pending_files (FMDirectoryView *view) |
2993 | { |
2994 | |
2995 | /* Don't dispatch any updates while the view is frozen. */ |
2996 | if (view->details->updates_frozen) { |
2997 | return; |
2998 | } |
2999 | |
3000 | process_new_files (view); |
3001 | process_old_files (view); |
3002 | |
3003 | if (view->details->model != NULL((void*)0) |
3004 | && baul_directory_are_all_files_seen (view->details->model) |
3005 | && g_hash_table_size (view->details->non_ready_files) == 0) { |
3006 | done_loading (view, TRUE(!(0))); |
3007 | } |
3008 | } |
3009 | |
3010 | void |
3011 | fm_directory_view_freeze_updates (FMDirectoryView *view) |
3012 | { |
3013 | view->details->updates_frozen = TRUE(!(0)); |
3014 | view->details->updates_queued = 0; |
3015 | view->details->needs_reload = FALSE(0); |
3016 | } |
3017 | |
3018 | void |
3019 | fm_directory_view_unfreeze_updates (FMDirectoryView *view) |
3020 | { |
3021 | view->details->updates_frozen = FALSE(0); |
3022 | |
3023 | if (view->details->needs_reload) { |
3024 | view->details->needs_reload = FALSE(0); |
3025 | if (view->details->model != NULL((void*)0)) { |
3026 | load_directory (view, view->details->model); |
3027 | } |
3028 | } else { |
3029 | schedule_idle_display_of_pending_files (view); |
3030 | } |
3031 | } |
3032 | |
3033 | static gboolean |
3034 | display_selection_info_idle_callback (gpointer data) |
3035 | { |
3036 | FMDirectoryView *view; |
3037 | |
3038 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
3039 | |
3040 | g_object_ref (G_OBJECT (view))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))); |
3041 | |
3042 | view->details->display_selection_idle_id = 0; |
3043 | fm_directory_view_display_selection_info (view); |
3044 | if (view->details->send_selection_change_to_shell) { |
3045 | fm_directory_view_send_selection_change (view); |
3046 | } |
3047 | |
3048 | g_object_unref (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2))))))))); |
3049 | |
3050 | return FALSE(0); |
3051 | } |
3052 | |
3053 | static void |
3054 | remove_update_menus_timeout_callback (FMDirectoryView *view) |
3055 | { |
3056 | if (view->details->update_menus_timeout_id != 0) { |
3057 | g_source_remove (view->details->update_menus_timeout_id); |
3058 | view->details->update_menus_timeout_id = 0; |
3059 | } |
3060 | } |
3061 | |
3062 | static void |
3063 | update_menus_if_pending (FMDirectoryView *view) |
3064 | { |
3065 | if (!view->details->menu_states_untrustworthy) { |
3066 | return; |
3067 | } |
3068 | |
3069 | remove_update_menus_timeout_callback (view); |
3070 | fm_directory_view_update_menus (view); |
3071 | } |
3072 | |
3073 | static gboolean |
3074 | update_menus_timeout_callback (gpointer data) |
3075 | { |
3076 | FMDirectoryView *view; |
3077 | |
3078 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
3079 | |
3080 | g_object_ref (G_OBJECT (view))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))); |
3081 | |
3082 | view->details->update_menus_timeout_id = 0; |
3083 | fm_directory_view_update_menus (view); |
3084 | |
3085 | g_object_unref (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2))))))))); |
3086 | |
3087 | return FALSE(0); |
3088 | } |
3089 | |
3090 | static gboolean |
3091 | display_pending_callback (gpointer data) |
3092 | { |
3093 | FMDirectoryView *view; |
3094 | |
3095 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
3096 | |
3097 | g_object_ref (G_OBJECT (view))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))); |
3098 | |
3099 | view->details->display_pending_source_id = 0; |
3100 | |
3101 | display_pending_files (view); |
3102 | |
3103 | g_object_unref (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2))))))))); |
3104 | |
3105 | return FALSE(0); |
3106 | } |
3107 | |
3108 | static void |
3109 | schedule_idle_display_of_pending_files (FMDirectoryView *view) |
3110 | { |
3111 | /* Get rid of a pending source as it might be a timeout */ |
3112 | unschedule_display_of_pending_files (view); |
3113 | |
3114 | /* We want higher priority than the idle that handles the relayout |
3115 | to avoid a resort on each add. But we still want to allow repaints |
3116 | and other hight prio events while we have pending files to show. */ |
3117 | view->details->display_pending_source_id = |
3118 | g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200 - 20, |
3119 | display_pending_callback, view, NULL((void*)0)); |
3120 | } |
3121 | |
3122 | static void |
3123 | schedule_timeout_display_of_pending_files (FMDirectoryView *view, guint interval) |
3124 | { |
3125 | /* No need to schedule an update if there's already one pending. */ |
3126 | if (view->details->display_pending_source_id != 0) { |
3127 | return; |
3128 | } |
3129 | |
3130 | view->details->display_pending_source_id = |
3131 | g_timeout_add (interval, display_pending_callback, view); |
3132 | } |
3133 | |
3134 | static void |
3135 | unschedule_display_of_pending_files (FMDirectoryView *view) |
3136 | { |
3137 | /* Get rid of source if it's active. */ |
3138 | if (view->details->display_pending_source_id != 0) { |
3139 | g_source_remove (view->details->display_pending_source_id); |
3140 | view->details->display_pending_source_id = 0; |
3141 | } |
3142 | } |
3143 | |
3144 | static void |
3145 | queue_pending_files (FMDirectoryView *view, |
3146 | BaulDirectory *directory, |
3147 | GList *files, |
3148 | GList **pending_list) |
3149 | { |
3150 | if (files == NULL((void*)0)) { |
3151 | return; |
3152 | } |
3153 | |
3154 | /* Don't queue any more updates if we need to reload anyway */ |
3155 | if (view->details->needs_reload) { |
3156 | return; |
3157 | } |
3158 | |
3159 | if (view->details->updates_frozen) { |
3160 | view->details->updates_queued += g_list_length (files); |
3161 | /* Mark the directory for reload when there are too much queued |
3162 | * changes to prevent the pending list from growing infinitely. |
3163 | */ |
3164 | if (view->details->updates_queued > MAX_QUEUED_UPDATES500) { |
3165 | view->details->needs_reload = TRUE(!(0)); |
3166 | return; |
3167 | } |
3168 | } |
3169 | |
3170 | |
3171 | |
3172 | *pending_list = g_list_concat (file_and_directory_list_from_files (directory, files), |
3173 | *pending_list); |
3174 | |
3175 | if (! view->details->loading || baul_directory_are_all_files_seen (directory)) { |
3176 | schedule_timeout_display_of_pending_files (view, view->details->update_interval); |
3177 | } |
3178 | } |
3179 | |
3180 | static void |
3181 | remove_changes_timeout_callback (FMDirectoryView *view) |
3182 | { |
3183 | if (view->details->changes_timeout_id != 0) { |
3184 | g_source_remove (view->details->changes_timeout_id); |
3185 | view->details->changes_timeout_id = 0; |
3186 | } |
3187 | } |
3188 | |
3189 | static void |
3190 | reset_update_interval (FMDirectoryView *view) |
3191 | { |
3192 | view->details->update_interval = UPDATE_INTERVAL_MIN100; |
3193 | remove_changes_timeout_callback (view); |
3194 | /* Reschedule a pending timeout to idle */ |
3195 | if (view->details->display_pending_source_id != 0) { |
3196 | schedule_idle_display_of_pending_files (view); |
3197 | } |
3198 | } |
3199 | |
3200 | static gboolean |
3201 | changes_timeout_callback (gpointer data) |
3202 | { |
3203 | gint64 now; |
3204 | gint64 time_delta; |
3205 | gboolean ret; |
3206 | FMDirectoryView *view; |
3207 | |
3208 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
3209 | |
3210 | g_object_ref (G_OBJECT (view))((__typeof__ (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))) (g_object_ref) (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view)), (((GType) ((20) << (2))))) ))))); |
3211 | |
3212 | now = g_get_monotonic_time(); |
3213 | time_delta = now - view->details->last_queued; |
3214 | |
3215 | if (time_delta < UPDATE_INTERVAL_RESET1000*1000) { |
3216 | if (view->details->update_interval < UPDATE_INTERVAL_MAX2000 && |
3217 | view->details->loading) { |
3218 | /* Increase */ |
3219 | view->details->update_interval += UPDATE_INTERVAL_INC250; |
3220 | } |
3221 | ret = TRUE(!(0)); |
3222 | } else { |
3223 | /* Reset */ |
3224 | reset_update_interval (view); |
3225 | ret = FALSE(0); |
3226 | } |
3227 | |
3228 | g_object_unref (G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2))))))))); |
3229 | |
3230 | return ret; |
3231 | } |
3232 | |
3233 | static void |
3234 | schedule_changes (FMDirectoryView *view) |
3235 | { |
3236 | /* Remember when the change was queued */ |
3237 | view->details->last_queued = g_get_monotonic_time(); |
3238 | |
3239 | /* No need to schedule if there are already changes pending or during loading */ |
3240 | if (view->details->changes_timeout_id != 0 || |
3241 | view->details->loading) { |
3242 | return; |
3243 | } |
3244 | |
3245 | view->details->changes_timeout_id = |
3246 | g_timeout_add (UPDATE_INTERVAL_TIMEOUT_INTERVAL250, changes_timeout_callback, view); |
3247 | } |
3248 | |
3249 | static void |
3250 | action_undo_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
3251 | gpointer callback_data) |
3252 | { |
3253 | real_action_undo (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type())))))); |
3254 | } |
3255 | |
3256 | static void |
3257 | action_redo_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
3258 | gpointer callback_data) |
3259 | { |
3260 | real_action_redo (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type())))))); |
3261 | } |
3262 | |
3263 | static void |
3264 | files_added_callback (BaulDirectory *directory, |
3265 | GList *files, |
3266 | gpointer callback_data) |
3267 | { |
3268 | FMDirectoryView *view; |
3269 | CtkWindow *window; |
3270 | char *uri; |
3271 | |
3272 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
3273 | |
3274 | window = fm_directory_view_get_containing_window (view); |
3275 | uri = fm_directory_view_get_uri (view); |
3276 | baul_debug_log_with_file_list (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_ASYNC"async", files, |
3277 | "files added in window %p: %s", |
3278 | window, |
3279 | uri ? uri : "(no directory)"); |
3280 | g_free (uri); |
3281 | |
3282 | schedule_changes (view); |
3283 | |
3284 | queue_pending_files (view, directory, files, &view->details->new_added_files); |
3285 | |
3286 | /* The number of items could have changed */ |
3287 | schedule_update_status (view); |
3288 | } |
3289 | |
3290 | static void |
3291 | files_changed_callback (BaulDirectory *directory, |
3292 | GList *files, |
3293 | gpointer callback_data) |
3294 | { |
3295 | FMDirectoryView *view; |
3296 | CtkWindow *window; |
3297 | char *uri; |
3298 | |
3299 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
3300 | |
3301 | window = fm_directory_view_get_containing_window (view); |
3302 | uri = fm_directory_view_get_uri (view); |
3303 | baul_debug_log_with_file_list (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_ASYNC"async", files, |
3304 | "files changed in window %p: %s", |
3305 | window, |
3306 | uri ? uri : "(no directory)"); |
3307 | g_free (uri); |
3308 | |
3309 | schedule_changes (view); |
3310 | |
3311 | queue_pending_files (view, directory, files, &view->details->new_changed_files); |
3312 | |
3313 | /* The free space or the number of items could have changed */ |
3314 | schedule_update_status (view); |
3315 | |
3316 | /* A change in MIME type could affect the Open with menu, for |
3317 | * one thing, so we need to update menus when files change. |
3318 | */ |
3319 | schedule_update_menus (view); |
3320 | } |
3321 | |
3322 | static void |
3323 | done_loading_callback (BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
3324 | gpointer callback_data) |
3325 | { |
3326 | FMDirectoryView *view; |
3327 | |
3328 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
3329 | |
3330 | process_new_files (view); |
3331 | if (g_hash_table_size (view->details->non_ready_files) == 0) { |
3332 | /* Unschedule a pending update and schedule a new one with the minimal |
3333 | * update interval. This gives the view a short chance at gathering the |
3334 | * (cached) deep counts. |
3335 | */ |
3336 | unschedule_display_of_pending_files (view); |
3337 | schedule_timeout_display_of_pending_files (view, UPDATE_INTERVAL_MIN100); |
3338 | } |
3339 | } |
3340 | |
3341 | static void |
3342 | load_error_callback (BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
3343 | GError *error, |
3344 | gpointer callback_data) |
3345 | { |
3346 | FMDirectoryView *view; |
3347 | |
3348 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
3349 | |
3350 | /* FIXME: By doing a stop, we discard some pending files. Is |
3351 | * that OK? |
3352 | */ |
3353 | fm_directory_view_stop (view); |
3354 | |
3355 | /* Emit a signal to tell subclasses that a load error has |
3356 | * occurred, so they can handle it in the UI. |
3357 | */ |
3358 | g_signal_emit (view, |
3359 | signals[LOAD_ERROR], 0, error); |
3360 | } |
3361 | |
3362 | static void |
3363 | real_load_error (FMDirectoryView *view, GError *error) |
3364 | { |
3365 | /* Report only one error per failed directory load (from the UI |
3366 | * point of view, not from the BaulDirectory point of view). |
3367 | * Otherwise you can get multiple identical errors caused by |
3368 | * unrelated code that just happens to try to iterate this |
3369 | * directory. |
3370 | */ |
3371 | if (!view->details->reported_load_error) { |
3372 | fm_report_error_loading_directory |
3373 | (fm_directory_view_get_directory_as_file (view), |
3374 | error, |
3375 | fm_directory_view_get_containing_window (view)); |
3376 | } |
3377 | view->details->reported_load_error = TRUE(!(0)); |
3378 | } |
3379 | |
3380 | void |
3381 | fm_directory_view_add_subdirectory (FMDirectoryView *view, |
3382 | BaulDirectory*directory) |
3383 | { |
3384 | BaulFileAttributes attributes; |
3385 | |
3386 | g_assert (!g_list_find (view->details->subdirectory_list, directory))do { if (!g_list_find (view->details->subdirectory_list , directory)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 3386, ((const char*) (__func__)), "!g_list_find (view->details->subdirectory_list, directory)" ); } while (0); |
3387 | |
3388 | baul_directory_ref (directory); |
3389 | |
3390 | attributes = |
3391 | BAUL_FILE_ATTRIBUTES_FOR_ICON(BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_LINK_INFO | BAUL_FILE_ATTRIBUTE_THUMBNAIL ) | |
3392 | BAUL_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT | |
3393 | BAUL_FILE_ATTRIBUTE_INFO | |
3394 | BAUL_FILE_ATTRIBUTE_LINK_INFO | |
3395 | BAUL_FILE_ATTRIBUTE_MOUNT | |
3396 | BAUL_FILE_ATTRIBUTE_EXTENSION_INFO; |
3397 | |
3398 | baul_directory_file_monitor_add (directory, |
3399 | &view->details->model, |
3400 | view->details->show_hidden_files, |
3401 | attributes, |
3402 | files_added_callback, view); |
3403 | |
3404 | g_signal_connectg_signal_connect_data ((directory), ("files_added"), (((GCallback ) (files_added_callback))), (view), ((void*)0), (GConnectFlags ) 0) |
3405 | (directory, "files_added",g_signal_connect_data ((directory), ("files_added"), (((GCallback ) (files_added_callback))), (view), ((void*)0), (GConnectFlags ) 0) |
3406 | G_CALLBACK (files_added_callback), view)g_signal_connect_data ((directory), ("files_added"), (((GCallback ) (files_added_callback))), (view), ((void*)0), (GConnectFlags ) 0); |
3407 | g_signal_connectg_signal_connect_data ((directory), ("files_changed"), (((GCallback ) (files_changed_callback))), (view), ((void*)0), (GConnectFlags ) 0) |
3408 | (directory, "files_changed",g_signal_connect_data ((directory), ("files_changed"), (((GCallback ) (files_changed_callback))), (view), ((void*)0), (GConnectFlags ) 0) |
3409 | G_CALLBACK (files_changed_callback), view)g_signal_connect_data ((directory), ("files_changed"), (((GCallback ) (files_changed_callback))), (view), ((void*)0), (GConnectFlags ) 0); |
3410 | |
3411 | view->details->subdirectory_list = g_list_prepend ( |
3412 | view->details->subdirectory_list, directory); |
3413 | } |
3414 | |
3415 | void |
3416 | fm_directory_view_remove_subdirectory (FMDirectoryView *view, |
3417 | BaulDirectory*directory) |
3418 | { |
3419 | g_assert (g_list_find (view->details->subdirectory_list, directory))do { if (g_list_find (view->details->subdirectory_list, directory)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 3419, ((const char*) (__func__)), "g_list_find (view->details->subdirectory_list, directory)" ); } while (0); |
3420 | |
3421 | view->details->subdirectory_list = g_list_remove ( |
3422 | view->details->subdirectory_list, directory); |
3423 | |
3424 | g_signal_handlers_disconnect_by_func (directory,g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (files_added_callback))), (view)) |
3425 | G_CALLBACK (files_added_callback),g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (files_added_callback))), (view)) |
3426 | view)g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (files_added_callback))), (view)); |
3427 | g_signal_handlers_disconnect_by_func (directory,g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (files_changed_callback))), (view)) |
3428 | G_CALLBACK (files_changed_callback),g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (files_changed_callback))), (view)) |
3429 | view)g_signal_handlers_disconnect_matched ((directory), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (files_changed_callback))), (view)); |
3430 | |
3431 | baul_directory_file_monitor_remove (directory, &view->details->model); |
3432 | |
3433 | baul_directory_unref (directory); |
3434 | } |
3435 | |
3436 | /** |
3437 | * fm_directory_view_clear: |
3438 | * |
3439 | * Emit the signal to clear the contents of the view. Subclasses must |
3440 | * override the signal handler for this signal. This is normally called |
3441 | * only by FMDirectoryView. |
3442 | * @view: FMDirectoryView to empty. |
3443 | * |
3444 | **/ |
3445 | void |
3446 | fm_directory_view_clear (FMDirectoryView *view) |
3447 | { |
3448 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3449 | |
3450 | g_signal_emit (view, signals[CLEAR], 0); |
3451 | } |
3452 | |
3453 | /** |
3454 | * fm_directory_view_begin_loading: |
3455 | * |
3456 | * Emit the signal to prepare for loading the contents of a new location. |
3457 | * Subclasses might want to override the signal handler for this signal. |
3458 | * This is normally called only by FMDirectoryView. |
3459 | * @view: FMDirectoryView that is switching to view a new location. |
3460 | * |
3461 | **/ |
3462 | void |
3463 | fm_directory_view_begin_loading (FMDirectoryView *view) |
3464 | { |
3465 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3466 | |
3467 | g_signal_emit (view, signals[BEGIN_LOADING], 0); |
3468 | } |
3469 | |
3470 | /** |
3471 | * fm_directory_view_end_loading: |
3472 | * |
3473 | * Emit the signal after loading the contents of a new location. |
3474 | * Subclasses might want to override the signal handler for this signal. |
3475 | * This is normally called only by FMDirectoryView. |
3476 | * @view: FMDirectoryView that is switching to view a new location. |
3477 | * |
3478 | **/ |
3479 | void |
3480 | fm_directory_view_end_loading (FMDirectoryView *view, |
3481 | gboolean all_files_seen) |
3482 | { |
3483 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3484 | |
3485 | g_signal_emit (view, signals[END_LOADING], 0, all_files_seen); |
3486 | } |
3487 | |
3488 | /** |
3489 | * fm_directory_view_get_loading: |
3490 | * @view: an #FMDirectoryView. |
3491 | * |
3492 | * Return value: #gboolean inicating whether @view is currently loaded. |
3493 | * |
3494 | **/ |
3495 | gboolean |
3496 | fm_directory_view_get_loading (FMDirectoryView *view) |
3497 | { |
3498 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
3499 | |
3500 | return view->details->loading; |
3501 | } |
3502 | |
3503 | /** |
3504 | * fm_directory_view_bump_zoom_level: |
3505 | * |
3506 | * bump the current zoom level by invoking the relevant subclass through the slot |
3507 | * |
3508 | **/ |
3509 | void |
3510 | fm_directory_view_bump_zoom_level (FMDirectoryView *view, int zoom_increment) |
3511 | { |
3512 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3513 | |
3514 | if (!fm_directory_view_supports_zooming (view)) { |
3515 | return; |
3516 | } |
3517 | |
3518 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> bump_zoom_level != ((void*)0)) { (* ((((FMDirectoryViewClass* ) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->bump_zoom_level) (view, zoom_increment); } } while (0) |
3519 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> bump_zoom_level != ((void*)0)) { (* ((((FMDirectoryViewClass* ) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->bump_zoom_level) (view, zoom_increment); } } while (0) |
3520 | bump_zoom_level, (view, zoom_increment))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> bump_zoom_level != ((void*)0)) { (* ((((FMDirectoryViewClass* ) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->bump_zoom_level) (view, zoom_increment); } } while (0); |
3521 | } |
3522 | |
3523 | /** |
3524 | * fm_directory_view_zoom_to_level: |
3525 | * |
3526 | * Set the current zoom level by invoking the relevant subclass through the slot |
3527 | * |
3528 | **/ |
3529 | void |
3530 | fm_directory_view_zoom_to_level (FMDirectoryView *view, |
3531 | BaulZoomLevel zoom_level) |
3532 | { |
3533 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3534 | |
3535 | if (!fm_directory_view_supports_zooming (view)) { |
3536 | return; |
3537 | } |
3538 | |
3539 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> zoom_to_level != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->zoom_to_level) (view, zoom_level); } } while (0) |
3540 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> zoom_to_level != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->zoom_to_level) (view, zoom_level); } } while (0) |
3541 | zoom_to_level, (view, zoom_level))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> zoom_to_level != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->zoom_to_level) (view, zoom_level); } } while (0); |
3542 | } |
3543 | |
3544 | |
3545 | BaulZoomLevel |
3546 | fm_directory_view_get_zoom_level (FMDirectoryView *view) |
3547 | { |
3548 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), BAUL_ZOOM_LEVEL_STANDARD)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (BAUL_ZOOM_LEVEL_STANDARD ); } } while (0); |
3549 | |
3550 | if (!fm_directory_view_supports_zooming (view)) { |
3551 | return BAUL_ZOOM_LEVEL_STANDARD; |
3552 | } |
3553 | |
3554 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_zoom_level == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_zoom_level) (view)) |
3555 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_zoom_level == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_zoom_level) (view)) |
3556 | get_zoom_level, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_zoom_level == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_zoom_level) (view)); |
3557 | } |
3558 | |
3559 | /** |
3560 | * fm_directory_view_restore_default_zoom_level: |
3561 | * |
3562 | * restore to the default zoom level by invoking the relevant subclass through the slot |
3563 | * |
3564 | **/ |
3565 | void |
3566 | fm_directory_view_restore_default_zoom_level (FMDirectoryView *view) |
3567 | { |
3568 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3569 | |
3570 | if (!fm_directory_view_supports_zooming (view)) { |
3571 | return; |
3572 | } |
3573 | |
3574 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> restore_default_zoom_level != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->restore_default_zoom_level) (view); } } while (0) |
3575 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> restore_default_zoom_level != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->restore_default_zoom_level) (view); } } while (0) |
3576 | restore_default_zoom_level, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> restore_default_zoom_level != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->restore_default_zoom_level) (view); } } while (0); |
3577 | } |
3578 | |
3579 | /** |
3580 | * fm_directory_view_can_zoom_in: |
3581 | * |
3582 | * Determine whether the view can be zoomed any closer. |
3583 | * @view: The zoomable FMDirectoryView. |
3584 | * |
3585 | * Return value: TRUE if @view can be zoomed any closer, FALSE otherwise. |
3586 | * |
3587 | **/ |
3588 | gboolean |
3589 | fm_directory_view_can_zoom_in (FMDirectoryView *view) |
3590 | { |
3591 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
3592 | |
3593 | if (!fm_directory_view_supports_zooming (view)) { |
3594 | return FALSE(0); |
3595 | } |
3596 | |
3597 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_zoom_in == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_zoom_in) (view)) |
3598 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_zoom_in == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_zoom_in) (view)) |
3599 | can_zoom_in, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_zoom_in == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_zoom_in) (view)); |
3600 | } |
3601 | |
3602 | /** |
3603 | * fm_directory_view_can_rename_file |
3604 | * |
3605 | * Determine whether a file can be renamed. |
3606 | * @file: A BaulFile |
3607 | * |
3608 | * Return value: TRUE if @file can be renamed, FALSE otherwise. |
3609 | * |
3610 | **/ |
3611 | static gboolean |
3612 | fm_directory_view_can_rename_file (FMDirectoryView *view, BaulFile *file) |
3613 | { |
3614 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_rename_file == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_rename_file) (view, file)) |
3615 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_rename_file == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_rename_file) (view, file)) |
3616 | can_rename_file, (view, file))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_rename_file == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_rename_file) (view, file)); |
3617 | } |
3618 | |
3619 | /** |
3620 | * fm_directory_view_can_zoom_out: |
3621 | * |
3622 | * Determine whether the view can be zoomed any further away. |
3623 | * @view: The zoomable FMDirectoryView. |
3624 | * |
3625 | * Return value: TRUE if @view can be zoomed any further away, FALSE otherwise. |
3626 | * |
3627 | **/ |
3628 | gboolean |
3629 | fm_directory_view_can_zoom_out (FMDirectoryView *view) |
3630 | { |
3631 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
3632 | |
3633 | if (!fm_directory_view_supports_zooming (view)) { |
3634 | return FALSE(0); |
3635 | } |
3636 | |
3637 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_zoom_out == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_zoom_out) (view)) |
3638 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_zoom_out == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_zoom_out) (view)) |
3639 | can_zoom_out, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> can_zoom_out == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->can_zoom_out) (view)); |
3640 | } |
3641 | |
3642 | CtkWidget * |
3643 | fm_directory_view_get_background_widget (FMDirectoryView *view) |
3644 | { |
3645 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
3646 | |
3647 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_background_widget == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_background_widget) (view)) |
3648 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_background_widget == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_background_widget) (view)) |
3649 | get_background_widget, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_background_widget == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_background_widget) (view)); |
3650 | } |
3651 | |
3652 | EelBackground * |
3653 | fm_directory_view_get_background (FMDirectoryView *view) |
3654 | { |
3655 | return eel_get_widget_background (fm_directory_view_get_background_widget (view)); |
3656 | } |
3657 | |
3658 | static void |
3659 | real_set_is_active (FMDirectoryView *view, |
3660 | gboolean is_active) |
3661 | { |
3662 | EelBackground *bg; |
3663 | |
3664 | bg = fm_directory_view_get_background (view); |
3665 | eel_background_set_active (bg, is_active); |
3666 | } |
3667 | |
3668 | static void |
3669 | fm_directory_view_set_is_active (FMDirectoryView *view, |
3670 | gboolean is_active) |
3671 | { |
3672 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3673 | |
3674 | EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> set_is_active != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->set_is_active) (view, is_active); } } while (0) |
3675 | set_is_active, (view, is_active))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> set_is_active != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->set_is_active) (view, is_active); } } while (0); |
3676 | } |
3677 | |
3678 | /** |
3679 | * fm_directory_view_get_selection: |
3680 | * |
3681 | * Get a list of BaulFile pointers that represents the |
3682 | * currently-selected items in this view. Subclasses must override |
3683 | * the signal handler for the 'get_selection' signal. Callers are |
3684 | * responsible for g_free-ing the list (but not its data). |
3685 | * @view: FMDirectoryView whose selected items are of interest. |
3686 | * |
3687 | * Return value: GList of BaulFile pointers representing the selection. |
3688 | * |
3689 | **/ |
3690 | GList * |
3691 | fm_directory_view_get_selection (FMDirectoryView *view) |
3692 | { |
3693 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
3694 | |
3695 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selection == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_selection) (view)) |
3696 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selection == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_selection) (view)) |
3697 | get_selection, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selection == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_selection) (view)); |
3698 | } |
3699 | |
3700 | void |
3701 | fm_directory_view_invert_selection (FMDirectoryView *view) |
3702 | { |
3703 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
3704 | |
3705 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> invert_selection != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->invert_selection) (view); } } while (0) |
3706 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> invert_selection != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->invert_selection) (view); } } while (0) |
3707 | invert_selection, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> invert_selection != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->invert_selection) (view); } } while (0); |
3708 | } |
3709 | |
3710 | GList * |
3711 | fm_directory_view_get_selection_for_file_transfer (FMDirectoryView *view) |
3712 | { |
3713 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
3714 | |
3715 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selection_for_file_transfer == ((void*)0)) ? 0 : ((* (((( FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((((((GObjectClass*) (((GTypeInstance*) ((view)))->g_class )))))), (fm_directory_view_get_type())))))->get_selection_for_file_transfer ) (view)) |
3716 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selection_for_file_transfer == ((void*)0)) ? 0 : ((* (((( FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((((((GObjectClass*) (((GTypeInstance*) ((view)))->g_class )))))), (fm_directory_view_get_type())))))->get_selection_for_file_transfer ) (view)) |
3717 | get_selection_for_file_transfer, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selection_for_file_transfer == ((void*)0)) ? 0 : ((* (((( FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((((((GObjectClass*) (((GTypeInstance*) ((view)))->g_class )))))), (fm_directory_view_get_type())))))->get_selection_for_file_transfer ) (view)); |
3718 | } |
3719 | |
3720 | guint |
3721 | fm_directory_view_get_item_count (FMDirectoryView *view) |
3722 | { |
3723 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (0); } } while (0); |
3724 | |
3725 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_item_count == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_item_count) (view)) |
3726 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_item_count == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_item_count) (view)) |
3727 | get_item_count, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_item_count == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_item_count) (view)); |
3728 | } |
3729 | |
3730 | CtkUIManager * |
3731 | fm_directory_view_get_ui_manager (FMDirectoryView *view) |
3732 | { |
3733 | if (view->details->window == NULL((void*)0)) { |
3734 | return NULL((void*)0); |
3735 | } |
3736 | return baul_window_info_get_ui_manager (view->details->window); |
3737 | } |
3738 | |
3739 | /** |
3740 | * fm_directory_view_get_model: |
3741 | * |
3742 | * Get the model for this FMDirectoryView. |
3743 | * @view: FMDirectoryView of interest. |
3744 | * |
3745 | * Return value: BaulDirectory for this view. |
3746 | * |
3747 | **/ |
3748 | BaulDirectory * |
3749 | fm_directory_view_get_model (FMDirectoryView *view) |
3750 | { |
3751 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
3752 | |
3753 | return view->details->model; |
3754 | } |
3755 | |
3756 | CdkAtom |
3757 | fm_directory_view_get_copied_files_atom (FMDirectoryView *view) |
3758 | { |
3759 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), CDK_NONE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((CdkAtom )((gpointer) (gulong) (0)))); } } while (0); |
3760 | |
3761 | return copied_files_atom; |
3762 | } |
3763 | |
3764 | static void |
3765 | prepend_uri_one (gpointer data, gpointer callback_data) |
3766 | { |
3767 | BaulFile *file; |
3768 | GList **result; |
3769 | |
3770 | g_assert (BAUL_IS_FILE (data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((data)); GType __t = (baul_file_get_type()); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 3770, ((const char*) (__func__)), "BAUL_IS_FILE (data)"); } while (0); |
3771 | g_assert (callback_data != NULL)do { if (callback_data != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 3771, ((const char*) ( __func__)), "callback_data != NULL"); } while (0); |
3772 | |
3773 | result = (GList **) callback_data; |
3774 | file = (BaulFile *) data; |
3775 | *result = g_list_prepend (*result, baul_file_get_uri (file)); |
3776 | } |
3777 | |
3778 | static void |
3779 | offset_drop_points (GArray *relative_item_points, |
3780 | int x_offset, int y_offset) |
3781 | { |
3782 | guint index; |
3783 | |
3784 | if (relative_item_points == NULL((void*)0)) { |
3785 | return; |
3786 | } |
3787 | |
3788 | for (index = 0; index < relative_item_points->len; index++) { |
3789 | g_array_index (relative_item_points, CdkPoint, index)(((CdkPoint*) (void *) (relative_item_points)->data) [(index )]).x += x_offset; |
3790 | g_array_index (relative_item_points, CdkPoint, index)(((CdkPoint*) (void *) (relative_item_points)->data) [(index )]).y += y_offset; |
3791 | } |
3792 | } |
3793 | |
3794 | static void |
3795 | fm_directory_view_create_links_for_files (FMDirectoryView *view, GList *files, |
3796 | GArray *relative_item_points) |
3797 | { |
3798 | GList *uris; |
3799 | char *dir_uri; |
3800 | CopyMoveDoneData *copy_move_done_data; |
3801 | g_assert (relative_item_points->len == 0do { if (relative_item_points->len == 0 || g_list_length ( files) == relative_item_points->len) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 3802, ((const char*) ( __func__)), "relative_item_points->len == 0 || g_list_length (files) == relative_item_points->len" ); } while (0) |
3802 | || g_list_length (files) == relative_item_points->len)do { if (relative_item_points->len == 0 || g_list_length ( files) == relative_item_points->len) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 3802, ((const char*) ( __func__)), "relative_item_points->len == 0 || g_list_length (files) == relative_item_points->len" ); } while (0); |
3803 | |
3804 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 3804, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
3805 | g_assert (files != NULL)do { if (files != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 3805, ((const char*) ( __func__)), "files != NULL"); } while (0); |
3806 | |
3807 | /* create a list of URIs */ |
3808 | uris = NULL((void*)0); |
3809 | g_list_foreach (files, prepend_uri_one, &uris); |
3810 | uris = g_list_reverse (uris); |
3811 | |
3812 | g_assert (g_list_length (uris) == g_list_length (files))do { if (g_list_length (uris) == g_list_length (files)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 3812, ((const char*) (__func__)), "g_list_length (uris) == g_list_length (files)" ); } while (0); |
3813 | |
3814 | /* offset the drop locations a bit so that we don't pile |
3815 | * up the icons on top of each other |
3816 | */ |
3817 | offset_drop_points (relative_item_points, |
3818 | DUPLICATE_HORIZONTAL_ICON_OFFSET70, |
3819 | DUPLICATE_VERTICAL_ICON_OFFSET30); |
3820 | |
3821 | copy_move_done_data = pre_copy_move (view); |
3822 | dir_uri = fm_directory_view_get_backing_uri (view); |
3823 | baul_file_operations_copy_move (uris, relative_item_points, dir_uri, CDK_ACTION_LINK, |
3824 | CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), copy_move_done_callback, copy_move_done_data); |
3825 | g_free (dir_uri); |
3826 | g_list_free_full (uris, g_free); |
3827 | } |
3828 | |
3829 | static void |
3830 | fm_directory_view_duplicate_selection (FMDirectoryView *view, GList *files, |
3831 | GArray *relative_item_points) |
3832 | { |
3833 | GList *uris; |
3834 | CopyMoveDoneData *copy_move_done_data; |
3835 | |
3836 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 3836, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
3837 | g_assert (files != NULL)do { if (files != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 3837, ((const char*) ( __func__)), "files != NULL"); } while (0); |
3838 | g_assert (g_list_length (files) == relative_item_points->lendo { if (g_list_length (files) == relative_item_points->len || relative_item_points->len == 0) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 3839, ((const char*) ( __func__)), "g_list_length (files) == relative_item_points->len || relative_item_points->len == 0" ); } while (0) |
3839 | || relative_item_points->len == 0)do { if (g_list_length (files) == relative_item_points->len || relative_item_points->len == 0) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 3839, ((const char*) ( __func__)), "g_list_length (files) == relative_item_points->len || relative_item_points->len == 0" ); } while (0); |
3840 | |
3841 | /* create a list of URIs */ |
3842 | uris = NULL((void*)0); |
3843 | g_list_foreach (files, prepend_uri_one, &uris); |
3844 | uris = g_list_reverse (uris); |
3845 | |
3846 | g_assert (g_list_length (uris) == g_list_length (files))do { if (g_list_length (uris) == g_list_length (files)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 3846, ((const char*) (__func__)), "g_list_length (uris) == g_list_length (files)" ); } while (0); |
3847 | |
3848 | /* offset the drop locations a bit so that we don't pile |
3849 | * up the icons on top of each other |
3850 | */ |
3851 | offset_drop_points (relative_item_points, |
3852 | DUPLICATE_HORIZONTAL_ICON_OFFSET70, |
3853 | DUPLICATE_VERTICAL_ICON_OFFSET30); |
3854 | |
3855 | copy_move_done_data = pre_copy_move (view); |
3856 | baul_file_operations_copy_move (uris, relative_item_points, NULL((void*)0), CDK_ACTION_COPY, |
3857 | CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), copy_move_done_callback, copy_move_done_data); |
3858 | g_list_free_full (uris, g_free); |
3859 | } |
3860 | |
3861 | /* special_link_in_selection |
3862 | * |
3863 | * Return TRUE if one of our special links is in the selection. |
3864 | * Special links include the following: |
3865 | * BAUL_DESKTOP_LINK_TRASH, BAUL_DESKTOP_LINK_HOME, BAUL_DESKTOP_LINK_MOUNT |
3866 | */ |
3867 | |
3868 | static gboolean |
3869 | special_link_in_selection (FMDirectoryView *view) |
3870 | { |
3871 | gboolean saw_link; |
3872 | GList *selection, *node; |
3873 | BaulFile *file = NULL((void*)0); |
3874 | |
3875 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
3876 | |
3877 | saw_link = FALSE(0); |
3878 | |
3879 | selection = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (fm_directory_view_get_type())))))); |
3880 | |
3881 | for (node = selection; node != NULL((void*)0); node = node->next) { |
3882 | file = BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), (baul_file_get_type()))))); |
3883 | |
3884 | saw_link = BAUL_IS_DESKTOP_ICON_FILE (file)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (file)); GType __t = (baul_desktop_icon_file_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))); |
3885 | |
3886 | if (saw_link) { |
3887 | break; |
3888 | } |
3889 | } |
3890 | |
3891 | baul_file_list_free (selection); |
3892 | |
3893 | return saw_link; |
3894 | } |
3895 | |
3896 | /* desktop_or_home_dir_in_selection |
3897 | * |
3898 | * Return TRUE if either the desktop or the home directory is in the selection. |
3899 | */ |
3900 | |
3901 | static gboolean |
3902 | desktop_or_home_dir_in_selection (FMDirectoryView *view) |
3903 | { |
3904 | gboolean saw_desktop_or_home_dir; |
3905 | GList *selection, *node; |
3906 | BaulFile *file = NULL((void*)0); |
3907 | |
3908 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
3909 | |
3910 | saw_desktop_or_home_dir = FALSE(0); |
3911 | |
3912 | selection = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (fm_directory_view_get_type())))))); |
3913 | |
3914 | for (node = selection; node != NULL((void*)0); node = node->next) { |
3915 | file = BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), (baul_file_get_type()))))); |
3916 | |
3917 | saw_desktop_or_home_dir = |
3918 | baul_file_is_home (file) |
3919 | || baul_file_is_desktop_directory (file); |
3920 | |
3921 | if (saw_desktop_or_home_dir) { |
3922 | break; |
3923 | } |
3924 | } |
3925 | |
3926 | baul_file_list_free (selection); |
3927 | |
3928 | return saw_desktop_or_home_dir; |
3929 | } |
3930 | |
3931 | static void |
3932 | trash_or_delete_done_cb (GHashTable *debuting_uris G_GNUC_UNUSED__attribute__ ((__unused__)), |
3933 | gboolean user_cancel, |
3934 | FMDirectoryView *view) |
3935 | { |
3936 | if (user_cancel) { |
3937 | view->details->selection_was_removed = FALSE(0); |
3938 | } |
3939 | } |
3940 | |
3941 | static void |
3942 | trash_or_delete_files (CtkWindow *parent_window, |
3943 | const GList *files, |
3944 | gboolean delete_if_all_already_in_trash G_GNUC_UNUSED__attribute__ ((__unused__)), |
3945 | FMDirectoryView *view) |
3946 | { |
3947 | GList *locations; |
3948 | const GList *node; |
3949 | |
3950 | locations = NULL((void*)0); |
3951 | for (node = files; node != NULL((void*)0); node = node->next) { |
3952 | locations = g_list_prepend (locations, |
3953 | baul_file_get_location ((BaulFile *) node->data)); |
3954 | } |
3955 | |
3956 | locations = g_list_reverse (locations); |
3957 | |
3958 | baul_file_operations_trash_or_delete (locations, |
3959 | parent_window, |
3960 | (BaulDeleteCallback) trash_or_delete_done_cb, |
3961 | view); |
3962 | g_list_free_full (locations, g_object_unref); |
3963 | } |
3964 | |
3965 | static gboolean |
3966 | can_rename_file (FMDirectoryView *view G_GNUC_UNUSED__attribute__ ((__unused__)), |
3967 | BaulFile *file) |
3968 | { |
3969 | return baul_file_can_rename (file); |
3970 | } |
3971 | |
3972 | static void |
3973 | start_renaming_file (FMDirectoryView *view, |
3974 | BaulFile *file, |
3975 | gboolean select_all G_GNUC_UNUSED__attribute__ ((__unused__))) |
3976 | { |
3977 | if (file != NULL((void*)0)) { |
3978 | fm_directory_view_select_file (view, file); |
3979 | } |
3980 | } |
3981 | |
3982 | typedef struct { |
3983 | FMDirectoryView *view; |
3984 | BaulFile *new_file; |
3985 | } RenameData; |
3986 | |
3987 | static gboolean |
3988 | delayed_rename_file_hack_callback (RenameData *data) |
3989 | { |
3990 | FMDirectoryView *view; |
3991 | BaulFile *new_file; |
3992 | |
3993 | view = data->view; |
3994 | new_file = data->new_file; |
3995 | |
3996 | if (view->details->window != NULL((void*)0) && |
3997 | view->details->active) { |
3998 | EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, view, start_renaming_file, (view, new_file, FALSE))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> start_renaming_file != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->start_renaming_file) (view, new_file, (0)); } } while (0); |
3999 | fm_directory_view_reveal_selection (view); |
4000 | } |
4001 | |
4002 | return FALSE(0); |
4003 | } |
4004 | |
4005 | static void |
4006 | delayed_rename_file_hack_removed (RenameData *data) |
4007 | { |
4008 | g_object_unref (data->view); |
4009 | baul_file_unref (data->new_file); |
4010 | g_free (data); |
4011 | } |
4012 | |
4013 | |
4014 | static void |
4015 | rename_file (FMDirectoryView *view, BaulFile *new_file) |
4016 | { |
4017 | /* HACK!!!! |
4018 | This is a work around bug in listview. After the rename is |
4019 | enabled we will get file changes due to info about the new |
4020 | file being read, which will cause the model to change. When |
4021 | the model changes CtkTreeView clears the editing. This hack just |
4022 | delays editing for some time to try to avoid this problem. |
4023 | A major problem is that the selection of the row causes us |
4024 | to load the slow mimetype for the file, which leads to a |
4025 | file_changed. So, before we delay we select the row. |
4026 | */ |
4027 | if (FM_IS_LIST_VIEW (view)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (view)); GType __t = (fm_list_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
4028 | RenameData *data; |
4029 | |
4030 | fm_directory_view_select_file (view, new_file); |
4031 | |
4032 | data = g_new (RenameData, 1)((RenameData *) g_malloc_n ((1), sizeof (RenameData))); |
4033 | data->view = g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)); |
4034 | data->new_file = baul_file_ref (new_file); |
4035 | if (view->details->delayed_rename_file_id != 0) { |
4036 | g_source_remove (view->details->delayed_rename_file_id); |
4037 | } |
4038 | view->details->delayed_rename_file_id = |
4039 | g_timeout_add_full (G_PRIORITY_DEFAULT0, |
4040 | 100, (GSourceFunc)delayed_rename_file_hack_callback, |
4041 | data, (GDestroyNotify) delayed_rename_file_hack_removed); |
4042 | |
4043 | return; |
4044 | } |
4045 | |
4046 | /* no need to select because start_renaming_file selects |
4047 | * fm_directory_view_select_file (view, new_file); |
4048 | */ |
4049 | EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, view, start_renaming_file, (view, new_file, FALSE))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> start_renaming_file != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->start_renaming_file) (view, new_file, (0)); } } while (0); |
4050 | fm_directory_view_reveal_selection (view); |
4051 | } |
4052 | |
4053 | static void |
4054 | reveal_newly_added_folder (FMDirectoryView *view, |
4055 | BaulFile *new_file, |
4056 | BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
4057 | GFile *target_location) |
4058 | { |
4059 | GFile *location; |
4060 | |
4061 | location = baul_file_get_location (new_file); |
4062 | if (g_file_equal (location, target_location)) { |
4063 | g_signal_handlers_disconnect_by_func (view,g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (reveal_newly_added_folder))), ((void *) target_location )) |
4064 | G_CALLBACK (reveal_newly_added_folder),g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (reveal_newly_added_folder))), ((void *) target_location )) |
4065 | (void *) target_location)g_signal_handlers_disconnect_matched ((view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (reveal_newly_added_folder))), ((void *) target_location )); |
4066 | rename_file (view, new_file); |
4067 | } |
4068 | g_object_unref (location); |
4069 | } |
4070 | |
4071 | typedef struct { |
4072 | FMDirectoryView *directory_view; |
4073 | GHashTable *added_locations; |
4074 | } NewFolderData; |
4075 | |
4076 | |
4077 | static void |
4078 | track_newly_added_locations (FMDirectoryView *view G_GNUC_UNUSED__attribute__ ((__unused__)), |
4079 | BaulFile *new_file, |
4080 | BaulDirectory *directory G_GNUC_UNUSED__attribute__ ((__unused__)), |
4081 | gpointer user_data) |
4082 | { |
4083 | NewFolderData *data; |
4084 | |
4085 | data = user_data; |
4086 | |
4087 | g_hash_table_insert (data->added_locations, baul_file_get_location (new_file), NULL((void*)0)); |
4088 | } |
4089 | |
4090 | static void |
4091 | new_folder_done (GFile *new_folder, gpointer user_data) |
4092 | { |
4093 | FMDirectoryView *directory_view; |
4094 | BaulFile *file; |
4095 | char screen_string[32]; |
4096 | CdkScreen *screen; |
4097 | NewFolderData *data; |
4098 | |
4099 | data = (NewFolderData *)user_data; |
4100 | |
4101 | directory_view = data->directory_view; |
4102 | |
4103 | if (directory_view == NULL((void*)0)) { |
4104 | goto fail; |
4105 | } |
4106 | |
4107 | g_signal_handlers_disconnect_by_func (directory_view,g_signal_handlers_disconnect_matched ((directory_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (track_newly_added_locations))), ((void *) data )) |
4108 | G_CALLBACK (track_newly_added_locations),g_signal_handlers_disconnect_matched ((directory_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (track_newly_added_locations))), ((void *) data )) |
4109 | (void *) data)g_signal_handlers_disconnect_matched ((directory_view), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (((GCallback) (track_newly_added_locations))), ((void *) data )); |
4110 | |
4111 | if (new_folder == NULL((void*)0)) { |
4112 | goto fail; |
4113 | } |
4114 | |
4115 | screen = ctk_widget_get_screen (CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((directory_view)), ((ctk_widget_get_type ()))))))); |
4116 | g_snprintf (screen_string, sizeof (screen_string), "%d", cdk_x11_screen_get_screen_number (screen)); |
4117 | |
4118 | |
4119 | file = baul_file_get (new_folder); |
4120 | baul_file_set_metadata |
4121 | (file, BAUL_METADATA_KEY_SCREEN"screen", |
4122 | NULL((void*)0), |
4123 | screen_string); |
4124 | |
4125 | if (g_hash_table_lookup_extended (data->added_locations, new_folder, NULL((void*)0), NULL((void*)0))) { |
4126 | /* The file was already added */ |
4127 | rename_file (directory_view, file); |
4128 | } else { |
4129 | /* We need to run after the default handler adds the folder we want to |
4130 | * operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we |
4131 | * must use connect_after. |
4132 | */ |
4133 | g_signal_connect_data (directory_view, |
4134 | "add_file", |
4135 | G_CALLBACK (reveal_newly_added_folder)((GCallback) (reveal_newly_added_folder)), |
4136 | g_object_ref (new_folder)((__typeof__ (new_folder)) (g_object_ref) (new_folder)), |
4137 | (GClosureNotify)g_object_unref, |
4138 | G_CONNECT_AFTER); |
4139 | } |
4140 | baul_file_unref (file); |
4141 | |
4142 | fail: |
4143 | g_hash_table_destroy (data->added_locations); |
4144 | eel_remove_weak_pointer (&data->directory_view); |
4145 | g_free (data); |
4146 | } |
4147 | |
4148 | |
4149 | static NewFolderData * |
4150 | new_folder_data_new (FMDirectoryView *directory_view) |
4151 | { |
4152 | NewFolderData *data; |
4153 | |
4154 | data = g_new (NewFolderData, 1)((NewFolderData *) g_malloc_n ((1), sizeof (NewFolderData))); |
4155 | data->directory_view = directory_view; |
4156 | data->added_locations = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, |
4157 | g_object_unref, NULL((void*)0)); |
4158 | eel_add_weak_pointer (&data->directory_view); |
4159 | |
4160 | return data; |
4161 | } |
4162 | |
4163 | static CdkPoint * |
4164 | context_menu_to_file_operation_position (FMDirectoryView *directory_view) |
4165 | { |
4166 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (directory_view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((directory_view)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (directory_view)" ); return (((void*)0)); } } while (0); |
4167 | |
4168 | if (fm_directory_view_using_manual_layout (directory_view) |
4169 | && directory_view->details->context_menu_position.x >= 0 |
4170 | && directory_view->details->context_menu_position.y >= 0) { |
4171 | EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, directory_view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((directory_view )))->g_class)))))), (fm_directory_view_get_type())))))-> widget_to_file_operation_position != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((directory_view)))->g_class)))))), ( fm_directory_view_get_type())))))->widget_to_file_operation_position ) (directory_view, &directory_view->details->context_menu_position ); } } while (0) |
4172 | widget_to_file_operation_position,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((directory_view )))->g_class)))))), (fm_directory_view_get_type())))))-> widget_to_file_operation_position != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((directory_view)))->g_class)))))), ( fm_directory_view_get_type())))))->widget_to_file_operation_position ) (directory_view, &directory_view->details->context_menu_position ); } } while (0) |
4173 | (directory_view, &directory_view->details->context_menu_position))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((directory_view )))->g_class)))))), (fm_directory_view_get_type())))))-> widget_to_file_operation_position != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((directory_view)))->g_class)))))), ( fm_directory_view_get_type())))))->widget_to_file_operation_position ) (directory_view, &directory_view->details->context_menu_position ); } } while (0); |
4174 | return &directory_view->details->context_menu_position; |
4175 | } else { |
4176 | return NULL((void*)0); |
4177 | } |
4178 | } |
4179 | |
4180 | static void |
4181 | update_context_menu_position_from_event (FMDirectoryView *view, |
4182 | CdkEventButton *event) |
4183 | { |
4184 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
4185 | |
4186 | if (event != NULL((void*)0)) { |
4187 | view->details->context_menu_position.x = event->x; |
4188 | view->details->context_menu_position.y = event->y; |
4189 | } else { |
4190 | view->details->context_menu_position.x = -1; |
4191 | view->details->context_menu_position.y = -1; |
4192 | } |
4193 | } |
4194 | |
4195 | void |
4196 | fm_directory_view_new_folder (FMDirectoryView *directory_view) |
4197 | { |
4198 | char *parent_uri; |
4199 | NewFolderData *data; |
4200 | CdkPoint *pos; |
4201 | |
4202 | data = new_folder_data_new (directory_view); |
4203 | |
4204 | g_signal_connect_data (directory_view, |
4205 | "add_file", |
4206 | G_CALLBACK (track_newly_added_locations)((GCallback) (track_newly_added_locations)), |
4207 | data, |
4208 | (GClosureNotify)NULL((void*)0), |
4209 | G_CONNECT_AFTER); |
4210 | |
4211 | pos = context_menu_to_file_operation_position (directory_view); |
4212 | |
4213 | parent_uri = fm_directory_view_get_backing_uri (directory_view); |
4214 | baul_file_operations_new_folder (CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((directory_view)), ((ctk_widget_get_type ())))))), |
4215 | pos, parent_uri, |
4216 | new_folder_done, data); |
4217 | |
4218 | g_free (parent_uri); |
4219 | } |
4220 | |
4221 | static NewFolderData * |
4222 | setup_new_folder_data (FMDirectoryView *directory_view) |
4223 | { |
4224 | NewFolderData *data; |
4225 | |
4226 | data = new_folder_data_new (directory_view); |
4227 | |
4228 | g_signal_connect_data (directory_view, |
4229 | "add_file", |
4230 | G_CALLBACK (track_newly_added_locations)((GCallback) (track_newly_added_locations)), |
4231 | data, |
4232 | (GClosureNotify)NULL((void*)0), |
4233 | G_CONNECT_AFTER); |
4234 | |
4235 | return data; |
4236 | } |
4237 | |
4238 | static void |
4239 | fm_directory_view_new_file_with_initial_contents (FMDirectoryView *directory_view, |
4240 | const char *parent_uri, |
4241 | const char *filename, |
4242 | const char *initial_contents, |
4243 | int length, |
4244 | CdkPoint *pos) |
4245 | { |
4246 | NewFolderData *data; |
4247 | |
4248 | g_assert (parent_uri != NULL)do { if (parent_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 4248, ((const char*) ( __func__)), "parent_uri != NULL"); } while (0); |
4249 | |
4250 | data = setup_new_folder_data (directory_view); |
4251 | |
4252 | if (pos == NULL((void*)0)) { |
4253 | pos = context_menu_to_file_operation_position (directory_view); |
4254 | } |
4255 | |
4256 | baul_file_operations_new_file (CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((directory_view)), ((ctk_widget_get_type ())))))), |
4257 | pos, parent_uri, filename, |
4258 | initial_contents, length, |
4259 | new_folder_done, data); |
4260 | } |
4261 | |
4262 | void |
4263 | fm_directory_view_new_file (FMDirectoryView *directory_view, |
4264 | const char *parent_uri, |
4265 | BaulFile *source) |
4266 | { |
4267 | CdkPoint *pos; |
4268 | NewFolderData *data; |
4269 | char *source_uri; |
4270 | char *container_uri; |
4271 | |
4272 | container_uri = NULL((void*)0); |
4273 | if (parent_uri == NULL((void*)0)) { |
4274 | container_uri = fm_directory_view_get_backing_uri (directory_view); |
4275 | g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 4275, ((const char*) ( __func__)), "container_uri != NULL"); } while (0); |
4276 | } |
4277 | |
4278 | if (source == NULL((void*)0)) { |
4279 | fm_directory_view_new_file_with_initial_contents (directory_view, |
4280 | parent_uri != NULL((void*)0) ? parent_uri : container_uri, |
4281 | NULL((void*)0), |
4282 | NULL((void*)0), |
4283 | 0, |
4284 | NULL((void*)0)); |
4285 | g_free (container_uri); |
4286 | return; |
4287 | } |
4288 | |
4289 | g_return_if_fail (baul_file_is_local (source))do { if ((baul_file_is_local (source))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "baul_file_is_local (source)" ); return; } } while (0); |
4290 | |
4291 | pos = context_menu_to_file_operation_position (directory_view); |
4292 | |
4293 | data = setup_new_folder_data (directory_view); |
4294 | |
4295 | source_uri = baul_file_get_uri (source); |
4296 | |
4297 | baul_file_operations_new_file_from_template (CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((directory_view)), ((ctk_widget_get_type ())))))), |
4298 | pos, |
4299 | parent_uri != NULL((void*)0) ? parent_uri : container_uri, |
4300 | NULL((void*)0), |
4301 | source_uri, |
4302 | new_folder_done, data); |
4303 | |
4304 | g_free (source_uri); |
4305 | g_free (container_uri); |
4306 | } |
4307 | |
4308 | /* handle the open command */ |
4309 | |
4310 | static void |
4311 | open_one_in_new_window (gpointer data, gpointer callback_data) |
4312 | { |
4313 | g_assert (BAUL_IS_FILE (data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((data)); GType __t = (baul_file_get_type()); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 4313, ((const char*) (__func__)), "BAUL_IS_FILE (data)"); } while (0); |
4314 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 4314, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
4315 | |
4316 | fm_directory_view_activate_file (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))), |
4317 | BAUL_FILE (data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (baul_file_get_type()))))), |
4318 | BAUL_WINDOW_OPEN_IN_NAVIGATION, |
4319 | 0); |
4320 | } |
4321 | |
4322 | static void |
4323 | open_one_in_folder_window (gpointer data, gpointer callback_data) |
4324 | { |
4325 | g_assert (BAUL_IS_FILE (data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((data)); GType __t = (baul_file_get_type()); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 4325, ((const char*) (__func__)), "BAUL_IS_FILE (data)"); } while (0); |
4326 | g_assert (FM_IS_DIRECTORY_VIEW (callback_data))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((callback_data)); GType __t = (fm_directory_view_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 4326, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)" ); } while (0); |
4327 | |
4328 | fm_directory_view_activate_file (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))), |
4329 | BAUL_FILE (data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (baul_file_get_type()))))), |
4330 | BAUL_WINDOW_OPEN_IN_SPATIAL, |
4331 | 0); |
4332 | } |
4333 | |
4334 | BaulFile * |
4335 | fm_directory_view_get_directory_as_file (FMDirectoryView *view) |
4336 | { |
4337 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 4337, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
4338 | |
4339 | return view->details->directory_as_file; |
4340 | } |
4341 | |
4342 | static void |
4343 | open_with_launch_application_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
4344 | gpointer callback_data) |
4345 | { |
4346 | ApplicationLaunchParameters *launch_parameters; |
4347 | |
4348 | launch_parameters = (ApplicationLaunchParameters *) callback_data; |
4349 | baul_launch_application |
4350 | (launch_parameters->application, |
4351 | launch_parameters->files, |
4352 | fm_directory_view_get_containing_window (launch_parameters->directory_view)); |
4353 | } |
4354 | |
4355 | static void |
4356 | open_parent_folder_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
4357 | gpointer callback_data) |
4358 | { |
4359 | gchar *uri; |
4360 | |
4361 | uri = (gchar *) callback_data; |
4362 | g_app_info_launch_default_for_uri (uri, NULL((void*)0), NULL((void*)0)); |
4363 | } |
4364 | |
4365 | static char * |
4366 | escape_action_name (const char *action_name, |
4367 | const char *prefix) |
4368 | { |
4369 | GString *s; |
4370 | |
4371 | if (action_name == NULL((void*)0)) { |
4372 | return NULL((void*)0); |
4373 | } |
4374 | |
4375 | s = g_string_new (prefix); |
4376 | |
4377 | while (*action_name != 0) { |
4378 | switch (*action_name) { |
4379 | case '\\': |
4380 | g_string_append (s, "\\\\")(__builtin_constant_p ("\\\\") ? __extension__ ({ const char * const __val = ("\\\\"); g_string_append_len_inline (s, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (s, "\\\\" , (gssize) -1)); |
4381 | break; |
4382 | case '/': |
4383 | g_string_append (s, "\\s")(__builtin_constant_p ("\\s") ? __extension__ ({ const char * const __val = ("\\s"); g_string_append_len_inline (s, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val) )) : (gssize) -1); }) : g_string_append_len_inline (s, "\\s", (gssize) -1)); |
4384 | break; |
4385 | case '&': |
4386 | g_string_append (s, "\\a")(__builtin_constant_p ("\\a") ? __extension__ ({ const char * const __val = ("\\a"); g_string_append_len_inline (s, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val) )) : (gssize) -1); }) : g_string_append_len_inline (s, "\\a", (gssize) -1)); |
4387 | break; |
4388 | case '"': |
4389 | g_string_append (s, "\\q")(__builtin_constant_p ("\\q") ? __extension__ ({ const char * const __val = ("\\q"); g_string_append_len_inline (s, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val) )) : (gssize) -1); }) : g_string_append_len_inline (s, "\\q", (gssize) -1)); |
4390 | break; |
4391 | default: |
4392 | g_string_append_c (s, *action_name)g_string_append_c_inline (s, *action_name); |
4393 | } |
4394 | |
4395 | action_name ++; |
4396 | } |
4397 | return g_string_free (s, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((s), ( (0))) : g_string_free_and_steal (s)) : (g_string_free) ((s), ( (0)))); |
4398 | } |
4399 | |
4400 | static char * |
4401 | escape_action_path (const char *action_path) |
4402 | { |
4403 | GString *s; |
4404 | |
4405 | if (action_path == NULL((void*)0)) { |
4406 | return NULL((void*)0); |
4407 | } |
4408 | |
4409 | s = g_string_sized_new (strlen (action_path) + 2); |
4410 | |
4411 | while (*action_path != 0) { |
4412 | switch (*action_path) { |
4413 | case '\\': |
4414 | g_string_append (s, "\\\\")(__builtin_constant_p ("\\\\") ? __extension__ ({ const char * const __val = ("\\\\"); g_string_append_len_inline (s, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (s, "\\\\" , (gssize) -1)); |
4415 | break; |
4416 | case '&': |
4417 | g_string_append (s, "\\a")(__builtin_constant_p ("\\a") ? __extension__ ({ const char * const __val = ("\\a"); g_string_append_len_inline (s, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val) )) : (gssize) -1); }) : g_string_append_len_inline (s, "\\a", (gssize) -1)); |
4418 | break; |
4419 | case '"': |
4420 | g_string_append (s, "\\q")(__builtin_constant_p ("\\q") ? __extension__ ({ const char * const __val = ("\\q"); g_string_append_len_inline (s, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val) )) : (gssize) -1); }) : g_string_append_len_inline (s, "\\q", (gssize) -1)); |
4421 | break; |
4422 | default: |
4423 | g_string_append_c (s, *action_path)g_string_append_c_inline (s, *action_path); |
4424 | } |
4425 | |
4426 | action_path ++; |
4427 | } |
4428 | return g_string_free (s, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((s), ( (0))) : g_string_free_and_steal (s)) : (g_string_free) ((s), ( (0)))); |
4429 | } |
4430 | |
4431 | |
4432 | static void |
4433 | add_submenu (CtkUIManager *ui_manager, |
4434 | CtkActionGroup *action_group, |
4435 | guint merge_id, |
4436 | const char *parent_path, |
4437 | const char *uri, |
4438 | const char *label, |
4439 | cairo_surface_t *surface, |
4440 | gboolean add_action) |
4441 | { |
4442 | if (parent_path != NULL((void*)0)) { |
4443 | char *escaped_label; |
4444 | char *action_name; |
4445 | char *submenu_name; |
4446 | char *escaped_submenu_name; |
4447 | |
4448 | action_name = escape_action_name (uri, "submenu_"); |
4449 | submenu_name = g_path_get_basename (uri); |
4450 | escaped_submenu_name = escape_action_path (submenu_name); |
4451 | escaped_label = eel_str_double_underscores (label); |
4452 | |
4453 | if (add_action) { |
4454 | CtkAction *action; |
4455 | |
4456 | action = ctk_action_new (action_name, |
4457 | escaped_label, |
4458 | NULL((void*)0), |
4459 | NULL((void*)0)); |
4460 | if (surface != NULL((void*)0)) { |
4461 | g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "menu-icon", |
4462 | cairo_surface_reference (surface), |
4463 | (GDestroyNotify)cairo_surface_destroy); |
4464 | } |
4465 | |
4466 | g_object_set (action, "hide-if-empty", FALSE(0), NULL((void*)0)); |
4467 | |
4468 | ctk_action_group_add_action (action_group, |
4469 | action); |
4470 | g_object_unref (action); |
4471 | } |
4472 | |
4473 | ctk_ui_manager_add_ui (ui_manager, |
4474 | merge_id, |
4475 | parent_path, |
4476 | escaped_submenu_name, |
4477 | action_name, |
4478 | CTK_UI_MANAGER_MENU, |
4479 | FALSE(0)); |
4480 | g_free (action_name); |
4481 | g_free (escaped_label); |
4482 | g_free (submenu_name); |
4483 | g_free (escaped_submenu_name); |
4484 | } |
4485 | } |
4486 | |
4487 | static void |
4488 | add_application_to_open_with_menu (FMDirectoryView *view, |
4489 | GAppInfo *application, |
4490 | GList *files, |
4491 | int index, |
4492 | const char *menu_placeholder, |
4493 | const char *popup_placeholder, |
4494 | const gboolean submenu) |
4495 | { |
4496 | ApplicationLaunchParameters *launch_parameters; |
4497 | char *tip; |
4498 | char *label; |
4499 | char *action_name; |
4500 | char *escaped_app; |
4501 | char *path; |
4502 | CtkAction *action; |
4503 | GIcon *app_icon; |
4504 | CtkWidget *menuitem; |
4505 | |
4506 | launch_parameters = application_launch_parameters_new |
4507 | (application, files, view); |
4508 | escaped_app = eel_str_double_underscores (g_app_info_get_display_name (application)); |
4509 | if (submenu) |
4510 | label = g_strdup_printf ("%s", escaped_app); |
4511 | else |
4512 | label = g_strdup_printf (_("Open With %s")gettext ("Open With %s"), escaped_app); |
4513 | |
4514 | tip = g_strdup_printf (ngettext ("Use \"%s\" to open the selected item", |
4515 | "Use \"%s\" to open the selected items", |
4516 | g_list_length (files)), |
4517 | escaped_app); |
4518 | g_free (escaped_app); |
4519 | |
4520 | action_name = g_strdup_printf ("open_with_%d", index); |
4521 | |
4522 | action = ctk_action_new (action_name, |
4523 | label, |
4524 | tip, |
4525 | NULL((void*)0)); |
4526 | |
4527 | app_icon = g_app_info_get_icon (application); |
4528 | if (app_icon != NULL((void*)0)) { |
4529 | g_object_ref (app_icon)((__typeof__ (app_icon)) (g_object_ref) (app_icon)); |
4530 | } else { |
4531 | app_icon = g_themed_icon_new ("application-x-executable"); |
4532 | } |
4533 | |
4534 | ctk_action_set_gicon (action, app_icon); |
4535 | g_object_unref (app_icon); |
4536 | |
4537 | g_signal_connect_data (action, "activate", |
4538 | G_CALLBACK (open_with_launch_application_callback)((GCallback) (open_with_launch_application_callback)), |
4539 | launch_parameters, |
4540 | (GClosureNotify)application_launch_parameters_free, 0); |
4541 | |
4542 | ctk_action_group_add_action (view->details->open_with_action_group, |
4543 | action); |
4544 | g_object_unref (action); |
4545 | |
4546 | ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window), |
4547 | view->details->open_with_merge_id, |
4548 | menu_placeholder, |
4549 | action_name, |
4550 | action_name, |
4551 | CTK_UI_MANAGER_MENUITEM, |
4552 | FALSE(0)); |
4553 | |
4554 | path = g_strdup_printf ("%s/%s", menu_placeholder, action_name); |
4555 | menuitem = ctk_ui_manager_get_widget ( |
4556 | baul_window_info_get_ui_manager (view->details->window), |
4557 | path); |
4558 | ctk_image_menu_item_set_always_show_image (CTK_IMAGE_MENU_ITEM (menuitem)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_image_menu_item_get_type ( ))))))), TRUE(!(0))); |
4559 | g_free (path); |
4560 | |
4561 | ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window), |
4562 | view->details->open_with_merge_id, |
4563 | popup_placeholder, |
4564 | action_name, |
4565 | action_name, |
4566 | CTK_UI_MANAGER_MENUITEM, |
4567 | FALSE(0)); |
4568 | |
4569 | path = g_strdup_printf ("%s/%s", popup_placeholder, action_name); |
4570 | menuitem = ctk_ui_manager_get_widget ( |
4571 | baul_window_info_get_ui_manager (view->details->window), |
4572 | path); |
4573 | ctk_image_menu_item_set_always_show_image (CTK_IMAGE_MENU_ITEM (menuitem)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_image_menu_item_get_type ( ))))))), TRUE(!(0))); |
4574 | |
4575 | g_free (path); |
4576 | g_free (action_name); |
4577 | g_free (label); |
4578 | g_free (tip); |
4579 | } |
4580 | |
4581 | static void |
4582 | add_parent_folder_to_open_menu (FMDirectoryView *view, |
4583 | GList *files, |
4584 | const char *menu_placeholder, |
4585 | const char *popup_placeholder) |
4586 | { |
4587 | BaulFile *file; |
4588 | gchar *uri; |
4589 | char *tip; |
4590 | char *label; |
4591 | char *action_name; |
4592 | char *path; |
4593 | CtkAction *action; |
4594 | CtkWidget *menuitem; |
4595 | |
4596 | file = g_list_first(files)->data; |
4597 | |
4598 | if (baul_file_is_directory (file)) |
4599 | return; |
4600 | |
4601 | uri = baul_file_get_parent_uri (file); |
4602 | |
4603 | label = g_strdup (_("Open parent location"))g_strdup_inline (gettext ("Open parent location")); |
4604 | tip = g_strdup (_("Open parent location for the selected item"))g_strdup_inline (gettext ("Open parent location for the selected item" )); |
4605 | action_name = g_strdup ("open_location")g_strdup_inline ("open_location"); |
4606 | |
4607 | action = ctk_action_new (action_name, |
4608 | label, |
4609 | tip, |
4610 | NULL((void*)0)); |
4611 | |
4612 | ctk_action_set_icon_name (action, "folder"); |
4613 | |
4614 | g_signal_connect_data (action, "activate", |
4615 | G_CALLBACK (open_parent_folder_callback)((GCallback) (open_parent_folder_callback)), |
4616 | uri, (GClosureNotify)g_free, 0); |
4617 | |
4618 | ctk_action_group_add_action (view->details->open_with_action_group, |
4619 | action); |
4620 | g_object_unref (action); |
4621 | |
4622 | ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window), |
4623 | view->details->open_with_merge_id, |
4624 | menu_placeholder, |
4625 | action_name, |
4626 | action_name, |
4627 | CTK_UI_MANAGER_MENUITEM, |
4628 | FALSE(0)); |
4629 | |
4630 | path = g_strdup_printf ("%s/%s", menu_placeholder, action_name); |
4631 | menuitem = ctk_ui_manager_get_widget ( |
4632 | baul_window_info_get_ui_manager (view->details->window), |
4633 | path); |
4634 | ctk_image_menu_item_set_always_show_image (CTK_IMAGE_MENU_ITEM (menuitem)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_image_menu_item_get_type ( ))))))), TRUE(!(0))); |
4635 | g_free (path); |
4636 | |
4637 | ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window), |
4638 | view->details->open_with_merge_id, |
4639 | popup_placeholder, |
4640 | action_name, |
4641 | action_name, |
4642 | CTK_UI_MANAGER_MENUITEM, |
4643 | FALSE(0)); |
4644 | |
4645 | path = g_strdup_printf ("%s/%s", popup_placeholder, action_name); |
4646 | menuitem = ctk_ui_manager_get_widget ( |
4647 | baul_window_info_get_ui_manager (view->details->window), |
4648 | path); |
4649 | ctk_image_menu_item_set_always_show_image (CTK_IMAGE_MENU_ITEM (menuitem)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_image_menu_item_get_type ( ))))))), TRUE(!(0))); |
4650 | |
4651 | g_free (path); |
4652 | g_free (action_name); |
4653 | g_free (label); |
4654 | g_free (tip); |
4655 | } |
4656 | |
4657 | static void |
4658 | get_x_content_async_callback (char **content G_GNUC_UNUSED__attribute__ ((__unused__)), |
4659 | gpointer user_data) |
4660 | { |
4661 | FMDirectoryView *view; |
4662 | |
4663 | view = FM_DIRECTORY_VIEW (user_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), (fm_directory_view_get_type()))))); |
4664 | |
4665 | if (view->details->window != NULL((void*)0)) { |
4666 | schedule_update_menus (view); |
4667 | } |
4668 | g_object_unref (view); |
4669 | } |
4670 | |
4671 | static void |
4672 | add_x_content_apps (FMDirectoryView *view, BaulFile *file, GList **applications) |
4673 | { |
4674 | GMount *mount; |
4675 | char **x_content_types; |
4676 | |
4677 | g_return_if_fail (applications != NULL)do { if ((applications != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "applications != NULL" ); return; } } while (0); |
4678 | |
4679 | mount = baul_file_get_mount (file); |
4680 | |
4681 | if (mount == NULL((void*)0)) { |
4682 | return; |
4683 | } |
4684 | |
4685 | x_content_types = baul_autorun_get_cached_x_content_types_for_mount (mount); |
4686 | if (x_content_types != NULL((void*)0)) { |
4687 | unsigned int n; |
4688 | |
4689 | for (n = 0; x_content_types[n] != NULL((void*)0); n++) { |
4690 | char *x_content_type = x_content_types[n]; |
4691 | GList *app_info_for_x_content_type; |
4692 | |
4693 | app_info_for_x_content_type = g_app_info_get_all_for_type (x_content_type); |
4694 | *applications = g_list_concat (*applications, app_info_for_x_content_type); |
4695 | } |
4696 | g_strfreev (x_content_types); |
4697 | } else { |
4698 | baul_autorun_get_x_content_types_for_mount_async (mount, |
4699 | get_x_content_async_callback, |
4700 | NULL((void*)0), |
4701 | g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view))); |
4702 | |
4703 | } |
4704 | |
4705 | g_object_unref (mount); |
4706 | } |
4707 | |
4708 | static void |
4709 | reset_open_with_menu (FMDirectoryView *view, GList *selection) |
4710 | { |
4711 | GList *applications, *node; |
4712 | gboolean submenu_visible, filter_default; |
4713 | int num_applications; |
4714 | int index; |
4715 | gboolean other_applications_visible; |
4716 | gboolean open_with_chooser_visible; |
4717 | CtkUIManager *ui_manager; |
4718 | CtkAction *action; |
4719 | GAppInfo *default_app; |
4720 | |
4721 | /* Clear any previous inserted items in the applications and viewers placeholders */ |
4722 | |
4723 | ui_manager = baul_window_info_get_ui_manager (view->details->window); |
4724 | baul_ui_unmerge_ui (ui_manager, |
4725 | &view->details->open_with_merge_id, |
4726 | &view->details->open_with_action_group); |
4727 | |
4728 | baul_ui_prepare_merge_ui (ui_manager, |
4729 | "OpenWithGroup", |
4730 | &view->details->open_with_merge_id, |
4731 | &view->details->open_with_action_group); |
4732 | |
4733 | num_applications = 0; |
Value stored to 'num_applications' is never read | |
4734 | |
4735 | other_applications_visible = (selection != NULL((void*)0)); |
4736 | filter_default = (selection != NULL((void*)0)); |
4737 | |
4738 | default_app = NULL((void*)0); |
4739 | if (filter_default) { |
4740 | default_app = baul_mime_get_default_application_for_files (selection); |
4741 | } |
4742 | |
4743 | applications = NULL((void*)0); |
4744 | if (other_applications_visible) { |
4745 | applications = baul_mime_get_applications_for_files (selection); |
4746 | } |
4747 | |
4748 | if (g_list_length (selection) == 1) { |
4749 | add_x_content_apps (view, BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type()))))), &applications); |
4750 | } |
4751 | |
4752 | |
4753 | num_applications = g_list_length (applications); |
4754 | |
4755 | if (file_list_all_are_folders (selection)) { |
4756 | submenu_visible = (num_applications > 2); |
4757 | } else { |
4758 | submenu_visible = (num_applications > 3); |
4759 | } |
4760 | |
4761 | for (node = applications, index = 0; node != NULL((void*)0); node = node->next, index++) { |
4762 | GAppInfo *application; |
4763 | char *menu_path; |
4764 | char *popup_path; |
4765 | |
4766 | application = node->data; |
4767 | |
4768 | if (default_app != NULL((void*)0) && g_app_info_equal (default_app, application)) { |
4769 | continue; |
4770 | } |
4771 | |
4772 | if (submenu_visible) { |
4773 | menu_path = FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER"/MenuBar/File/Open Placeholder/Open With/Applications Placeholder"; |
4774 | popup_path = FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER"/selection/Open Placeholder/Open With/Applications Placeholder"; |
4775 | } else { |
4776 | menu_path = FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER"/MenuBar/File/Open Placeholder/Applications Placeholder"; |
4777 | popup_path = FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER"/selection/Open Placeholder/Applications Placeholder"; |
4778 | } |
4779 | |
4780 | ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window), |
4781 | view->details->open_with_merge_id, |
4782 | menu_path, |
4783 | "separator", |
4784 | NULL((void*)0), |
4785 | CTK_UI_MANAGER_SEPARATOR, |
4786 | FALSE(0)); |
4787 | |
4788 | add_application_to_open_with_menu (view, |
4789 | node->data, |
4790 | selection, |
4791 | index, |
4792 | menu_path, popup_path, submenu_visible); |
4793 | |
4794 | } |
4795 | g_list_free_full (applications, g_object_unref); |
4796 | if (default_app != NULL((void*)0)) { |
4797 | g_object_unref (default_app); |
4798 | } |
4799 | |
4800 | /* Show open parent folder action if we are in search mode */ |
4801 | if (eel_uri_is_search (fm_directory_view_get_uri (view)) && g_list_length (selection) == 1) |
4802 | add_parent_folder_to_open_menu (view, |
4803 | selection, |
4804 | FM_DIRECTORY_VIEW_MENU_PATH_OPEN"/MenuBar/File/Open Placeholder/Open", |
4805 | FM_DIRECTORY_VIEW_POPUP_PATH_OPEN"/selection/Open Placeholder/Open"); |
4806 | |
4807 | open_with_chooser_visible = other_applications_visible && |
4808 | g_list_length (selection) == 1; |
4809 | |
4810 | if (submenu_visible) { |
4811 | action = ctk_action_group_get_action (view->details->dir_action_group, |
4812 | FM_ACTION_OTHER_APPLICATION1"OtherApplication1"); |
4813 | ctk_action_set_visible (action, open_with_chooser_visible); |
4814 | action = ctk_action_group_get_action (view->details->dir_action_group, |
4815 | FM_ACTION_OTHER_APPLICATION2"OtherApplication2"); |
4816 | ctk_action_set_visible (action, FALSE(0)); |
4817 | } else { |
4818 | action = ctk_action_group_get_action (view->details->dir_action_group, |
4819 | FM_ACTION_OTHER_APPLICATION1"OtherApplication1"); |
4820 | ctk_action_set_visible (action, FALSE(0)); |
4821 | action = ctk_action_group_get_action (view->details->dir_action_group, |
4822 | FM_ACTION_OTHER_APPLICATION2"OtherApplication2"); |
4823 | ctk_action_set_visible (action, open_with_chooser_visible); |
4824 | } |
4825 | } |
4826 | |
4827 | static GList * |
4828 | get_all_extension_menu_items (CtkWidget *window, |
4829 | GList *selection) |
4830 | { |
4831 | GList *items; |
4832 | GList *providers; |
4833 | GList *l; |
4834 | |
4835 | providers = baul_extensions_get_for_type (BAUL_TYPE_MENU_PROVIDER(baul_menu_provider_get_type ())); |
4836 | items = NULL((void*)0); |
4837 | |
4838 | for (l = providers; l != NULL((void*)0); l = l->next) { |
4839 | BaulMenuProvider *provider; |
4840 | GList *file_items; |
4841 | |
4842 | provider = BAUL_MENU_PROVIDER (l->data)((((BaulMenuProvider*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((l->data)), ((baul_menu_provider_get_type ())))))); |
4843 | file_items = baul_menu_provider_get_file_items (provider, |
4844 | window, |
4845 | selection); |
4846 | items = g_list_concat (items, file_items); |
4847 | } |
4848 | |
4849 | baul_module_extension_list_free (providers); |
4850 | |
4851 | return items; |
4852 | } |
4853 | |
4854 | typedef struct |
4855 | { |
4856 | BaulMenuItem *item; |
4857 | FMDirectoryView *view; |
4858 | GList *selection; |
4859 | CtkAction *action; |
4860 | } ExtensionActionCallbackData; |
4861 | |
4862 | |
4863 | static void |
4864 | extension_action_callback_data_free (ExtensionActionCallbackData *data) |
4865 | { |
4866 | g_object_unref (data->item); |
4867 | baul_file_list_free (data->selection); |
4868 | |
4869 | g_free (data); |
4870 | } |
4871 | |
4872 | static gboolean |
4873 | search_in_menu_items (GList* items, const char *item_name) |
4874 | { |
4875 | GList* list; |
4876 | |
4877 | for (list = items; list != NULL((void*)0); list = list->next) { |
4878 | BaulMenu* menu; |
4879 | char *name; |
4880 | |
4881 | g_object_get (list->data, "name", &name, NULL((void*)0)); |
4882 | if (strcmp (name, item_name) == 0) { |
4883 | g_free (name); |
4884 | return TRUE(!(0)); |
4885 | } |
4886 | g_free (name); |
4887 | |
4888 | menu = NULL((void*)0); |
4889 | g_object_get (list->data, "menu", &menu, NULL((void*)0)); |
4890 | if (menu != NULL((void*)0)) { |
4891 | gboolean ret; |
4892 | GList* submenus; |
4893 | |
4894 | submenus = baul_menu_get_items (menu); |
4895 | ret = search_in_menu_items (submenus, item_name); |
4896 | baul_menu_item_list_free (submenus); |
4897 | g_object_unref (menu); |
4898 | if (ret) { |
4899 | return TRUE(!(0)); |
4900 | } |
4901 | } |
4902 | } |
4903 | return FALSE(0); |
4904 | } |
4905 | |
4906 | static void |
4907 | extension_action_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
4908 | gpointer callback_data) |
4909 | { |
4910 | ExtensionActionCallbackData *data; |
4911 | char *item_name; |
4912 | gboolean is_valid; |
4913 | GList *l; |
4914 | GList *items; |
4915 | |
4916 | data = callback_data; |
4917 | |
4918 | /* Make sure the selected menu item is valid for the final sniffed |
4919 | * mime type */ |
4920 | g_object_get (data->item, "name", &item_name, NULL((void*)0)); |
4921 | items = get_all_extension_menu_items (ctk_widget_get_toplevel (CTK_WIDGET (data->view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->view)), ((ctk_widget_get_type ()))))))), |
4922 | data->selection); |
4923 | |
4924 | is_valid = search_in_menu_items (items, item_name); |
4925 | |
4926 | for (l = items; l != NULL((void*)0); l = l->next) { |
4927 | g_object_unref (l->data); |
4928 | } |
4929 | g_list_free (items); |
4930 | |
4931 | g_free (item_name); |
4932 | |
4933 | if (is_valid) { |
4934 | baul_menu_item_activate (data->item); |
4935 | } |
4936 | } |
4937 | |
4938 | static cairo_surface_t * |
4939 | get_menu_icon (const char *icon_name, |
4940 | CtkWidget *widget) |
4941 | { |
4942 | BaulIconInfo *info; |
4943 | cairo_surface_t *surface; |
4944 | int size, scale; |
4945 | |
4946 | size = baul_get_icon_size_for_stock_size (CTK_ICON_SIZE_MENU); |
4947 | scale = ctk_widget_get_scale_factor (widget); |
4948 | |
4949 | if (g_path_is_absolute (icon_name)) { |
4950 | info = baul_icon_info_lookup_from_path (icon_name, size, scale); |
4951 | } else { |
4952 | info = baul_icon_info_lookup_from_name (icon_name, size, scale); |
4953 | } |
4954 | surface = baul_icon_info_get_surface_nodefault_at_size (info, size); |
4955 | g_object_unref (info); |
4956 | |
4957 | return surface; |
4958 | } |
4959 | |
4960 | static cairo_surface_t * |
4961 | get_menu_icon_for_file (BaulFile *file, |
4962 | CtkWidget *widget) |
4963 | { |
4964 | BaulIconInfo *info; |
4965 | cairo_surface_t *surface; |
4966 | int size, scale; |
4967 | |
4968 | size = baul_get_icon_size_for_stock_size (CTK_ICON_SIZE_MENU); |
4969 | scale = ctk_widget_get_scale_factor (widget); |
4970 | |
4971 | info = baul_file_get_icon (file, size, scale, 0); |
4972 | surface = baul_icon_info_get_surface_nodefault_at_size (info, size); |
4973 | g_object_unref (info); |
4974 | |
4975 | return surface; |
4976 | } |
4977 | |
4978 | static CtkAction * |
4979 | add_extension_action_for_files (FMDirectoryView *view, |
4980 | BaulMenuItem *item, |
4981 | GList *files) |
4982 | { |
4983 | char *name, *label, *tip, *icon; |
4984 | gboolean sensitive, priority; |
4985 | CtkAction *action; |
4986 | ExtensionActionCallbackData *data; |
4987 | |
4988 | g_object_get (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((item)), (((GType) ((20) << (2)))))))), |
4989 | "name", &name, "label", &label, |
4990 | "tip", &tip, "icon", &icon, |
4991 | "sensitive", &sensitive, |
4992 | "priority", &priority, |
4993 | NULL((void*)0)); |
4994 | |
4995 | action = ctk_action_new (name, |
4996 | label, |
4997 | tip, |
4998 | icon); |
4999 | |
5000 | if (icon != NULL((void*)0)) { |
5001 | cairo_surface_t *surface; |
5002 | |
5003 | surface = get_menu_icon (icon, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
5004 | |
5005 | if (surface != NULL((void*)0)) { |
5006 | g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "menu-icon", |
5007 | surface, |
5008 | (GDestroyNotify)cairo_surface_destroy); |
5009 | } |
5010 | } |
5011 | |
5012 | ctk_action_set_sensitive (action, sensitive); |
5013 | g_object_set (action, "is-important", priority, NULL((void*)0)); |
5014 | |
5015 | data = g_new0 (ExtensionActionCallbackData, 1)((ExtensionActionCallbackData *) g_malloc0_n ((1), sizeof (ExtensionActionCallbackData ))); |
5016 | data->item = g_object_ref (item)((__typeof__ (item)) (g_object_ref) (item)); |
5017 | data->view = view; |
5018 | data->selection = baul_file_list_copy (files); |
5019 | data->action = action; |
5020 | |
5021 | g_signal_connect_data (action, "activate", |
5022 | G_CALLBACK (extension_action_callback)((GCallback) (extension_action_callback)), |
5023 | data, |
5024 | (GClosureNotify)extension_action_callback_data_free, 0); |
5025 | |
5026 | ctk_action_group_add_action (view->details->extensions_menu_action_group, |
5027 | CTK_ACTION (action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_action_get_type ()))))))); |
5028 | g_object_unref (action); |
5029 | |
5030 | g_free (name); |
5031 | g_free (label); |
5032 | g_free (tip); |
5033 | g_free (icon); |
5034 | |
5035 | return action; |
5036 | } |
5037 | |
5038 | static void |
5039 | add_extension_menu_items (FMDirectoryView *view, |
5040 | GList *files, |
5041 | GList *menu_items, |
5042 | const char *subdirectory) |
5043 | { |
5044 | CtkUIManager *ui_manager; |
5045 | GList *l; |
5046 | |
5047 | ui_manager = baul_window_info_get_ui_manager (view->details->window); |
5048 | |
5049 | for (l = menu_items; l; l = l->next) { |
5050 | BaulMenuItem *item; |
5051 | BaulMenu *menu; |
5052 | CtkAction *action; |
5053 | const gchar *action_name; |
5054 | char *path; |
5055 | |
5056 | item = BAUL_MENU_ITEM (l->data)((((BaulMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((baul_menu_item_get_type())))))); |
5057 | |
5058 | g_object_get (item, "menu", &menu, NULL((void*)0)); |
5059 | |
5060 | action = add_extension_action_for_files (view, item, files); |
5061 | |
5062 | path = g_build_path ("/", FM_DIRECTORY_VIEW_POPUP_PATH_EXTENSION_ACTIONS"/selection/Extension Actions", subdirectory, NULL((void*)0)); |
5063 | action_name = ctk_action_get_name (action); |
5064 | |
5065 | ctk_ui_manager_add_ui (ui_manager, |
5066 | view->details->extensions_menu_merge_id, |
5067 | path, |
5068 | action_name, |
5069 | action_name, |
5070 | (menu != NULL((void*)0)) ? CTK_UI_MANAGER_MENU : CTK_UI_MANAGER_MENUITEM, |
5071 | FALSE(0)); |
5072 | g_free (path); |
5073 | |
5074 | path = g_build_path ("/", FM_DIRECTORY_VIEW_MENU_PATH_EXTENSION_ACTIONS_PLACEHOLDER"/MenuBar/Edit/Extension Actions", subdirectory, NULL((void*)0)); |
5075 | ctk_ui_manager_add_ui (ui_manager, |
5076 | view->details->extensions_menu_merge_id, |
5077 | path, |
5078 | action_name, |
5079 | action_name, |
5080 | (menu != NULL((void*)0)) ? CTK_UI_MANAGER_MENU : CTK_UI_MANAGER_MENUITEM, |
5081 | FALSE(0)); |
5082 | g_free (path); |
5083 | |
5084 | /* recursively fill the menu */ |
5085 | if (menu != NULL((void*)0)) { |
5086 | char *subdir; |
5087 | GList *children; |
5088 | |
5089 | children = baul_menu_get_items (menu); |
5090 | |
5091 | subdir = g_build_path ("/", subdirectory, ctk_action_get_name (action), NULL((void*)0)); |
5092 | add_extension_menu_items (view, |
5093 | files, |
5094 | children, |
5095 | subdir); |
5096 | |
5097 | baul_menu_item_list_free (children); |
5098 | g_free (subdir); |
5099 | } |
5100 | } |
5101 | } |
5102 | |
5103 | static void |
5104 | reset_extension_actions_menu (FMDirectoryView *view, GList *selection) |
5105 | { |
5106 | GList *items; |
5107 | CtkUIManager *ui_manager; |
5108 | |
5109 | /* Clear any previous inserted items in the extension actions placeholder */ |
5110 | ui_manager = baul_window_info_get_ui_manager (view->details->window); |
5111 | |
5112 | baul_ui_unmerge_ui (ui_manager, |
5113 | &view->details->extensions_menu_merge_id, |
5114 | &view->details->extensions_menu_action_group); |
5115 | |
5116 | baul_ui_prepare_merge_ui (ui_manager, |
5117 | "DirExtensionsMenuGroup", |
5118 | &view->details->extensions_menu_merge_id, |
5119 | &view->details->extensions_menu_action_group); |
5120 | |
5121 | items = get_all_extension_menu_items (ctk_widget_get_toplevel (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))), |
5122 | selection); |
5123 | if (items != NULL((void*)0)) { |
5124 | add_extension_menu_items (view, selection, items, ""); |
5125 | |
5126 | g_list_free_full (items, g_object_unref); |
5127 | } |
5128 | } |
5129 | |
5130 | static char * |
5131 | change_to_view_directory (FMDirectoryView *view) |
5132 | { |
5133 | char *path; |
5134 | char *old_path; |
5135 | |
5136 | old_path = g_get_current_dir (); |
5137 | |
5138 | path = get_view_directory (view); |
5139 | |
5140 | /* FIXME: What to do about non-local directories? */ |
5141 | if (path != NULL((void*)0)) { |
5142 | g_chdir (path); |
5143 | } |
5144 | |
5145 | g_free (path); |
5146 | |
5147 | return old_path; |
5148 | } |
5149 | |
5150 | static char ** |
5151 | get_file_names_as_parameter_array (GList *selection, |
5152 | BaulDirectory *model) |
5153 | { |
5154 | char **parameters; |
5155 | GList *node; |
5156 | GFile *model_location; |
5157 | int i; |
5158 | BaulFile *file = NULL((void*)0); |
5159 | GFile *file_location = NULL((void*)0); |
5160 | |
5161 | if (model == NULL((void*)0)) { |
5162 | return NULL((void*)0); |
5163 | } |
5164 | |
5165 | parameters = g_new (char *, g_list_length (selection) + 1)((char * *) g_malloc_n ((g_list_length (selection) + 1), sizeof (char *))); |
5166 | |
5167 | model_location = baul_directory_get_location (model); |
5168 | |
5169 | for (node = selection, i = 0; node != NULL((void*)0); node = node->next, i++) { |
5170 | file = BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), (baul_file_get_type()))))); |
5171 | |
5172 | if (!baul_file_is_local (file)) { |
5173 | parameters[i] = NULL((void*)0); |
5174 | g_strfreev (parameters); |
5175 | return NULL((void*)0); |
5176 | } |
5177 | |
5178 | file_location = baul_file_get_location (BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), (baul_file_get_type())))))); |
5179 | parameters[i] = g_file_get_relative_path (model_location, file_location); |
5180 | if (parameters[i] == NULL((void*)0)) { |
5181 | parameters[i] = g_file_get_path (file_location); |
5182 | } |
5183 | g_object_unref (file_location); |
5184 | } |
5185 | |
5186 | g_object_unref (model_location); |
5187 | |
5188 | parameters[i] = NULL((void*)0); |
5189 | return parameters; |
5190 | } |
5191 | |
5192 | static char * |
5193 | get_file_paths_or_uris_as_newline_delimited_string (GList *selection, gboolean get_paths) |
5194 | { |
5195 | char *path; |
5196 | char *result; |
5197 | BaulDesktopLink *link; |
5198 | GString *expanding_string; |
5199 | GList *node; |
5200 | GFile *location; |
5201 | |
5202 | expanding_string = g_string_new (""); |
5203 | for (node = selection; node != NULL((void*)0); node = node->next) { |
5204 | char *uri; |
5205 | |
5206 | uri = NULL((void*)0); |
5207 | |
5208 | if (BAUL_IS_DESKTOP_ICON_FILE (node->data)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (node->data)); GType __t = (baul_desktop_icon_file_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
5209 | link = baul_desktop_icon_file_get_link (BAUL_DESKTOP_ICON_FILE (node->data)((((BaulDesktopIconFile*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((node->data)), (baul_desktop_icon_file_get_type ())))))); |
5210 | if (link != NULL((void*)0)) { |
5211 | location = baul_desktop_link_get_activation_location (link); |
5212 | uri = g_file_get_uri (location); |
5213 | g_object_unref (location); |
5214 | g_object_unref (G_OBJECT (link)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((link)), (((GType) ((20) << (2))))))))); |
5215 | } |
5216 | } else { |
5217 | uri = baul_file_get_uri (BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), (baul_file_get_type())))))); |
5218 | } |
5219 | if (uri == NULL((void*)0)) { |
5220 | continue; |
5221 | } |
5222 | |
5223 | if (get_paths) { |
5224 | path = g_filename_from_uri (uri, NULL((void*)0), NULL((void*)0)); |
5225 | if (path != NULL((void*)0)) { |
5226 | g_string_append (expanding_string, path)(__builtin_constant_p (path) ? __extension__ ({ const char * const __val = (path); g_string_append_len_inline (expanding_string , __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + ! (__val))) : (gssize) -1); }) : g_string_append_len_inline (expanding_string , path, (gssize) -1)); |
5227 | g_free (path); |
5228 | g_string_append (expanding_string, "\n")(__builtin_constant_p ("\n") ? __extension__ ({ const char * const __val = ("\n"); g_string_append_len_inline (expanding_string , __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + ! (__val))) : (gssize) -1); }) : g_string_append_len_inline (expanding_string , "\n", (gssize) -1)); |
5229 | } |
5230 | } else { |
5231 | g_string_append (expanding_string, uri)(__builtin_constant_p (uri) ? __extension__ ({ const char * const __val = (uri); g_string_append_len_inline (expanding_string, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + ! (__val))) : (gssize) -1); }) : g_string_append_len_inline (expanding_string , uri, (gssize) -1)); |
5232 | g_string_append (expanding_string, "\n")(__builtin_constant_p ("\n") ? __extension__ ({ const char * const __val = ("\n"); g_string_append_len_inline (expanding_string , __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + ! (__val))) : (gssize) -1); }) : g_string_append_len_inline (expanding_string , "\n", (gssize) -1)); |
5233 | } |
5234 | g_free (uri); |
5235 | } |
5236 | |
5237 | result = expanding_string->str; |
5238 | g_string_free (expanding_string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((expanding_string ), ((0))) : g_string_free_and_steal (expanding_string)) : (g_string_free ) ((expanding_string), ((0)))); |
5239 | |
5240 | return result; |
5241 | } |
5242 | |
5243 | static char * |
5244 | get_file_paths_as_newline_delimited_string (GList *selection) |
5245 | { |
5246 | return get_file_paths_or_uris_as_newline_delimited_string (selection, TRUE(!(0))); |
5247 | } |
5248 | |
5249 | static char * |
5250 | get_file_uris_as_newline_delimited_string (GList *selection) |
5251 | { |
5252 | return get_file_paths_or_uris_as_newline_delimited_string (selection, FALSE(0)); |
5253 | } |
5254 | |
5255 | /* returns newly allocated strings for setting the environment variables */ |
5256 | static void |
5257 | get_strings_for_environment_variables (FMDirectoryView *view, GList *selected_files, |
5258 | char **file_paths, char **uris, char **uri) |
5259 | { |
5260 | char *directory_uri; |
5261 | |
5262 | /* We need to check that the directory uri starts with "file:" since |
5263 | * baul_directory_is_local returns FALSE for nfs. |
5264 | */ |
5265 | directory_uri = baul_directory_get_uri (view->details->model); |
5266 | if (eel_str_has_prefix (directory_uri, "file:") || |
5267 | eel_uri_is_desktop (directory_uri) || |
5268 | eel_uri_is_trash (directory_uri)) { |
5269 | *file_paths = get_file_paths_as_newline_delimited_string (selected_files); |
5270 | } else { |
5271 | *file_paths = g_strdup ("")g_strdup_inline (""); |
5272 | } |
5273 | g_free (directory_uri); |
5274 | |
5275 | *uris = get_file_uris_as_newline_delimited_string (selected_files); |
5276 | |
5277 | *uri = baul_directory_get_uri (view->details->model); |
5278 | if (eel_uri_is_desktop (*uri)) { |
5279 | g_free (*uri); |
5280 | *uri = baul_get_desktop_directory_uri (); |
5281 | } |
5282 | } |
5283 | |
5284 | static FMDirectoryView * |
5285 | get_directory_view_of_extra_pane (FMDirectoryView *view) |
5286 | { |
5287 | BaulWindowSlotInfo *slot; |
5288 | |
5289 | slot = baul_window_info_get_extra_slot (fm_directory_view_get_baul_window (view)); |
5290 | if (slot != NULL((void*)0)) { |
5291 | BaulView *next_view; |
5292 | |
5293 | next_view = baul_window_slot_info_get_current_view (slot); |
5294 | |
5295 | if (FM_IS_DIRECTORY_VIEW (next_view)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (next_view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
5296 | return FM_DIRECTORY_VIEW (next_view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((next_view)), (fm_directory_view_get_type()))))); |
5297 | } |
5298 | } |
5299 | return NULL((void*)0); |
5300 | } |
5301 | |
5302 | /* |
5303 | * Set up some environment variables that scripts can use |
5304 | * to take advantage of the current Baul state. |
5305 | */ |
5306 | static void set_script_environment_variables(FMDirectoryView* view, GList* selected_files) |
5307 | { |
5308 | char* file_paths; |
5309 | char* uris; |
5310 | char* uri; |
5311 | char* geometry_string; |
5312 | FMDirectoryView* next_view; |
5313 | |
5314 | get_strings_for_environment_variables(view, selected_files, &file_paths, &uris, &uri); |
5315 | |
5316 | g_setenv("BAUL_SCRIPT_SELECTED_FILE_PATHS", file_paths, TRUE(!(0))); |
5317 | g_setenv("NAUTILUS_SCRIPT_SELECTED_FILE_PATHS", file_paths, TRUE(!(0))); // compatibilidad GNOME |
5318 | |
5319 | g_free(file_paths); |
5320 | |
5321 | g_setenv("BAUL_SCRIPT_SELECTED_URIS", uris, TRUE(!(0))); |
5322 | g_setenv("NAUTILUS_SCRIPT_SELECTED_URIS", uris, TRUE(!(0))); // compatibilidad GNOME |
5323 | |
5324 | g_free(uris); |
5325 | |
5326 | g_setenv("BAUL_SCRIPT_CURRENT_URI", uri, TRUE(!(0))); |
5327 | g_setenv("NAUTILUS_SCRIPT_CURRENT_URI", uri, TRUE(!(0))); // compatibilidad GNOME |
5328 | |
5329 | |
5330 | g_free(uri); |
5331 | |
5332 | geometry_string = eel_ctk_window_get_geometry_string(CTK_WINDOW (fm_directory_view_get_containing_window (view))((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((fm_directory_view_get_containing_window (view))), ((ctk_window_get_type ()))))))); |
5333 | |
5334 | g_setenv("BAUL_SCRIPT_WINDOW_GEOMETRY", geometry_string, TRUE(!(0))); |
5335 | g_setenv("NAUTILUS_SCRIPT_WINDOW_GEOMETRY", geometry_string, TRUE(!(0))); // compatibilidad GNOME |
5336 | |
5337 | g_free(geometry_string); |
5338 | |
5339 | /* next pane */ |
5340 | next_view = get_directory_view_of_extra_pane(view); |
5341 | |
5342 | if (next_view) |
5343 | { |
5344 | GList* next_pane_selected_files = fm_directory_view_get_selection (next_view); |
5345 | |
5346 | get_strings_for_environment_variables(next_view, next_pane_selected_files, &file_paths, &uris, &uri); |
5347 | |
5348 | baul_file_list_free(next_pane_selected_files); |
5349 | } |
5350 | else |
5351 | { |
5352 | file_paths = g_strdup("")g_strdup_inline (""); |
5353 | uris = g_strdup("")g_strdup_inline (""); |
5354 | uri = g_strdup("")g_strdup_inline (""); |
5355 | } |
5356 | |
5357 | g_setenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS", file_paths, TRUE(!(0))); |
5358 | g_setenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS", file_paths, TRUE(!(0))); // compatibilidad GNOME |
5359 | g_free(file_paths); |
5360 | |
5361 | g_setenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS", uris, TRUE(!(0))); |
5362 | g_setenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_URIS", uris, TRUE(!(0))); // compatibilidad GNOME |
5363 | g_free(uris); |
5364 | |
5365 | g_setenv("BAUL_SCRIPT_NEXT_PANE_CURRENT_URI", uri, TRUE(!(0))); |
5366 | g_setenv("NAUTILUS_SCRIPT_NEXT_PANE_CURRENT_URI", uri, TRUE(!(0))); // compatibilidad GNOME |
5367 | g_free(uri); |
5368 | } |
5369 | |
5370 | /* Unset all the special script environment variables. */ |
5371 | static void unset_script_environment_variables(void) |
5372 | { |
5373 | g_unsetenv("BAUL_SCRIPT_SELECTED_FILE_PATHS"); |
5374 | g_unsetenv("NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); |
5375 | |
5376 | g_unsetenv("BAUL_SCRIPT_SELECTED_URIS"); |
5377 | g_unsetenv("NAUTILUS_SCRIPT_SELECTED_URIS"); |
5378 | |
5379 | g_unsetenv("BAUL_SCRIPT_CURRENT_URI"); |
5380 | g_unsetenv("NAUTILUS_SCRIPT_CURRENT_URI"); |
5381 | |
5382 | g_unsetenv("BAUL_SCRIPT_WINDOW_GEOMETRY"); |
5383 | g_unsetenv("NAUTILUS_SCRIPT_WINDOW_GEOMETRY"); |
5384 | |
5385 | g_unsetenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS"); |
5386 | g_unsetenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS"); |
5387 | |
5388 | g_unsetenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS"); |
5389 | g_unsetenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_URIS"); |
5390 | |
5391 | g_unsetenv("BAUL_SCRIPT_NEXT_PANE_CURRENT_URI"); |
5392 | g_unsetenv("NAUTILUS_SCRIPT_NEXT_PANE_CURRENT_URI"); |
5393 | } |
5394 | |
5395 | static void |
5396 | run_script_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
5397 | gpointer callback_data) |
5398 | { |
5399 | ScriptLaunchParameters *launch_parameters; |
5400 | CdkScreen *screen; |
5401 | GList *selected_files; |
5402 | char *file_uri; |
5403 | char *local_file_path; |
5404 | char *quoted_path; |
5405 | char *old_working_dir; |
5406 | char **parameters, *name; |
5407 | CtkWindow *window; |
5408 | |
5409 | launch_parameters = (ScriptLaunchParameters *) callback_data; |
5410 | |
5411 | file_uri = baul_file_get_uri (launch_parameters->file); |
5412 | local_file_path = g_filename_from_uri (file_uri, NULL((void*)0), NULL((void*)0)); |
5413 | g_assert (local_file_path != NULL)do { if (local_file_path != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 5413, ((const char*) ( __func__)), "local_file_path != NULL"); } while (0); |
5414 | g_free (file_uri); |
5415 | |
5416 | quoted_path = g_shell_quote (local_file_path); |
5417 | |
5418 | old_working_dir = change_to_view_directory (launch_parameters->directory_view); |
5419 | |
5420 | selected_files = fm_directory_view_get_selection (launch_parameters->directory_view); |
5421 | set_script_environment_variables (launch_parameters->directory_view, selected_files); |
5422 | |
5423 | parameters = get_file_names_as_parameter_array (selected_files, |
5424 | launch_parameters->directory_view->details->model); |
5425 | |
5426 | screen = ctk_widget_get_screen (CTK_WIDGET (launch_parameters->directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((launch_parameters->directory_view)), ((ctk_widget_get_type ()))))))); |
5427 | |
5428 | name = baul_file_get_name (launch_parameters->file); |
5429 | /* FIXME: handle errors with dialog? Or leave up to each script? */ |
5430 | window = fm_directory_view_get_containing_window (launch_parameters->directory_view); |
5431 | baul_debug_log (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER", |
5432 | "directory view run_script_callback, window=%p, name=\"%s\", script_path=\"%s\" (omitting script parameters)", |
5433 | window, name, local_file_path); |
5434 | baul_launch_application_from_command_array (screen, name, quoted_path, FALSE(0), |
5435 | (const char * const *) parameters); |
5436 | g_free (local_file_path); |
5437 | g_free (name); |
5438 | g_strfreev (parameters); |
5439 | |
5440 | baul_file_list_free (selected_files); |
5441 | unset_script_environment_variables (); |
5442 | g_chdir (old_working_dir); |
5443 | g_free (old_working_dir); |
5444 | g_free (quoted_path); |
5445 | } |
5446 | |
5447 | static void |
5448 | add_script_to_scripts_menus (FMDirectoryView *directory_view, |
5449 | BaulFile *file, |
5450 | const char *menu_path, |
5451 | const char *popup_path, |
5452 | const char *popup_bg_path) |
5453 | { |
5454 | ScriptLaunchParameters *launch_parameters; |
5455 | char *tip; |
5456 | char *name; |
5457 | char *uri; |
5458 | char *action_name; |
5459 | char *escaped_label; |
5460 | cairo_surface_t *surface; |
5461 | CtkUIManager *ui_manager; |
5462 | CtkAction *action; |
5463 | |
5464 | name = baul_file_get_display_name (file); |
5465 | uri = baul_file_get_uri (file); |
5466 | tip = g_strdup_printf (_("Run \"%s\" on any selected items")gettext ("Run \"%s\" on any selected items"), name); |
5467 | |
5468 | launch_parameters = script_launch_parameters_new (file, directory_view); |
5469 | |
5470 | action_name = escape_action_name (uri, "script_"); |
5471 | escaped_label = eel_str_double_underscores (name); |
5472 | |
5473 | action = ctk_action_new (action_name, |
5474 | escaped_label, |
5475 | tip, |
5476 | NULL((void*)0)); |
5477 | |
5478 | surface = get_menu_icon_for_file (file, CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((directory_view)), ((ctk_widget_get_type ()))))))); |
5479 | if (surface != NULL((void*)0)) { |
5480 | g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "menu-icon", |
5481 | surface, |
5482 | (GDestroyNotify)cairo_surface_destroy); |
5483 | } |
5484 | |
5485 | g_signal_connect_data (action, "activate", |
5486 | G_CALLBACK (run_script_callback)((GCallback) (run_script_callback)), |
5487 | launch_parameters, |
5488 | (GClosureNotify)script_launch_parameters_free, 0); |
5489 | |
5490 | ctk_action_group_add_action_with_accel (directory_view->details->scripts_action_group, |
5491 | action, NULL((void*)0)); |
5492 | g_object_unref (action); |
5493 | |
5494 | ui_manager = baul_window_info_get_ui_manager (directory_view->details->window); |
5495 | |
5496 | ctk_ui_manager_add_ui (ui_manager, |
5497 | directory_view->details->scripts_merge_id, |
5498 | menu_path, |
5499 | action_name, |
5500 | action_name, |
5501 | CTK_UI_MANAGER_MENUITEM, |
5502 | FALSE(0)); |
5503 | ctk_ui_manager_add_ui (ui_manager, |
5504 | directory_view->details->scripts_merge_id, |
5505 | popup_path, |
5506 | action_name, |
5507 | action_name, |
5508 | CTK_UI_MANAGER_MENUITEM, |
5509 | FALSE(0)); |
5510 | ctk_ui_manager_add_ui (ui_manager, |
5511 | directory_view->details->scripts_merge_id, |
5512 | popup_bg_path, |
5513 | action_name, |
5514 | action_name, |
5515 | CTK_UI_MANAGER_MENUITEM, |
5516 | FALSE(0)); |
5517 | |
5518 | g_free (name); |
5519 | g_free (uri); |
5520 | g_free (tip); |
5521 | g_free (action_name); |
5522 | g_free (escaped_label); |
5523 | } |
5524 | |
5525 | static void |
5526 | add_submenu_to_directory_menus (FMDirectoryView *directory_view, |
5527 | CtkActionGroup *action_group, |
5528 | guint merge_id, |
5529 | BaulFile *file, |
5530 | const char *menu_path, |
5531 | const char *popup_path, |
5532 | const char *popup_bg_path) |
5533 | { |
5534 | char *name; |
5535 | cairo_surface_t *surface; |
5536 | char *uri; |
5537 | CtkUIManager *ui_manager; |
5538 | |
5539 | ui_manager = baul_window_info_get_ui_manager (directory_view->details->window); |
5540 | uri = baul_file_get_uri (file); |
5541 | name = baul_file_get_display_name (file); |
5542 | surface = get_menu_icon_for_file (file, CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((directory_view)), ((ctk_widget_get_type ()))))))); |
5543 | add_submenu (ui_manager, action_group, merge_id, menu_path, uri, name, surface, TRUE(!(0))); |
5544 | add_submenu (ui_manager, action_group, merge_id, popup_path, uri, name, surface, FALSE(0)); |
5545 | add_submenu (ui_manager, action_group, merge_id, popup_bg_path, uri, name, surface, FALSE(0)); |
5546 | if (surface) { |
5547 | cairo_surface_destroy (surface); |
5548 | } |
5549 | g_free (name); |
5550 | g_free (uri); |
5551 | } |
5552 | |
5553 | static gboolean |
5554 | directory_belongs_in_scripts_menu (const char *uri) |
5555 | { |
5556 | int num_levels; |
5557 | int i; |
5558 | |
5559 | if (!eel_str_has_prefix (uri, scripts_directory_uri)) { |
5560 | return FALSE(0); |
5561 | } |
5562 | |
5563 | num_levels = 0; |
5564 | for (i = scripts_directory_uri_length; uri[i] != '\0'; i++) { |
5565 | if (uri[i] == '/') { |
5566 | num_levels++; |
5567 | } |
5568 | } |
5569 | |
5570 | if (num_levels > MAX_MENU_LEVELS5) { |
5571 | return FALSE(0); |
5572 | } |
5573 | |
5574 | return TRUE(!(0)); |
5575 | } |
5576 | |
5577 | static gboolean |
5578 | update_directory_in_scripts_menu (FMDirectoryView *view, BaulDirectory *directory) |
5579 | { |
5580 | char *menu_path, *popup_path, *popup_bg_path; |
5581 | GList *file_list, *filtered, *node; |
5582 | gboolean any_scripts; |
5583 | BaulDirectory *dir; |
5584 | char *uri; |
5585 | char *escaped_path; |
5586 | BaulFile *file = NULL((void*)0); |
5587 | |
5588 | uri = baul_directory_get_uri (directory); |
5589 | escaped_path = escape_action_path (uri + scripts_directory_uri_length); |
5590 | g_free (uri); |
5591 | menu_path = g_strconcat (FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER"/MenuBar/File/Open Placeholder/Scripts/Scripts Placeholder", |
5592 | escaped_path, |
5593 | NULL((void*)0)); |
5594 | popup_path = g_strconcat (FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER"/selection/Open Placeholder/Scripts/Scripts Placeholder", |
5595 | escaped_path, |
5596 | NULL((void*)0)); |
5597 | popup_bg_path = g_strconcat (FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_SCRIPTS_PLACEHOLDER"/background/Before Zoom Items/New Object Items/Scripts/Scripts Placeholder", |
5598 | escaped_path, |
5599 | NULL((void*)0)); |
5600 | g_free (escaped_path); |
5601 | |
5602 | file_list = baul_directory_get_file_list (directory); |
5603 | filtered = baul_file_list_filter_hidden (file_list, FALSE(0)); |
5604 | baul_file_list_free (file_list); |
5605 | |
5606 | file_list = baul_file_list_sort_by_display_name (filtered); |
5607 | |
5608 | any_scripts = FALSE(0); |
5609 | for (node = file_list; node != NULL((void*)0); node = node->next) { |
5610 | file = node->data; |
5611 | |
5612 | if (baul_file_is_launchable (file)) { |
5613 | add_script_to_scripts_menus (view, file, menu_path, popup_path, popup_bg_path); |
5614 | any_scripts = TRUE(!(0)); |
5615 | } else if (baul_file_is_directory (file)) { |
5616 | uri = baul_file_get_uri (file); |
5617 | if (directory_belongs_in_scripts_menu (uri)) { |
5618 | dir = baul_directory_get_by_uri (uri); |
5619 | add_directory_to_scripts_directory_list (view, dir); |
5620 | baul_directory_unref (dir); |
5621 | |
5622 | add_submenu_to_directory_menus (view, |
5623 | view->details->scripts_action_group, |
5624 | view->details->scripts_merge_id, |
5625 | file, menu_path, popup_path, popup_bg_path); |
5626 | |
5627 | any_scripts = TRUE(!(0)); |
5628 | } |
5629 | g_free (uri); |
5630 | } |
5631 | } |
5632 | |
5633 | baul_file_list_free (file_list); |
5634 | |
5635 | g_free (popup_path); |
5636 | g_free (popup_bg_path); |
5637 | g_free (menu_path); |
5638 | |
5639 | return any_scripts; |
5640 | } |
5641 | |
5642 | static void |
5643 | update_scripts_menu (FMDirectoryView *view) |
5644 | { |
5645 | gboolean any_scripts; |
5646 | GList *sorted_copy, *node; |
5647 | CtkUIManager *ui_manager; |
5648 | CtkAction *action; |
5649 | BaulDirectory *directory = NULL((void*)0); |
5650 | |
5651 | /* There is a race condition here. If we don't mark the scripts menu as |
5652 | valid before we begin our task then we can lose script menu updates that |
5653 | occur before we finish. */ |
5654 | view->details->scripts_invalid = FALSE(0); |
5655 | |
5656 | ui_manager = baul_window_info_get_ui_manager (view->details->window); |
5657 | baul_ui_unmerge_ui (ui_manager, |
5658 | &view->details->scripts_merge_id, |
5659 | &view->details->scripts_action_group); |
5660 | |
5661 | baul_ui_prepare_merge_ui (ui_manager, |
5662 | "ScriptsGroup", |
5663 | &view->details->scripts_merge_id, |
5664 | &view->details->scripts_action_group); |
5665 | |
5666 | /* As we walk through the directories, remove any that no longer belong. */ |
5667 | any_scripts = FALSE(0); |
5668 | sorted_copy = baul_directory_list_sort_by_uri |
5669 | (baul_directory_list_copy (view->details->scripts_directory_list)); |
5670 | for (node = sorted_copy; node != NULL((void*)0); node = node->next) { |
5671 | char *uri; |
5672 | |
5673 | directory = node->data; |
5674 | |
5675 | uri = baul_directory_get_uri (directory); |
5676 | if (!directory_belongs_in_scripts_menu (uri)) { |
5677 | remove_directory_from_scripts_directory_list (view, directory); |
5678 | } else if (update_directory_in_scripts_menu (view, directory)) { |
5679 | any_scripts = TRUE(!(0)); |
5680 | } |
5681 | g_free (uri); |
5682 | } |
5683 | baul_directory_list_free (sorted_copy); |
5684 | |
5685 | action = ctk_action_group_get_action (view->details->dir_action_group, FM_ACTION_SCRIPTS"Scripts"); |
5686 | ctk_action_set_visible (action, any_scripts); |
5687 | } |
5688 | |
5689 | static void |
5690 | create_template_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
5691 | gpointer callback_data) |
5692 | { |
5693 | CreateTemplateParameters *parameters; |
5694 | |
5695 | parameters = callback_data; |
5696 | |
5697 | fm_directory_view_new_file (parameters->directory_view, NULL((void*)0), parameters->file); |
5698 | } |
5699 | |
5700 | static void |
5701 | add_template_to_templates_menus (FMDirectoryView *directory_view, |
5702 | BaulFile *file, |
5703 | const char *menu_path, |
5704 | const char *popup_bg_path) |
5705 | { |
5706 | char *tmp, *tip, *uri, *name; |
5707 | char *escaped_label; |
5708 | cairo_surface_t *surface; |
5709 | char *action_name; |
5710 | CreateTemplateParameters *parameters; |
5711 | CtkUIManager *ui_manager; |
5712 | CtkAction *action; |
5713 | |
5714 | tmp = baul_file_get_display_name (file); |
5715 | name = eel_filename_strip_extension (tmp); |
5716 | g_free (tmp); |
5717 | |
5718 | uri = baul_file_get_uri (file); |
5719 | tip = g_strdup_printf (_("Create Document from template \"%s\"")gettext ("Create Document from template \"%s\""), name); |
5720 | |
5721 | action_name = escape_action_name (uri, "template_"); |
5722 | escaped_label = eel_str_double_underscores (name); |
5723 | |
5724 | parameters = create_template_parameters_new (file, directory_view); |
5725 | |
5726 | action = ctk_action_new (action_name, |
5727 | escaped_label, |
5728 | tip, |
5729 | NULL((void*)0)); |
5730 | |
5731 | surface = get_menu_icon_for_file (file, CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((directory_view)), ((ctk_widget_get_type ()))))))); |
5732 | if (surface != NULL((void*)0)) { |
5733 | g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "menu-icon", |
5734 | surface, |
5735 | (GDestroyNotify)cairo_surface_destroy); |
5736 | } |
5737 | |
5738 | g_signal_connect_data (action, "activate", |
5739 | G_CALLBACK (create_template_callback)((GCallback) (create_template_callback)), |
5740 | parameters, |
5741 | (GClosureNotify)create_templates_parameters_free, 0); |
5742 | |
5743 | ctk_action_group_add_action (directory_view->details->templates_action_group, |
5744 | action); |
5745 | g_object_unref (action); |
5746 | |
5747 | ui_manager = baul_window_info_get_ui_manager (directory_view->details->window); |
5748 | |
5749 | ctk_ui_manager_add_ui (ui_manager, |
5750 | directory_view->details->templates_merge_id, |
5751 | menu_path, |
5752 | action_name, |
5753 | action_name, |
5754 | CTK_UI_MANAGER_MENUITEM, |
5755 | FALSE(0)); |
5756 | |
5757 | ctk_ui_manager_add_ui (ui_manager, |
5758 | directory_view->details->templates_merge_id, |
5759 | popup_bg_path, |
5760 | action_name, |
5761 | action_name, |
5762 | CTK_UI_MANAGER_MENUITEM, |
5763 | FALSE(0)); |
5764 | |
5765 | g_free (escaped_label); |
5766 | g_free (name); |
5767 | g_free (tip); |
5768 | g_free (uri); |
5769 | g_free (action_name); |
5770 | } |
5771 | |
5772 | static void |
5773 | update_templates_directory (FMDirectoryView *view) |
5774 | { |
5775 | GList *node, *next; |
5776 | |
5777 | for (node = view->details->templates_directory_list; node != NULL((void*)0); node = next) { |
5778 | next = node->next; |
5779 | remove_directory_from_templates_directory_list (view, node->data); |
5780 | } |
5781 | |
5782 | if (baul_should_use_templates_directory ()) { |
5783 | BaulDirectory *templates_directory; |
5784 | char *templates_uri; |
5785 | |
5786 | templates_uri = baul_get_templates_directory_uri (); |
5787 | templates_directory = baul_directory_get_by_uri (templates_uri); |
5788 | g_free (templates_uri); |
5789 | add_directory_to_templates_directory_list (view, templates_directory); |
5790 | baul_directory_unref (templates_directory); |
5791 | } |
5792 | } |
5793 | |
5794 | static void |
5795 | user_dirs_changed (FMDirectoryView *view) |
5796 | { |
5797 | update_templates_directory (view); |
5798 | view->details->templates_invalid = TRUE(!(0)); |
5799 | schedule_update_menus (view); |
5800 | } |
5801 | |
5802 | static gboolean |
5803 | directory_belongs_in_templates_menu (const char *templates_directory_uri, |
5804 | const char *uri) |
5805 | { |
5806 | int num_levels; |
5807 | int i; |
5808 | |
5809 | if (templates_directory_uri == NULL((void*)0)) { |
5810 | return FALSE(0); |
5811 | } |
5812 | |
5813 | if (!g_str_has_prefix (uri, templates_directory_uri)(__builtin_constant_p (templates_directory_uri)? __extension__ ({ const char * const __str = (uri); const char * const __prefix = (templates_directory_uri); gboolean __result = (0); if (__str == ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix ) (__str, __prefix); else { const size_t __str_len = strlen ( ((__str) + !(__str))); const size_t __prefix_len = strlen ((( __prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result = memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len ) == 0; } __result; }) : (g_str_has_prefix) (uri, templates_directory_uri ) )) { |
5814 | return FALSE(0); |
5815 | } |
5816 | |
5817 | num_levels = 0; |
5818 | for (i = strlen (templates_directory_uri); uri[i] != '\0'; i++) { |
5819 | if (uri[i] == '/') { |
5820 | num_levels++; |
5821 | } |
5822 | } |
5823 | |
5824 | if (num_levels > MAX_MENU_LEVELS5) { |
5825 | return FALSE(0); |
5826 | } |
5827 | |
5828 | return TRUE(!(0)); |
5829 | } |
5830 | |
5831 | static gboolean |
5832 | update_directory_in_templates_menu (FMDirectoryView *view, |
5833 | const char *templates_directory_uri, |
5834 | BaulDirectory *directory) |
5835 | { |
5836 | char *menu_path, *popup_bg_path; |
5837 | GList *file_list, *filtered, *node; |
5838 | gboolean any_templates; |
5839 | BaulDirectory *dir; |
5840 | char *escaped_path; |
5841 | char *uri; |
5842 | int num; |
5843 | BaulFile *file = NULL((void*)0); |
5844 | |
5845 | /* We know this directory belongs to the template dir, so it must exist */ |
5846 | g_assert (templates_directory_uri)do { if (templates_directory_uri) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 5846, ((const char*) ( __func__)), "templates_directory_uri"); } while (0); |
5847 | |
5848 | uri = baul_directory_get_uri (directory); |
5849 | escaped_path = escape_action_path (uri + strlen (templates_directory_uri)); |
5850 | g_free (uri); |
5851 | menu_path = g_strconcat (FM_DIRECTORY_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER"/MenuBar/File/New Items Placeholder/New Documents/New Documents Placeholder", |
5852 | escaped_path, |
5853 | NULL((void*)0)); |
5854 | popup_bg_path = g_strconcat (FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_NEW_DOCUMENTS_PLACEHOLDER"/background/Before Zoom Items/New Object Items/New Documents/New Documents Placeholder", |
5855 | escaped_path, |
5856 | NULL((void*)0)); |
5857 | g_free (escaped_path); |
5858 | |
5859 | file_list = baul_directory_get_file_list (directory); |
5860 | filtered = baul_file_list_filter_hidden (file_list, FALSE(0)); |
5861 | baul_file_list_free (file_list); |
5862 | |
5863 | file_list = baul_file_list_sort_by_display_name (filtered); |
5864 | |
5865 | num = 0; |
5866 | any_templates = FALSE(0); |
5867 | for (node = file_list; num < TEMPLATE_LIMIT30 && node != NULL((void*)0); node = node->next, num++) { |
5868 | file = node->data; |
5869 | |
5870 | if (baul_file_is_directory (file)) { |
5871 | uri = baul_file_get_uri (file); |
5872 | if (directory_belongs_in_templates_menu (templates_directory_uri, uri)) { |
5873 | dir = baul_directory_get_by_uri (uri); |
5874 | add_directory_to_templates_directory_list (view, dir); |
5875 | baul_directory_unref (dir); |
5876 | |
5877 | add_submenu_to_directory_menus (view, |
5878 | view->details->templates_action_group, |
5879 | view->details->templates_merge_id, |
5880 | file, menu_path, NULL((void*)0), popup_bg_path); |
5881 | |
5882 | any_templates = TRUE(!(0)); |
5883 | } |
5884 | g_free (uri); |
5885 | } else if (baul_file_can_read (file)) { |
5886 | add_template_to_templates_menus (view, file, menu_path, popup_bg_path); |
5887 | any_templates = TRUE(!(0)); |
5888 | } |
5889 | } |
5890 | |
5891 | baul_file_list_free (file_list); |
5892 | |
5893 | g_free (popup_bg_path); |
5894 | g_free (menu_path); |
5895 | |
5896 | return any_templates; |
5897 | } |
5898 | |
5899 | |
5900 | |
5901 | static void |
5902 | update_templates_menu (FMDirectoryView *view) |
5903 | { |
5904 | gboolean any_templates; |
5905 | GList *sorted_copy, *node; |
5906 | CtkUIManager *ui_manager; |
5907 | CtkAction *action; |
5908 | char *templates_directory_uri; |
5909 | BaulDirectory *directory = NULL((void*)0); |
5910 | |
5911 | if (baul_should_use_templates_directory ()) { |
5912 | templates_directory_uri = baul_get_templates_directory_uri (); |
5913 | } else { |
5914 | templates_directory_uri = NULL((void*)0); |
5915 | } |
5916 | |
5917 | /* There is a race condition here. If we don't mark the scripts menu as |
5918 | valid before we begin our task then we can lose template menu updates that |
5919 | occur before we finish. */ |
5920 | view->details->templates_invalid = FALSE(0); |
5921 | |
5922 | ui_manager = baul_window_info_get_ui_manager (view->details->window); |
5923 | baul_ui_unmerge_ui (ui_manager, |
5924 | &view->details->templates_merge_id, |
5925 | &view->details->templates_action_group); |
5926 | |
5927 | baul_ui_prepare_merge_ui (ui_manager, |
5928 | "TemplatesGroup", |
5929 | &view->details->templates_merge_id, |
5930 | &view->details->templates_action_group); |
5931 | |
5932 | /* As we walk through the directories, remove any that no longer belong. */ |
5933 | any_templates = FALSE(0); |
5934 | sorted_copy = baul_directory_list_sort_by_uri |
5935 | (baul_directory_list_copy (view->details->templates_directory_list)); |
5936 | for (node = sorted_copy; node != NULL((void*)0); node = node->next) { |
5937 | char *uri; |
5938 | |
5939 | directory = node->data; |
5940 | |
5941 | uri = baul_directory_get_uri (directory); |
5942 | if (!directory_belongs_in_templates_menu (templates_directory_uri, uri)) { |
5943 | remove_directory_from_templates_directory_list (view, directory); |
5944 | } else if (update_directory_in_templates_menu (view, |
5945 | templates_directory_uri, |
5946 | directory)) { |
5947 | any_templates = TRUE(!(0)); |
5948 | } |
5949 | g_free (uri); |
5950 | } |
5951 | baul_directory_list_free (sorted_copy); |
5952 | |
5953 | action = ctk_action_group_get_action (view->details->dir_action_group, FM_ACTION_NO_TEMPLATES"No Templates"); |
5954 | ctk_action_set_visible (action, !any_templates); |
5955 | |
5956 | g_free (templates_directory_uri); |
5957 | } |
5958 | |
5959 | |
5960 | static void |
5961 | action_open_scripts_folder_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
5962 | gpointer callback_data) |
5963 | { |
5964 | FMDirectoryView *view; |
5965 | |
5966 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
5967 | |
5968 | open_location (view, scripts_directory_uri, BAUL_WINDOW_OPEN_ACCORDING_TO_MODE, 0); |
5969 | |
5970 | eel_show_info_dialog_with_details |
5971 | (_("All executable files in this folder will appear in the "gettext ("All executable files in this folder will appear in the " "Scripts menu.") |
5972 | "Scripts menu.")gettext ("All executable files in this folder will appear in the " "Scripts menu."), |
5973 | _("Choosing a script from the menu will run "gettext ("Choosing a script from the menu will run " "that script with any selected items as input." ) |
5974 | "that script with any selected items as input.")gettext ("Choosing a script from the menu will run " "that script with any selected items as input." ), |
5975 | _("All executable files in this folder will appear in the "gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5976 | "Scripts menu. Choosing a script from the menu will run "gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5977 | "that script.\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5978 | "When executed from a local folder, scripts will be passed "gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5979 | "the selected file names. When executed from a remote folder "gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5980 | "(e.g. a folder showing web or ftp content), scripts will "gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5981 | "be passed no parameters.\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5982 | "In all cases, the following environment variables will be "gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5983 | "set by Baul, which the scripts may use:\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5984 | "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5985 | "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5986 | "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5987 | "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5988 | "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5989 | "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n"gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ) |
5990 | "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window")gettext ("All executable files in this folder will appear in the " "Scripts menu. Choosing a script from the menu will run " "that script.\n\n" "When executed from a local folder, scripts will be passed " "the selected file names. When executed from a remote folder " "(e.g. a folder showing web or ftp content), scripts will " "be passed no parameters.\n\n" "In all cases, the following environment variables will be " "set by Baul, which the scripts may use:\n\n" "BAUL_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)\n\n" "BAUL_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files\n\n" "BAUL_SCRIPT_CURRENT_URI: URI for current location\n\n" "BAUL_SCRIPT_WINDOW_GEOMETRY: position and size of current window\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS: newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)\n\n" "BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS: newline-delimited URIs for selected files in the inactive pane of a split-view window\n\n" "BAUL_SCRIPT_NEXT_PANE_CURRENT_URI: URI for current location in the inactive pane of a split-view window" ), |
5991 | fm_directory_view_get_containing_window (view)); |
5992 | } |
5993 | |
5994 | static CtkMenu * |
5995 | create_popup_menu (FMDirectoryView *view, const char *popup_path) |
5996 | { |
5997 | CtkWidget *menu; |
5998 | |
5999 | menu = ctk_ui_manager_get_widget (baul_window_info_get_ui_manager (view->details->window), |
6000 | popup_path); |
6001 | ctk_menu_set_screen (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_menu_get_type ())))))), |
6002 | ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))))); |
6003 | ctk_widget_show (CTK_WIDGET (menu)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_widget_get_type ()))))))); |
6004 | |
6005 | return CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_menu_get_type ())))))); |
6006 | } |
6007 | |
6008 | static void |
6009 | copy_or_cut_files (FMDirectoryView *view, |
6010 | GList *clipboard_contents, |
6011 | gboolean cut) |
6012 | { |
6013 | int count; |
6014 | char *status_string; |
6015 | BaulClipboardInfo info; |
6016 | CtkTargetList *target_list; |
6017 | CtkTargetEntry *targets; |
6018 | int n_targets; |
6019 | |
6020 | info.files = clipboard_contents; |
6021 | info.cut = cut; |
6022 | |
6023 | target_list = ctk_target_list_new (NULL((void*)0), 0); |
6024 | ctk_target_list_add (target_list, copied_files_atom, 0, 0); |
6025 | ctk_target_list_add_uri_targets (target_list, 0); |
6026 | ctk_target_list_add_text_targets (target_list, 0); |
6027 | |
6028 | targets = ctk_target_table_new_from_list (target_list, &n_targets); |
6029 | ctk_target_list_unref (target_list); |
6030 | |
6031 | ctk_clipboard_set_with_data (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))), |
6032 | targets, n_targets, |
6033 | baul_get_clipboard_callback, baul_clear_clipboard_callback, |
6034 | NULL((void*)0)); |
6035 | ctk_target_table_free (targets, n_targets); |
6036 | |
6037 | baul_clipboard_monitor_set_clipboard_info (baul_clipboard_monitor_get (), &info); |
6038 | |
6039 | count = g_list_length (clipboard_contents); |
6040 | if (count == 1) { |
6041 | char *name; |
6042 | |
6043 | name = baul_file_get_display_name (clipboard_contents->data); |
6044 | if (cut) { |
6045 | status_string = g_strdup_printf (_("\"%s\" will be moved "gettext ("\"%s\" will be moved " "if you select the Paste command" ) |
6046 | "if you select the Paste command")gettext ("\"%s\" will be moved " "if you select the Paste command" ), |
6047 | name); |
6048 | } else { |
6049 | status_string = g_strdup_printf (_("\"%s\" will be copied "gettext ("\"%s\" will be copied " "if you select the Paste command" ) |
6050 | "if you select the Paste command")gettext ("\"%s\" will be copied " "if you select the Paste command" ), |
6051 | name); |
6052 | } |
6053 | g_free (name); |
6054 | } else { |
6055 | if (cut) { |
6056 | status_string = g_strdup_printf (ngettext("The %'d selected item will be moved " |
6057 | "if you select the Paste command", |
6058 | "The %'d selected items will be moved " |
6059 | "if you select the Paste command", |
6060 | count), |
6061 | count); |
6062 | } else { |
6063 | status_string = g_strdup_printf (ngettext("The %'d selected item will be copied " |
6064 | "if you select the Paste command", |
6065 | "The %'d selected items will be copied " |
6066 | "if you select the Paste command", |
6067 | count), |
6068 | count); |
6069 | } |
6070 | } |
6071 | |
6072 | baul_window_slot_info_set_status (view->details->slot, |
6073 | status_string); |
6074 | g_free (status_string); |
6075 | } |
6076 | |
6077 | static void |
6078 | action_copy_files_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6079 | gpointer callback_data) |
6080 | { |
6081 | FMDirectoryView *view; |
6082 | GList *selection; |
6083 | |
6084 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6085 | |
6086 | selection = fm_directory_view_get_selection_for_file_transfer (view); |
6087 | copy_or_cut_files (view, selection, FALSE(0)); |
6088 | baul_file_list_free (selection); |
6089 | } |
6090 | |
6091 | static void |
6092 | move_copy_selection_to_location (FMDirectoryView *view, |
6093 | int copy_action, |
6094 | char *target_uri) |
6095 | { |
6096 | GList *selection, *uris, *l; |
6097 | |
6098 | selection = fm_directory_view_get_selection_for_file_transfer (view); |
6099 | if (selection == NULL((void*)0)) { |
6100 | return; |
6101 | } |
6102 | |
6103 | uris = NULL((void*)0); |
6104 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6105 | uris = g_list_prepend (uris, |
6106 | baul_file_get_uri ((BaulFile *) l->data)); |
6107 | } |
6108 | uris = g_list_reverse (uris); |
6109 | |
6110 | fm_directory_view_move_copy_items (uris, NULL((void*)0), target_uri, |
6111 | copy_action, |
6112 | 0, 0, |
6113 | view); |
6114 | |
6115 | g_list_free_full (uris, g_free); |
6116 | baul_file_list_free (selection); |
6117 | } |
6118 | |
6119 | static void |
6120 | move_copy_selection_to_next_pane (FMDirectoryView *view, |
6121 | int copy_action) |
6122 | { |
6123 | BaulWindowSlotInfo *slot; |
6124 | char *dest_location; |
6125 | |
6126 | slot = baul_window_info_get_extra_slot (fm_directory_view_get_baul_window (view)); |
6127 | g_return_if_fail (slot != NULL)do { if ((slot != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "slot != NULL"); return ; } } while (0); |
6128 | |
6129 | dest_location = baul_window_slot_info_get_current_location (slot); |
6130 | g_return_if_fail (dest_location != NULL)do { if ((dest_location != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "dest_location != NULL" ); return; } } while (0); |
6131 | |
6132 | move_copy_selection_to_location (view, copy_action, dest_location); |
6133 | } |
6134 | |
6135 | static void |
6136 | action_copy_to_next_pane_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6137 | gpointer callback_data) |
6138 | { |
6139 | FMDirectoryView *view; |
6140 | |
6141 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6142 | move_copy_selection_to_next_pane (view, |
6143 | CDK_ACTION_COPY); |
6144 | } |
6145 | |
6146 | static void |
6147 | action_move_to_next_pane_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6148 | gpointer callback_data) |
6149 | { |
6150 | BaulWindowSlotInfo *slot; |
6151 | char *dest_location; |
6152 | FMDirectoryView *view; |
6153 | |
6154 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6155 | |
6156 | slot = baul_window_info_get_extra_slot (fm_directory_view_get_baul_window (view)); |
6157 | g_return_if_fail (slot != NULL)do { if ((slot != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "slot != NULL"); return ; } } while (0); |
6158 | |
6159 | dest_location = baul_window_slot_info_get_current_location (slot); |
6160 | g_return_if_fail (dest_location != NULL)do { if ((dest_location != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "dest_location != NULL" ); return; } } while (0); |
6161 | |
6162 | move_copy_selection_to_location (view, CDK_ACTION_MOVE, dest_location); |
6163 | } |
6164 | |
6165 | static void |
6166 | action_copy_to_home_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6167 | gpointer callback_data) |
6168 | { |
6169 | FMDirectoryView *view; |
6170 | char *dest_location; |
6171 | |
6172 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6173 | |
6174 | dest_location = baul_get_home_directory_uri (); |
6175 | move_copy_selection_to_location (view, CDK_ACTION_COPY, dest_location); |
6176 | g_free (dest_location); |
6177 | } |
6178 | |
6179 | static void |
6180 | action_move_to_home_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6181 | gpointer callback_data) |
6182 | { |
6183 | FMDirectoryView *view; |
6184 | char *dest_location; |
6185 | |
6186 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6187 | |
6188 | dest_location = baul_get_home_directory_uri (); |
6189 | move_copy_selection_to_location (view, CDK_ACTION_MOVE, dest_location); |
6190 | g_free (dest_location); |
6191 | } |
6192 | |
6193 | static void |
6194 | action_copy_to_desktop_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6195 | gpointer callback_data) |
6196 | { |
6197 | FMDirectoryView *view; |
6198 | char *dest_location; |
6199 | |
6200 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6201 | |
6202 | dest_location = baul_get_desktop_directory_uri (); |
6203 | move_copy_selection_to_location (view, CDK_ACTION_COPY, dest_location); |
6204 | g_free (dest_location); |
6205 | } |
6206 | |
6207 | static void |
6208 | action_move_to_desktop_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6209 | gpointer callback_data) |
6210 | { |
6211 | FMDirectoryView *view; |
6212 | char *dest_location; |
6213 | |
6214 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6215 | |
6216 | dest_location = baul_get_desktop_directory_uri (); |
6217 | move_copy_selection_to_location (view, CDK_ACTION_MOVE, dest_location); |
6218 | g_free (dest_location); |
6219 | } |
6220 | |
6221 | static void |
6222 | action_cut_files_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6223 | gpointer callback_data) |
6224 | { |
6225 | FMDirectoryView *view; |
6226 | GList *selection; |
6227 | |
6228 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6229 | |
6230 | selection = fm_directory_view_get_selection_for_file_transfer (view); |
6231 | copy_or_cut_files (view, selection, TRUE(!(0))); |
6232 | baul_file_list_free (selection); |
6233 | } |
6234 | |
6235 | static void |
6236 | paste_clipboard_data (FMDirectoryView *view, |
6237 | CtkSelectionData *selection_data, |
6238 | char *destination_uri) |
6239 | { |
6240 | gboolean cut; |
6241 | GList *item_uris; |
6242 | |
6243 | cut = FALSE(0); |
6244 | item_uris = baul_clipboard_get_uri_list_from_selection_data (selection_data, &cut, |
6245 | copied_files_atom); |
6246 | |
6247 | if (item_uris == NULL((void*)0)|| destination_uri == NULL((void*)0)) { |
6248 | baul_window_slot_info_set_status (view->details->slot, |
6249 | _("There is nothing on the clipboard to paste.")gettext ("There is nothing on the clipboard to paste.")); |
6250 | } else { |
6251 | fm_directory_view_move_copy_items (item_uris, NULL((void*)0), destination_uri, |
6252 | cut ? CDK_ACTION_MOVE : CDK_ACTION_COPY, |
6253 | 0, 0, |
6254 | view); |
6255 | |
6256 | /* If items are cut then remove from clipboard */ |
6257 | if (cut) { |
6258 | ctk_clipboard_clear (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))))); |
6259 | } |
6260 | |
6261 | g_list_free_full (item_uris, g_free); |
6262 | } |
6263 | } |
6264 | |
6265 | static void |
6266 | paste_clipboard_received_callback (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)), |
6267 | CtkSelectionData *selection_data, |
6268 | gpointer data) |
6269 | { |
6270 | FMDirectoryView *view; |
6271 | char *view_uri; |
6272 | |
6273 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6274 | |
6275 | view_uri = fm_directory_view_get_backing_uri (view); |
6276 | |
6277 | if (view->details->window != NULL((void*)0)) { |
6278 | paste_clipboard_data (view, selection_data, view_uri); |
6279 | } |
6280 | |
6281 | g_free (view_uri); |
6282 | |
6283 | g_object_unref (view); |
6284 | } |
6285 | |
6286 | typedef struct { |
6287 | FMDirectoryView *view; |
6288 | BaulFile *target; |
6289 | } PasteIntoData; |
6290 | |
6291 | static void |
6292 | paste_into_clipboard_received_callback (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)), |
6293 | CtkSelectionData *selection_data, |
6294 | gpointer callback_data) |
6295 | { |
6296 | PasteIntoData *data; |
6297 | FMDirectoryView *view; |
6298 | |
6299 | data = (PasteIntoData *) callback_data; |
6300 | |
6301 | view = FM_DIRECTORY_VIEW (data->view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->view)), (fm_directory_view_get_type()))))); |
6302 | |
6303 | if (view->details->window != NULL((void*)0)) { |
6304 | char *directory_uri; |
6305 | |
6306 | directory_uri = baul_file_get_activation_uri (data->target); |
6307 | |
6308 | paste_clipboard_data (view, selection_data, directory_uri); |
6309 | |
6310 | g_free (directory_uri); |
6311 | } |
6312 | |
6313 | g_object_unref (view); |
6314 | baul_file_unref (data->target); |
6315 | g_free (data); |
6316 | } |
6317 | |
6318 | static void |
6319 | action_paste_files_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6320 | gpointer callback_data) |
6321 | { |
6322 | FMDirectoryView *view; |
6323 | |
6324 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6325 | |
6326 | g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)); |
6327 | ctk_clipboard_request_contents (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))), |
6328 | copied_files_atom, |
6329 | paste_clipboard_received_callback, |
6330 | view); |
6331 | } |
6332 | |
6333 | static void |
6334 | paste_into (FMDirectoryView *view, |
6335 | BaulFile *target) |
6336 | { |
6337 | PasteIntoData *data; |
6338 | |
6339 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 6339, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
6340 | g_assert (BAUL_IS_FILE (target))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((target)); GType __t = (baul_file_get_type()); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 6340, ((const char*) (__func__)), "BAUL_IS_FILE (target)"); } while (0); |
6341 | |
6342 | data = g_new (PasteIntoData, 1)((PasteIntoData *) g_malloc_n ((1), sizeof (PasteIntoData))); |
6343 | |
6344 | data->view = g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)); |
6345 | data->target = baul_file_ref (target); |
6346 | |
6347 | ctk_clipboard_request_contents (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))), |
6348 | copied_files_atom, |
6349 | paste_into_clipboard_received_callback, |
6350 | data); |
6351 | } |
6352 | |
6353 | static void |
6354 | action_paste_files_into_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6355 | gpointer callback_data) |
6356 | { |
6357 | FMDirectoryView *view; |
6358 | GList *selection; |
6359 | |
6360 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6361 | selection = fm_directory_view_get_selection (view); |
6362 | if (selection != NULL((void*)0)) { |
6363 | paste_into (view, BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type())))))); |
6364 | baul_file_list_free (selection); |
6365 | } |
6366 | |
6367 | } |
6368 | |
6369 | static void |
6370 | real_action_undo (FMDirectoryView *view) |
6371 | { |
6372 | BaulUndoStackManager *manager = baul_undostack_manager_instance (); |
6373 | |
6374 | /* Disable menus because they are in an untrustworthy status */ |
6375 | view->details->undo_active = FALSE(0); |
6376 | view->details->redo_active = FALSE(0); |
6377 | fm_directory_view_update_menus (view); |
6378 | |
6379 | baul_undostack_manager_undo (manager, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), finish_undoredo_callback); |
6380 | } |
6381 | |
6382 | static void |
6383 | real_action_redo (FMDirectoryView *view) |
6384 | { |
6385 | BaulUndoStackManager *manager = baul_undostack_manager_instance (); |
6386 | |
6387 | /* Disable menus because they are in an untrustworthy status */ |
6388 | view->details->undo_active = FALSE(0); |
6389 | view->details->redo_active = FALSE(0); |
6390 | fm_directory_view_update_menus (view); |
6391 | |
6392 | baul_undostack_manager_redo (manager, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), finish_undoredo_callback); |
6393 | } |
6394 | |
6395 | static void |
6396 | real_action_rename (FMDirectoryView *view, |
6397 | gboolean select_all) |
6398 | { |
6399 | GList *selection; |
6400 | |
6401 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 6401, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
6402 | |
6403 | selection = fm_directory_view_get_selection (view); |
6404 | |
6405 | if (selection_not_empty_in_menu_callback (view, selection)) { |
6406 | BaulFile *file; |
6407 | |
6408 | file = BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type()))))); |
6409 | |
6410 | if (!select_all) { |
6411 | /* directories don't have a file extension, so |
6412 | * they are always pre-selected as a whole */ |
6413 | select_all = baul_file_is_directory (file); |
6414 | } |
6415 | EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, view, start_renaming_file, (view, file, select_all))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> start_renaming_file != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->start_renaming_file) (view, file, select_all); } } while (0); |
6416 | } |
6417 | |
6418 | baul_file_list_free (selection); |
6419 | } |
6420 | |
6421 | static void |
6422 | action_rename_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6423 | gpointer callback_data) |
6424 | { |
6425 | real_action_rename (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))), FALSE(0)); |
6426 | } |
6427 | |
6428 | static void |
6429 | action_rename_select_all_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6430 | gpointer callback_data) |
6431 | { |
6432 | real_action_rename (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))), TRUE(!(0))); |
6433 | } |
6434 | |
6435 | static void |
6436 | file_mount_callback (BaulFile *file G_GNUC_UNUSED__attribute__ ((__unused__)), |
6437 | GFile *result_location G_GNUC_UNUSED__attribute__ ((__unused__)), |
6438 | GError *error, |
6439 | gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
6440 | { |
6441 | if (error != NULL((void*)0) && |
6442 | (error->domain != G_IO_ERRORg_io_error_quark() || |
6443 | (error->code != G_IO_ERROR_CANCELLED && |
6444 | error->code != G_IO_ERROR_FAILED_HANDLED && |
6445 | error->code != G_IO_ERROR_ALREADY_MOUNTED))) { |
6446 | eel_show_error_dialog (_("Unable to mount location")gettext ("Unable to mount location"), |
6447 | error->message, NULL((void*)0)); |
6448 | } |
6449 | } |
6450 | |
6451 | static void |
6452 | file_unmount_callback (BaulFile *file G_GNUC_UNUSED__attribute__ ((__unused__)), |
6453 | GFile *result_location G_GNUC_UNUSED__attribute__ ((__unused__)), |
6454 | GError *error, |
6455 | gpointer callback_data) |
6456 | { |
6457 | FMDirectoryView *view; |
6458 | |
6459 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6460 | fm_directory_view_set_initiated_unmount (view, FALSE(0)); |
6461 | g_object_unref (view); |
6462 | |
6463 | if (error != NULL((void*)0) && |
6464 | (error->domain != G_IO_ERRORg_io_error_quark() || |
6465 | (error->code != G_IO_ERROR_CANCELLED && |
6466 | error->code != G_IO_ERROR_FAILED_HANDLED))) { |
6467 | eel_show_error_dialog (_("Unable to unmount location")gettext ("Unable to unmount location"), |
6468 | error->message, NULL((void*)0)); |
6469 | } |
6470 | } |
6471 | |
6472 | static void |
6473 | file_eject_callback (BaulFile *file G_GNUC_UNUSED__attribute__ ((__unused__)), |
6474 | GFile *result_location G_GNUC_UNUSED__attribute__ ((__unused__)), |
6475 | GError *error, |
6476 | gpointer callback_data) |
6477 | { |
6478 | FMDirectoryView *view; |
6479 | |
6480 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
6481 | fm_directory_view_set_initiated_unmount (view, FALSE(0)); |
6482 | g_object_unref (view); |
6483 | |
6484 | if (error != NULL((void*)0) && |
6485 | (error->domain != G_IO_ERRORg_io_error_quark() || |
6486 | (error->code != G_IO_ERROR_CANCELLED && |
6487 | error->code != G_IO_ERROR_FAILED_HANDLED))) { |
6488 | eel_show_error_dialog (_("Unable to eject location")gettext ("Unable to eject location"), |
6489 | error->message, NULL((void*)0)); |
6490 | } |
6491 | } |
6492 | |
6493 | static void |
6494 | file_stop_callback (BaulFile *file G_GNUC_UNUSED__attribute__ ((__unused__)), |
6495 | GFile *result_location G_GNUC_UNUSED__attribute__ ((__unused__)), |
6496 | GError *error, |
6497 | gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
6498 | { |
6499 | if (error != NULL((void*)0) && |
6500 | (error->domain != G_IO_ERRORg_io_error_quark() || |
6501 | (error->code != G_IO_ERROR_CANCELLED && |
6502 | error->code != G_IO_ERROR_FAILED_HANDLED))) { |
6503 | eel_show_error_dialog (_("Unable to stop drive")gettext ("Unable to stop drive"), |
6504 | error->message, NULL((void*)0)); |
6505 | } |
6506 | } |
6507 | |
6508 | static void |
6509 | action_mount_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6510 | gpointer data) |
6511 | { |
6512 | GList *selection, *l; |
6513 | FMDirectoryView *view; |
6514 | GMountOperation *mount_op; |
6515 | BaulFile *file = NULL((void*)0); |
6516 | |
6517 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6518 | |
6519 | selection = fm_directory_view_get_selection (view); |
6520 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6521 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
6522 | |
6523 | if (baul_file_can_mount (file)) { |
6524 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6525 | g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION); |
6526 | baul_file_mount (file, mount_op, NULL((void*)0), |
6527 | file_mount_callback, NULL((void*)0)); |
6528 | g_object_unref (mount_op); |
6529 | } |
6530 | } |
6531 | baul_file_list_free (selection); |
6532 | } |
6533 | |
6534 | static void |
6535 | action_unmount_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6536 | gpointer data) |
6537 | { |
6538 | GList *selection, *l; |
6539 | FMDirectoryView *view; |
6540 | BaulFile *file = NULL((void*)0); |
6541 | |
6542 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6543 | |
6544 | selection = fm_directory_view_get_selection (view); |
6545 | |
6546 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6547 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
6548 | if (baul_file_can_unmount (file)) { |
6549 | GMountOperation *mount_op; |
6550 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6551 | fm_directory_view_set_initiated_unmount (view, TRUE(!(0))); |
6552 | baul_file_unmount (file, mount_op, NULL((void*)0), |
6553 | file_unmount_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view))); |
6554 | g_object_unref (mount_op); |
6555 | } |
6556 | } |
6557 | baul_file_list_free (selection); |
6558 | } |
6559 | |
6560 | static void |
6561 | action_format_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6562 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
6563 | { |
6564 | #ifdef TODO_GIO |
6565 | GList *selection, *l; |
6566 | FMDirectoryView *view; |
6567 | BaulFile *file = NULL((void*)0); |
6568 | |
6569 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6570 | |
6571 | selection = fm_directory_view_get_selection (view); |
6572 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6573 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
6574 | |
6575 | if (something) { |
6576 | g_spawn_command_line_async ("gfloppy", NULL((void*)0)); |
6577 | } |
6578 | } |
6579 | baul_file_list_free (selection); |
6580 | #endif |
6581 | } |
6582 | |
6583 | static void |
6584 | action_eject_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6585 | gpointer data) |
6586 | { |
6587 | GList *selection, *l; |
6588 | FMDirectoryView *view; |
6589 | BaulFile *file = NULL((void*)0); |
6590 | |
6591 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6592 | |
6593 | selection = fm_directory_view_get_selection (view); |
6594 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6595 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
6596 | |
6597 | if (baul_file_can_eject (file)) { |
6598 | GMountOperation *mount_op; |
6599 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6600 | fm_directory_view_set_initiated_unmount (view, TRUE(!(0))); |
6601 | baul_file_eject (file, mount_op, NULL((void*)0), |
6602 | file_eject_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view))); |
6603 | g_object_unref (mount_op); |
6604 | } |
6605 | } |
6606 | baul_file_list_free (selection); |
6607 | } |
6608 | |
6609 | static void |
6610 | file_start_callback (BaulFile *file G_GNUC_UNUSED__attribute__ ((__unused__)), |
6611 | GFile *result_location G_GNUC_UNUSED__attribute__ ((__unused__)), |
6612 | GError *error, |
6613 | gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
6614 | { |
6615 | if (error != NULL((void*)0) && |
6616 | (error->domain != G_IO_ERRORg_io_error_quark() || |
6617 | (error->code != G_IO_ERROR_CANCELLED && |
6618 | error->code != G_IO_ERROR_FAILED_HANDLED && |
6619 | error->code != G_IO_ERROR_ALREADY_MOUNTED))) { |
6620 | eel_show_error_dialog (_("Unable to start location")gettext ("Unable to start location"), |
6621 | error->message, NULL((void*)0)); |
6622 | } |
6623 | } |
6624 | |
6625 | static void |
6626 | action_start_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6627 | gpointer data) |
6628 | { |
6629 | GList *selection, *l; |
6630 | FMDirectoryView *view; |
6631 | GMountOperation *mount_op; |
6632 | BaulFile *file = NULL((void*)0); |
6633 | |
6634 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6635 | |
6636 | selection = fm_directory_view_get_selection (view); |
6637 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6638 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
6639 | |
6640 | if (baul_file_can_start (file) || baul_file_can_start_degraded (file)) { |
6641 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6642 | baul_file_start (file, mount_op, NULL((void*)0), |
6643 | file_start_callback, NULL((void*)0)); |
6644 | g_object_unref (mount_op); |
6645 | } |
6646 | } |
6647 | baul_file_list_free (selection); |
6648 | } |
6649 | |
6650 | static void |
6651 | action_stop_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6652 | gpointer data) |
6653 | { |
6654 | GList *selection, *l; |
6655 | FMDirectoryView *view; |
6656 | BaulFile *file = NULL((void*)0); |
6657 | |
6658 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6659 | |
6660 | selection = fm_directory_view_get_selection (view); |
6661 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6662 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
6663 | |
6664 | if (baul_file_can_stop (file)) { |
6665 | GMountOperation *mount_op; |
6666 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6667 | baul_file_stop (file, mount_op, NULL((void*)0), |
6668 | file_stop_callback, NULL((void*)0)); |
6669 | g_object_unref (mount_op); |
6670 | } |
6671 | } |
6672 | baul_file_list_free (selection); |
6673 | } |
6674 | |
6675 | static void |
6676 | action_detect_media_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6677 | gpointer data) |
6678 | { |
6679 | GList *selection, *l; |
6680 | FMDirectoryView *view; |
6681 | BaulFile *file = NULL((void*)0); |
6682 | |
6683 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6684 | |
6685 | selection = fm_directory_view_get_selection (view); |
6686 | for (l = selection; l != NULL((void*)0); l = l->next) { |
6687 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
6688 | |
6689 | if (baul_file_can_poll_for_media (file) && !baul_file_is_media_check_automatic (file)) { |
6690 | baul_file_poll_for_media (file); |
6691 | } |
6692 | } |
6693 | baul_file_list_free (selection); |
6694 | } |
6695 | |
6696 | static void |
6697 | action_self_mount_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6698 | gpointer data) |
6699 | { |
6700 | BaulFile *file; |
6701 | FMDirectoryView *view; |
6702 | GMountOperation *mount_op; |
6703 | |
6704 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6705 | |
6706 | file = fm_directory_view_get_directory_as_file (view); |
6707 | if (file == NULL((void*)0)) { |
6708 | return; |
6709 | } |
6710 | |
6711 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6712 | g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION); |
6713 | baul_file_mount (file, mount_op, NULL((void*)0), file_mount_callback, NULL((void*)0)); |
6714 | g_object_unref (mount_op); |
6715 | } |
6716 | |
6717 | static void |
6718 | action_self_unmount_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6719 | gpointer data) |
6720 | { |
6721 | BaulFile *file; |
6722 | FMDirectoryView *view; |
6723 | GMountOperation *mount_op; |
6724 | |
6725 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6726 | |
6727 | file = fm_directory_view_get_directory_as_file (view); |
6728 | if (file == NULL((void*)0)) { |
6729 | return; |
6730 | } |
6731 | |
6732 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6733 | fm_directory_view_set_initiated_unmount (view, TRUE(!(0))); |
6734 | baul_file_unmount (file, mount_op, NULL((void*)0), file_unmount_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view))); |
6735 | g_object_unref (mount_op); |
6736 | } |
6737 | |
6738 | static void |
6739 | action_self_eject_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6740 | gpointer data) |
6741 | { |
6742 | BaulFile *file; |
6743 | FMDirectoryView *view; |
6744 | GMountOperation *mount_op; |
6745 | |
6746 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6747 | |
6748 | file = fm_directory_view_get_directory_as_file (view); |
6749 | if (file == NULL((void*)0)) { |
6750 | return; |
6751 | } |
6752 | |
6753 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6754 | fm_directory_view_set_initiated_unmount (view, TRUE(!(0))); |
6755 | baul_file_eject (file, mount_op, NULL((void*)0), file_eject_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view))); |
6756 | g_object_unref (mount_op); |
6757 | } |
6758 | |
6759 | static void |
6760 | action_self_format_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6761 | gpointer data) |
6762 | { |
6763 | BaulFile *file; |
6764 | FMDirectoryView *view; |
6765 | |
6766 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6767 | |
6768 | file = fm_directory_view_get_directory_as_file (view); |
6769 | if (file == NULL((void*)0)) { |
6770 | return; |
6771 | } |
6772 | |
6773 | #ifdef TODO_GIO |
6774 | if (something) { |
6775 | g_spawn_command_line_async ("gfloppy", NULL((void*)0)); |
6776 | } |
6777 | #endif |
6778 | } |
6779 | |
6780 | static void |
6781 | action_self_start_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6782 | gpointer data) |
6783 | { |
6784 | BaulFile *file; |
6785 | FMDirectoryView *view; |
6786 | GMountOperation *mount_op; |
6787 | |
6788 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6789 | |
6790 | file = fm_directory_view_get_directory_as_file (view); |
6791 | if (file == NULL((void*)0)) { |
6792 | return; |
6793 | } |
6794 | |
6795 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6796 | baul_file_start (file, mount_op, NULL((void*)0), file_start_callback, NULL((void*)0)); |
6797 | g_object_unref (mount_op); |
6798 | } |
6799 | |
6800 | static void |
6801 | action_self_stop_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6802 | gpointer data) |
6803 | { |
6804 | BaulFile *file; |
6805 | FMDirectoryView *view; |
6806 | GMountOperation *mount_op; |
6807 | |
6808 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6809 | |
6810 | file = fm_directory_view_get_directory_as_file (view); |
6811 | if (file == NULL((void*)0)) { |
6812 | return; |
6813 | } |
6814 | |
6815 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6816 | baul_file_stop (file, mount_op, NULL((void*)0), |
6817 | file_stop_callback, NULL((void*)0)); |
6818 | g_object_unref (mount_op); |
6819 | } |
6820 | |
6821 | static void |
6822 | action_self_detect_media_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6823 | gpointer data) |
6824 | { |
6825 | BaulFile *file; |
6826 | FMDirectoryView *view; |
6827 | |
6828 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6829 | |
6830 | file = fm_directory_view_get_directory_as_file (view); |
6831 | if (file == NULL((void*)0)) { |
6832 | return; |
6833 | } |
6834 | |
6835 | baul_file_poll_for_media (file); |
6836 | } |
6837 | |
6838 | static void |
6839 | action_location_mount_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6840 | gpointer data) |
6841 | { |
6842 | BaulFile *file; |
6843 | FMDirectoryView *view; |
6844 | GMountOperation *mount_op; |
6845 | |
6846 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6847 | |
6848 | file = view->details->location_popup_directory_as_file; |
6849 | if (file == NULL((void*)0)) { |
6850 | return; |
6851 | } |
6852 | |
6853 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6854 | g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION); |
6855 | baul_file_mount (file, mount_op, NULL((void*)0), file_mount_callback, NULL((void*)0)); |
6856 | g_object_unref (mount_op); |
6857 | } |
6858 | |
6859 | static void |
6860 | action_location_unmount_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6861 | gpointer data) |
6862 | { |
6863 | BaulFile *file; |
6864 | FMDirectoryView *view; |
6865 | GMountOperation *mount_op; |
6866 | |
6867 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6868 | |
6869 | file = view->details->location_popup_directory_as_file; |
6870 | if (file == NULL((void*)0)) { |
6871 | return; |
6872 | } |
6873 | |
6874 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6875 | fm_directory_view_set_initiated_unmount (view, TRUE(!(0))); |
6876 | baul_file_unmount (file, mount_op, NULL((void*)0), |
6877 | file_unmount_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view))); |
6878 | g_object_unref (mount_op); |
6879 | } |
6880 | |
6881 | static void |
6882 | action_location_eject_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6883 | gpointer data) |
6884 | { |
6885 | BaulFile *file; |
6886 | FMDirectoryView *view; |
6887 | GMountOperation *mount_op; |
6888 | |
6889 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6890 | |
6891 | file = view->details->location_popup_directory_as_file; |
6892 | if (file == NULL((void*)0)) { |
6893 | return; |
6894 | } |
6895 | |
6896 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6897 | fm_directory_view_set_initiated_unmount (view, TRUE(!(0))); |
6898 | baul_file_eject (file, mount_op, NULL((void*)0), |
6899 | file_eject_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view))); |
6900 | g_object_unref (mount_op); |
6901 | } |
6902 | |
6903 | static void |
6904 | action_location_format_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6905 | gpointer data) |
6906 | { |
6907 | BaulFile *file; |
6908 | FMDirectoryView *view; |
6909 | |
6910 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6911 | |
6912 | file = view->details->location_popup_directory_as_file; |
6913 | if (file == NULL((void*)0)) { |
6914 | return; |
6915 | } |
6916 | |
6917 | #ifdef TODO_GIO |
6918 | if (something) { |
6919 | g_spawn_command_line_async ("gfloppy", NULL((void*)0)); |
6920 | } |
6921 | #endif |
6922 | } |
6923 | |
6924 | static void |
6925 | action_location_start_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6926 | gpointer data) |
6927 | { |
6928 | BaulFile *file; |
6929 | FMDirectoryView *view; |
6930 | GMountOperation *mount_op; |
6931 | |
6932 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6933 | |
6934 | file = view->details->location_popup_directory_as_file; |
6935 | if (file == NULL((void*)0)) { |
6936 | return; |
6937 | } |
6938 | |
6939 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6940 | baul_file_start (file, mount_op, NULL((void*)0), file_start_callback, NULL((void*)0)); |
6941 | g_object_unref (mount_op); |
6942 | } |
6943 | |
6944 | static void |
6945 | action_location_stop_volume_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6946 | gpointer data) |
6947 | { |
6948 | BaulFile *file; |
6949 | FMDirectoryView *view; |
6950 | GMountOperation *mount_op; |
6951 | |
6952 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6953 | |
6954 | file = view->details->location_popup_directory_as_file; |
6955 | if (file == NULL((void*)0)) { |
6956 | return; |
6957 | } |
6958 | |
6959 | mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view)); |
6960 | baul_file_stop (file, mount_op, NULL((void*)0), |
6961 | file_stop_callback, NULL((void*)0)); |
6962 | g_object_unref (mount_op); |
6963 | } |
6964 | |
6965 | static void |
6966 | action_location_detect_media_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
6967 | gpointer data) |
6968 | { |
6969 | BaulFile *file; |
6970 | FMDirectoryView *view; |
6971 | |
6972 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
6973 | |
6974 | file = view->details->location_popup_directory_as_file; |
6975 | if (file == NULL((void*)0)) { |
6976 | return; |
6977 | } |
6978 | |
6979 | baul_file_poll_for_media (file); |
6980 | } |
6981 | |
6982 | static void |
6983 | connect_to_server_response_callback (CtkDialog *dialog, |
6984 | int response_id G_GNUC_UNUSED__attribute__ ((__unused__)), |
6985 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
6986 | { |
6987 | #ifdef GIO_CONVERSION_DONE |
6988 | CtkEntry *entry; |
6989 | char *uri; |
6990 | const char *name; |
6991 | char *icon; |
6992 | |
6993 | entry = CTK_ENTRY (data)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), ((ctk_entry_get_type ())))))); |
6994 | |
6995 | switch (response_id) { |
6996 | case CTK_RESPONSE_OK: |
6997 | uri = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "link-uri"); |
6998 | icon = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "link-icon"); |
6999 | name = ctk_entry_get_text (entry); |
7000 | cafe_vfs_connect_to_server (uri, (char *)name, icon); |
7001 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
7002 | break; |
7003 | case CTK_RESPONSE_NONE: |
7004 | case CTK_RESPONSE_DELETE_EVENT: |
7005 | case CTK_RESPONSE_CANCEL: |
7006 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
7007 | break; |
7008 | default : |
7009 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 7009, ((const char*) (__func__)), ((void*)0)); } while (0); |
7010 | } |
7011 | #endif |
7012 | /* FIXME: the above code should make a server connection permanent */ |
7013 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
7014 | } |
7015 | |
7016 | static void |
7017 | entry_activate_callback (CtkEntry *entry G_GNUC_UNUSED__attribute__ ((__unused__)), |
7018 | gpointer user_data) |
7019 | { |
7020 | CtkDialog *dialog; |
7021 | |
7022 | dialog = CTK_DIALOG (user_data)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), ((ctk_dialog_get_type ())))))); |
7023 | ctk_dialog_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); |
7024 | } |
7025 | |
7026 | static void |
7027 | action_connect_to_server_link_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7028 | gpointer data) |
7029 | { |
7030 | BaulFile *file; |
7031 | GList *selection; |
7032 | FMDirectoryView *view; |
7033 | char *uri; |
7034 | BaulIconInfo *icon; |
7035 | const char *icon_name; |
7036 | char *name; |
7037 | gint scale; |
7038 | |
7039 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
7040 | |
7041 | selection = fm_directory_view_get_selection (view); |
7042 | |
7043 | if (!eel_g_list_exactly_one_item (selection)) { |
7044 | baul_file_list_free (selection); |
7045 | return; |
7046 | } |
7047 | |
7048 | file = BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type()))))); |
7049 | scale = ctk_widget_get_scale_factor (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
7050 | |
7051 | uri = baul_file_get_activation_uri (file); |
7052 | icon = baul_file_get_icon (file, BAUL_ICON_SIZE_STANDARD48, scale, 0); |
7053 | icon_name = baul_icon_info_get_used_name (icon); |
7054 | name = baul_file_get_display_name (file); |
7055 | |
7056 | if (uri != NULL((void*)0)) { |
7057 | CtkWidget *dialog; |
7058 | CtkWidget *label; |
7059 | CtkWidget *entry; |
7060 | CtkWidget *box; |
7061 | char *title; |
7062 | |
7063 | title = g_strdup_printf (_("Connect to Server %s")gettext ("Connect to Server %s"), name); |
7064 | |
7065 | dialog = ctk_dialog_new (); |
7066 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), title); |
7067 | ctk_window_set_transient_for (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), fm_directory_view_get_containing_window (view)); |
7068 | |
7069 | eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
7070 | _("_Cancel")gettext ("_Cancel"), |
7071 | "process-stop", |
7072 | CTK_RESPONSE_CANCEL); |
7073 | |
7074 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
7075 | _("_Connect")gettext ("_Connect"), |
7076 | CTK_RESPONSE_OK); |
7077 | |
7078 | g_object_set_data_full (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "link-uri", g_strdup (uri)g_strdup_inline (uri), g_free); |
7079 | g_object_set_data_full (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "link-icon", g_strdup (icon_name)g_strdup_inline (icon_name), g_free); |
7080 | |
7081 | ctk_container_set_border_width (CTK_CONTAINER (dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_container_get_type ())))))), 5); |
7082 | ctk_box_set_spacing (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_box_get_type ())))))), 2); |
7083 | |
7084 | box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12); |
7085 | ctk_widget_show (box); |
7086 | ctk_box_pack_start (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_box_get_type ())))))), |
7087 | box, TRUE(!(0)), TRUE(!(0)), 0); |
7088 | |
7089 | label = ctk_label_new_with_mnemonic (_("Link _name:")gettext ("Link _name:")); |
7090 | ctk_widget_show (label); |
7091 | |
7092 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), label, TRUE(!(0)), TRUE(!(0)), 12); |
7093 | |
7094 | entry = ctk_entry_new (); |
7095 | if (name) { |
7096 | ctk_entry_set_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), name); |
7097 | } |
7098 | g_signal_connect (entry,g_signal_connect_data ((entry), ("activate"), (((GCallback) ( entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags ) 0) |
7099 | "activate",g_signal_connect_data ((entry), ("activate"), (((GCallback) ( entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags ) 0) |
7100 | G_CALLBACK (entry_activate_callback),g_signal_connect_data ((entry), ("activate"), (((GCallback) ( entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags ) 0) |
7101 | dialog)g_signal_connect_data ((entry), ("activate"), (((GCallback) ( entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags ) 0); |
7102 | |
7103 | ctk_widget_show (entry); |
7104 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), entry); |
7105 | |
7106 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), entry, TRUE(!(0)), TRUE(!(0)), 12); |
7107 | |
7108 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
7109 | CTK_RESPONSE_OK); |
7110 | g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) ( connect_to_server_response_callback))), (entry), ((void*)0), ( GConnectFlags) 0) |
7111 | G_CALLBACK (connect_to_server_response_callback),g_signal_connect_data ((dialog), ("response"), (((GCallback) ( connect_to_server_response_callback))), (entry), ((void*)0), ( GConnectFlags) 0) |
7112 | entry)g_signal_connect_data ((dialog), ("response"), (((GCallback) ( connect_to_server_response_callback))), (entry), ((void*)0), ( GConnectFlags) 0); |
7113 | ctk_widget_show (dialog); |
7114 | } |
7115 | |
7116 | g_free (uri); |
7117 | g_object_unref (icon); |
7118 | g_free (name); |
7119 | } |
7120 | |
7121 | static void |
7122 | action_location_open_alternate_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7123 | gpointer callback_data) |
7124 | { |
7125 | FMDirectoryView *view; |
7126 | BaulFile *file; |
7127 | |
7128 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7129 | |
7130 | file = view->details->location_popup_directory_as_file; |
7131 | if (file == NULL((void*)0)) { |
7132 | return; |
7133 | } |
7134 | |
7135 | fm_directory_view_activate_file (view, |
7136 | file, |
7137 | BAUL_WINDOW_OPEN_IN_NAVIGATION, |
7138 | 0); |
7139 | } |
7140 | |
7141 | static void |
7142 | action_location_open_in_new_tab_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7143 | gpointer callback_data) |
7144 | { |
7145 | FMDirectoryView *view; |
7146 | BaulFile *file; |
7147 | |
7148 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7149 | |
7150 | file = view->details->location_popup_directory_as_file; |
7151 | if (file == NULL((void*)0)) { |
7152 | return; |
7153 | } |
7154 | |
7155 | fm_directory_view_activate_file (view, |
7156 | file, |
7157 | BAUL_WINDOW_OPEN_ACCORDING_TO_MODE, |
7158 | BAUL_WINDOW_OPEN_FLAG_NEW_TAB); |
7159 | } |
7160 | |
7161 | static void |
7162 | action_location_open_folder_window_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7163 | gpointer callback_data) |
7164 | { |
7165 | FMDirectoryView *view; |
7166 | BaulFile *file; |
7167 | |
7168 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7169 | |
7170 | file = view->details->location_popup_directory_as_file; |
7171 | g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ; } } while (0); |
7172 | |
7173 | fm_directory_view_activate_file (view, |
7174 | file, |
7175 | BAUL_WINDOW_OPEN_IN_SPATIAL, |
7176 | 0); |
7177 | } |
7178 | |
7179 | static void |
7180 | action_location_cut_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7181 | gpointer callback_data) |
7182 | { |
7183 | FMDirectoryView *view; |
7184 | BaulFile *file; |
7185 | GList *files; |
7186 | |
7187 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7188 | |
7189 | file = view->details->location_popup_directory_as_file; |
7190 | g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ; } } while (0); |
7191 | |
7192 | files = g_list_append (NULL((void*)0), file); |
7193 | copy_or_cut_files (view, files, TRUE(!(0))); |
7194 | g_list_free (files); |
7195 | } |
7196 | |
7197 | static void |
7198 | action_location_copy_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7199 | gpointer callback_data) |
7200 | { |
7201 | FMDirectoryView *view; |
7202 | BaulFile *file; |
7203 | GList *files; |
7204 | |
7205 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7206 | |
7207 | file = view->details->location_popup_directory_as_file; |
7208 | g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ; } } while (0); |
7209 | |
7210 | files = g_list_append (NULL((void*)0), file); |
7211 | copy_or_cut_files (view, files, FALSE(0)); |
7212 | g_list_free (files); |
7213 | } |
7214 | |
7215 | static void |
7216 | action_location_paste_files_into_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7217 | gpointer callback_data) |
7218 | { |
7219 | FMDirectoryView *view; |
7220 | BaulFile *file; |
7221 | |
7222 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7223 | |
7224 | file = view->details->location_popup_directory_as_file; |
7225 | g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ; } } while (0); |
7226 | |
7227 | paste_into (view, file); |
7228 | } |
7229 | |
7230 | static void |
7231 | action_location_trash_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7232 | gpointer callback_data) |
7233 | { |
7234 | FMDirectoryView *view; |
7235 | BaulFile *file; |
7236 | GList *files; |
7237 | |
7238 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7239 | |
7240 | file = view->details->location_popup_directory_as_file; |
7241 | g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ; } } while (0); |
7242 | |
7243 | files = g_list_append (NULL((void*)0), file); |
7244 | trash_or_delete_files (fm_directory_view_get_containing_window (view), |
7245 | files, TRUE(!(0)), |
7246 | view); |
7247 | g_list_free (files); |
7248 | } |
7249 | |
7250 | static void |
7251 | action_location_delete_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7252 | gpointer callback_data) |
7253 | { |
7254 | FMDirectoryView *view; |
7255 | BaulFile *file; |
7256 | GFile *location; |
7257 | GList *files; |
7258 | |
7259 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7260 | |
7261 | file = view->details->location_popup_directory_as_file; |
7262 | g_return_if_fail (file != NULL)do { if ((file != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "file != NULL"); return ; } } while (0); |
7263 | |
7264 | location = baul_file_get_location (file); |
7265 | |
7266 | files = g_list_append (NULL((void*)0), location); |
7267 | baul_file_operations_delete (files, fm_directory_view_get_containing_window (view), |
7268 | NULL((void*)0), NULL((void*)0)); |
7269 | |
7270 | g_list_free_full (files, g_object_unref); |
7271 | } |
7272 | |
7273 | static void |
7274 | action_location_restore_from_trash_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7275 | gpointer callback_data) |
7276 | { |
7277 | FMDirectoryView *view; |
7278 | BaulFile *file; |
7279 | GList l; |
7280 | |
7281 | view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
7282 | file = view->details->location_popup_directory_as_file; |
7283 | |
7284 | l.prev = NULL((void*)0); |
7285 | l.next = NULL((void*)0); |
7286 | l.data = file; |
7287 | baul_restore_files_from_trash (&l, |
7288 | fm_directory_view_get_containing_window (view)); |
7289 | } |
7290 | |
7291 | static void |
7292 | fm_directory_view_init_show_hidden_files (FMDirectoryView *view) |
7293 | { |
7294 | BaulWindowShowHiddenFilesMode mode; |
7295 | gboolean show_hidden_changed; |
7296 | gboolean show_hidden_default_setting; |
7297 | |
7298 | if (view->details->ignore_hidden_file_preferences) { |
7299 | return; |
7300 | } |
7301 | |
7302 | show_hidden_changed = FALSE(0); |
7303 | mode = baul_window_info_get_hidden_files_mode (view->details->window); |
7304 | |
7305 | if (mode == BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { |
7306 | show_hidden_default_setting = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_SHOW_HIDDEN_FILES"show-hidden-files"); |
7307 | if (show_hidden_default_setting != view->details->show_hidden_files) { |
7308 | view->details->show_hidden_files = show_hidden_default_setting; |
7309 | show_hidden_changed = TRUE(!(0)); |
7310 | } |
7311 | } else { |
7312 | if (mode == BAUL_WINDOW_SHOW_HIDDEN_FILES_ENABLE) { |
7313 | show_hidden_changed = !view->details->show_hidden_files; |
7314 | view->details->show_hidden_files = TRUE(!(0)); |
7315 | } else { |
7316 | show_hidden_changed = view->details->show_hidden_files; |
7317 | view->details->show_hidden_files = FALSE(0); |
7318 | } |
7319 | } |
7320 | |
7321 | if (show_hidden_changed && (view->details->model != NULL((void*)0))) { |
7322 | load_directory (view, view->details->model); |
7323 | } |
7324 | |
7325 | } |
7326 | |
7327 | static void |
7328 | fm_directory_view_init_show_backup_files (FMDirectoryView *view) |
7329 | { |
7330 | BaulWindowShowBackupFilesMode mode; |
7331 | gboolean show_backup_changed; |
7332 | gboolean show_backup_default_setting; |
7333 | |
7334 | show_backup_changed = FALSE(0); |
7335 | mode = baul_window_info_get_backup_files_mode (view->details->window); |
7336 | |
7337 | if (mode == BAUL_WINDOW_SHOW_BACKUP_FILES_DEFAULT) { |
7338 | show_backup_default_setting = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_SHOW_BACKUP_FILES"show-backup-files"); |
7339 | if (show_backup_default_setting != view->details->show_backup_files) { |
7340 | view->details->show_backup_files = show_backup_default_setting; |
7341 | show_backup_changed = TRUE(!(0)); |
7342 | } |
7343 | } else { |
7344 | if (mode == BAUL_WINDOW_SHOW_BACKUP_FILES_ENABLE) { |
7345 | show_backup_changed = !view->details->show_backup_files; |
7346 | view->details->show_backup_files = TRUE(!(0)); |
7347 | } else { |
7348 | show_backup_changed = view->details->show_backup_files; |
7349 | view->details->show_backup_files = FALSE(0); |
7350 | } |
7351 | } |
7352 | |
7353 | if (show_backup_changed && (view->details->model != NULL((void*)0))) { |
7354 | load_directory (view, view->details->model); |
7355 | } |
7356 | |
7357 | } |
7358 | |
7359 | static const CtkActionEntry directory_view_entries[] = { |
7360 | /* name, icon name, label */ { "New Documents", "document-new", N_("Create _Document")("Create _Document") }, |
7361 | /* name, icon name, label */ { "Open With", NULL((void*)0), N_("Open Wit_h")("Open Wit_h"), |
7362 | NULL((void*)0), N_("Choose a program with which to open the selected item")("Choose a program with which to open the selected item") }, |
7363 | /* name, icon name */ { "Properties", "document-properties", |
7364 | /* label, accelerator */ N_("_Properties")("_Properties"), "<alt>Return", |
7365 | /* tooltip */ N_("View or modify the properties of each selected item")("View or modify the properties of each selected item"), |
7366 | G_CALLBACK (action_properties_callback)((GCallback) (action_properties_callback)) }, |
7367 | /* name, icon name */ { "PropertiesAccel", NULL((void*)0), |
7368 | /* label, accelerator */ "PropertiesAccel", "<control>I", |
7369 | /* tooltip */ NULL((void*)0), |
7370 | G_CALLBACK (action_properties_callback)((GCallback) (action_properties_callback)) }, |
7371 | /* name, icon name */ { "New Folder", "folder-new", |
7372 | /* label, accelerator */ N_("Create _Folder")("Create _Folder"), "<control><shift>N", |
7373 | /* tooltip */ N_("Create a new empty folder inside this folder")("Create a new empty folder inside this folder"), |
7374 | G_CALLBACK (action_new_folder_callback)((GCallback) (action_new_folder_callback)) }, |
7375 | /* name, icon name, label */ { "No Templates", NULL((void*)0), N_("No templates installed")("No templates installed") }, |
7376 | /* name, icon name */ { "New Empty File", NULL((void*)0), |
7377 | /* Translators: this is used to indicate that a file doesn't contain anything */ |
7378 | /* label, accelerator */ N_("_Empty File")("_Empty File"), NULL((void*)0), |
7379 | /* tooltip */ N_("Create a new empty file inside this folder")("Create a new empty file inside this folder"), |
7380 | G_CALLBACK (action_new_empty_file_callback)((GCallback) (action_new_empty_file_callback)) }, |
7381 | /* name, icon name */ { "New Launcher", NULL((void*)0), |
7382 | /* label, accelerator */ N_("Create L_auncher...")("Create L_auncher..."), NULL((void*)0), |
7383 | /* tooltip */ N_("Create a new launcher")("Create a new launcher"), |
7384 | G_CALLBACK (action_new_launcher_callback)((GCallback) (action_new_launcher_callback)) }, |
7385 | /* name, icon name */ { "Open", NULL((void*)0), |
7386 | /* label, accelerator */ N_("_Open")("_Open"), "<control>o", |
7387 | /* tooltip */ N_("Open the selected item in this window")("Open the selected item in this window"), |
7388 | G_CALLBACK (action_open_callback)((GCallback) (action_open_callback)) }, |
7389 | /* name, icon name */ { "OpenAccel", NULL((void*)0), |
7390 | /* label, accelerator */ "OpenAccel", "<alt>Down", |
7391 | /* tooltip */ NULL((void*)0), |
7392 | G_CALLBACK (action_open_callback)((GCallback) (action_open_callback)) }, |
7393 | /* name, icon name */ { "OpenAlternate", NULL((void*)0), |
7394 | /* label, accelerator */ N_("Open in Navigation Window")("Open in Navigation Window"), "<control><shift>w", |
7395 | /* tooltip */ N_("Open each selected item in a navigation window")("Open each selected item in a navigation window"), |
7396 | G_CALLBACK (action_open_alternate_callback)((GCallback) (action_open_alternate_callback)) }, |
7397 | /* name, icon name */ { "OpenInNewTab", NULL((void*)0), |
7398 | /* label, accelerator */ N_("Open in New _Tab")("Open in New _Tab"), "<control><shift>o", |
7399 | /* tooltip */ N_("Open each selected item in a new tab")("Open each selected item in a new tab"), |
7400 | G_CALLBACK (action_open_new_tab_callback)((GCallback) (action_open_new_tab_callback)) }, |
7401 | /* name, icon name */ { "OpenFolderWindow", NULL((void*)0), |
7402 | /* label, accelerator */ N_("Open in _Folder Window")("Open in _Folder Window"), NULL((void*)0), |
7403 | /* tooltip */ N_("Open each selected item in a folder window")("Open each selected item in a folder window"), |
7404 | G_CALLBACK (action_open_folder_window_callback)((GCallback) (action_open_folder_window_callback)) }, |
7405 | /* name, icon name */ { "OtherApplication1", NULL((void*)0), |
7406 | /* label, accelerator */ N_("Other _Application...")("Other _Application..."), NULL((void*)0), |
7407 | /* tooltip */ N_("Choose another application with which to open the selected item")("Choose another application with which to open the selected item" ), |
7408 | G_CALLBACK (action_other_application_callback)((GCallback) (action_other_application_callback)) }, |
7409 | /* name, icon name */ { "OtherApplication2", NULL((void*)0), |
7410 | /* label, accelerator */ N_("Open With Other _Application...")("Open With Other _Application..."), NULL((void*)0), |
7411 | /* tooltip */ N_("Choose another application with which to open the selected item")("Choose another application with which to open the selected item" ), |
7412 | G_CALLBACK (action_other_application_callback)((GCallback) (action_other_application_callback)) }, |
7413 | /* name, icon name */ { "Open Scripts Folder", NULL((void*)0), |
7414 | /* label, accelerator */ N_("_Open Scripts Folder")("_Open Scripts Folder"), NULL((void*)0), |
7415 | /* tooltip */ N_("Show the folder containing the scripts that appear in this menu")("Show the folder containing the scripts that appear in this menu" ), |
7416 | G_CALLBACK (action_open_scripts_folder_callback)((GCallback) (action_open_scripts_folder_callback)) }, |
7417 | /* name, icon name */ { "Empty Trash", BAUL_ICON_TRASH"user-trash", |
7418 | /* label, accelerator */ N_("E_mpty Trash")("E_mpty Trash"), NULL((void*)0), |
7419 | /* tooltip */ N_("Delete all items in the Trash")("Delete all items in the Trash"), |
7420 | G_CALLBACK (action_empty_trash_callback)((GCallback) (action_empty_trash_callback)) }, |
7421 | /* name, icon name */ { "Cut", "edit-cut", |
7422 | /* label, accelerator */ N_("Cu_t")("Cu_t"), "<control>X", |
7423 | /* tooltip */ N_("Prepare the selected files to be moved with a Paste command")("Prepare the selected files to be moved with a Paste command" ), |
7424 | G_CALLBACK (action_cut_files_callback)((GCallback) (action_cut_files_callback)) }, |
7425 | /* name, icon name */ { "Copy", "edit-copy", |
7426 | /* label, accelerator */ N_("_Copy")("_Copy"), "<control>C", |
7427 | /* tooltip */ N_("Prepare the selected files to be copied with a Paste command")("Prepare the selected files to be copied with a Paste command" ), |
7428 | G_CALLBACK (action_copy_files_callback)((GCallback) (action_copy_files_callback)) }, |
7429 | /* name, icon name */ { "Paste", "edit-paste", |
7430 | /* label, accelerator */ N_("_Paste")("_Paste"), "<control>V", |
7431 | /* tooltip */ N_("Move or copy files previously selected by a Cut or Copy command")("Move or copy files previously selected by a Cut or Copy command" ), |
7432 | G_CALLBACK (action_paste_files_callback)((GCallback) (action_paste_files_callback)) }, |
7433 | /* We make accelerator "" instead of null here to not inherit the stock |
7434 | accelerator for paste */ |
7435 | /* name, icon name */ { "Paste Files Into", "edit-paste", |
7436 | /* label, accelerator */ N_("_Paste Into Folder")("_Paste Into Folder"), "", |
7437 | /* tooltip */ N_("Move or copy files previously selected by a Cut or Copy command into the selected folder")("Move or copy files previously selected by a Cut or Copy command into the selected folder" ), |
7438 | G_CALLBACK (action_paste_files_into_callback)((GCallback) (action_paste_files_into_callback)) }, |
7439 | /* name, icon name, label */ { "CopyToMenu", NULL((void*)0), N_("Cop_y to")("Cop_y to") }, |
7440 | /* name, icon name, label */ { "MoveToMenu", NULL((void*)0), N_("M_ove to")("M_ove to") }, |
7441 | /* name, icon name */ { "Select All", NULL((void*)0), |
7442 | /* label, accelerator */ N_("Select _All")("Select _All"), "<control>A", |
7443 | /* tooltip */ N_("Select all items in this window")("Select all items in this window"), |
7444 | G_CALLBACK (action_select_all_callback)((GCallback) (action_select_all_callback)) }, |
7445 | /* name, icon name */ { "Select Pattern", NULL((void*)0), |
7446 | /* label, accelerator */ N_("Select I_tems Matching...")("Select I_tems Matching..."), "<control>S", |
7447 | /* tooltip */ N_("Select items in this window matching a given pattern")("Select items in this window matching a given pattern"), |
7448 | G_CALLBACK (action_select_pattern_callback)((GCallback) (action_select_pattern_callback)) }, |
7449 | /* name, icon name */ { "Invert Selection", NULL((void*)0), |
7450 | /* label, accelerator */ N_("_Invert Selection")("_Invert Selection"), "<control><shift>I", |
7451 | /* tooltip */ N_("Select all and only the items that are not currently selected")("Select all and only the items that are not currently selected" ), |
7452 | G_CALLBACK (action_invert_selection_callback)((GCallback) (action_invert_selection_callback)) }, |
7453 | /* name, icon name */ { "Duplicate", NULL((void*)0), |
7454 | /* label, accelerator */ N_("D_uplicate")("D_uplicate"), NULL((void*)0), |
7455 | /* tooltip */ N_("Duplicate each selected item")("Duplicate each selected item"), |
7456 | G_CALLBACK (action_duplicate_callback)((GCallback) (action_duplicate_callback)) }, |
7457 | /* name, icon name */ { "Create Link", NULL((void*)0), |
7458 | /* label, accelerator */ N_("Ma_ke Link")("Ma_ke Link"), "<control>M", |
7459 | /* tooltip */ N_("Create a symbolic link for each selected item")("Create a symbolic link for each selected item"), |
7460 | G_CALLBACK (action_create_link_callback)((GCallback) (action_create_link_callback)) }, |
7461 | /* name, icon name */ { "Rename", NULL((void*)0), |
7462 | /* label, accelerator */ N_("_Rename...")("_Rename..."), "F2", |
7463 | /* tooltip */ N_("Rename selected item")("Rename selected item"), |
7464 | G_CALLBACK (action_rename_callback)((GCallback) (action_rename_callback)) }, |
7465 | /* name, icon name */ { "RenameSelectAll", NULL((void*)0), |
7466 | /* label, accelerator */ "RenameSelectAll", "<shift>F2", |
7467 | /* tooltip */ NULL((void*)0), |
7468 | G_CALLBACK (action_rename_select_all_callback)((GCallback) (action_rename_select_all_callback)) }, |
7469 | /* name, icon name */ { "Trash", NULL((void*)0), |
7470 | /* label, accelerator */ N_("Mo_ve to Trash")("Mo_ve to Trash"), NULL((void*)0), |
7471 | /* tooltip */ N_("Move each selected item to the Trash")("Move each selected item to the Trash"), |
7472 | G_CALLBACK (action_trash_callback)((GCallback) (action_trash_callback)) }, |
7473 | /* name, icon name */ { "Delete", NULL((void*)0), |
7474 | /* label, accelerator */ N_("_Delete")("_Delete"), NULL((void*)0), |
7475 | /* tooltip */ N_("Delete each selected item, without moving to the Trash")("Delete each selected item, without moving to the Trash"), |
7476 | G_CALLBACK (action_delete_callback)((GCallback) (action_delete_callback)) }, |
7477 | /* name, icon name */ { "Restore From Trash", NULL((void*)0), |
7478 | /* label, accelerator */ N_("_Restore")("_Restore"), NULL((void*)0), |
7479 | NULL((void*)0), |
7480 | G_CALLBACK (action_restore_from_trash_callback)((GCallback) (action_restore_from_trash_callback)) }, |
7481 | /* name, icon name */ { FM_ACTION_UNDO"Undo", "edit-undo", |
7482 | /* label, accelerator */ N_("_Undo")("_Undo"), "<control>Z", |
7483 | /* tooltip */ N_("Undo the last action")("Undo the last action"), |
7484 | G_CALLBACK (action_undo_callback)((GCallback) (action_undo_callback)) }, |
7485 | /* name, icon name */ { FM_ACTION_REDO"Redo", "edit-redo", |
7486 | /* label, accelerator */ N_("_Redo")("_Redo"), "<control>Y", |
7487 | /* tooltip */ N_("Redo the last undone action")("Redo the last undone action"), |
7488 | G_CALLBACK (action_redo_callback)((GCallback) (action_redo_callback)) }, |
7489 | |
7490 | /* |
7491 | * multiview-TODO: decide whether "Reset to Defaults" should |
7492 | * be window-wide, and not just view-wide. |
7493 | * Since this also resets the "Show hidden files" mode, |
7494 | * it is a mixture of both ATM. |
7495 | */ |
7496 | /* name, icon name */ { "Reset to Defaults", NULL((void*)0), |
7497 | /* label, accelerator */ N_("Reset View to _Defaults")("Reset View to _Defaults"), NULL((void*)0), |
7498 | /* tooltip */ N_("Reset sorting order and zoom level to match preferences for this view")("Reset sorting order and zoom level to match preferences for this view" ), |
7499 | G_CALLBACK (action_reset_to_defaults_callback)((GCallback) (action_reset_to_defaults_callback)) }, |
7500 | /* name, icon name */ { "Connect To Server Link", NULL((void*)0), |
7501 | /* label, accelerator */ N_("Connect To This Server")("Connect To This Server"), NULL((void*)0), |
7502 | /* tooltip */ N_("Make a permanent connection to this server")("Make a permanent connection to this server"), |
7503 | G_CALLBACK (action_connect_to_server_link_callback)((GCallback) (action_connect_to_server_link_callback)) }, |
7504 | /* name, icon name */ { "Mount Volume", NULL((void*)0), |
7505 | /* label, accelerator */ N_("_Mount")("_Mount"), NULL((void*)0), |
7506 | /* tooltip */ N_("Mount the selected volume")("Mount the selected volume"), |
7507 | G_CALLBACK (action_mount_volume_callback)((GCallback) (action_mount_volume_callback)) }, |
7508 | /* name, icon name */ { "Unmount Volume", NULL((void*)0), |
7509 | /* label, accelerator */ N_("_Unmount")("_Unmount"), NULL((void*)0), |
7510 | /* tooltip */ N_("Unmount the selected volume")("Unmount the selected volume"), |
7511 | G_CALLBACK (action_unmount_volume_callback)((GCallback) (action_unmount_volume_callback)) }, |
7512 | /* name, icon name */ { "Eject Volume", NULL((void*)0), |
7513 | /* label, accelerator */ N_("_Eject")("_Eject"), NULL((void*)0), |
7514 | /* tooltip */ N_("Eject the selected volume")("Eject the selected volume"), |
7515 | G_CALLBACK (action_eject_volume_callback)((GCallback) (action_eject_volume_callback)) }, |
7516 | /* name, icon name */ { "Format Volume", NULL((void*)0), |
7517 | /* label, accelerator */ N_("_Format")("_Format"), NULL((void*)0), |
7518 | /* tooltip */ N_("Format the selected volume")("Format the selected volume"), |
7519 | G_CALLBACK (action_format_volume_callback)((GCallback) (action_format_volume_callback)) }, |
7520 | /* name, icon name */ { "Start Volume", NULL((void*)0), |
7521 | /* label, accelerator */ N_("_Start")("_Start"), NULL((void*)0), |
7522 | /* tooltip */ N_("Start the selected volume")("Start the selected volume"), |
7523 | G_CALLBACK (action_start_volume_callback)((GCallback) (action_start_volume_callback)) }, |
7524 | /* name, icon name */ { "Stop Volume", NULL((void*)0), |
7525 | /* label, accelerator */ N_("_Stop")("_Stop"), NULL((void*)0), |
7526 | /* tooltip */ N_("Stop the selected volume")("Stop the selected volume"), |
7527 | G_CALLBACK (action_stop_volume_callback)((GCallback) (action_stop_volume_callback)) }, |
7528 | /* name, icon name */ { "Poll", NULL((void*)0), |
7529 | /* label, accelerator */ N_("_Detect Media")("_Detect Media"), NULL((void*)0), |
7530 | /* tooltip */ N_("Detect media in the selected drive")("Detect media in the selected drive"), |
7531 | G_CALLBACK (action_detect_media_callback)((GCallback) (action_detect_media_callback)) }, |
7532 | /* name, icon name */ { "Self Mount Volume", NULL((void*)0), |
7533 | /* label, accelerator */ N_("_Mount")("_Mount"), NULL((void*)0), |
7534 | /* tooltip */ N_("Mount the volume associated with the open folder")("Mount the volume associated with the open folder"), |
7535 | G_CALLBACK (action_self_mount_volume_callback)((GCallback) (action_self_mount_volume_callback)) }, |
7536 | /* name, icon name */ { "Self Unmount Volume", NULL((void*)0), |
7537 | /* label, accelerator */ N_("_Unmount")("_Unmount"), NULL((void*)0), |
7538 | /* tooltip */ N_("Unmount the volume associated with the open folder")("Unmount the volume associated with the open folder"), |
7539 | G_CALLBACK (action_self_unmount_volume_callback)((GCallback) (action_self_unmount_volume_callback)) }, |
7540 | /* name, icon name */ { "Self Eject Volume", NULL((void*)0), |
7541 | /* label, accelerator */ N_("_Eject")("_Eject"), NULL((void*)0), |
7542 | /* tooltip */ N_("Eject the volume associated with the open folder")("Eject the volume associated with the open folder"), |
7543 | G_CALLBACK (action_self_eject_volume_callback)((GCallback) (action_self_eject_volume_callback)) }, |
7544 | /* name, icon name */ { "Self Format Volume", NULL((void*)0), |
7545 | /* label, accelerator */ N_("_Format")("_Format"), NULL((void*)0), |
7546 | /* tooltip */ N_("Format the volume associated with the open folder")("Format the volume associated with the open folder"), |
7547 | G_CALLBACK (action_self_format_volume_callback)((GCallback) (action_self_format_volume_callback)) }, |
7548 | /* name, icon name */ { "Self Start Volume", NULL((void*)0), |
7549 | /* label, accelerator */ N_("_Start")("_Start"), NULL((void*)0), |
7550 | /* tooltip */ N_("Start the volume associated with the open folder")("Start the volume associated with the open folder"), |
7551 | G_CALLBACK (action_self_start_volume_callback)((GCallback) (action_self_start_volume_callback)) }, |
7552 | /* name, icon name */ { "Self Stop Volume", NULL((void*)0), |
7553 | /* label, accelerator */ N_("_Stop")("_Stop"), NULL((void*)0), |
7554 | /* tooltip */ N_("Stop the volume associated with the open folder")("Stop the volume associated with the open folder"), |
7555 | G_CALLBACK (action_self_stop_volume_callback)((GCallback) (action_self_stop_volume_callback)) }, |
7556 | /* name, icon name */ { "Self Poll", NULL((void*)0), |
7557 | /* label, accelerator */ N_("_Detect Media")("_Detect Media"), NULL((void*)0), |
7558 | /* tooltip */ N_("Detect media in the selected drive")("Detect media in the selected drive"), |
7559 | G_CALLBACK (action_self_detect_media_callback)((GCallback) (action_self_detect_media_callback)) }, |
7560 | /* name, icon name */ { "OpenCloseParent", NULL((void*)0), |
7561 | /* label, accelerator */ N_("Open File and Close window")("Open File and Close window"), "<alt><shift>Down", |
7562 | /* tooltip */ NULL((void*)0), |
7563 | G_CALLBACK (action_open_close_parent_callback)((GCallback) (action_open_close_parent_callback)) }, |
7564 | /* name, icon name */ { "Save Search", NULL((void*)0), |
7565 | /* label, accelerator */ N_("Sa_ve Search")("Sa_ve Search"), NULL((void*)0), |
7566 | /* tooltip */ N_("Save the edited search")("Save the edited search"), |
7567 | G_CALLBACK (action_save_search_callback)((GCallback) (action_save_search_callback)) }, |
7568 | /* name, icon name */ { "Save Search As", NULL((void*)0), |
7569 | /* label, accelerator */ N_("Sa_ve Search As...")("Sa_ve Search As..."), NULL((void*)0), |
7570 | /* tooltip */ N_("Save the current search as a file")("Save the current search as a file"), |
7571 | G_CALLBACK (action_save_search_as_callback)((GCallback) (action_save_search_as_callback)) }, |
7572 | |
7573 | /* Location-specific actions */ |
7574 | /* name, icon name */ { FM_ACTION_LOCATION_OPEN_ALTERNATE"LocationOpenAlternate", NULL((void*)0), |
7575 | /* label, accelerator */ N_("Open in Navigation Window")("Open in Navigation Window"), "", |
7576 | /* tooltip */ N_("Open this folder in a navigation window")("Open this folder in a navigation window"), |
7577 | G_CALLBACK (action_location_open_alternate_callback)((GCallback) (action_location_open_alternate_callback)) }, |
7578 | /* name, icon name */ { FM_ACTION_LOCATION_OPEN_IN_NEW_TAB"LocationOpenInNewTab", NULL((void*)0), |
7579 | /* label, accelerator */ N_("Open in New _Tab")("Open in New _Tab"), "", |
7580 | /* tooltip */ N_("Open this folder in a new tab")("Open this folder in a new tab"), |
7581 | G_CALLBACK (action_location_open_in_new_tab_callback)((GCallback) (action_location_open_in_new_tab_callback)) }, |
7582 | |
7583 | /* name, icon name */ { FM_ACTION_LOCATION_OPEN_FOLDER_WINDOW"LocationOpenFolderWindow", NULL((void*)0), |
7584 | /* label, accelerator */ N_("Open in _Folder Window")("Open in _Folder Window"), "", |
7585 | /* tooltip */ N_("Open this folder in a folder window")("Open this folder in a folder window"), |
7586 | G_CALLBACK (action_location_open_folder_window_callback)((GCallback) (action_location_open_folder_window_callback)) }, |
7587 | |
7588 | /* name, icon name */ { FM_ACTION_LOCATION_CUT"LocationCut", "edit-cut", |
7589 | /* label, accelerator */ N_("Cu_t")("Cu_t"), "", |
7590 | /* tooltip */ N_("Prepare this folder to be moved with a Paste command")("Prepare this folder to be moved with a Paste command"), |
7591 | G_CALLBACK (action_location_cut_callback)((GCallback) (action_location_cut_callback)) }, |
7592 | /* name, icon name */ { FM_ACTION_LOCATION_COPY"LocationCopy", "edit-copy", |
7593 | /* label, accelerator */ N_("_Copy")("_Copy"), "", |
7594 | /* tooltip */ N_("Prepare this folder to be copied with a Paste command")("Prepare this folder to be copied with a Paste command"), |
7595 | G_CALLBACK (action_location_copy_callback)((GCallback) (action_location_copy_callback)) }, |
7596 | /* name, icon name */ { FM_ACTION_LOCATION_PASTE_FILES_INTO"LocationPasteFilesInto", "edit-paste", |
7597 | /* label, accelerator */ N_("_Paste Into Folder")("_Paste Into Folder"), "", |
7598 | /* tooltip */ N_("Move or copy files previously selected by a Cut or Copy command into this folder")("Move or copy files previously selected by a Cut or Copy command into this folder" ), |
7599 | G_CALLBACK (action_location_paste_files_into_callback)((GCallback) (action_location_paste_files_into_callback)) }, |
7600 | |
7601 | /* name, icon name */ { FM_ACTION_LOCATION_TRASH"LocationTrash", NULL((void*)0), |
7602 | /* label, accelerator */ N_("Mo_ve to Trash")("Mo_ve to Trash"), "", |
7603 | /* tooltip */ N_("Move this folder to the Trash")("Move this folder to the Trash"), |
7604 | G_CALLBACK (action_location_trash_callback)((GCallback) (action_location_trash_callback)) }, |
7605 | /* name, icon name */ { FM_ACTION_LOCATION_DELETE"LocationDelete", BAUL_ICON_DELETE"edit-delete", |
7606 | /* label, accelerator */ N_("_Delete")("_Delete"), "", |
7607 | /* tooltip */ N_("Delete this folder, without moving to the Trash")("Delete this folder, without moving to the Trash"), |
7608 | G_CALLBACK (action_location_delete_callback)((GCallback) (action_location_delete_callback)) }, |
7609 | /* name, icon name */ { FM_ACTION_LOCATION_RESTORE_FROM_TRASH"LocationRestoreFromTrash", NULL((void*)0), |
7610 | /* label, accelerator */ N_("_Restore")("_Restore"), NULL((void*)0), NULL((void*)0), |
7611 | G_CALLBACK (action_location_restore_from_trash_callback)((GCallback) (action_location_restore_from_trash_callback)) }, |
7612 | |
7613 | /* name, icon name */ { "Location Mount Volume", NULL((void*)0), |
7614 | /* label, accelerator */ N_("_Mount")("_Mount"), NULL((void*)0), |
7615 | /* tooltip */ N_("Mount the volume associated with this folder")("Mount the volume associated with this folder"), |
7616 | G_CALLBACK (action_location_mount_volume_callback)((GCallback) (action_location_mount_volume_callback)) }, |
7617 | /* name, icon name */ { "Location Unmount Volume", NULL((void*)0), |
7618 | /* label, accelerator */ N_("_Unmount")("_Unmount"), NULL((void*)0), |
7619 | /* tooltip */ N_("Unmount the volume associated with this folder")("Unmount the volume associated with this folder"), |
7620 | G_CALLBACK (action_location_unmount_volume_callback)((GCallback) (action_location_unmount_volume_callback)) }, |
7621 | /* name, icon name */ { "Location Eject Volume", NULL((void*)0), |
7622 | /* label, accelerator */ N_("_Eject")("_Eject"), NULL((void*)0), |
7623 | /* tooltip */ N_("Eject the volume associated with this folder")("Eject the volume associated with this folder"), |
7624 | G_CALLBACK (action_location_eject_volume_callback)((GCallback) (action_location_eject_volume_callback)) }, |
7625 | /* name, icon name */ { "Location Format Volume", NULL((void*)0), |
7626 | /* label, accelerator */ N_("_Format")("_Format"), NULL((void*)0), |
7627 | /* tooltip */ N_("Format the volume associated with this folder")("Format the volume associated with this folder"), |
7628 | G_CALLBACK (action_location_format_volume_callback)((GCallback) (action_location_format_volume_callback)) }, |
7629 | /* name, icon name */ { "Location Start Volume", NULL((void*)0), |
7630 | /* label, accelerator */ N_("_Start")("_Start"), NULL((void*)0), |
7631 | /* tooltip */ N_("Start the volume associated with this folder")("Start the volume associated with this folder"), |
7632 | G_CALLBACK (action_location_start_volume_callback)((GCallback) (action_location_start_volume_callback)) }, |
7633 | /* name, icon name */ { "Location Stop Volume", NULL((void*)0), |
7634 | /* label, accelerator */ N_("_Stop")("_Stop"), NULL((void*)0), |
7635 | /* tooltip */ N_("Stop the volume associated with this folder")("Stop the volume associated with this folder"), |
7636 | G_CALLBACK (action_location_stop_volume_callback)((GCallback) (action_location_stop_volume_callback)) }, |
7637 | /* name, icon name */ { "Location Poll", NULL((void*)0), |
7638 | /* label, accelerator */ N_("_Detect Media")("_Detect Media"), NULL((void*)0), |
7639 | /* tooltip */ N_("Detect media in the selected drive")("Detect media in the selected drive"), |
7640 | G_CALLBACK (action_location_detect_media_callback)((GCallback) (action_location_detect_media_callback)) }, |
7641 | |
7642 | /* name, icon name */ { "LocationProperties", "document-properties", |
7643 | /* label, accelerator */ N_("_Properties")("_Properties"), NULL((void*)0), |
7644 | /* tooltip */ N_("View or modify the properties of this folder")("View or modify the properties of this folder"), |
7645 | G_CALLBACK (action_location_properties_callback)((GCallback) (action_location_properties_callback)) }, |
7646 | |
7647 | /* name, icon name, label */ {FM_ACTION_COPY_TO_NEXT_PANE"Copy to next pane", NULL((void*)0), N_("_Other pane")("_Other pane"), |
7648 | NULL((void*)0), N_("Copy the current selection to the other pane in the window")("Copy the current selection to the other pane in the window" ), |
7649 | G_CALLBACK (action_copy_to_next_pane_callback)((GCallback) (action_copy_to_next_pane_callback)) }, |
7650 | /* name, icon name, label */ {FM_ACTION_MOVE_TO_NEXT_PANE"Move to next pane", NULL((void*)0), N_("_Other pane")("_Other pane"), |
7651 | NULL((void*)0), N_("Move the current selection to the other pane in the window")("Move the current selection to the other pane in the window" ), |
7652 | G_CALLBACK (action_move_to_next_pane_callback)((GCallback) (action_move_to_next_pane_callback)) }, |
7653 | /* name, icon name, label */ {FM_ACTION_COPY_TO_HOME"Copy to Home", BAUL_ICON_HOME"user-home", |
7654 | N_("_Home Folder")("_Home Folder"), NULL((void*)0), |
7655 | N_("Copy the current selection to the home folder")("Copy the current selection to the home folder"), |
7656 | G_CALLBACK (action_copy_to_home_callback)((GCallback) (action_copy_to_home_callback)) }, |
7657 | /* name, icon name, label */ {FM_ACTION_MOVE_TO_HOME"Move to Home", BAUL_ICON_HOME"user-home", |
7658 | N_("_Home Folder")("_Home Folder"), NULL((void*)0), |
7659 | N_("Move the current selection to the home folder")("Move the current selection to the home folder"), |
7660 | G_CALLBACK (action_move_to_home_callback)((GCallback) (action_move_to_home_callback)) }, |
7661 | /* name, icon name, label */ {FM_ACTION_COPY_TO_DESKTOP"Copy to Desktop", BAUL_ICON_DESKTOP"user-desktop", |
7662 | N_("_Desktop")("_Desktop"), NULL((void*)0), |
7663 | N_("Copy the current selection to the desktop")("Copy the current selection to the desktop"), |
7664 | G_CALLBACK (action_copy_to_desktop_callback)((GCallback) (action_copy_to_desktop_callback)) }, |
7665 | /* name, icon name, label */ {FM_ACTION_MOVE_TO_DESKTOP"Move to Desktop", BAUL_ICON_DESKTOP"user-desktop", |
7666 | N_("_Desktop")("_Desktop"), NULL((void*)0), |
7667 | N_("Move the current selection to the desktop")("Move the current selection to the desktop"), |
7668 | G_CALLBACK (action_move_to_desktop_callback)((GCallback) (action_move_to_desktop_callback)) }, |
7669 | }; |
7670 | |
7671 | static void |
7672 | connect_proxy (FMDirectoryView *view, |
7673 | CtkAction *action, |
7674 | CtkWidget *proxy, |
7675 | CtkActionGroup *action_group G_GNUC_UNUSED__attribute__ ((__unused__))) |
7676 | { |
7677 | const gchar *action_name; |
7678 | |
7679 | action_name = ctk_action_get_name (action); |
7680 | |
7681 | if (strcmp (action_name, FM_ACTION_NEW_EMPTY_FILE"New Empty File") == 0 && |
7682 | CTK_IS_IMAGE_MENU_ITEM (proxy)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (proxy)); GType __t = ((ctk_image_menu_item_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
7683 | cairo_surface_t *surface; |
7684 | |
7685 | surface = get_menu_icon ("text-x-generic", CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
7686 | |
7687 | if (surface != NULL((void*)0)) { |
7688 | CtkWidget *image; |
7689 | |
7690 | image = ctk_image_new_from_surface (surface); |
7691 | ctk_image_menu_item_set_image (CTK_IMAGE_MENU_ITEM (proxy)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((proxy)), ((ctk_image_menu_item_get_type ()) ))))), image); |
7692 | |
7693 | cairo_surface_destroy (surface); |
7694 | } |
7695 | } |
7696 | } |
7697 | |
7698 | static void |
7699 | pre_activate (FMDirectoryView *view, |
7700 | CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
7701 | CtkActionGroup *action_group G_GNUC_UNUSED__attribute__ ((__unused__))) |
7702 | { |
7703 | CdkEvent *event; |
7704 | CtkWidget *proxy; |
7705 | gboolean activated_from_popup; |
7706 | |
7707 | /* check whether action was activated through a popup menu. |
7708 | * If not, unset the last stored context menu popup position */ |
7709 | activated_from_popup = FALSE(0); |
7710 | |
7711 | event = ctk_get_current_event (); |
7712 | proxy = ctk_get_event_widget (event); |
7713 | |
7714 | if (proxy != NULL((void*)0)) { |
7715 | CtkWidget *toplevel; |
7716 | CdkWindowTypeHint hint; |
7717 | |
7718 | toplevel = ctk_widget_get_toplevel (proxy); |
7719 | |
7720 | if (CTK_IS_WINDOW (toplevel)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (toplevel)); GType __t = ((ctk_window_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
7721 | hint = ctk_window_get_type_hint (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_window_get_type ()))))))); |
7722 | |
7723 | if (hint == CDK_WINDOW_TYPE_HINT_POPUP_MENU) { |
7724 | activated_from_popup = TRUE(!(0)); |
7725 | } |
7726 | } |
7727 | } |
7728 | |
7729 | if (!activated_from_popup) { |
7730 | update_context_menu_position_from_event (view, NULL((void*)0)); |
7731 | } |
7732 | } |
7733 | |
7734 | static void |
7735 | real_merge_menus (FMDirectoryView *view) |
7736 | { |
7737 | CtkActionGroup *action_group; |
7738 | CtkUIManager *ui_manager; |
7739 | CtkAction *action; |
7740 | const char *ui; |
7741 | char *tooltip; |
7742 | |
7743 | ui_manager = baul_window_info_get_ui_manager (view->details->window); |
7744 | |
7745 | action_group = ctk_action_group_new ("DirViewActions"); |
7746 | ctk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"baul"); |
7747 | view->details->dir_action_group = action_group; |
7748 | ctk_action_group_add_actions (action_group, |
7749 | directory_view_entries, G_N_ELEMENTS (directory_view_entries)(sizeof (directory_view_entries) / sizeof ((directory_view_entries )[0])), |
7750 | view); |
7751 | |
7752 | /* Translators: %s is a directory */ |
7753 | tooltip = g_strdup_printf(_("Run or manage scripts from %s")gettext ("Run or manage scripts from %s"), "~/.config/baul/scripts"); |
7754 | /* Create a script action here specially because its tooltip is dynamic */ |
7755 | action = ctk_action_new ("Scripts", _("_Scripts")gettext ("_Scripts"), tooltip, NULL((void*)0)); |
7756 | ctk_action_group_add_action (action_group, action); |
7757 | g_object_unref (action); |
7758 | g_free (tooltip); |
7759 | |
7760 | action = ctk_action_group_get_action (action_group, FM_ACTION_NO_TEMPLATES"No Templates"); |
7761 | ctk_action_set_sensitive (action, FALSE(0)); |
7762 | |
7763 | g_signal_connect_object (action_group, "connect-proxy", |
7764 | G_CALLBACK (connect_proxy)((GCallback) (connect_proxy)), G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), |
7765 | G_CONNECT_SWAPPED); |
7766 | g_signal_connect_object (action_group, "pre-activate", |
7767 | G_CALLBACK (pre_activate)((GCallback) (pre_activate)), G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), |
7768 | G_CONNECT_SWAPPED); |
7769 | |
7770 | /* Insert action group at end so clipboard action group ends up before it */ |
7771 | ctk_ui_manager_insert_action_group (ui_manager, action_group, -1); |
7772 | g_object_unref (action_group); /* owned by ui manager */ |
7773 | |
7774 | ui = baul_ui_string_get ("baul-directory-view-ui.xml"); |
7775 | view->details->dir_merge_id = ctk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL((void*)0)); |
7776 | g_signal_connect_object (fm_directory_view_get_background (view), "settings_changed", |
7777 | G_CALLBACK (schedule_update_menus)((GCallback) (schedule_update_menus)), G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), (((GType) ((20) << (2)))))))), |
7778 | G_CONNECT_SWAPPED); |
7779 | view->details->scripts_invalid = TRUE(!(0)); |
7780 | view->details->templates_invalid = TRUE(!(0)); |
7781 | } |
7782 | |
7783 | |
7784 | static gboolean |
7785 | can_paste_into_file (BaulFile *file) |
7786 | { |
7787 | if (baul_file_is_directory (file) && |
7788 | baul_file_can_write (file)) { |
7789 | return TRUE(!(0)); |
7790 | } |
7791 | if (baul_file_has_activation_uri (file)) { |
7792 | GFile *location; |
7793 | BaulFile *activation_file; |
7794 | gboolean res; |
7795 | |
7796 | location = baul_file_get_activation_location (file); |
7797 | activation_file = baul_file_get (location); |
7798 | g_object_unref (location); |
7799 | |
7800 | /* The target location might not have data for it read yet, |
7801 | and we can't want to do sync I/O, so treat the unknown |
7802 | case as can-write */ |
7803 | res = (baul_file_get_file_type (activation_file) == G_FILE_TYPE_UNKNOWN) || |
7804 | (baul_file_get_file_type (activation_file) == G_FILE_TYPE_DIRECTORY && |
7805 | baul_file_can_write (activation_file)); |
7806 | |
7807 | baul_file_unref (activation_file); |
7808 | |
7809 | return res; |
7810 | } |
7811 | |
7812 | return FALSE(0); |
7813 | } |
7814 | |
7815 | static void |
7816 | clipboard_targets_received (CtkClipboard *clipboard G_GNUC_UNUSED__attribute__ ((__unused__)), |
7817 | CdkAtom *targets, |
7818 | int n_targets, |
7819 | gpointer user_data) |
7820 | { |
7821 | FMDirectoryView *view; |
7822 | gboolean can_paste; |
7823 | GList *selection; |
7824 | int count; |
7825 | CtkAction *action; |
7826 | |
7827 | view = FM_DIRECTORY_VIEW (user_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), (fm_directory_view_get_type()))))); |
7828 | can_paste = FALSE(0); |
7829 | |
7830 | if (view->details->window == NULL((void*)0) || |
7831 | !view->details->active) { |
7832 | /* We've been destroyed or became inactive since call */ |
7833 | g_object_unref (view); |
7834 | return; |
7835 | } |
7836 | |
7837 | if (targets) { |
7838 | int i; |
7839 | |
7840 | for (i=0; i < n_targets; i++) { |
7841 | if (targets[i] == copied_files_atom) { |
7842 | can_paste = TRUE(!(0)); |
7843 | } |
7844 | } |
7845 | } |
7846 | |
7847 | |
7848 | selection = fm_directory_view_get_selection (view); |
7849 | count = g_list_length (selection); |
7850 | |
7851 | action = ctk_action_group_get_action (view->details->dir_action_group, |
7852 | FM_ACTION_PASTE"Paste"); |
7853 | ctk_action_set_sensitive (action, |
7854 | can_paste && !fm_directory_view_is_read_only (view)); |
7855 | |
7856 | action = ctk_action_group_get_action (view->details->dir_action_group, |
7857 | FM_ACTION_PASTE_FILES_INTO"Paste Files Into"); |
7858 | ctk_action_set_sensitive (action, |
7859 | can_paste && count == 1 && |
7860 | can_paste_into_file (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type()))))))); |
7861 | |
7862 | action = ctk_action_group_get_action (view->details->dir_action_group, |
7863 | FM_ACTION_LOCATION_PASTE_FILES_INTO"LocationPasteFilesInto"); |
7864 | g_object_set_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), |
7865 | "can-paste-according-to-clipboard", |
7866 | GINT_TO_POINTER (can_paste)((gpointer) (glong) (can_paste))); |
7867 | ctk_action_set_sensitive (action, |
7868 | GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-clipboard"))) |
7869 | "can-paste-according-to-clipboard"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-clipboard"))) && |
7870 | GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-destination"))) |
7871 | "can-paste-according-to-destination"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-destination")))); |
7872 | |
7873 | baul_file_list_free (selection); |
7874 | |
7875 | g_object_unref (view); |
7876 | } |
7877 | |
7878 | static gboolean |
7879 | showing_trash_directory (FMDirectoryView *view) |
7880 | { |
7881 | BaulFile *file; |
7882 | |
7883 | file = fm_directory_view_get_directory_as_file (view); |
7884 | if (file != NULL((void*)0)) { |
7885 | return baul_file_is_in_trash (file); |
7886 | } |
7887 | return FALSE(0); |
7888 | } |
7889 | |
7890 | static gboolean |
7891 | should_show_empty_trash (FMDirectoryView *view) |
7892 | { |
7893 | return (showing_trash_directory (view) || baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION); |
7894 | } |
7895 | |
7896 | static gboolean |
7897 | file_list_all_are_folders (GList *file_list) |
7898 | { |
7899 | GList *l; |
7900 | char *activation_uri; |
7901 | gboolean is_dir; |
7902 | BaulFile *linked_file; |
7903 | BaulFile *file = NULL((void*)0); |
7904 | |
7905 | for (l = file_list; l != NULL((void*)0); l = l->next) { |
7906 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
7907 | if (baul_file_is_baul_link (file) && |
7908 | !BAUL_IS_DESKTOP_ICON_FILE (file)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (file)); GType __t = (baul_desktop_icon_file_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
7909 | if (baul_file_is_launcher (file)) { |
7910 | return FALSE(0); |
7911 | } |
7912 | |
7913 | activation_uri = baul_file_get_activation_uri (file); |
7914 | |
7915 | if (activation_uri == NULL((void*)0)) { |
7916 | g_free (activation_uri); |
7917 | return FALSE(0); |
7918 | } |
7919 | |
7920 | linked_file = baul_file_get_existing_by_uri (activation_uri); |
7921 | |
7922 | /* We might not actually know the type of the linked file yet, |
7923 | * however we don't want to schedule a read, since that might do things |
7924 | * like ask for password etc. This is a bit unfortunate, but I don't |
7925 | * know any way around it, so we do various heuristics here |
7926 | * to get things mostly right |
7927 | */ |
7928 | is_dir = |
7929 | (linked_file != NULL((void*)0) && |
7930 | baul_file_is_directory (linked_file)) || |
7931 | (activation_uri != NULL((void*)0) && |
7932 | activation_uri[strlen (activation_uri) - 1] == '/'); |
7933 | |
7934 | baul_file_unref (linked_file); |
7935 | g_free (activation_uri); |
7936 | |
7937 | if (!is_dir) { |
7938 | return FALSE(0); |
7939 | } |
7940 | } else if (!(baul_file_is_directory (file) || |
7941 | BAUL_IS_DESKTOP_ICON_FILE (file)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (file)); GType __t = (baul_desktop_icon_file_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { |
7942 | return FALSE(0); |
7943 | } |
7944 | } |
7945 | return TRUE(!(0)); |
7946 | } |
7947 | |
7948 | static void |
7949 | file_should_show_foreach (BaulFile *file, |
7950 | gboolean *show_mount, |
7951 | gboolean *show_unmount, |
7952 | gboolean *show_eject, |
7953 | gboolean *show_connect, |
7954 | gboolean *show_format, |
7955 | gboolean *show_start, |
7956 | gboolean *show_stop, |
7957 | gboolean *show_poll, |
7958 | GDriveStartStopType *start_stop_type) |
7959 | { |
7960 | *show_mount = FALSE(0); |
7961 | *show_unmount = FALSE(0); |
7962 | *show_eject = FALSE(0); |
7963 | *show_connect = FALSE(0); |
7964 | *show_format = FALSE(0); |
7965 | *show_start = FALSE(0); |
7966 | *show_stop = FALSE(0); |
7967 | *show_poll = FALSE(0); |
7968 | |
7969 | if (baul_file_can_eject (file)) { |
7970 | *show_eject = TRUE(!(0)); |
7971 | } |
7972 | |
7973 | if (baul_file_can_mount (file)) { |
7974 | *show_mount = TRUE(!(0)); |
7975 | |
7976 | #ifdef TODO_GIO |
7977 | if (something && |
7978 | g_find_program_in_path ("gfloppy")) { |
7979 | *show_format = TRUE(!(0)); |
7980 | } |
7981 | #endif |
7982 | } |
7983 | |
7984 | if (baul_file_can_start (file) || baul_file_can_start_degraded (file)) { |
7985 | *show_start = TRUE(!(0)); |
7986 | } |
7987 | |
7988 | if (baul_file_can_stop (file)) { |
7989 | *show_stop = TRUE(!(0)); |
7990 | } |
7991 | |
7992 | /* Dot not show both Unmount and Eject/Safe Removal; too confusing to |
7993 | * have too many menu entries */ |
7994 | if (baul_file_can_unmount (file) && !*show_eject && !*show_stop) { |
7995 | *show_unmount = TRUE(!(0)); |
7996 | } |
7997 | |
7998 | if (baul_file_can_poll_for_media (file) && !baul_file_is_media_check_automatic (file)) { |
7999 | *show_poll = TRUE(!(0)); |
8000 | } |
8001 | |
8002 | *start_stop_type = baul_file_get_start_stop_type (file); |
8003 | |
8004 | if (baul_file_is_baul_link (file)) { |
8005 | char *uri; |
8006 | |
8007 | uri = baul_file_get_activation_uri (file); |
8008 | if (uri != NULL((void*)0) && |
8009 | (eel_istr_has_prefix (uri, "ftp:") || |
8010 | eel_istr_has_prefix (uri, "ssh:") || |
8011 | eel_istr_has_prefix (uri, "sftp:") || |
8012 | eel_istr_has_prefix (uri, "dav:") || |
8013 | eel_istr_has_prefix (uri, "davs:"))) { |
8014 | *show_connect = TRUE(!(0)); |
8015 | } |
8016 | g_free (uri); |
8017 | } |
8018 | } |
8019 | |
8020 | static void |
8021 | file_should_show_self (BaulFile *file, |
8022 | gboolean *show_mount, |
8023 | gboolean *show_unmount, |
8024 | gboolean *show_eject, |
8025 | gboolean *show_format, |
8026 | gboolean *show_start, |
8027 | gboolean *show_stop, |
8028 | gboolean *show_poll, |
8029 | GDriveStartStopType *start_stop_type) |
8030 | { |
8031 | *show_mount = FALSE(0); |
8032 | *show_unmount = FALSE(0); |
8033 | *show_eject = FALSE(0); |
8034 | *show_format = FALSE(0); |
8035 | *show_start = FALSE(0); |
8036 | *show_stop = FALSE(0); |
8037 | *show_poll = FALSE(0); |
8038 | |
8039 | if (file == NULL((void*)0)) { |
8040 | return; |
8041 | } |
8042 | |
8043 | if (baul_file_can_eject (file)) { |
8044 | *show_eject = TRUE(!(0)); |
8045 | } |
8046 | |
8047 | if (baul_file_can_mount (file)) { |
8048 | *show_mount = TRUE(!(0)); |
8049 | } |
8050 | |
8051 | #ifdef TODO_GIO |
8052 | if (something && g_find_program_in_path ("gfloppy")) { |
8053 | *show_format = TRUE(!(0)); |
8054 | } |
8055 | #endif |
8056 | |
8057 | if (baul_file_can_start (file) || baul_file_can_start_degraded (file)) { |
8058 | *show_start = TRUE(!(0)); |
8059 | } |
8060 | |
8061 | if (baul_file_can_stop (file)) { |
8062 | *show_stop = TRUE(!(0)); |
8063 | } |
8064 | |
8065 | /* Dot not show both Unmount and Eject/Safe Removal; too confusing to |
8066 | * have too many menu entries */ |
8067 | if (baul_file_can_unmount (file) && !*show_eject && !*show_stop) { |
8068 | *show_unmount = TRUE(!(0)); |
8069 | } |
8070 | |
8071 | if (baul_file_can_poll_for_media (file) && !baul_file_is_media_check_automatic (file)) { |
8072 | *show_poll = TRUE(!(0)); |
8073 | } |
8074 | |
8075 | *start_stop_type = baul_file_get_start_stop_type (file); |
8076 | |
8077 | } |
8078 | |
8079 | static gboolean |
8080 | files_are_all_directories (GList *files) |
8081 | { |
8082 | GList *l; |
8083 | gboolean all_directories; |
8084 | BaulFile *file = NULL((void*)0); |
8085 | |
8086 | all_directories = TRUE(!(0)); |
8087 | |
8088 | for (l = files; l != NULL((void*)0); l = l->next) { |
8089 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
8090 | all_directories &= baul_file_is_directory (file); |
8091 | } |
8092 | |
8093 | return all_directories; |
8094 | } |
8095 | |
8096 | static gboolean |
8097 | files_is_none_directory (GList *files) |
8098 | { |
8099 | GList *l; |
8100 | gboolean no_directory; |
8101 | BaulFile *file = NULL((void*)0); |
8102 | |
8103 | no_directory = TRUE(!(0)); |
8104 | |
8105 | for (l = files; l != NULL((void*)0); l = l->next) { |
8106 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
8107 | no_directory &= !baul_file_is_directory (file); |
8108 | } |
8109 | |
8110 | return no_directory; |
8111 | } |
8112 | |
8113 | static void |
8114 | update_restore_from_trash_action (CtkAction *action, |
8115 | GList *files, |
8116 | gboolean is_self) |
8117 | { |
8118 | BaulFile *original_file; |
8119 | BaulFile *original_dir; |
8120 | GHashTable *original_dirs_hash; |
8121 | GList *original_dirs; |
8122 | GFile *original_location; |
8123 | char *original_name; |
8124 | |
8125 | original_file = NULL((void*)0); |
8126 | original_dir = NULL((void*)0); |
8127 | original_dirs = NULL((void*)0); |
8128 | original_dirs_hash = NULL((void*)0); |
8129 | original_location = NULL((void*)0); |
8130 | original_name = NULL((void*)0); |
8131 | |
8132 | if (files != NULL((void*)0)) { |
8133 | if (g_list_length (files) == 1) { |
8134 | original_file = baul_file_get_trash_original_file (files->data); |
8135 | } else { |
8136 | original_dirs_hash = baul_trashed_files_get_original_directories (files, NULL((void*)0)); |
8137 | if (original_dirs_hash != NULL((void*)0)) { |
8138 | original_dirs = g_hash_table_get_keys (original_dirs_hash); |
8139 | if (g_list_length (original_dirs) == 1) { |
8140 | original_dir = baul_file_ref (BAUL_FILE (original_dirs->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((original_dirs->data)), (baul_file_get_type())))))); |
8141 | } |
8142 | } |
8143 | } |
8144 | } |
8145 | |
8146 | if (original_file != NULL((void*)0) || original_dirs != NULL((void*)0)) { |
8147 | char *tooltip; |
8148 | |
8149 | ctk_action_set_visible (action, TRUE(!(0))); |
8150 | |
8151 | if (original_file != NULL((void*)0)) { |
8152 | original_location = baul_file_get_location (original_file); |
8153 | } else if (original_dir != NULL((void*)0)) { |
8154 | original_location = baul_file_get_location (original_dir); |
8155 | } |
8156 | |
8157 | if (original_location != NULL((void*)0)) { |
8158 | original_name = g_file_get_parse_name (original_location); |
8159 | } |
8160 | |
8161 | if (is_self) { |
8162 | g_assert (g_list_length (files) == 1)do { if (g_list_length (files) == 1) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 8162, ((const char*) ( __func__)), "g_list_length (files) == 1"); } while (0); |
8163 | g_assert (original_location != NULL)do { if (original_location != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 8163, ((const char*) ( __func__)), "original_location != NULL"); } while (0); |
8164 | tooltip = g_strdup_printf (_("Move the open folder out of the trash to \"%s\"")gettext ("Move the open folder out of the trash to \"%s\""), original_name); |
8165 | } else if (files_are_all_directories (files)) { |
8166 | if (original_name != NULL((void*)0)) { |
8167 | tooltip = g_strdup_printf (ngettext ("Move the selected folder out of the trash to \"%s\"", |
8168 | "Move the selected folders out of the trash to \"%s\"", |
8169 | g_list_length (files)), original_name); |
8170 | } else { |
8171 | tooltip = g_strdup_printf (ngettext ("Move the selected folder out of the trash", |
8172 | "Move the selected folders out of the trash", |
8173 | g_list_length (files))); |
8174 | } |
8175 | } else if (files_is_none_directory (files)) { |
8176 | if (original_name != NULL((void*)0)) { |
8177 | tooltip = g_strdup_printf (ngettext ("Move the selected file out of the trash to \"%s\"", |
8178 | "Move the selected files out of the trash to \"%s\"", |
8179 | g_list_length (files)), original_name); |
8180 | } else { |
8181 | tooltip = g_strdup_printf (ngettext ("Move the selected file out of the trash", |
8182 | "Move the selected files out of the trash", |
8183 | g_list_length (files))); |
8184 | } |
8185 | } else { |
8186 | if (original_name != NULL((void*)0)) { |
8187 | tooltip = g_strdup_printf (ngettext ("Move the selected item out of the trash to \"%s\"", |
8188 | "Move the selected items out of the trash to \"%s\"", |
8189 | g_list_length (files)), original_name); |
8190 | } else { |
8191 | tooltip = g_strdup_printf (ngettext ("Move the selected item out of the trash", |
8192 | "Move the selected items out of the trash", |
8193 | g_list_length (files))); |
8194 | } |
8195 | } |
8196 | g_free (original_name); |
8197 | |
8198 | g_object_set (action, "tooltip", tooltip, NULL((void*)0)); |
8199 | |
8200 | if (original_location != NULL((void*)0)) { |
8201 | g_object_unref (original_location); |
8202 | } |
8203 | } else { |
8204 | ctk_action_set_visible (action, FALSE(0)); |
8205 | } |
8206 | |
8207 | baul_file_unref (original_file); |
8208 | baul_file_unref (original_dir); |
8209 | g_list_free (original_dirs); |
8210 | |
8211 | if (original_dirs_hash != NULL((void*)0)) { |
8212 | g_hash_table_destroy (original_dirs_hash); |
8213 | } |
8214 | } |
8215 | |
8216 | static void |
8217 | real_update_menus_volumes (FMDirectoryView *view, |
8218 | GList *selection, |
8219 | gint selection_count) |
8220 | { |
8221 | GList *l; |
8222 | BaulFile *file; |
8223 | gboolean show_mount; |
8224 | gboolean show_unmount; |
8225 | gboolean show_eject; |
8226 | gboolean show_connect; |
8227 | gboolean show_format; |
8228 | gboolean show_start; |
8229 | gboolean show_stop; |
8230 | gboolean show_poll; |
8231 | GDriveStartStopType start_stop_type; |
8232 | gboolean show_self_mount; |
8233 | gboolean show_self_unmount; |
8234 | gboolean show_self_eject; |
8235 | gboolean show_self_format; |
8236 | gboolean show_self_start; |
8237 | gboolean show_self_stop; |
8238 | gboolean show_self_poll; |
8239 | GDriveStartStopType self_start_stop_type; |
8240 | CtkAction *action; |
8241 | |
8242 | show_mount = (selection != NULL((void*)0)); |
8243 | show_unmount = (selection != NULL((void*)0)); |
8244 | show_eject = (selection != NULL((void*)0)); |
8245 | show_connect = (selection != NULL((void*)0) && selection_count == 1); |
8246 | show_format = (selection != NULL((void*)0) && selection_count == 1); |
8247 | show_start = (selection != NULL((void*)0) && selection_count == 1); |
8248 | show_stop = (selection != NULL((void*)0) && selection_count == 1); |
8249 | show_poll = (selection != NULL((void*)0) && selection_count == 1); |
8250 | start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN; |
8251 | self_start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN; |
8252 | |
8253 | for (l = selection; l != NULL((void*)0) && (show_mount || show_unmount |
8254 | || show_eject || show_connect |
8255 | || show_format || show_start |
8256 | || show_stop || show_poll); |
8257 | l = l->next) { |
8258 | gboolean show_mount_one; |
8259 | gboolean show_unmount_one; |
8260 | gboolean show_eject_one; |
8261 | gboolean show_connect_one; |
8262 | gboolean show_format_one; |
8263 | gboolean show_start_one; |
8264 | gboolean show_stop_one; |
8265 | gboolean show_poll_one; |
8266 | |
8267 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
8268 | file_should_show_foreach (file, |
8269 | &show_mount_one, |
8270 | &show_unmount_one, |
8271 | &show_eject_one, |
8272 | &show_connect_one, |
8273 | &show_format_one, |
8274 | &show_start_one, |
8275 | &show_stop_one, |
8276 | &show_poll_one, |
8277 | &start_stop_type); |
8278 | |
8279 | show_mount &= show_mount_one; |
8280 | show_unmount &= show_unmount_one; |
8281 | show_eject &= show_eject_one; |
8282 | show_connect &= show_connect_one; |
8283 | show_format &= show_format_one; |
8284 | show_start &= show_start_one; |
8285 | show_stop &= show_stop_one; |
8286 | show_poll &= show_poll_one; |
8287 | } |
8288 | |
8289 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8290 | FM_ACTION_CONNECT_TO_SERVER_LINK"Connect To Server Link"); |
8291 | ctk_action_set_visible (action, show_connect); |
8292 | |
8293 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8294 | FM_ACTION_MOUNT_VOLUME"Mount Volume"); |
8295 | ctk_action_set_visible (action, show_mount); |
8296 | |
8297 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8298 | FM_ACTION_UNMOUNT_VOLUME"Unmount Volume"); |
8299 | ctk_action_set_visible (action, show_unmount); |
8300 | |
8301 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8302 | FM_ACTION_EJECT_VOLUME"Eject Volume"); |
8303 | ctk_action_set_visible (action, show_eject); |
8304 | |
8305 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8306 | FM_ACTION_FORMAT_VOLUME"Format Volume"); |
8307 | ctk_action_set_visible (action, show_format); |
8308 | |
8309 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8310 | FM_ACTION_START_VOLUME"Start Volume"); |
8311 | ctk_action_set_visible (action, show_start); |
8312 | if (show_start) { |
8313 | switch (start_stop_type) { |
8314 | default: |
8315 | case G_DRIVE_START_STOP_TYPE_UNKNOWN: |
8316 | ctk_action_set_label (action, _("_Start")gettext ("_Start")); |
8317 | ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive")); |
8318 | break; |
8319 | case G_DRIVE_START_STOP_TYPE_SHUTDOWN: |
8320 | ctk_action_set_label (action, _("_Start")gettext ("_Start")); |
8321 | ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive")); |
8322 | break; |
8323 | case G_DRIVE_START_STOP_TYPE_NETWORK: |
8324 | ctk_action_set_label (action, _("_Connect")gettext ("_Connect")); |
8325 | ctk_action_set_tooltip (action, _("Connect to the selected drive")gettext ("Connect to the selected drive")); |
8326 | break; |
8327 | case G_DRIVE_START_STOP_TYPE_MULTIDISK: |
8328 | ctk_action_set_label (action, _("_Start Multi-disk Drive")gettext ("_Start Multi-disk Drive")); |
8329 | ctk_action_set_tooltip (action, _("Start the selected multi-disk drive")gettext ("Start the selected multi-disk drive")); |
8330 | break; |
8331 | case G_DRIVE_START_STOP_TYPE_PASSWORD: |
8332 | ctk_action_set_label (action, _("U_nlock Drive")gettext ("U_nlock Drive")); |
8333 | ctk_action_set_tooltip (action, _("Unlock the selected drive")gettext ("Unlock the selected drive")); |
8334 | break; |
8335 | } |
8336 | } |
8337 | |
8338 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8339 | FM_ACTION_STOP_VOLUME"Stop Volume"); |
8340 | ctk_action_set_visible (action, show_stop); |
8341 | if (show_stop) { |
8342 | switch (start_stop_type) { |
8343 | default: |
8344 | case G_DRIVE_START_STOP_TYPE_UNKNOWN: |
8345 | ctk_action_set_label (action, _("_Stop")gettext ("_Stop")); |
8346 | ctk_action_set_tooltip (action, _("Stop the selected drive")gettext ("Stop the selected drive")); |
8347 | break; |
8348 | case G_DRIVE_START_STOP_TYPE_SHUTDOWN: |
8349 | ctk_action_set_label (action, _("_Safely Remove Drive")gettext ("_Safely Remove Drive")); |
8350 | ctk_action_set_tooltip (action, _("Safely remove the selected drive")gettext ("Safely remove the selected drive")); |
8351 | break; |
8352 | case G_DRIVE_START_STOP_TYPE_NETWORK: |
8353 | ctk_action_set_label (action, _("_Disconnect")gettext ("_Disconnect")); |
8354 | ctk_action_set_tooltip (action, _("Disconnect the selected drive")gettext ("Disconnect the selected drive")); |
8355 | break; |
8356 | case G_DRIVE_START_STOP_TYPE_MULTIDISK: |
8357 | ctk_action_set_label (action, _("_Stop Multi-disk Drive")gettext ("_Stop Multi-disk Drive")); |
8358 | ctk_action_set_tooltip (action, _("Stop the selected multi-disk drive")gettext ("Stop the selected multi-disk drive")); |
8359 | break; |
8360 | case G_DRIVE_START_STOP_TYPE_PASSWORD: |
8361 | ctk_action_set_label (action, _("_Lock Drive")gettext ("_Lock Drive")); |
8362 | ctk_action_set_tooltip (action, _("Lock the selected drive")gettext ("Lock the selected drive")); |
8363 | break; |
8364 | } |
8365 | } |
8366 | |
8367 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8368 | FM_ACTION_POLL"Poll"); |
8369 | ctk_action_set_visible (action, show_poll); |
8370 | |
8371 | show_self_mount = show_self_unmount = show_self_eject = |
8372 | show_self_format = show_self_start = show_self_stop = show_self_poll = FALSE(0); |
8373 | |
8374 | file = fm_directory_view_get_directory_as_file (view); |
8375 | file_should_show_self (file, |
8376 | &show_self_mount, |
8377 | &show_self_unmount, |
8378 | &show_self_eject, |
8379 | &show_self_format, |
8380 | &show_self_start, |
8381 | &show_self_stop, |
8382 | &show_self_poll, |
8383 | &self_start_stop_type); |
8384 | |
8385 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8386 | FM_ACTION_SELF_MOUNT_VOLUME"Self Mount Volume"); |
8387 | ctk_action_set_visible (action, show_self_mount); |
8388 | |
8389 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8390 | FM_ACTION_SELF_UNMOUNT_VOLUME"Self Unmount Volume"); |
8391 | ctk_action_set_visible (action, show_self_unmount); |
8392 | |
8393 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8394 | FM_ACTION_SELF_EJECT_VOLUME"Self Eject Volume"); |
8395 | ctk_action_set_visible (action, show_self_eject); |
8396 | |
8397 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8398 | FM_ACTION_SELF_FORMAT_VOLUME"Self Format Volume"); |
8399 | ctk_action_set_visible (action, show_self_format); |
8400 | |
8401 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8402 | FM_ACTION_SELF_START_VOLUME"Self Start Volume"); |
8403 | ctk_action_set_visible (action, show_self_start); |
8404 | if (show_self_start) { |
8405 | switch (self_start_stop_type) { |
8406 | default: |
8407 | case G_DRIVE_START_STOP_TYPE_UNKNOWN: |
8408 | ctk_action_set_label (action, _("_Start")gettext ("_Start")); |
8409 | ctk_action_set_tooltip (action, _("Start the drive associated with the open folder")gettext ("Start the drive associated with the open folder")); |
8410 | break; |
8411 | case G_DRIVE_START_STOP_TYPE_SHUTDOWN: |
8412 | ctk_action_set_label (action, _("_Start")gettext ("_Start")); |
8413 | ctk_action_set_tooltip (action, _("Start the drive associated with the open folder")gettext ("Start the drive associated with the open folder")); |
8414 | break; |
8415 | case G_DRIVE_START_STOP_TYPE_NETWORK: |
8416 | ctk_action_set_label (action, _("_Connect")gettext ("_Connect")); |
8417 | ctk_action_set_tooltip (action, _("Connect to the drive associated with the open folder")gettext ("Connect to the drive associated with the open folder" )); |
8418 | break; |
8419 | case G_DRIVE_START_STOP_TYPE_MULTIDISK: |
8420 | ctk_action_set_label (action, _("_Start Multi-disk Drive")gettext ("_Start Multi-disk Drive")); |
8421 | ctk_action_set_tooltip (action, _("Start the multi-disk drive associated with the open folder")gettext ("Start the multi-disk drive associated with the open folder" )); |
8422 | break; |
8423 | case G_DRIVE_START_STOP_TYPE_PASSWORD: |
8424 | ctk_action_set_label (action, _("_Unlock Drive")gettext ("_Unlock Drive")); |
8425 | ctk_action_set_tooltip (action, _("Unlock the drive associated with the open folder")gettext ("Unlock the drive associated with the open folder")); |
8426 | break; |
8427 | } |
8428 | } |
8429 | |
8430 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8431 | FM_ACTION_SELF_STOP_VOLUME"Self Stop Volume"); |
8432 | ctk_action_set_visible (action, show_self_stop); |
8433 | if (show_self_stop) { |
8434 | switch (self_start_stop_type) { |
8435 | default: |
8436 | case G_DRIVE_START_STOP_TYPE_UNKNOWN: |
8437 | ctk_action_set_label (action, _("_Stop")gettext ("_Stop")); |
8438 | ctk_action_set_tooltip (action, _("_Stop the drive associated with the open folder")gettext ("_Stop the drive associated with the open folder")); |
8439 | break; |
8440 | case G_DRIVE_START_STOP_TYPE_SHUTDOWN: |
8441 | ctk_action_set_label (action, _("_Safely Remove Drive")gettext ("_Safely Remove Drive")); |
8442 | ctk_action_set_tooltip (action, _("Safely remove the drive associated with the open folder")gettext ("Safely remove the drive associated with the open folder" )); |
8443 | break; |
8444 | case G_DRIVE_START_STOP_TYPE_NETWORK: |
8445 | ctk_action_set_label (action, _("_Disconnect")gettext ("_Disconnect")); |
8446 | ctk_action_set_tooltip (action, _("Disconnect the drive associated with the open folder")gettext ("Disconnect the drive associated with the open folder" )); |
8447 | break; |
8448 | case G_DRIVE_START_STOP_TYPE_MULTIDISK: |
8449 | ctk_action_set_label (action, _("_Stop Multi-disk Drive")gettext ("_Stop Multi-disk Drive")); |
8450 | ctk_action_set_tooltip (action, _("Stop the multi-disk drive associated with the open folder")gettext ("Stop the multi-disk drive associated with the open folder" )); |
8451 | break; |
8452 | case G_DRIVE_START_STOP_TYPE_PASSWORD: |
8453 | ctk_action_set_label (action, _("_Lock Drive")gettext ("_Lock Drive")); |
8454 | ctk_action_set_tooltip (action, _("Lock the drive associated with the open folder")gettext ("Lock the drive associated with the open folder")); |
8455 | break; |
8456 | } |
8457 | } |
8458 | |
8459 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8460 | FM_ACTION_SELF_POLL"Self Poll"); |
8461 | ctk_action_set_visible (action, show_self_poll); |
8462 | |
8463 | } |
8464 | |
8465 | static void |
8466 | real_update_location_menu_volumes (FMDirectoryView *view) |
8467 | { |
8468 | CtkAction *action; |
8469 | BaulFile *file; |
8470 | gboolean show_mount; |
8471 | gboolean show_unmount; |
8472 | gboolean show_eject; |
8473 | gboolean show_connect; |
8474 | gboolean show_format; |
8475 | gboolean show_start; |
8476 | gboolean show_stop; |
8477 | gboolean show_poll; |
8478 | GDriveStartStopType start_stop_type; |
8479 | |
8480 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 8480, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
8481 | g_assert (BAUL_IS_FILE (view->details->location_popup_directory_as_file))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view->details->location_popup_directory_as_file)); GType __t = (baul_file_get_type()); gboolean __r; if (!__inst ) __r = (0); else if (__inst->g_class && __inst-> g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr ( ((gchar*) 0), "fm-directory-view.c", 8481, ((const char*) (__func__ )), "BAUL_IS_FILE (view->details->location_popup_directory_as_file)" ); } while (0); |
8482 | |
8483 | file = BAUL_FILE (view->details->location_popup_directory_as_file)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->details->location_popup_directory_as_file)), (baul_file_get_type()))))); |
8484 | file_should_show_foreach (file, |
8485 | &show_mount, |
8486 | &show_unmount, |
8487 | &show_eject, |
8488 | &show_connect, |
8489 | &show_format, |
8490 | &show_start, |
8491 | &show_stop, |
8492 | &show_poll, |
8493 | &start_stop_type); |
8494 | |
8495 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8496 | FM_ACTION_LOCATION_MOUNT_VOLUME"Location Mount Volume"); |
8497 | ctk_action_set_visible (action, show_mount); |
8498 | |
8499 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8500 | FM_ACTION_LOCATION_UNMOUNT_VOLUME"Location Unmount Volume"); |
8501 | ctk_action_set_visible (action, show_unmount); |
8502 | |
8503 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8504 | FM_ACTION_LOCATION_EJECT_VOLUME"Location Eject Volume"); |
8505 | ctk_action_set_visible (action, show_eject); |
8506 | |
8507 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8508 | FM_ACTION_LOCATION_FORMAT_VOLUME"Location Format Volume"); |
8509 | ctk_action_set_visible (action, show_format); |
8510 | |
8511 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8512 | FM_ACTION_LOCATION_START_VOLUME"Location Start Volume"); |
8513 | ctk_action_set_visible (action, show_start); |
8514 | if (show_start) { |
8515 | switch (start_stop_type) { |
8516 | default: |
8517 | case G_DRIVE_START_STOP_TYPE_UNKNOWN: |
8518 | ctk_action_set_label (action, _("_Start")gettext ("_Start")); |
8519 | ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive")); |
8520 | break; |
8521 | case G_DRIVE_START_STOP_TYPE_SHUTDOWN: |
8522 | ctk_action_set_label (action, _("_Start")gettext ("_Start")); |
8523 | ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive")); |
8524 | break; |
8525 | case G_DRIVE_START_STOP_TYPE_NETWORK: |
8526 | ctk_action_set_label (action, _("_Connect")gettext ("_Connect")); |
8527 | ctk_action_set_tooltip (action, _("Connect to the selected drive")gettext ("Connect to the selected drive")); |
8528 | break; |
8529 | case G_DRIVE_START_STOP_TYPE_MULTIDISK: |
8530 | ctk_action_set_label (action, _("_Start Multi-disk Drive")gettext ("_Start Multi-disk Drive")); |
8531 | ctk_action_set_tooltip (action, _("Start the selected multi-disk drive")gettext ("Start the selected multi-disk drive")); |
8532 | break; |
8533 | case G_DRIVE_START_STOP_TYPE_PASSWORD: |
8534 | ctk_action_set_label (action, _("_Unlock Drive")gettext ("_Unlock Drive")); |
8535 | ctk_action_set_tooltip (action, _("Unlock the selected drive")gettext ("Unlock the selected drive")); |
8536 | break; |
8537 | } |
8538 | } |
8539 | |
8540 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8541 | FM_ACTION_LOCATION_STOP_VOLUME"Location Stop Volume"); |
8542 | ctk_action_set_visible (action, show_stop); |
8543 | if (show_stop) { |
8544 | switch (start_stop_type) { |
8545 | default: |
8546 | case G_DRIVE_START_STOP_TYPE_UNKNOWN: |
8547 | ctk_action_set_label (action, _("_Stop")gettext ("_Stop")); |
8548 | ctk_action_set_tooltip (action, _("Stop the selected volume")gettext ("Stop the selected volume")); |
8549 | break; |
8550 | case G_DRIVE_START_STOP_TYPE_SHUTDOWN: |
8551 | ctk_action_set_label (action, _("_Safely Remove Drive")gettext ("_Safely Remove Drive")); |
8552 | ctk_action_set_tooltip (action, _("Safely remove the selected drive")gettext ("Safely remove the selected drive")); |
8553 | break; |
8554 | case G_DRIVE_START_STOP_TYPE_NETWORK: |
8555 | ctk_action_set_label (action, _("_Disconnect")gettext ("_Disconnect")); |
8556 | ctk_action_set_tooltip (action, _("Disconnect the selected drive")gettext ("Disconnect the selected drive")); |
8557 | break; |
8558 | case G_DRIVE_START_STOP_TYPE_MULTIDISK: |
8559 | ctk_action_set_label (action, _("_Stop Multi-disk Drive")gettext ("_Stop Multi-disk Drive")); |
8560 | ctk_action_set_tooltip (action, _("Stop the selected multi-disk drive")gettext ("Stop the selected multi-disk drive")); |
8561 | break; |
8562 | case G_DRIVE_START_STOP_TYPE_PASSWORD: |
8563 | ctk_action_set_label (action, _("_Lock Drive")gettext ("_Lock Drive")); |
8564 | ctk_action_set_tooltip (action, _("Lock the selected drive")gettext ("Lock the selected drive")); |
8565 | break; |
8566 | } |
8567 | } |
8568 | |
8569 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8570 | FM_ACTION_LOCATION_POLL"Location Poll"); |
8571 | ctk_action_set_visible (action, show_poll); |
8572 | } |
8573 | |
8574 | /* TODO: we should split out this routine into two functions: |
8575 | * Update on clipboard changes |
8576 | * Update on selection changes |
8577 | */ |
8578 | static void |
8579 | real_update_paste_menu (FMDirectoryView *view, |
8580 | GList *selection, |
8581 | gint selection_count) |
8582 | { |
8583 | gboolean can_paste_files_into; |
8584 | gboolean selection_is_read_only; |
8585 | gboolean is_read_only; |
8586 | CtkAction *action; |
8587 | |
8588 | selection_is_read_only = selection_count == 1 && |
8589 | (!baul_file_can_write (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type())))))) && |
8590 | !baul_file_has_activation_uri (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type()))))))); |
8591 | |
8592 | is_read_only = fm_directory_view_is_read_only (view); |
8593 | |
8594 | can_paste_files_into = (selection_count == 1 && |
8595 | can_paste_into_file (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((selection->data)), (baul_file_get_type()))))))); |
8596 | |
8597 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8598 | FM_ACTION_PASTE"Paste"); |
8599 | ctk_action_set_sensitive (action, !is_read_only); |
8600 | |
8601 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8602 | FM_ACTION_PASTE_FILES_INTO"Paste Files Into"); |
8603 | ctk_action_set_visible (action, can_paste_files_into); |
8604 | ctk_action_set_sensitive (action, !selection_is_read_only); |
8605 | |
8606 | /* Ask the clipboard */ |
8607 | g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)); /* Need to keep the object alive until we get the reply */ |
8608 | ctk_clipboard_request_targets (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))), |
8609 | clipboard_targets_received, |
8610 | view); |
8611 | } |
8612 | |
8613 | static void |
8614 | real_update_location_menu (FMDirectoryView *view) |
8615 | { |
8616 | CtkAction *action; |
8617 | BaulFile *file; |
8618 | gboolean is_special_link; |
8619 | gboolean is_desktop_or_home_dir; |
8620 | gboolean can_delete_file, show_delete; |
8621 | gboolean show_separate_delete_command; |
8622 | gboolean show_open_folder_window; |
8623 | gboolean show_open_in_new_tab; |
8624 | GList l; |
8625 | char *label; |
8626 | char *tip; |
8627 | |
8628 | show_open_folder_window = FALSE(0); |
8629 | show_open_in_new_tab = FALSE(0); |
8630 | |
8631 | if (baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION) { |
8632 | if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) { |
8633 | label = _("Open in New _Window")gettext ("Open in New _Window"); |
8634 | } else { |
8635 | label = _("Browse in New _Window")gettext ("Browse in New _Window"); |
8636 | show_open_folder_window = TRUE(!(0)); |
8637 | } |
8638 | |
8639 | show_open_in_new_tab = TRUE(!(0)); |
8640 | } else { |
8641 | label = g_strdup (ngettext ("_Browse Folder",g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders" , 1)) |
8642 | "_Browse Folders", 1))g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders" , 1)); |
8643 | } |
8644 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8645 | FM_ACTION_LOCATION_OPEN_ALTERNATE"LocationOpenAlternate"); |
8646 | g_object_set (action, |
8647 | "label", label, |
8648 | NULL((void*)0)); |
8649 | |
8650 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8651 | FM_ACTION_LOCATION_OPEN_IN_NEW_TAB"LocationOpenInNewTab"); |
8652 | ctk_action_set_visible (action, show_open_in_new_tab); |
8653 | |
8654 | if (show_open_in_new_tab) { |
8655 | if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) { |
8656 | label = _("Open in New _Tab")gettext ("Open in New _Tab"); |
8657 | } else { |
8658 | label = _("Browse in New _Tab")gettext ("Browse in New _Tab"); |
8659 | } |
8660 | g_object_set (action, |
8661 | "label", label, |
8662 | NULL((void*)0)); |
8663 | } |
8664 | |
8665 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8666 | FM_ACTION_LOCATION_OPEN_FOLDER_WINDOW"LocationOpenFolderWindow"); |
8667 | ctk_action_set_visible (action, show_open_folder_window); |
8668 | |
8669 | file = view->details->location_popup_directory_as_file; |
8670 | g_assert (BAUL_IS_FILE (file))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((file)); GType __t = (baul_file_get_type()); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 8670, ((const char*) (__func__)), "BAUL_IS_FILE (file)"); } while (0); |
8671 | g_assert (baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO |do { if (baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO )) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 8673, ((const char*) (__func__)), "baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)" ); } while (0) |
8672 | BAUL_FILE_ATTRIBUTE_MOUNT |do { if (baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO )) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 8673, ((const char*) (__func__)), "baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)" ); } while (0) |
8673 | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO))do { if (baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO )) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 8673, ((const char*) (__func__)), "baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)" ); } while (0); |
8674 | |
8675 | is_special_link = BAUL_IS_DESKTOP_ICON_FILE (file)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (file)); GType __t = (baul_desktop_icon_file_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))); |
8676 | is_desktop_or_home_dir = baul_file_is_home (file) |
8677 | || baul_file_is_desktop_directory (file); |
8678 | |
8679 | can_delete_file = |
8680 | baul_file_can_delete (file) && |
8681 | !is_special_link && |
8682 | !is_desktop_or_home_dir; |
8683 | |
8684 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8685 | FM_ACTION_LOCATION_CUT"LocationCut"); |
8686 | ctk_action_set_sensitive (action, can_delete_file); |
8687 | |
8688 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8689 | FM_ACTION_LOCATION_PASTE_FILES_INTO"LocationPasteFilesInto"); |
8690 | g_object_set_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), |
8691 | "can-paste-according-to-destination", |
8692 | GINT_TO_POINTER (can_paste_into_file (file))((gpointer) (glong) (can_paste_into_file (file)))); |
8693 | ctk_action_set_sensitive (action, |
8694 | GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-clipboard"))) |
8695 | "can-paste-according-to-clipboard"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-clipboard"))) && |
8696 | GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action),((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-destination"))) |
8697 | "can-paste-according-to-destination"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((action)), (((GType) ((20) << (2))) ))))), "can-paste-according-to-destination")))); |
8698 | |
8699 | show_delete = TRUE(!(0)); |
8700 | |
8701 | if (file != NULL((void*)0) && |
8702 | baul_file_is_in_trash (file)) { |
8703 | if (baul_file_is_self_owned (file)) { |
8704 | show_delete = FALSE(0); |
8705 | } |
8706 | |
8707 | label = _("_Delete Permanently")gettext ("_Delete Permanently"); |
8708 | tip = _("Delete the open folder permanently")gettext ("Delete the open folder permanently"); |
8709 | show_separate_delete_command = FALSE(0); |
8710 | } else { |
8711 | label = _("Mo_ve to Trash")gettext ("Mo_ve to Trash"); |
8712 | tip = _("Move the open folder to the Trash")gettext ("Move the open folder to the Trash"); |
8713 | show_separate_delete_command = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ENABLE_DELETE"enable-delete"); |
8714 | } |
8715 | |
8716 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8717 | FM_ACTION_LOCATION_TRASH"LocationTrash"); |
8718 | g_object_set (action, |
8719 | "label", label, |
8720 | "tooltip", tip, |
8721 | "icon-name", (file != NULL((void*)0) && |
8722 | baul_file_is_in_trash (file)) ? |
8723 | BAUL_ICON_DELETE"edit-delete" : BAUL_ICON_TRASH_FULL"user-trash-full", |
8724 | NULL((void*)0)); |
8725 | ctk_action_set_sensitive (action, can_delete_file); |
8726 | ctk_action_set_visible (action, show_delete); |
8727 | |
8728 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8729 | FM_ACTION_LOCATION_DELETE"LocationDelete"); |
8730 | ctk_action_set_visible (action, show_separate_delete_command); |
8731 | if (show_separate_delete_command) { |
8732 | ctk_action_set_sensitive (action, can_delete_file); |
8733 | g_object_set (action, |
8734 | "icon-name", BAUL_ICON_DELETE"edit-delete", |
8735 | "sensitive", can_delete_file, |
8736 | NULL((void*)0)); |
8737 | } |
8738 | |
8739 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8740 | FM_ACTION_LOCATION_RESTORE_FROM_TRASH"LocationRestoreFromTrash"); |
8741 | l.prev = NULL((void*)0); |
8742 | l.next = NULL((void*)0); |
8743 | l.data = file; |
8744 | update_restore_from_trash_action (action, &l, TRUE(!(0))); |
8745 | |
8746 | real_update_location_menu_volumes (view); |
8747 | |
8748 | /* we silently assume that fm_directory_view_supports_properties always returns the same value. |
8749 | * Therefore, we don't update the sensitivity of FM_ACTION_LOCATION_PROPERTIES */ |
8750 | } |
8751 | |
8752 | static void |
8753 | clipboard_changed_callback (BaulClipboardMonitor *monitor G_GNUC_UNUSED__attribute__ ((__unused__)), |
8754 | FMDirectoryView *view) |
8755 | { |
8756 | GList *selection; |
8757 | gint selection_count; |
8758 | |
8759 | if (!view->details->active) { |
8760 | return; |
8761 | } |
8762 | |
8763 | selection = fm_directory_view_get_selection (view); |
8764 | selection_count = g_list_length (selection); |
8765 | |
8766 | real_update_paste_menu (view, selection, selection_count); |
8767 | |
8768 | baul_file_list_free (selection); |
8769 | |
8770 | } |
8771 | |
8772 | static gboolean |
8773 | can_delete_all (GList *files) |
8774 | { |
8775 | GList *l; |
8776 | BaulFile *file = NULL((void*)0); |
8777 | |
8778 | for (l = files; l != NULL((void*)0); l = l->next) { |
8779 | file = l->data; |
8780 | if (!baul_file_can_delete (file)) { |
8781 | return FALSE(0); |
8782 | } |
8783 | } |
8784 | return TRUE(!(0)); |
8785 | } |
8786 | |
8787 | static gboolean |
8788 | has_writable_extra_pane (FMDirectoryView *view) |
8789 | { |
8790 | FMDirectoryView *other_view; |
8791 | |
8792 | other_view = get_directory_view_of_extra_pane (view); |
8793 | if (other_view != NULL((void*)0)) { |
8794 | return !fm_directory_view_is_read_only (other_view); |
8795 | } |
8796 | return FALSE(0); |
8797 | } |
8798 | |
8799 | static void |
8800 | real_update_menus (FMDirectoryView *view) |
8801 | { |
8802 | GList *selection, *l; |
8803 | gint selection_count; |
8804 | const char *tip, *label; |
8805 | char *label_with_underscore; |
8806 | gboolean selection_contains_special_link; |
8807 | gboolean selection_contains_desktop_or_home_dir; |
8808 | gboolean can_create_files; |
8809 | gboolean can_delete_files; |
8810 | gboolean can_copy_files; |
8811 | gboolean can_link_files; |
8812 | gboolean can_duplicate_files; |
8813 | gboolean show_separate_delete_command; |
8814 | gboolean vfolder_directory; |
8815 | gboolean disable_command_line; |
8816 | gboolean show_open_alternate; |
8817 | gboolean can_open; |
8818 | gboolean show_app; |
8819 | gboolean show_save_search; |
8820 | gboolean save_search_sensitive; |
8821 | gboolean show_save_search_as; |
8822 | gboolean show_open_folder_window; |
8823 | CtkAction *action; |
8824 | GAppInfo *app; |
8825 | GIcon *app_icon; |
8826 | CtkWidget *menuitem; |
8827 | gboolean next_pane_is_writable; |
8828 | gboolean show_properties; |
8829 | |
8830 | selection = fm_directory_view_get_selection (view); |
8831 | selection_count = g_list_length (selection); |
8832 | |
8833 | selection_contains_special_link = special_link_in_selection (view); |
8834 | selection_contains_desktop_or_home_dir = desktop_or_home_dir_in_selection (view); |
8835 | |
8836 | can_create_files = fm_directory_view_supports_creating_files (view); |
8837 | can_delete_files = |
8838 | can_delete_all (selection) && |
8839 | selection_count != 0 && |
8840 | !selection_contains_special_link && |
8841 | !selection_contains_desktop_or_home_dir; |
8842 | can_copy_files = selection_count != 0 |
8843 | && !selection_contains_special_link; |
8844 | |
8845 | can_duplicate_files = can_create_files && can_copy_files; |
8846 | can_link_files = can_create_files && can_copy_files; |
8847 | |
8848 | vfolder_directory = we_are_in_vfolder_desktop_dir (view); |
8849 | |
8850 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8851 | FM_ACTION_RENAME"Rename"); |
8852 | ctk_action_set_sensitive (action, |
8853 | selection_count == 1 && |
8854 | fm_directory_view_can_rename_file (view, selection->data)); |
8855 | |
8856 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8857 | FM_ACTION_NEW_FOLDER"New Folder"); |
8858 | ctk_action_set_sensitive (action, can_create_files); |
8859 | |
8860 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8861 | FM_ACTION_OPEN"Open"); |
8862 | ctk_action_set_sensitive (action, selection_count != 0); |
8863 | |
8864 | can_open = show_app = selection_count != 0; |
8865 | |
8866 | for (l = selection; l != NULL((void*)0); l = l->next) { |
8867 | BaulFile *file; |
8868 | |
8869 | file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), (baul_file_get_type()))))); |
8870 | |
8871 | /* Double-check if the files' MIME types have changed before we |
8872 | commit to a choice of applications for them. This can happen |
8873 | if, for instance, a file was originally created with 0 bytes |
8874 | and then content was added to it later-- it will change from |
8875 | plaintext to something else. */ |
8876 | baul_file_refresh_info (file); |
8877 | |
8878 | if (!baul_mime_file_opens_in_external_app (file)) { |
8879 | show_app = FALSE(0); |
8880 | } |
8881 | |
8882 | if (!show_app) { |
8883 | break; |
8884 | } |
8885 | } |
8886 | |
8887 | label_with_underscore = NULL((void*)0); |
8888 | |
8889 | app = NULL((void*)0); |
8890 | app_icon = NULL((void*)0); |
8891 | |
8892 | if (can_open && show_app) { |
8893 | app = baul_mime_get_default_application_for_files (selection); |
8894 | } |
8895 | |
8896 | if (app != NULL((void*)0)) { |
8897 | char *escaped_app; |
8898 | |
8899 | escaped_app = eel_str_double_underscores (g_app_info_get_display_name (app)); |
8900 | label_with_underscore = g_strdup_printf (_("_Open With %s")gettext ("_Open With %s"), |
8901 | escaped_app); |
8902 | |
8903 | app_icon = g_app_info_get_icon (app); |
8904 | if (app_icon != NULL((void*)0)) { |
8905 | g_object_ref (app_icon)((__typeof__ (app_icon)) (g_object_ref) (app_icon)); |
8906 | } |
8907 | |
8908 | g_free (escaped_app); |
8909 | g_object_unref (app); |
8910 | } |
8911 | |
8912 | g_object_set (action, "label", |
8913 | label_with_underscore ? label_with_underscore : _("_Open")gettext ("_Open"), |
8914 | NULL((void*)0)); |
8915 | |
8916 | menuitem = ctk_ui_manager_get_widget ( |
8917 | baul_window_info_get_ui_manager (view->details->window), |
8918 | FM_DIRECTORY_VIEW_MENU_PATH_OPEN"/MenuBar/File/Open Placeholder/Open"); |
8919 | |
8920 | /* Only force displaying the icon if it is an application icon */ |
8921 | ctk_image_menu_item_set_always_show_image ( |
8922 | CTK_IMAGE_MENU_ITEM (menuitem)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_image_menu_item_get_type ( ))))))), app_icon != NULL((void*)0)); |
8923 | |
8924 | menuitem = ctk_ui_manager_get_widget ( |
8925 | baul_window_info_get_ui_manager (view->details->window), |
8926 | FM_DIRECTORY_VIEW_POPUP_PATH_OPEN"/selection/Open Placeholder/Open"); |
8927 | |
8928 | /* Only force displaying the icon if it is an application icon */ |
8929 | ctk_image_menu_item_set_always_show_image ( |
8930 | CTK_IMAGE_MENU_ITEM (menuitem)((((CtkImageMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_image_menu_item_get_type ( ))))))), app_icon != NULL((void*)0)); |
8931 | |
8932 | if (app_icon == NULL((void*)0)) { |
8933 | app_icon = g_themed_icon_new ("document-open"); |
8934 | } |
8935 | |
8936 | ctk_action_set_gicon (action, app_icon); |
8937 | g_object_unref (app_icon); |
8938 | |
8939 | ctk_action_set_visible (action, can_open); |
8940 | |
8941 | g_free (label_with_underscore); |
8942 | |
8943 | show_open_alternate = file_list_all_are_folders (selection) && |
8944 | selection_count > 0 && |
8945 | !(baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_DESKTOP && |
8946 | g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")); |
8947 | show_open_folder_window = FALSE(0); |
8948 | if (baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION) { |
8949 | if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) { |
8950 | if (selection_count == 0 || selection_count == 1) { |
8951 | label_with_underscore = g_strdup (_("Open in New _Window"))g_strdup_inline (gettext ("Open in New _Window")); |
8952 | } else { |
8953 | label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Window", |
8954 | "Open in %'d New _Windows", |
8955 | selection_count), |
8956 | selection_count); |
8957 | } |
8958 | } else { |
8959 | if (selection_count == 0 || selection_count == 1) { |
8960 | label_with_underscore = g_strdup (_("Browse in New _Window"))g_strdup_inline (gettext ("Browse in New _Window")); |
8961 | } else { |
8962 | label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Window", |
8963 | "Browse in %'d New _Windows", |
8964 | selection_count), |
8965 | selection_count); |
8966 | } |
8967 | show_open_folder_window = show_open_alternate; |
8968 | } |
8969 | } else { |
8970 | label_with_underscore = g_strdup (ngettext ("_Browse Folder",g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders" , selection_count)) |
8971 | "_Browse Folders",g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders" , selection_count)) |
8972 | selection_count))g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders" , selection_count)); |
8973 | } |
8974 | |
8975 | action = ctk_action_group_get_action (view->details->dir_action_group, |
8976 | FM_ACTION_OPEN_ALTERNATE"OpenAlternate"); |
8977 | g_object_set (action, "label", |
8978 | label_with_underscore, |
8979 | NULL((void*)0)); |
8980 | g_free (label_with_underscore); |
8981 | |
8982 | ctk_action_set_sensitive (action, selection_count != 0); |
8983 | ctk_action_set_visible (action, show_open_alternate); |
8984 | |
8985 | /* Open in New Tab action */ |
8986 | if (baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION) { |
8987 | |
8988 | if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) { |
8989 | if (selection_count == 0 || selection_count == 1) { |
8990 | label_with_underscore = g_strdup (_("Open in New _Tab"))g_strdup_inline (gettext ("Open in New _Tab")); |
8991 | } else { |
8992 | label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Tab", |
8993 | "Open in %'d New _Tabs", |
8994 | selection_count), |
8995 | selection_count); |
8996 | } |
8997 | } else { |
8998 | if (selection_count == 0 || selection_count == 1) { |
8999 | label_with_underscore = g_strdup (_("Browse in New _Tab"))g_strdup_inline (gettext ("Browse in New _Tab")); |
9000 | } else { |
9001 | label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Tab", |
9002 | "Browse in %'d New _Tabs", |
9003 | selection_count), |
9004 | selection_count); |
9005 | } |
9006 | } |
9007 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9008 | FM_ACTION_OPEN_IN_NEW_TAB"OpenInNewTab"); |
9009 | ctk_action_set_sensitive (action, selection_count != 0); |
9010 | ctk_action_set_visible (action, show_open_alternate); |
9011 | g_object_set (action, "label", |
9012 | label_with_underscore, |
9013 | NULL((void*)0)); |
9014 | g_free (label_with_underscore); |
9015 | } else { |
9016 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9017 | FM_ACTION_OPEN_IN_NEW_TAB"OpenInNewTab"); |
9018 | ctk_action_set_visible (action, FALSE(0)); |
9019 | } |
9020 | |
9021 | /* next pane actions, only in navigation mode */ |
9022 | if (baul_window_info_get_window_type (view->details->window) != BAUL_WINDOW_NAVIGATION) { |
9023 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9024 | FM_ACTION_COPY_TO_NEXT_PANE"Copy to next pane"); |
9025 | ctk_action_set_visible (action, FALSE(0)); |
9026 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9027 | FM_ACTION_MOVE_TO_NEXT_PANE"Move to next pane"); |
9028 | ctk_action_set_visible (action, FALSE(0)); |
9029 | } |
9030 | |
9031 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9032 | FM_ACTION_OPEN_FOLDER_WINDOW"OpenFolderWindow"); |
9033 | ctk_action_set_visible (action, show_open_folder_window); |
9034 | |
9035 | /* Broken into its own function just for convenience */ |
9036 | reset_open_with_menu (view, selection); |
9037 | reset_extension_actions_menu (view, selection); |
9038 | |
9039 | if (all_selected_items_in_trash (view)) { |
9040 | label = _("_Delete Permanently")gettext ("_Delete Permanently"); |
9041 | tip = _("Delete all selected items permanently")gettext ("Delete all selected items permanently"); |
9042 | show_separate_delete_command = FALSE(0); |
9043 | } else { |
9044 | label = _("Mo_ve to Trash")gettext ("Mo_ve to Trash"); |
9045 | tip = _("Move each selected item to the Trash")gettext ("Move each selected item to the Trash"); |
9046 | show_separate_delete_command = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ENABLE_DELETE"enable-delete"); |
9047 | } |
9048 | |
9049 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9050 | FM_ACTION_TRASH"Trash"); |
9051 | g_object_set (action, |
9052 | "label", label, |
9053 | "tooltip", tip, |
9054 | "icon-name", all_selected_items_in_trash (view) ? |
9055 | BAUL_ICON_DELETE"edit-delete" : BAUL_ICON_TRASH_FULL"user-trash-full", |
9056 | NULL((void*)0)); |
9057 | ctk_action_set_sensitive (action, can_delete_files); |
9058 | |
9059 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9060 | FM_ACTION_DELETE"Delete"); |
9061 | ctk_action_set_visible (action, show_separate_delete_command); |
9062 | |
9063 | if (show_separate_delete_command) { |
9064 | g_object_set (action, |
9065 | "label", _("_Delete")gettext ("_Delete"), |
9066 | "icon-name", BAUL_ICON_DELETE"edit-delete", |
9067 | NULL((void*)0)); |
9068 | } |
9069 | ctk_action_set_sensitive (action, can_delete_files); |
9070 | |
9071 | |
9072 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9073 | FM_ACTION_RESTORE_FROM_TRASH"Restore From Trash"); |
9074 | update_restore_from_trash_action (action, selection, FALSE(0)); |
9075 | |
9076 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9077 | FM_ACTION_DUPLICATE"Duplicate"); |
9078 | ctk_action_set_sensitive (action, can_duplicate_files); |
9079 | |
9080 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9081 | FM_ACTION_CREATE_LINK"Create Link"); |
9082 | ctk_action_set_sensitive (action, can_link_files); |
9083 | g_object_set (action, "label", |
9084 | ngettext ("Ma_ke Link", |
9085 | "Ma_ke Links", |
9086 | selection_count), |
9087 | NULL((void*)0)); |
9088 | |
9089 | show_properties = (!FM_IS_DESKTOP_ICON_VIEW (view)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (view)); GType __t = (fm_desktop_icon_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) || selection_count > 0) && |
9090 | fm_directory_view_supports_properties (view); |
9091 | |
9092 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9093 | FM_ACTION_PROPERTIES"Properties"); |
9094 | |
9095 | ctk_action_set_sensitive (action, show_properties); |
9096 | |
9097 | if (selection_count == 0) { |
9098 | ctk_action_set_tooltip (action, _("View or modify the properties of the open folder")gettext ("View or modify the properties of the open folder")); |
9099 | } else { |
9100 | ctk_action_set_tooltip (action, _("View or modify the properties of each selected item")gettext ("View or modify the properties of each selected item" )); |
9101 | } |
9102 | |
9103 | ctk_action_set_visible (action, show_properties); |
9104 | |
9105 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9106 | FM_ACTION_PROPERTIES_ACCEL"PropertiesAccel"); |
9107 | |
9108 | ctk_action_set_sensitive (action, show_properties); |
9109 | |
9110 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9111 | FM_ACTION_EMPTY_TRASH"Empty Trash"); |
9112 | g_object_set (action, |
9113 | "label", _("E_mpty Trash")gettext ("E_mpty Trash"), |
9114 | NULL((void*)0)); |
9115 | ctk_action_set_sensitive (action, !baul_trash_monitor_is_empty ()); |
9116 | ctk_action_set_visible (action, should_show_empty_trash (view)); |
9117 | |
9118 | show_save_search = FALSE(0); |
9119 | save_search_sensitive = FALSE(0); |
9120 | show_save_search_as = FALSE(0); |
9121 | if (view->details->model && |
9122 | BAUL_IS_SEARCH_DIRECTORY (view->details->model)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (view->details->model)); GType __t = (baul_search_directory_get_type ()); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
9123 | BaulSearchDirectory *search; |
9124 | |
9125 | search = BAUL_SEARCH_DIRECTORY (view->details->model)((((BaulSearchDirectory*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((view->details->model)), (baul_search_directory_get_type ()))))); |
9126 | if (baul_search_directory_is_saved_search (search)) { |
9127 | show_save_search = TRUE(!(0)); |
9128 | save_search_sensitive = baul_search_directory_is_modified (search); |
9129 | } else { |
9130 | show_save_search_as = TRUE(!(0)); |
9131 | } |
9132 | } |
9133 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9134 | FM_ACTION_SAVE_SEARCH"Save Search"); |
9135 | ctk_action_set_visible (action, show_save_search); |
9136 | ctk_action_set_sensitive (action, save_search_sensitive); |
9137 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9138 | FM_ACTION_SAVE_SEARCH_AS"Save Search As"); |
9139 | ctk_action_set_visible (action, show_save_search_as); |
9140 | |
9141 | |
9142 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9143 | FM_ACTION_SELECT_ALL"Select All"); |
9144 | ctk_action_set_sensitive (action, !fm_directory_view_is_empty (view)); |
9145 | |
9146 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9147 | FM_ACTION_SELECT_PATTERN"Select Pattern"); |
9148 | ctk_action_set_sensitive (action, !fm_directory_view_is_empty (view)); |
9149 | |
9150 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9151 | FM_ACTION_INVERT_SELECTION"Invert Selection"); |
9152 | ctk_action_set_sensitive (action, !fm_directory_view_is_empty (view)); |
9153 | |
9154 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9155 | FM_ACTION_CUT"Cut"); |
9156 | ctk_action_set_sensitive (action, can_delete_files); |
9157 | |
9158 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9159 | FM_ACTION_COPY"Copy"); |
9160 | ctk_action_set_sensitive (action, can_copy_files); |
9161 | |
9162 | real_update_paste_menu (view, selection, selection_count); |
9163 | |
9164 | disable_command_line = g_settings_get_boolean (cafe_lockdown_preferences, BAUL_PREFERENCES_LOCKDOWN_COMMAND_LINE"disable-command-line"); |
9165 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9166 | FM_ACTION_NEW_LAUNCHER"New Launcher"); |
9167 | ctk_action_set_visible (action, vfolder_directory && !disable_command_line); |
9168 | ctk_action_set_sensitive (action, can_create_files); |
9169 | |
9170 | real_update_menus_volumes (view, selection, selection_count); |
9171 | |
9172 | undo_update_menu (view); |
9173 | |
9174 | baul_file_list_free (selection); |
9175 | |
9176 | if (view->details->scripts_invalid) { |
9177 | update_scripts_menu (view); |
9178 | } |
9179 | |
9180 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9181 | FM_ACTION_NEW_DOCUMENTS"New Documents"); |
9182 | ctk_action_set_sensitive (action, can_create_files); |
9183 | |
9184 | if (can_create_files && view->details->templates_invalid) { |
9185 | update_templates_menu (view); |
9186 | } |
9187 | |
9188 | next_pane_is_writable = has_writable_extra_pane (view); |
9189 | |
9190 | /* next pane: works if file is copyable, and next pane is writable */ |
9191 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9192 | FM_ACTION_COPY_TO_NEXT_PANE"Copy to next pane"); |
9193 | ctk_action_set_sensitive (action, can_copy_files && next_pane_is_writable); |
9194 | |
9195 | /* move to next pane: works if file is cuttable, and next pane is writable */ |
9196 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9197 | FM_ACTION_MOVE_TO_NEXT_PANE"Move to next pane"); |
9198 | ctk_action_set_sensitive (action, can_delete_files && next_pane_is_writable); |
9199 | |
9200 | |
9201 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9202 | FM_ACTION_COPY_TO_HOME"Copy to Home"); |
9203 | ctk_action_set_sensitive (action, can_copy_files); |
9204 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9205 | FM_ACTION_COPY_TO_DESKTOP"Copy to Desktop"); |
9206 | ctk_action_set_sensitive (action, can_copy_files); |
9207 | |
9208 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9209 | FM_ACTION_MOVE_TO_HOME"Move to Home"); |
9210 | ctk_action_set_sensitive (action, can_delete_files); |
9211 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9212 | FM_ACTION_MOVE_TO_DESKTOP"Move to Desktop"); |
9213 | ctk_action_set_sensitive (action, can_delete_files); |
9214 | |
9215 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9216 | "CopyToMenu"); |
9217 | ctk_action_set_sensitive (action, can_copy_files); |
9218 | action = ctk_action_group_get_action (view->details->dir_action_group, |
9219 | "MoveToMenu"); |
9220 | ctk_action_set_sensitive (action, can_delete_files); |
9221 | } |
9222 | |
9223 | /** |
9224 | * fm_directory_view_pop_up_selection_context_menu |
9225 | * |
9226 | * Pop up a context menu appropriate to the selected items. |
9227 | * @view: FMDirectoryView of interest. |
9228 | * @event: The event that triggered this context menu. |
9229 | * |
9230 | * Return value: BaulDirectory for this view. |
9231 | * |
9232 | **/ |
9233 | void |
9234 | fm_directory_view_pop_up_selection_context_menu (FMDirectoryView *view, |
9235 | CdkEventButton *event) |
9236 | { |
9237 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9237, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9238 | |
9239 | /* Make the context menu items not flash as they update to proper disabled, |
9240 | * etc. states by forcing menus to update now. |
9241 | */ |
9242 | update_menus_if_pending (view); |
9243 | |
9244 | update_context_menu_position_from_event (view, event); |
9245 | |
9246 | /* FIXME: passing event from here won't work |
9247 | * for ctk_menu_popup_at_pointer (in eel_pop_up_context_menu() ) |
9248 | * if the menu is being triggered from here by the menu key |
9249 | */ |
9250 | eel_pop_up_context_menu (create_popup_menu |
9251 | (view, FM_DIRECTORY_VIEW_POPUP_PATH_SELECTION"/selection"), |
9252 | NULL((void*)0)); |
9253 | } |
9254 | |
9255 | /** |
9256 | * fm_directory_view_pop_up_background_context_menu |
9257 | * |
9258 | * Pop up a context menu appropriate to the view globally at the last right click location. |
9259 | * @view: FMDirectoryView of interest. |
9260 | * |
9261 | * Return value: BaulDirectory for this view. |
9262 | * |
9263 | **/ |
9264 | void |
9265 | fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view, |
9266 | CdkEventButton *event) |
9267 | { |
9268 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9268, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9269 | |
9270 | /* Make the context menu items not flash as they update to proper disabled, |
9271 | * etc. states by forcing menus to update now. |
9272 | */ |
9273 | update_menus_if_pending (view); |
9274 | |
9275 | update_context_menu_position_from_event (view, event); |
9276 | |
9277 | eel_pop_up_context_menu (create_popup_menu |
9278 | (view, FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND"/background"), |
9279 | event); |
9280 | } |
9281 | |
9282 | static void |
9283 | real_pop_up_location_context_menu (FMDirectoryView *view) |
9284 | { |
9285 | /* always update the menu before showing it. Shouldn't be too expensive. */ |
9286 | real_update_location_menu (view); |
9287 | |
9288 | update_context_menu_position_from_event (view, view->details->location_popup_event); |
9289 | |
9290 | eel_pop_up_context_menu (create_popup_menu |
9291 | (view, FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION"/location"), |
9292 | view->details->location_popup_event); |
9293 | } |
9294 | |
9295 | static void |
9296 | location_popup_file_attributes_ready (BaulFile *file, |
9297 | gpointer data) |
9298 | { |
9299 | FMDirectoryView *view; |
9300 | |
9301 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
9302 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9302, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9303 | |
9304 | g_assert (file == view->details->location_popup_directory_as_file)do { if (file == view->details->location_popup_directory_as_file ) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9304, ((const char*) (__func__)), "file == view->details->location_popup_directory_as_file" ); } while (0); |
9305 | |
9306 | real_pop_up_location_context_menu (view); |
9307 | } |
9308 | |
9309 | static void |
9310 | unschedule_pop_up_location_context_menu (FMDirectoryView *view) |
9311 | { |
9312 | if (view->details->location_popup_directory_as_file != NULL((void*)0)) { |
9313 | g_assert (BAUL_IS_FILE (view->details->location_popup_directory_as_file))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view->details->location_popup_directory_as_file)); GType __t = (baul_file_get_type()); gboolean __r; if (!__inst ) __r = (0); else if (__inst->g_class && __inst-> g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr ( ((gchar*) 0), "fm-directory-view.c", 9313, ((const char*) (__func__ )), "BAUL_IS_FILE (view->details->location_popup_directory_as_file)" ); } while (0); |
9314 | baul_file_cancel_call_when_ready (view->details->location_popup_directory_as_file, |
9315 | location_popup_file_attributes_ready, |
9316 | view); |
9317 | baul_file_unref (view->details->location_popup_directory_as_file); |
9318 | view->details->location_popup_directory_as_file = NULL((void*)0); |
9319 | } |
9320 | } |
9321 | |
9322 | static void |
9323 | schedule_pop_up_location_context_menu (FMDirectoryView *view, |
9324 | CdkEventButton *event, |
9325 | BaulFile *file) |
9326 | { |
9327 | g_assert (BAUL_IS_FILE (file))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((file)); GType __t = (baul_file_get_type()); gboolean __r ; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9327, ((const char*) (__func__)), "BAUL_IS_FILE (file)"); } while (0); |
9328 | |
9329 | if (view->details->location_popup_event != NULL((void*)0)) { |
9330 | cdk_event_free ((CdkEvent *) view->details->location_popup_event); |
9331 | } |
9332 | view->details->location_popup_event = (CdkEventButton *) cdk_event_copy ((CdkEvent *)event); |
9333 | |
9334 | if (file == view->details->location_popup_directory_as_file) { |
9335 | if (baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | |
9336 | BAUL_FILE_ATTRIBUTE_MOUNT | |
9337 | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)) { |
9338 | real_pop_up_location_context_menu (view); |
9339 | } |
9340 | } else { |
9341 | unschedule_pop_up_location_context_menu (view); |
9342 | |
9343 | view->details->location_popup_directory_as_file = baul_file_ref (file); |
9344 | baul_file_call_when_ready (view->details->location_popup_directory_as_file, |
9345 | BAUL_FILE_ATTRIBUTE_INFO | |
9346 | BAUL_FILE_ATTRIBUTE_MOUNT | |
9347 | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO, |
9348 | location_popup_file_attributes_ready, |
9349 | view); |
9350 | } |
9351 | } |
9352 | |
9353 | /** |
9354 | * fm_directory_view_pop_up_location_context_menu |
9355 | * |
9356 | * Pop up a context menu appropriate to the view globally. |
9357 | * @view: FMDirectoryView of interest. |
9358 | * @event: CdkEventButton triggering the popup. |
9359 | * @location: The location the popup-menu should be created for, |
9360 | * or NULL for the currently displayed location. |
9361 | * |
9362 | **/ |
9363 | void |
9364 | fm_directory_view_pop_up_location_context_menu (FMDirectoryView *view, |
9365 | CdkEventButton *event, |
9366 | const char *location) |
9367 | { |
9368 | BaulFile *file; |
9369 | |
9370 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9370, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9371 | |
9372 | if (location != NULL((void*)0)) { |
9373 | file = baul_file_get_by_uri (location); |
9374 | } else { |
9375 | file = baul_file_ref (view->details->directory_as_file); |
9376 | } |
9377 | |
9378 | if (file != NULL((void*)0)) { |
9379 | schedule_pop_up_location_context_menu (view, event, file); |
9380 | baul_file_unref (file); |
9381 | } |
9382 | } |
9383 | |
9384 | static void |
9385 | fm_directory_view_drop_proxy_received_uris (FMDirectoryView *view, |
9386 | const GList *source_uri_list, |
9387 | const char *target_uri, |
9388 | CdkDragAction action) |
9389 | { |
9390 | char *container_uri; |
9391 | |
9392 | container_uri = NULL((void*)0); |
9393 | if (target_uri == NULL((void*)0)) { |
9394 | container_uri = fm_directory_view_get_backing_uri (view); |
9395 | g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 9395, ((const char*) ( __func__)), "container_uri != NULL"); } while (0); |
9396 | } |
9397 | |
9398 | if (action == CDK_ACTION_ASK) { |
9399 | action = baul_drag_drop_action_ask |
9400 | (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), |
9401 | CDK_ACTION_MOVE | CDK_ACTION_COPY | CDK_ACTION_LINK); |
9402 | if (action == 0) { |
9403 | return; |
9404 | } |
9405 | } |
9406 | |
9407 | baul_clipboard_clear_if_colliding_uris (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), |
9408 | source_uri_list, |
9409 | fm_directory_view_get_copied_files_atom (view)); |
9410 | |
9411 | fm_directory_view_move_copy_items (source_uri_list, NULL((void*)0), |
9412 | target_uri != NULL((void*)0) ? target_uri : container_uri, |
9413 | action, 0, 0, view); |
9414 | |
9415 | g_free (container_uri); |
9416 | } |
9417 | |
9418 | static void |
9419 | fm_directory_view_drop_proxy_received_netscape_url (FMDirectoryView *view, |
9420 | const char *netscape_url, |
9421 | const char *target_uri, |
9422 | CdkDragAction action) |
9423 | { |
9424 | fm_directory_view_handle_netscape_url_drop (view, |
9425 | netscape_url, |
9426 | target_uri, |
9427 | action, 0, 0); |
9428 | } |
9429 | |
9430 | static void |
9431 | schedule_update_menus (FMDirectoryView *view) |
9432 | { |
9433 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9433, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9434 | |
9435 | /* Don't schedule updates after destroy (#349551), |
9436 | * or if we are not active. |
9437 | */ |
9438 | if (view->details->window == NULL((void*)0) || |
9439 | !view->details->active) { |
9440 | return; |
9441 | } |
9442 | |
9443 | view->details->menu_states_untrustworthy = TRUE(!(0)); |
9444 | |
9445 | /* Schedule a menu update with the current update interval */ |
9446 | if (view->details->update_menus_timeout_id == 0) { |
9447 | view->details->update_menus_timeout_id |
9448 | = g_timeout_add (view->details->update_interval, update_menus_timeout_callback, view); |
9449 | } |
9450 | } |
9451 | |
9452 | static void |
9453 | remove_update_status_idle_callback (FMDirectoryView *view) |
9454 | { |
9455 | if (view->details->update_status_idle_id != 0) { |
9456 | g_source_remove (view->details->update_status_idle_id); |
9457 | view->details->update_status_idle_id = 0; |
9458 | } |
9459 | } |
9460 | |
9461 | static gboolean |
9462 | update_status_idle_callback (gpointer data) |
9463 | { |
9464 | FMDirectoryView *view; |
9465 | |
9466 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
9467 | fm_directory_view_display_selection_info (view); |
9468 | view->details->update_status_idle_id = 0; |
9469 | return FALSE(0); |
9470 | } |
9471 | |
9472 | static void |
9473 | schedule_update_status (FMDirectoryView *view) |
9474 | { |
9475 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9475, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9476 | |
9477 | /* Make sure we haven't already destroyed it */ |
9478 | if (view->details->window == NULL((void*)0)) { |
9479 | return; |
9480 | } |
9481 | |
9482 | if (view->details->loading) { |
9483 | /* Don't update status bar while loading the dir */ |
9484 | return; |
9485 | } |
9486 | |
9487 | if (view->details->update_status_idle_id == 0) { |
9488 | view->details->update_status_idle_id = |
9489 | g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200 - 20, |
9490 | update_status_idle_callback, view, NULL((void*)0)); |
9491 | } |
9492 | } |
9493 | |
9494 | /** |
9495 | * fm_directory_view_notify_selection_changed: |
9496 | * |
9497 | * Notify this view that the selection has changed. This is normally |
9498 | * called only by subclasses. |
9499 | * @view: FMDirectoryView whose selection has changed. |
9500 | * |
9501 | **/ |
9502 | void |
9503 | fm_directory_view_notify_selection_changed (FMDirectoryView *view) |
9504 | { |
9505 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9506 | |
9507 | if (baul_debug_log_is_domain_enabled (BAUL_DEBUG_LOG_DOMAIN_USER"USER")) { |
9508 | GList *selection; |
9509 | CtkWindow *window; |
9510 | |
9511 | selection = fm_directory_view_get_selection (view); |
9512 | |
9513 | window = fm_directory_view_get_containing_window (view); |
9514 | baul_debug_log_with_file_list (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER", selection, |
9515 | "selection changed in window %p", |
9516 | window); |
9517 | baul_file_list_free (selection); |
9518 | } |
9519 | |
9520 | view->details->selection_was_removed = FALSE(0); |
9521 | |
9522 | if (!view->details->selection_change_is_due_to_shell) { |
9523 | view->details->send_selection_change_to_shell = TRUE(!(0)); |
9524 | } |
9525 | |
9526 | /* Schedule a display of the new selection. */ |
9527 | if (view->details->display_selection_idle_id == 0) { |
9528 | view->details->display_selection_idle_id |
9529 | = g_idle_add (display_selection_info_idle_callback, |
9530 | view); |
9531 | } |
9532 | |
9533 | if (view->details->batching_selection_level != 0) { |
9534 | view->details->selection_changed_while_batched = TRUE(!(0)); |
9535 | } else { |
9536 | /* Here is the work we do only when we're not |
9537 | * batching selection changes. In other words, it's the slower |
9538 | * stuff that we don't want to slow down selection techniques |
9539 | * such as rubberband-selecting in icon view. |
9540 | */ |
9541 | |
9542 | /* Schedule an update of menu item states to match selection */ |
9543 | schedule_update_menus (view); |
9544 | } |
9545 | } |
9546 | |
9547 | static void |
9548 | file_changed_callback (BaulFile *file, gpointer callback_data) |
9549 | { |
9550 | FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type()))))); |
9551 | |
9552 | schedule_changes (view); |
9553 | |
9554 | schedule_update_menus (view); |
9555 | schedule_update_status (view); |
9556 | |
9557 | /* We might have different capabilities, so we need to update |
9558 | * relative icon emblems . (Writeable etc). |
9559 | * Don't do this for trash, as it never changes writability |
9560 | * but does change a lot for the file count attribute. |
9561 | */ |
9562 | if (!baul_file_is_in_trash (file)) { |
9563 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> emblems_changed != ((void*)0)) { (* ((((FMDirectoryViewClass* ) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->emblems_changed) (view); } } while (0) |
9564 | (FM_DIRECTORY_VIEW_CLASS, view, emblems_changed, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> emblems_changed != ((void*)0)) { (* ((((FMDirectoryViewClass* ) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->emblems_changed) (view); } } while (0); |
9565 | } |
9566 | } |
9567 | |
9568 | /** |
9569 | * load_directory: |
9570 | * |
9571 | * Switch the displayed location to a new uri. If the uri is not valid, |
9572 | * the location will not be switched; user feedback will be provided instead. |
9573 | * @view: FMDirectoryView whose location will be changed. |
9574 | * @uri: A string representing the uri to switch to. |
9575 | * |
9576 | **/ |
9577 | static void |
9578 | load_directory (FMDirectoryView *view, |
9579 | BaulDirectory *directory) |
9580 | { |
9581 | BaulDirectory *old_directory; |
9582 | BaulFile *old_file; |
9583 | BaulFileAttributes attributes; |
9584 | |
9585 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9585, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9586 | g_assert (BAUL_IS_DIRECTORY (directory))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((directory)); GType __t = (baul_directory_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9586, ((const char*) (__func__)), "BAUL_IS_DIRECTORY (directory)" ); } while (0); |
9587 | |
9588 | fm_directory_view_stop (view); |
9589 | fm_directory_view_clear (view); |
9590 | |
9591 | view->details->loading = TRUE(!(0)); |
9592 | |
9593 | /* Update menus when directory is empty, before going to new |
9594 | * location, so they won't have any false lingering knowledge |
9595 | * of old selection. |
9596 | */ |
9597 | schedule_update_menus (view); |
9598 | |
9599 | while (view->details->subdirectory_list != NULL((void*)0)) { |
9600 | fm_directory_view_remove_subdirectory (view, |
9601 | view->details->subdirectory_list->data); |
9602 | } |
9603 | |
9604 | disconnect_model_handlers (view); |
9605 | |
9606 | old_directory = view->details->model; |
9607 | baul_directory_ref (directory); |
9608 | view->details->model = directory; |
9609 | baul_directory_unref (old_directory); |
9610 | |
9611 | old_file = view->details->directory_as_file; |
9612 | view->details->directory_as_file = |
9613 | baul_directory_get_corresponding_file (directory); |
9614 | baul_file_unref (old_file); |
9615 | |
9616 | view->details->reported_load_error = FALSE(0); |
9617 | |
9618 | /* FIXME bugzilla.gnome.org 45062: In theory, we also need to monitor metadata here (as |
9619 | * well as doing a call when ready), in case external forces |
9620 | * change the directory's file metadata. |
9621 | */ |
9622 | attributes = |
9623 | BAUL_FILE_ATTRIBUTE_INFO | |
9624 | BAUL_FILE_ATTRIBUTE_MOUNT | |
9625 | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO; |
9626 | view->details->metadata_for_directory_as_file_pending = TRUE(!(0)); |
9627 | view->details->metadata_for_files_in_directory_pending = TRUE(!(0)); |
9628 | baul_file_call_when_ready |
9629 | (view->details->directory_as_file, |
9630 | attributes, |
9631 | metadata_for_directory_as_file_ready_callback, view); |
9632 | baul_directory_call_when_ready |
9633 | (view->details->model, |
9634 | attributes, |
9635 | FALSE(0), |
9636 | metadata_for_files_in_directory_ready_callback, view); |
9637 | |
9638 | /* If capabilities change, then we need to update the menus |
9639 | * because of New Folder, and relative emblems. |
9640 | */ |
9641 | attributes = |
9642 | BAUL_FILE_ATTRIBUTE_INFO | |
9643 | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO; |
9644 | baul_file_monitor_add (view->details->directory_as_file, |
9645 | &view->details->directory_as_file, |
9646 | attributes); |
9647 | |
9648 | view->details->file_changed_handler_id = g_signal_connectg_signal_connect_data ((view->details->directory_as_file ), ("changed"), (((GCallback) (file_changed_callback))), (view ), ((void*)0), (GConnectFlags) 0) |
9649 | (view->details->directory_as_file, "changed",g_signal_connect_data ((view->details->directory_as_file ), ("changed"), (((GCallback) (file_changed_callback))), (view ), ((void*)0), (GConnectFlags) 0) |
9650 | G_CALLBACK (file_changed_callback), view)g_signal_connect_data ((view->details->directory_as_file ), ("changed"), (((GCallback) (file_changed_callback))), (view ), ((void*)0), (GConnectFlags) 0); |
9651 | } |
9652 | |
9653 | static void |
9654 | finish_loading (FMDirectoryView *view) |
9655 | { |
9656 | BaulFileAttributes attributes; |
9657 | |
9658 | baul_window_info_report_load_underway (view->details->window, |
9659 | BAUL_VIEW (view)((((BaulView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((baul_view_get_type ()))))))); |
9660 | |
9661 | /* Tell interested parties that we've begun loading this directory now. |
9662 | * Subclasses use this to know that the new metadata is now available. |
9663 | */ |
9664 | fm_directory_view_begin_loading (view); |
9665 | |
9666 | /* Assume we have now all information to show window */ |
9667 | baul_window_info_view_visible (view->details->window, BAUL_VIEW (view)((((BaulView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((baul_view_get_type ()))))))); |
9668 | |
9669 | if (baul_directory_are_all_files_seen (view->details->model)) { |
9670 | /* Unschedule a pending update and schedule a new one with the minimal |
9671 | * update interval. This gives the view a short chance at gathering the |
9672 | * (cached) deep counts. |
9673 | */ |
9674 | unschedule_display_of_pending_files (view); |
9675 | schedule_timeout_display_of_pending_files (view, UPDATE_INTERVAL_MIN100); |
9676 | } |
9677 | |
9678 | /* Start loading. */ |
9679 | |
9680 | /* Connect handlers to learn about loading progress. */ |
9681 | view->details->done_loading_handler_id = g_signal_connectg_signal_connect_data ((view->details->model), ("done_loading" ), (((GCallback) (done_loading_callback))), (view), ((void*)0 ), (GConnectFlags) 0) |
9682 | (view->details->model, "done_loading",g_signal_connect_data ((view->details->model), ("done_loading" ), (((GCallback) (done_loading_callback))), (view), ((void*)0 ), (GConnectFlags) 0) |
9683 | G_CALLBACK (done_loading_callback), view)g_signal_connect_data ((view->details->model), ("done_loading" ), (((GCallback) (done_loading_callback))), (view), ((void*)0 ), (GConnectFlags) 0); |
9684 | view->details->load_error_handler_id = g_signal_connectg_signal_connect_data ((view->details->model), ("load_error" ), (((GCallback) (load_error_callback))), (view), ((void*)0), (GConnectFlags) 0) |
9685 | (view->details->model, "load_error",g_signal_connect_data ((view->details->model), ("load_error" ), (((GCallback) (load_error_callback))), (view), ((void*)0), (GConnectFlags) 0) |
9686 | G_CALLBACK (load_error_callback), view)g_signal_connect_data ((view->details->model), ("load_error" ), (((GCallback) (load_error_callback))), (view), ((void*)0), (GConnectFlags) 0); |
9687 | |
9688 | /* Monitor the things needed to get the right icon. Also |
9689 | * monitor a directory's item count because the "size" |
9690 | * attribute is based on that, and the file's metadata |
9691 | * and possible custom name. |
9692 | */ |
9693 | attributes = |
9694 | BAUL_FILE_ATTRIBUTES_FOR_ICON(BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_LINK_INFO | BAUL_FILE_ATTRIBUTE_THUMBNAIL ) | |
9695 | BAUL_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT | |
9696 | BAUL_FILE_ATTRIBUTE_INFO | |
9697 | BAUL_FILE_ATTRIBUTE_LINK_INFO | |
9698 | BAUL_FILE_ATTRIBUTE_MOUNT | |
9699 | BAUL_FILE_ATTRIBUTE_EXTENSION_INFO; |
9700 | |
9701 | baul_directory_file_monitor_add (view->details->model, |
9702 | &view->details->model, |
9703 | view->details->show_hidden_files, |
9704 | attributes, |
9705 | files_added_callback, view); |
9706 | |
9707 | view->details->files_added_handler_id = g_signal_connectg_signal_connect_data ((view->details->model), ("files_added" ), (((GCallback) (files_added_callback))), (view), ((void*)0) , (GConnectFlags) 0) |
9708 | (view->details->model, "files_added",g_signal_connect_data ((view->details->model), ("files_added" ), (((GCallback) (files_added_callback))), (view), ((void*)0) , (GConnectFlags) 0) |
9709 | G_CALLBACK (files_added_callback), view)g_signal_connect_data ((view->details->model), ("files_added" ), (((GCallback) (files_added_callback))), (view), ((void*)0) , (GConnectFlags) 0); |
9710 | view->details->files_changed_handler_id = g_signal_connectg_signal_connect_data ((view->details->model), ("files_changed" ), (((GCallback) (files_changed_callback))), (view), ((void*) 0), (GConnectFlags) 0) |
9711 | (view->details->model, "files_changed",g_signal_connect_data ((view->details->model), ("files_changed" ), (((GCallback) (files_changed_callback))), (view), ((void*) 0), (GConnectFlags) 0) |
9712 | G_CALLBACK (files_changed_callback), view)g_signal_connect_data ((view->details->model), ("files_changed" ), (((GCallback) (files_changed_callback))), (view), ((void*) 0), (GConnectFlags) 0); |
9713 | } |
9714 | |
9715 | static void |
9716 | finish_loading_if_all_metadata_loaded (FMDirectoryView *view) |
9717 | { |
9718 | if (!view->details->metadata_for_directory_as_file_pending && |
9719 | !view->details->metadata_for_files_in_directory_pending) { |
9720 | finish_loading (view); |
9721 | } |
9722 | } |
9723 | |
9724 | static void |
9725 | metadata_for_directory_as_file_ready_callback (BaulFile *file, |
9726 | gpointer callback_data) |
9727 | { |
9728 | FMDirectoryView *view; |
9729 | |
9730 | view = callback_data; |
9731 | |
9732 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9732, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9733 | g_assert (view->details->directory_as_file == file)do { if (view->details->directory_as_file == file) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9733, ((const char*) (__func__)), "view->details->directory_as_file == file" ); } while (0); |
9734 | g_assert (view->details->metadata_for_directory_as_file_pending)do { if (view->details->metadata_for_directory_as_file_pending ) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9734, ((const char*) (__func__)), "view->details->metadata_for_directory_as_file_pending" ); } while (0); |
9735 | |
9736 | view->details->metadata_for_directory_as_file_pending = FALSE(0); |
9737 | |
9738 | finish_loading_if_all_metadata_loaded (view); |
9739 | } |
9740 | |
9741 | static void |
9742 | metadata_for_files_in_directory_ready_callback (BaulDirectory *directory, |
9743 | GList *files G_GNUC_UNUSED__attribute__ ((__unused__)), |
9744 | gpointer callback_data) |
9745 | { |
9746 | FMDirectoryView *view; |
9747 | |
9748 | view = callback_data; |
9749 | |
9750 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9750, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9751 | g_assert (view->details->model == directory)do { if (view->details->model == directory) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 9751, ((const char*) ( __func__)), "view->details->model == directory"); } while (0); |
9752 | g_assert (view->details->metadata_for_files_in_directory_pending)do { if (view->details->metadata_for_files_in_directory_pending ) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9752, ((const char*) (__func__)), "view->details->metadata_for_files_in_directory_pending" ); } while (0); |
9753 | |
9754 | view->details->metadata_for_files_in_directory_pending = FALSE(0); |
9755 | |
9756 | finish_loading_if_all_metadata_loaded (view); |
9757 | } |
9758 | |
9759 | static void |
9760 | finish_undoredo_callback (gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
9761 | { |
9762 | } |
9763 | |
9764 | char ** |
9765 | fm_directory_view_get_emblem_names_to_exclude (FMDirectoryView *view) |
9766 | { |
9767 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
9768 | |
9769 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_emblem_names_to_exclude == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_emblem_names_to_exclude) (view)) |
9770 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_emblem_names_to_exclude == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_emblem_names_to_exclude) (view)) |
9771 | get_emblem_names_to_exclude, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_emblem_names_to_exclude == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_emblem_names_to_exclude) (view)); |
9772 | } |
9773 | |
9774 | static char ** |
9775 | real_get_emblem_names_to_exclude (FMDirectoryView *view) |
9776 | { |
9777 | char **excludes; |
9778 | int i; |
9779 | |
9780 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 9780, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
9781 | |
9782 | excludes = g_new (char *, 3)((char * *) g_malloc_n ((3), sizeof (char *))); |
9783 | |
9784 | i = 0; |
9785 | excludes[i++] = g_strdup (BAUL_FILE_EMBLEM_NAME_TRASH)g_strdup_inline ("trash"); |
9786 | |
9787 | if (!baul_file_can_write (view->details->directory_as_file)) { |
9788 | excludes[i++] = g_strdup (BAUL_FILE_EMBLEM_NAME_CANT_WRITE)g_strdup_inline ("nowrite"); |
9789 | } |
9790 | |
9791 | excludes[i++] = NULL((void*)0); |
9792 | |
9793 | return excludes; |
9794 | } |
9795 | |
9796 | /** |
9797 | * fm_directory_view_merge_menus: |
9798 | * |
9799 | * Add this view's menus to the window's menu bar. |
9800 | * @view: FMDirectoryView in question. |
9801 | */ |
9802 | static void |
9803 | fm_directory_view_merge_menus (FMDirectoryView *view) |
9804 | { |
9805 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9806 | |
9807 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> merge_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->merge_menus) (view); } } while (0) |
9808 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> merge_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->merge_menus) (view); } } while (0) |
9809 | merge_menus, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> merge_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->merge_menus) (view); } } while (0); |
9810 | } |
9811 | |
9812 | static void |
9813 | fm_directory_view_unmerge_menus (FMDirectoryView *view) |
9814 | { |
9815 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9816 | |
9817 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> unmerge_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->unmerge_menus) (view); } } while (0) |
9818 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> unmerge_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->unmerge_menus) (view); } } while (0) |
9819 | unmerge_menus, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> unmerge_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->unmerge_menus) (view); } } while (0); |
9820 | } |
9821 | |
9822 | static void |
9823 | disconnect_handler (GObject *object, guint *id) |
9824 | { |
9825 | if (*id != 0) { |
9826 | g_signal_handler_disconnect (object, *id); |
9827 | *id = 0; |
9828 | } |
9829 | } |
9830 | |
9831 | static void |
9832 | disconnect_directory_handler (FMDirectoryView *view, guint *id) |
9833 | { |
9834 | disconnect_handler (G_OBJECT (view->details->model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->details->model)), (((GType) ((20) << ( 2)))))))), id); |
9835 | } |
9836 | |
9837 | static void |
9838 | disconnect_directory_as_file_handler (FMDirectoryView *view, guint *id) |
9839 | { |
9840 | disconnect_handler (G_OBJECT (view->details->directory_as_file)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view->details->directory_as_file)), (((GType) ((20 ) << (2)))))))), id); |
9841 | } |
9842 | |
9843 | static void |
9844 | disconnect_model_handlers (FMDirectoryView *view) |
9845 | { |
9846 | if (view->details->model == NULL((void*)0)) { |
9847 | return; |
9848 | } |
9849 | disconnect_directory_handler (view, &view->details->files_added_handler_id); |
9850 | disconnect_directory_handler (view, &view->details->files_changed_handler_id); |
9851 | disconnect_directory_handler (view, &view->details->done_loading_handler_id); |
9852 | disconnect_directory_handler (view, &view->details->load_error_handler_id); |
9853 | disconnect_directory_as_file_handler (view, &view->details->file_changed_handler_id); |
9854 | baul_file_cancel_call_when_ready (view->details->directory_as_file, |
9855 | metadata_for_directory_as_file_ready_callback, |
9856 | view); |
9857 | baul_directory_cancel_callback (view->details->model, |
9858 | metadata_for_files_in_directory_ready_callback, |
9859 | view); |
9860 | baul_directory_file_monitor_remove (view->details->model, |
9861 | &view->details->model); |
9862 | baul_file_monitor_remove (view->details->directory_as_file, |
9863 | &view->details->directory_as_file); |
9864 | } |
9865 | |
9866 | /** |
9867 | * fm_directory_view_reset_to_defaults: |
9868 | * |
9869 | * set sorting order, zoom level, etc. to match defaults |
9870 | * |
9871 | **/ |
9872 | void |
9873 | fm_directory_view_reset_to_defaults (FMDirectoryView *view) |
9874 | { |
9875 | BaulWindowShowHiddenFilesMode mode; |
9876 | |
9877 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9878 | |
9879 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> reset_to_defaults != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->reset_to_defaults) (view); } } while (0) |
9880 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> reset_to_defaults != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->reset_to_defaults) (view); } } while (0) |
9881 | reset_to_defaults, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> reset_to_defaults != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->reset_to_defaults) (view); } } while (0); |
9882 | mode = baul_window_info_get_hidden_files_mode (view->details->window); |
9883 | if (mode != BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { |
9884 | baul_window_info_set_hidden_files_mode (view->details->window, |
9885 | BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT); |
9886 | } |
9887 | } |
9888 | |
9889 | /** |
9890 | * fm_directory_view_select_all: |
9891 | * |
9892 | * select all the items in the view |
9893 | * |
9894 | **/ |
9895 | void |
9896 | fm_directory_view_select_all (FMDirectoryView *view) |
9897 | { |
9898 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9899 | |
9900 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> select_all != ((void*)0)) { (* ((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->select_all) (view); } } while (0) |
9901 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> select_all != ((void*)0)) { (* ((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->select_all) (view); } } while (0) |
9902 | select_all, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> select_all != ((void*)0)) { (* ((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->select_all) (view); } } while (0); |
9903 | } |
9904 | |
9905 | /** |
9906 | * fm_directory_view_set_selection: |
9907 | * |
9908 | * set the selection to the items identified in @selection. @selection |
9909 | * should be a list of BaulFiles |
9910 | * |
9911 | **/ |
9912 | void |
9913 | fm_directory_view_set_selection (FMDirectoryView *view, GList *selection) |
9914 | { |
9915 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9916 | |
9917 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> set_selection != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->set_selection) (view, selection); } } while (0) |
9918 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> set_selection != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->set_selection) (view, selection); } } while (0) |
9919 | set_selection, (view, selection))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> set_selection != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->set_selection) (view, selection); } } while (0); |
9920 | } |
9921 | |
9922 | static void |
9923 | fm_directory_view_select_file (FMDirectoryView *view, BaulFile *file) |
9924 | { |
9925 | GList file_list; |
9926 | |
9927 | file_list.data = file; |
9928 | file_list.next = NULL((void*)0); |
9929 | file_list.prev = NULL((void*)0); |
9930 | fm_directory_view_set_selection (view, &file_list); |
9931 | } |
9932 | |
9933 | /** |
9934 | * fm_directory_view_get_selected_icon_locations: |
9935 | * |
9936 | * return an array of locations of selected icons if available |
9937 | * Return value: GArray of CdkPoints |
9938 | * |
9939 | **/ |
9940 | GArray * |
9941 | fm_directory_view_get_selected_icon_locations (FMDirectoryView *view) |
9942 | { |
9943 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
9944 | |
9945 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selected_icon_locations == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_selected_icon_locations) (view)) |
9946 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selected_icon_locations == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_selected_icon_locations) (view)) |
9947 | get_selected_icon_locations, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> get_selected_icon_locations == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->get_selected_icon_locations) (view)); |
9948 | } |
9949 | |
9950 | /** |
9951 | * fm_directory_view_reveal_selection: |
9952 | * |
9953 | * Scroll as necessary to reveal the selected items. |
9954 | **/ |
9955 | void |
9956 | fm_directory_view_reveal_selection (FMDirectoryView *view) |
9957 | { |
9958 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9959 | |
9960 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> reveal_selection != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->reveal_selection) (view); } } while (0) |
9961 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> reveal_selection != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->reveal_selection) (view); } } while (0) |
9962 | reveal_selection, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> reveal_selection != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->reveal_selection) (view); } } while (0); |
9963 | } |
9964 | |
9965 | /** |
9966 | * fm_directory_view_stop: |
9967 | * |
9968 | * Stop the current ongoing process, such as switching to a new uri. |
9969 | * @view: FMDirectoryView in question. |
9970 | * |
9971 | **/ |
9972 | void |
9973 | fm_directory_view_stop (FMDirectoryView *view) |
9974 | { |
9975 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
9976 | |
9977 | unschedule_display_of_pending_files (view); |
9978 | reset_update_interval (view); |
9979 | |
9980 | /* Free extra undisplayed files */ |
9981 | file_and_directory_list_free (view->details->new_added_files); |
9982 | view->details->new_added_files = NULL((void*)0); |
9983 | file_and_directory_list_free (view->details->new_changed_files); |
9984 | view->details->new_changed_files = NULL((void*)0); |
9985 | g_hash_table_remove_all (view->details->non_ready_files); |
9986 | file_and_directory_list_free (view->details->old_added_files); |
9987 | view->details->old_added_files = NULL((void*)0); |
9988 | file_and_directory_list_free (view->details->old_changed_files); |
9989 | view->details->old_changed_files = NULL((void*)0); |
9990 | g_list_free_full (view->details->pending_locations_selected, g_object_unref); |
9991 | view->details->pending_locations_selected = NULL((void*)0); |
9992 | |
9993 | if (view->details->model != NULL((void*)0)) { |
9994 | baul_directory_file_monitor_remove (view->details->model, view); |
9995 | } |
9996 | done_loading (view, FALSE(0)); |
9997 | } |
9998 | |
9999 | gboolean |
10000 | fm_directory_view_is_read_only (FMDirectoryView *view) |
10001 | { |
10002 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10003 | |
10004 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> is_read_only == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->is_read_only) (view)) |
10005 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> is_read_only == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->is_read_only) (view)) |
10006 | is_read_only, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> is_read_only == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->is_read_only) (view)); |
10007 | } |
10008 | |
10009 | gboolean |
10010 | fm_directory_view_is_empty (FMDirectoryView *view) |
10011 | { |
10012 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10013 | |
10014 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> is_empty == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->is_empty) (view)) |
10015 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> is_empty == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->is_empty) (view)) |
10016 | is_empty, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> is_empty == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->is_empty) (view)); |
10017 | } |
10018 | |
10019 | gboolean |
10020 | fm_directory_view_is_editable (FMDirectoryView *view) |
10021 | { |
10022 | BaulDirectory *directory; |
10023 | |
10024 | directory = fm_directory_view_get_model (view); |
10025 | |
10026 | if (directory != NULL((void*)0)) { |
10027 | return baul_directory_is_editable (directory); |
10028 | } |
10029 | |
10030 | return TRUE(!(0)); |
10031 | } |
10032 | |
10033 | void |
10034 | fm_directory_view_set_initiated_unmount (FMDirectoryView *view, |
10035 | gboolean initiated_unmount) |
10036 | { |
10037 | if (view->details->window != NULL((void*)0)) { |
10038 | baul_window_info_set_initiated_unmount(view->details->window, |
10039 | initiated_unmount); |
10040 | } |
10041 | } |
10042 | |
10043 | static gboolean |
10044 | real_is_read_only (FMDirectoryView *view) |
10045 | { |
10046 | BaulFile *file; |
10047 | |
10048 | if (!fm_directory_view_is_editable (view)) { |
10049 | return TRUE(!(0)); |
10050 | } |
10051 | |
10052 | file = fm_directory_view_get_directory_as_file (view); |
10053 | if (file != NULL((void*)0)) { |
10054 | return !baul_file_can_write (file); |
10055 | } |
10056 | return FALSE(0); |
10057 | } |
10058 | |
10059 | gboolean |
10060 | fm_directory_view_supports_creating_files (FMDirectoryView *view) |
10061 | { |
10062 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10063 | |
10064 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_creating_files == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_creating_files) (view)) |
10065 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_creating_files == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_creating_files) (view)) |
10066 | supports_creating_files, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_creating_files == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_creating_files) (view)); |
10067 | } |
10068 | |
10069 | gboolean |
10070 | fm_directory_view_accepts_dragged_files (FMDirectoryView *view) |
10071 | { |
10072 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10073 | |
10074 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> accepts_dragged_files == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->accepts_dragged_files) (view)) |
10075 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> accepts_dragged_files == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->accepts_dragged_files) (view)) |
10076 | accepts_dragged_files, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> accepts_dragged_files == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->accepts_dragged_files) (view)); |
10077 | } |
10078 | |
10079 | /** |
10080 | * fm_directory_view_should_show_file |
10081 | * |
10082 | * Returns whether or not this file should be displayed based on |
10083 | * current filtering options. |
10084 | */ |
10085 | gboolean |
10086 | fm_directory_view_should_show_file (FMDirectoryView *view, BaulFile *file) |
10087 | { |
10088 | return baul_file_should_show (file, |
10089 | view->details->show_hidden_files, |
10090 | view->details->show_foreign_files, |
10091 | view->details->show_backup_files); |
10092 | } |
10093 | |
10094 | static gboolean |
10095 | real_supports_creating_files (FMDirectoryView *view) |
10096 | { |
10097 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10098 | |
10099 | return !fm_directory_view_is_read_only (view) && !showing_trash_directory (view); |
10100 | } |
10101 | |
10102 | static gboolean |
10103 | real_accepts_dragged_files (FMDirectoryView *view) |
10104 | { |
10105 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10106 | |
10107 | return !fm_directory_view_is_read_only (view); |
10108 | } |
10109 | |
10110 | gboolean |
10111 | fm_directory_view_supports_properties (FMDirectoryView *view) |
10112 | { |
10113 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10114 | |
10115 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_properties == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_properties) (view)) |
10116 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_properties == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_properties) (view)) |
10117 | supports_properties, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_properties == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_properties) (view)); |
10118 | } |
10119 | |
10120 | static gboolean |
10121 | real_supports_properties (FMDirectoryView *view) |
10122 | { |
10123 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10124 | |
10125 | return TRUE(!(0)); |
10126 | } |
10127 | |
10128 | gboolean |
10129 | fm_directory_view_supports_zooming (FMDirectoryView *view) |
10130 | { |
10131 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10132 | |
10133 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_zooming == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_zooming) (view)) |
10134 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_zooming == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_zooming) (view)) |
10135 | supports_zooming, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> supports_zooming == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->supports_zooming) (view)); |
10136 | } |
10137 | |
10138 | static gboolean |
10139 | real_supports_zooming (FMDirectoryView *view) |
10140 | { |
10141 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10142 | |
10143 | return TRUE(!(0)); |
10144 | } |
10145 | |
10146 | gboolean |
10147 | fm_directory_view_using_manual_layout (FMDirectoryView *view) |
10148 | { |
10149 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10150 | |
10151 | return EEL_CALL_METHOD_WITH_RETURN_VALUE(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> using_manual_layout == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->using_manual_layout) (view)) |
10152 | (FM_DIRECTORY_VIEW_CLASS, view,(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> using_manual_layout == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->using_manual_layout) (view)) |
10153 | using_manual_layout, (view))(((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view) ))->g_class)))))), (fm_directory_view_get_type())))))-> using_manual_layout == ((void*)0)) ? 0 : ((* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->using_manual_layout) (view)); |
10154 | } |
10155 | |
10156 | static gboolean |
10157 | real_using_manual_layout (FMDirectoryView *view) |
10158 | { |
10159 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10160 | |
10161 | return FALSE(0); |
10162 | } |
10163 | |
10164 | /** |
10165 | * fm_directory_view_update_menus: |
10166 | * |
10167 | * Update the sensitivity and wording of dynamic menu items. |
10168 | * @view: FMDirectoryView in question. |
10169 | */ |
10170 | void |
10171 | fm_directory_view_update_menus (FMDirectoryView *view) |
10172 | { |
10173 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
10174 | |
10175 | if (!view->details->active) { |
10176 | return; |
10177 | } |
10178 | |
10179 | |
10180 | EEL_CALL_METHODdo { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> update_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->update_menus) (view); } } while (0) |
10181 | (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> update_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->update_menus) (view); } } while (0) |
10182 | update_menus, (view))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> update_menus != ((void*)0)) { (* ((((FMDirectoryViewClass*) ( void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->update_menus) (view); } } while (0); |
10183 | |
10184 | view->details->menu_states_untrustworthy = FALSE(0); |
10185 | } |
10186 | |
10187 | static void |
10188 | schedule_update_menus_callback (gpointer callback_data) |
10189 | { |
10190 | schedule_update_menus (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (fm_directory_view_get_type())))))); |
10191 | } |
10192 | |
10193 | void |
10194 | fm_directory_view_ignore_hidden_file_preferences (FMDirectoryView *view) |
10195 | { |
10196 | g_return_if_fail (view->details->model == NULL)do { if ((view->details->model == ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__ )), "view->details->model == NULL"); return; } } while ( 0); |
10197 | |
10198 | if (view->details->ignore_hidden_file_preferences) { |
10199 | return; |
10200 | } |
10201 | |
10202 | view->details->show_hidden_files = FALSE(0); |
10203 | view->details->ignore_hidden_file_preferences = TRUE(!(0)); |
10204 | } |
10205 | |
10206 | void |
10207 | fm_directory_view_set_show_foreign (FMDirectoryView *view, |
10208 | gboolean show_foreign) |
10209 | { |
10210 | view->details->show_foreign_files = show_foreign; |
10211 | } |
10212 | |
10213 | char * |
10214 | fm_directory_view_get_uri (FMDirectoryView *view) |
10215 | { |
10216 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
10217 | if (view->details->model == NULL((void*)0)) { |
10218 | return NULL((void*)0); |
10219 | } |
10220 | return baul_directory_get_uri (view->details->model); |
10221 | } |
10222 | |
10223 | /* Get the real directory where files will be stored and created */ |
10224 | char * |
10225 | fm_directory_view_get_backing_uri (FMDirectoryView *view) |
10226 | { |
10227 | BaulDirectory *directory; |
10228 | char *uri; |
10229 | |
10230 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return (((void *)0)); } } while (0); |
10231 | |
10232 | if (view->details->model == NULL((void*)0)) { |
10233 | return NULL((void*)0); |
10234 | } |
10235 | |
10236 | directory = view->details->model; |
10237 | |
10238 | if (BAUL_IS_DESKTOP_DIRECTORY (directory)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (directory)); GType __t = (baul_desktop_directory_get_type()) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) { |
10239 | directory = baul_desktop_directory_get_real_directory (BAUL_DESKTOP_DIRECTORY (directory)((((BaulDesktopDirectory*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((directory)), (baul_desktop_directory_get_type ())))))); |
10240 | } else { |
10241 | baul_directory_ref (directory); |
10242 | } |
10243 | |
10244 | uri = baul_directory_get_uri (directory); |
10245 | |
10246 | baul_directory_unref (directory); |
10247 | |
10248 | return uri; |
10249 | } |
10250 | |
10251 | void |
10252 | fm_directory_view_move_copy_items (const GList *item_uris, |
10253 | GArray *relative_item_points, |
10254 | const char *target_uri, |
10255 | int copy_action, |
10256 | int x, int y, |
10257 | FMDirectoryView *view) |
10258 | { |
10259 | BaulFile *target_file; |
10260 | |
10261 | g_assert (relative_item_points == NULLdo { if (relative_item_points == ((void*)0) || relative_item_points ->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points ->len) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10263, ((const char*) (__func__)), "relative_item_points == NULL || relative_item_points->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points->len" ); } while (0) |
10262 | || relative_item_points->len == 0do { if (relative_item_points == ((void*)0) || relative_item_points ->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points ->len) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10263, ((const char*) (__func__)), "relative_item_points == NULL || relative_item_points->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points->len" ); } while (0) |
10263 | || g_list_length ((GList *)item_uris) == relative_item_points->len)do { if (relative_item_points == ((void*)0) || relative_item_points ->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points ->len) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10263, ((const char*) (__func__)), "relative_item_points == NULL || relative_item_points->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points->len" ); } while (0); |
10264 | |
10265 | /* add the drop location to the icon offsets */ |
10266 | offset_drop_points (relative_item_points, x, y); |
10267 | |
10268 | target_file = baul_file_get_existing_by_uri (target_uri); |
10269 | /* special-case "command:" here instead of starting a move/copy */ |
10270 | if (target_file != NULL((void*)0) && baul_file_is_launcher (target_file)) { |
10271 | baul_file_unref (target_file); |
10272 | baul_launch_desktop_file ( |
10273 | ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))), |
10274 | target_uri, item_uris, |
10275 | fm_directory_view_get_containing_window (view)); |
10276 | return; |
10277 | } else if (copy_action == CDK_ACTION_COPY && |
10278 | baul_is_grapa_installed () && |
10279 | target_file != NULL((void*)0) && |
10280 | baul_file_is_archive (target_file)) { |
10281 | char *command, *quoted_uri, *tmp; |
10282 | const GList *l; |
10283 | CdkScreen *screen; |
10284 | |
10285 | /* Handle dropping onto a grapa archiver file, instead of starting a move/copy */ |
10286 | |
10287 | baul_file_unref (target_file); |
10288 | |
10289 | quoted_uri = g_shell_quote (target_uri); |
10290 | command = g_strconcat ("grapa -a ", quoted_uri, NULL((void*)0)); |
10291 | g_free (quoted_uri); |
10292 | |
10293 | for (l = item_uris; l != NULL((void*)0); l = l->next) { |
10294 | quoted_uri = g_shell_quote ((char *) l->data); |
10295 | |
10296 | tmp = g_strconcat (command, " ", quoted_uri, NULL((void*)0)); |
10297 | g_free (command); |
10298 | command = tmp; |
10299 | |
10300 | g_free (quoted_uri); |
10301 | } |
10302 | |
10303 | screen = ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
10304 | if (screen == NULL((void*)0)) { |
10305 | screen = cdk_screen_get_default (); |
10306 | } |
10307 | |
10308 | cafe_cdk_spawn_command_line_on_screen(screen, command, NULL((void*)0)); |
10309 | g_free (command); |
10310 | |
10311 | return; |
10312 | } |
10313 | baul_file_unref (target_file); |
10314 | |
10315 | baul_file_operations_copy_move |
10316 | (item_uris, relative_item_points, |
10317 | target_uri, copy_action, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), |
10318 | copy_move_done_callback, pre_copy_move (view)); |
10319 | } |
10320 | |
10321 | gboolean |
10322 | fm_directory_view_can_accept_item (BaulFile *target_item, |
10323 | const char *item_uri, |
10324 | FMDirectoryView *view) |
10325 | { |
10326 | g_return_val_if_fail (BAUL_IS_FILE (target_item), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((target_item)); GType __t = (baul_file_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "BAUL_IS_FILE (target_item)"); return ((0)); } } while (0); |
10327 | g_return_val_if_fail (item_uri != NULL, FALSE)do { if ((item_uri != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "item_uri != NULL" ); return ((0)); } } while (0); |
10328 | g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return ((0)); } } while (0); |
10329 | |
10330 | return baul_drag_can_accept_item (target_item, item_uri); |
10331 | } |
10332 | |
10333 | static void |
10334 | fm_directory_view_trash_state_changed_callback (BaulTrashMonitor *trash_monitor G_GNUC_UNUSED__attribute__ ((__unused__)), |
10335 | gboolean state G_GNUC_UNUSED__attribute__ ((__unused__)), |
10336 | gpointer callback_data) |
10337 | { |
10338 | FMDirectoryView *view; |
10339 | |
10340 | view = (FMDirectoryView *) callback_data; |
10341 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10341, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
10342 | |
10343 | schedule_update_menus (view); |
10344 | } |
10345 | |
10346 | void |
10347 | fm_directory_view_start_batching_selection_changes (FMDirectoryView *view) |
10348 | { |
10349 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
10350 | |
10351 | ++view->details->batching_selection_level; |
10352 | view->details->selection_changed_while_batched = FALSE(0); |
10353 | } |
10354 | |
10355 | void |
10356 | fm_directory_view_stop_batching_selection_changes (FMDirectoryView *view) |
10357 | { |
10358 | g_return_if_fail (FM_IS_DIRECTORY_VIEW (view))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char* ) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"); return; } } while (0); |
10359 | g_return_if_fail (view->details->batching_selection_level > 0)do { if ((view->details->batching_selection_level > 0 )) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "view->details->batching_selection_level > 0" ); return; } } while (0); |
10360 | |
10361 | if (--view->details->batching_selection_level == 0) { |
10362 | if (view->details->selection_changed_while_batched) { |
10363 | fm_directory_view_notify_selection_changed (view); |
10364 | } |
10365 | } |
10366 | } |
10367 | |
10368 | static void |
10369 | revert_slashes (char *string) |
10370 | { |
10371 | while (*string != 0) { |
10372 | if (*string == '/') { |
10373 | *string = '\\'; |
10374 | } |
10375 | string++; |
10376 | } |
10377 | } |
10378 | |
10379 | |
10380 | static CdkDragAction |
10381 | ask_link_action (FMDirectoryView *view) |
10382 | { |
10383 | int button_pressed; |
10384 | CdkDragAction result; |
10385 | CtkWindow *parent_window; |
10386 | CtkWidget *dialog; |
10387 | |
10388 | parent_window = NULL((void*)0); |
10389 | |
10390 | /* Don't use desktop window as parent, since that means |
10391 | we show up an all desktops etc */ |
10392 | if (! FM_IS_DESKTOP_ICON_VIEW (view)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (view)); GType __t = (fm_desktop_icon_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) { |
10393 | parent_window = CTK_WINDOW (fm_directory_view_get_containing_window (view))((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((fm_directory_view_get_containing_window (view))), ((ctk_window_get_type ())))))); |
10394 | } |
10395 | |
10396 | dialog = ctk_message_dialog_new (parent_window, |
10397 | CTK_DIALOG_DESTROY_WITH_PARENT, |
10398 | CTK_MESSAGE_QUESTION, |
10399 | CTK_BUTTONS_NONE, |
10400 | _("Download location?")gettext ("Download location?")); |
10401 | |
10402 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ()) ))))), |
10403 | _("You can download it or make a link to it.")gettext ("You can download it or make a link to it.")); |
10404 | |
10405 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
10406 | _("Make a _Link")gettext ("Make a _Link"), 0); |
10407 | |
10408 | eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
10409 | _("_Cancel")gettext ("_Cancel"), |
10410 | "process-stop", 1); |
10411 | |
10412 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
10413 | _("_Download")gettext ("_Download"), 2); |
10414 | |
10415 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), ""); /* as per HIG */ |
10416 | ctk_window_set_focus_on_map (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); |
10417 | ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), 2); |
10418 | |
10419 | ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ()))))))); |
10420 | |
10421 | button_pressed = ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))); |
10422 | |
10423 | ctk_widget_destroy (dialog); |
10424 | |
10425 | switch (button_pressed) { |
10426 | case 0: |
10427 | result = CDK_ACTION_LINK; |
10428 | break; |
10429 | case 1: |
10430 | case CTK_RESPONSE_DELETE_EVENT: |
10431 | result = 0; |
10432 | break; |
10433 | case 2: |
10434 | result = CDK_ACTION_COPY; |
10435 | break; |
10436 | default: |
10437 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10437, ((const char*) (__func__)), ((void*)0)); } while (0); |
10438 | result = 0; |
10439 | } |
10440 | |
10441 | return result; |
10442 | } |
10443 | |
10444 | typedef struct { |
10445 | FMDirectoryView *view; |
10446 | GCancellable *cancellable; |
10447 | char *encoded_url; |
10448 | char *target_uri; |
10449 | int x; |
10450 | int y; |
10451 | guint timeout; |
10452 | } NetscapeUrlDropAsk; |
10453 | |
10454 | static void |
10455 | handle_netscape_url_drop_ask_cb (GObject *source_object, |
10456 | GAsyncResult *res, |
10457 | gpointer user_data) |
10458 | { |
10459 | NetscapeUrlDropAsk *data; |
10460 | CdkDragAction action; |
10461 | GFileInfo *info; |
10462 | GFile *f; |
10463 | const char *mime_type; |
10464 | |
10465 | data = user_data; |
10466 | f = G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))); |
10467 | |
10468 | info = g_file_query_info_finish (f, res, NULL((void*)0)); |
10469 | mime_type = NULL((void*)0); |
10470 | |
10471 | if (info) { |
10472 | mime_type = g_file_info_get_content_type (info); |
10473 | } |
10474 | |
10475 | if (mime_type != NULL((void*)0) && |
10476 | (g_content_type_equals (mime_type, "text/html") || |
10477 | g_content_type_equals (mime_type, "text/xml") || |
10478 | g_content_type_equals (mime_type, "application/xhtml+xml"))) { |
10479 | action = CDK_ACTION_LINK; |
10480 | } else if (mime_type != NULL((void*)0) && |
10481 | g_content_type_equals (mime_type, "text/plain")) { |
10482 | action = ask_link_action (data->view); |
10483 | } else { |
10484 | action = CDK_ACTION_COPY; |
10485 | } |
10486 | if (info) { |
10487 | g_object_unref (info); |
10488 | } |
10489 | |
10490 | if (action != 0) { |
10491 | fm_directory_view_handle_netscape_url_drop (data->view, |
10492 | data->encoded_url, |
10493 | data->target_uri, |
10494 | action, |
10495 | data->x, data->y); |
10496 | } |
10497 | |
10498 | g_object_unref (data->view); |
10499 | g_object_unref (data->cancellable); |
10500 | if (data->timeout != 0) { |
10501 | g_source_remove (data->timeout); |
10502 | } |
10503 | g_free (data->encoded_url); |
10504 | g_free (data->target_uri); |
10505 | g_free (data); |
10506 | } |
10507 | |
10508 | static gboolean |
10509 | handle_netscape_url_drop_timeout (gpointer user_data) |
10510 | { |
10511 | NetscapeUrlDropAsk *data; |
10512 | |
10513 | data = user_data; |
10514 | |
10515 | g_cancellable_cancel (data->cancellable); |
10516 | data->timeout = 0; |
10517 | |
10518 | return FALSE(0); |
10519 | } |
10520 | |
10521 | static inline void |
10522 | fm_directory_view_widget_to_file_operation_position (FMDirectoryView *view, |
10523 | CdkPoint *position) |
10524 | { |
10525 | EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, view,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> widget_to_file_operation_position != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->widget_to_file_operation_position) (view, position ); } } while (0) |
10526 | widget_to_file_operation_position,do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> widget_to_file_operation_position != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->widget_to_file_operation_position) (view, position ); } } while (0) |
10527 | (view, position))do { if (((((FMDirectoryViewClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass*) (((GTypeInstance*) ((view )))->g_class)))))), (fm_directory_view_get_type())))))-> widget_to_file_operation_position != ((void*)0)) { (* ((((FMDirectoryViewClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((((((GObjectClass *) (((GTypeInstance*) ((view)))->g_class)))))), (fm_directory_view_get_type ())))))->widget_to_file_operation_position) (view, position ); } } while (0); |
10528 | } |
10529 | |
10530 | static void |
10531 | fm_directory_view_widget_to_file_operation_position_xy (FMDirectoryView *view, |
10532 | int *x, int *y) |
10533 | { |
10534 | CdkPoint position; |
10535 | |
10536 | position.x = *x; |
10537 | position.y = *y; |
10538 | fm_directory_view_widget_to_file_operation_position (view, &position); |
10539 | *x = position.x; |
10540 | *y = position.y; |
10541 | } |
10542 | |
10543 | void |
10544 | fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view, |
10545 | const char *encoded_url, |
10546 | const char *target_uri, |
10547 | CdkDragAction action, |
10548 | int x, |
10549 | int y) |
10550 | { |
10551 | CdkPoint point; |
10552 | char *url, *title; |
10553 | char *container_uri; |
10554 | char **bits; |
10555 | GList *uri_list = NULL((void*)0); |
10556 | GFile *f; |
10557 | |
10558 | if (encoded_url == NULL((void*)0)) { |
10559 | return; |
10560 | } |
10561 | |
10562 | container_uri = NULL((void*)0); |
10563 | if (target_uri == NULL((void*)0)) { |
10564 | container_uri = fm_directory_view_get_backing_uri (view); |
10565 | g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 10565, ((const char*) ( __func__)), "container_uri != NULL"); } while (0); |
10566 | } |
10567 | |
10568 | f = g_file_new_for_uri (target_uri != NULL((void*)0) ? target_uri : container_uri); |
10569 | if (!g_file_is_native (f)) { |
10570 | eel_show_warning_dialog (_("Drag and drop is not supported.")gettext ("Drag and drop is not supported."), |
10571 | _("Drag and drop is only supported on local file systems.")gettext ("Drag and drop is only supported on local file systems." ), |
10572 | fm_directory_view_get_containing_window (view)); |
10573 | g_object_unref (f); |
10574 | g_free (container_uri); |
10575 | return; |
10576 | } |
10577 | g_object_unref (f); |
10578 | |
10579 | /* _NETSCAPE_URL_ works like this: $URL\n$TITLE */ |
10580 | bits = g_strsplit (encoded_url, "\n", 0); |
10581 | switch (g_strv_length (bits)) { |
10582 | case 0: |
10583 | g_strfreev (bits); |
10584 | g_free (container_uri); |
10585 | return; |
10586 | case 1: |
10587 | url = bits[0]; |
10588 | title = NULL((void*)0); |
10589 | break; |
10590 | default: |
10591 | url = bits[0]; |
10592 | title = bits[1]; |
10593 | } |
10594 | |
10595 | if (action == CDK_ACTION_ASK) { |
10596 | NetscapeUrlDropAsk *data; |
10597 | |
10598 | f = g_file_new_for_uri (url); |
10599 | data = g_new0 (NetscapeUrlDropAsk, 1)((NetscapeUrlDropAsk *) g_malloc0_n ((1), sizeof (NetscapeUrlDropAsk ))); |
10600 | data->view = g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)); |
10601 | data->cancellable = g_cancellable_new (); |
10602 | data->encoded_url = g_strdup (encoded_url)g_strdup_inline (encoded_url); |
10603 | data->target_uri = g_strdup (target_uri)g_strdup_inline (target_uri); |
10604 | data->x = x; |
10605 | data->y = y; |
10606 | /* Ensure we wait at most 1 second for mimetype */ |
10607 | data->timeout = g_timeout_add (1000, |
10608 | handle_netscape_url_drop_timeout, |
10609 | data); |
10610 | g_file_query_info_async (f, |
10611 | G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type", 0, |
10612 | 0, data->cancellable, |
10613 | handle_netscape_url_drop_ask_cb, |
10614 | data); |
10615 | |
10616 | g_strfreev (bits); |
10617 | g_free (container_uri); |
10618 | return; |
10619 | } |
10620 | |
10621 | fm_directory_view_widget_to_file_operation_position_xy (view, &x, &y); |
10622 | |
10623 | /* We don't support CDK_ACTION_ASK or CDK_ACTION_PRIVATE |
10624 | * and we don't support combinations either. */ |
10625 | if ((action != CDK_ACTION_DEFAULT) && |
10626 | (action != CDK_ACTION_COPY) && |
10627 | (action != CDK_ACTION_MOVE) && |
10628 | (action != CDK_ACTION_LINK)) { |
10629 | eel_show_warning_dialog (_("Drag and drop is not supported.")gettext ("Drag and drop is not supported."), |
10630 | _("An invalid drag type was used.")gettext ("An invalid drag type was used."), |
10631 | fm_directory_view_get_containing_window (view)); |
10632 | g_strfreev (bits); |
10633 | g_free (container_uri); |
10634 | return; |
10635 | } |
10636 | |
10637 | if (action == CDK_ACTION_LINK) { |
10638 | char *link_name; |
10639 | |
10640 | if (eel_str_is_empty (title)) { |
10641 | GFile *f; |
10642 | |
10643 | f = g_file_new_for_uri (url); |
10644 | link_name = g_file_get_basename (f); |
10645 | g_object_unref (f); |
10646 | } else { |
10647 | link_name = g_strdup (title)g_strdup_inline (title); |
10648 | } |
10649 | |
10650 | if (!eel_str_is_empty (link_name)) { |
10651 | CdkScreen *screen; |
10652 | int screen_num; |
10653 | char *link_display_name; |
10654 | |
10655 | link_display_name = g_strdup_printf (_("Link to %s")gettext ("Link to %s"), link_name); |
10656 | |
10657 | /* The filename can't contain slashes, strip em. |
10658 | (the basename of http://foo/ is http://foo/) */ |
10659 | revert_slashes (link_name); |
10660 | |
10661 | point.x = x; |
10662 | point.y = y; |
10663 | |
10664 | screen = ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ()))))))); |
10665 | screen_num = cdk_x11_screen_get_screen_number (screen); |
10666 | |
10667 | baul_link_local_create (target_uri != NULL((void*)0) ? target_uri : container_uri, |
10668 | link_name, |
10669 | link_display_name, |
10670 | "cafe-fs-bookmark", |
10671 | url, |
10672 | &point, |
10673 | screen_num, |
10674 | TRUE(!(0))); |
10675 | |
10676 | g_free (link_display_name); |
10677 | } |
10678 | g_free (link_name); |
10679 | } else { |
10680 | GArray *points; |
10681 | |
10682 | CdkPoint tmp_point = { 0, 0 }; |
10683 | |
10684 | /* pass in a 1-item array of icon positions, relative to x, y */ |
10685 | points = g_array_new (FALSE(0), TRUE(!(0)), sizeof (CdkPoint)); |
10686 | g_array_append_val (points, tmp_point)g_array_append_vals (points, &(tmp_point), 1); |
10687 | |
10688 | uri_list = g_list_append (uri_list, url); |
10689 | |
10690 | fm_directory_view_move_copy_items (uri_list, points, |
10691 | target_uri != NULL((void*)0) ? target_uri : container_uri, |
10692 | action, x, y, view); |
10693 | |
10694 | g_list_free (uri_list); |
10695 | g_array_free (points, TRUE(!(0))); |
10696 | } |
10697 | |
10698 | g_strfreev (bits); |
10699 | g_free (container_uri); |
10700 | } |
10701 | |
10702 | void |
10703 | fm_directory_view_handle_uri_list_drop (FMDirectoryView *view, |
10704 | const char *item_uris, |
10705 | const char *target_uri, |
10706 | CdkDragAction action, |
10707 | int x, |
10708 | int y) |
10709 | { |
10710 | gchar **uri_list; |
10711 | GList *real_uri_list = NULL((void*)0); |
10712 | char *container_uri; |
10713 | int n_uris, i; |
10714 | GArray *points; |
10715 | |
10716 | if (item_uris == NULL((void*)0)) { |
10717 | return; |
10718 | } |
10719 | |
10720 | container_uri = NULL((void*)0); |
10721 | if (target_uri == NULL((void*)0)) { |
10722 | container_uri = fm_directory_view_get_backing_uri (view); |
10723 | g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 10723, ((const char*) ( __func__)), "container_uri != NULL"); } while (0); |
10724 | } |
10725 | |
10726 | if (action == CDK_ACTION_ASK) { |
10727 | action = baul_drag_drop_action_ask |
10728 | (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((view)), ((ctk_widget_get_type ())))))), |
10729 | CDK_ACTION_MOVE | CDK_ACTION_COPY | CDK_ACTION_LINK); |
10730 | if (action == 0) { |
10731 | g_free (container_uri); |
10732 | return; |
10733 | } |
10734 | } |
10735 | |
10736 | /* We don't support CDK_ACTION_ASK or CDK_ACTION_PRIVATE |
10737 | * and we don't support combinations either. */ |
10738 | if ((action != CDK_ACTION_DEFAULT) && |
10739 | (action != CDK_ACTION_COPY) && |
10740 | (action != CDK_ACTION_MOVE) && |
10741 | (action != CDK_ACTION_LINK)) { |
10742 | eel_show_warning_dialog (_("Drag and drop is not supported.")gettext ("Drag and drop is not supported."), |
10743 | _("An invalid drag type was used.")gettext ("An invalid drag type was used."), |
10744 | fm_directory_view_get_containing_window (view)); |
10745 | g_free (container_uri); |
10746 | return; |
10747 | } |
10748 | |
10749 | n_uris = 0; |
10750 | uri_list = g_uri_list_extract_uris (item_uris); |
10751 | for (i = 0; uri_list[i] != NULL((void*)0); i++) { |
10752 | real_uri_list = g_list_append (real_uri_list, uri_list[i]); |
10753 | n_uris++; |
10754 | } |
10755 | g_free (uri_list); |
10756 | |
10757 | /* do nothing if no real uris are left */ |
10758 | if (n_uris == 0) { |
10759 | g_free (container_uri); |
10760 | return; |
10761 | } |
10762 | |
10763 | if (n_uris == 1) { |
10764 | CdkPoint tmp_point = { 0, 0 }; |
10765 | |
10766 | /* pass in a 1-item array of icon positions, relative to x, y */ |
10767 | points = g_array_new (FALSE(0), TRUE(!(0)), sizeof (CdkPoint)); |
10768 | g_array_append_val (points, tmp_point)g_array_append_vals (points, &(tmp_point), 1); |
10769 | } else { |
10770 | points = NULL((void*)0); |
10771 | } |
10772 | |
10773 | fm_directory_view_widget_to_file_operation_position_xy (view, &x, &y); |
10774 | |
10775 | fm_directory_view_move_copy_items (real_uri_list, points, |
10776 | target_uri != NULL((void*)0) ? target_uri : container_uri, |
10777 | action, x, y, view); |
10778 | |
10779 | g_list_free_full (real_uri_list, g_free); |
10780 | |
10781 | if (points != NULL((void*)0)) |
10782 | g_array_free (points, TRUE(!(0))); |
10783 | |
10784 | g_free (container_uri); |
10785 | } |
10786 | |
10787 | void |
10788 | fm_directory_view_handle_text_drop (FMDirectoryView *view, |
10789 | const char *text, |
10790 | const char *target_uri, |
10791 | CdkDragAction action, |
10792 | int x, |
10793 | int y) |
10794 | { |
10795 | int length; |
10796 | char *container_uri; |
10797 | CdkPoint pos; |
10798 | |
10799 | if (text == NULL((void*)0)) { |
10800 | return; |
10801 | } |
10802 | |
10803 | g_return_if_fail (action == CDK_ACTION_COPY)do { if ((action == CDK_ACTION_COPY)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "action == CDK_ACTION_COPY" ); return; } } while (0); |
10804 | |
10805 | container_uri = NULL((void*)0); |
10806 | if (target_uri == NULL((void*)0)) { |
10807 | container_uri = fm_directory_view_get_backing_uri (view); |
10808 | g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 10808, ((const char*) ( __func__)), "container_uri != NULL"); } while (0); |
10809 | } |
10810 | |
10811 | length = strlen (text); |
10812 | |
10813 | pos.x = x; |
10814 | pos.y = y; |
10815 | fm_directory_view_widget_to_file_operation_position (view, &pos); |
10816 | |
10817 | fm_directory_view_new_file_with_initial_contents ( |
10818 | view, target_uri != NULL((void*)0) ? target_uri : container_uri, |
10819 | /* Translators: This is the filename used for when you dnd text to a directory */ |
10820 | _("dropped text.txt")gettext ("dropped text.txt"), |
10821 | text, length, &pos); |
10822 | |
10823 | g_free (container_uri); |
10824 | } |
10825 | |
10826 | void |
10827 | fm_directory_view_handle_raw_drop (FMDirectoryView *view, |
10828 | const char *raw_data, |
10829 | int length, |
10830 | const char *target_uri, |
10831 | const char *direct_save_uri, |
10832 | CdkDragAction action, |
10833 | int x, |
10834 | int y) |
10835 | { |
10836 | char *container_uri, *filename; |
10837 | CdkPoint pos; |
10838 | |
10839 | if (raw_data == NULL((void*)0)) { |
10840 | return; |
10841 | } |
10842 | |
10843 | g_return_if_fail (action == CDK_ACTION_COPY)do { if ((action == CDK_ACTION_COPY)) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "action == CDK_ACTION_COPY" ); return; } } while (0); |
10844 | |
10845 | container_uri = NULL((void*)0); |
10846 | if (target_uri == NULL((void*)0)) { |
10847 | container_uri = fm_directory_view_get_backing_uri (view); |
10848 | g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 10848, ((const char*) ( __func__)), "container_uri != NULL"); } while (0); |
10849 | } |
10850 | |
10851 | pos.x = x; |
10852 | pos.y = y; |
10853 | fm_directory_view_widget_to_file_operation_position (view, &pos); |
10854 | |
10855 | filename = NULL((void*)0); |
10856 | if (direct_save_uri != NULL((void*)0)) { |
10857 | GFile *direct_save_full; |
10858 | |
10859 | direct_save_full = g_file_new_for_uri (direct_save_uri); |
10860 | filename = g_file_get_basename (direct_save_full); |
10861 | } |
10862 | if (filename == NULL((void*)0)) { |
10863 | /* Translators: This is the filename used for when you dnd raw |
10864 | * data to a directory, if the source didn't supply a name. |
10865 | */ |
10866 | filename = _("dropped data")gettext ("dropped data"); |
10867 | } |
10868 | |
10869 | fm_directory_view_new_file_with_initial_contents ( |
10870 | view, target_uri != NULL((void*)0) ? target_uri : container_uri, |
10871 | filename, raw_data, length, &pos); |
10872 | |
10873 | g_free (container_uri); |
10874 | } |
10875 | |
10876 | gboolean |
10877 | fm_directory_view_get_active (FMDirectoryView *view) |
10878 | { |
10879 | g_assert (FM_IS_DIRECTORY_VIEW (view))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((view)); GType __t = (fm_directory_view_get_type()); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10879, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)" ); } while (0); |
10880 | return view->details->active; |
10881 | } |
10882 | |
10883 | static GArray * |
10884 | real_get_selected_icon_locations (FMDirectoryView *view G_GNUC_UNUSED__attribute__ ((__unused__))) |
10885 | { |
10886 | /* By default, just return an empty list. */ |
10887 | return g_array_new (FALSE(0), TRUE(!(0)), sizeof (CdkPoint)); |
10888 | } |
10889 | |
10890 | static void |
10891 | fm_directory_view_set_property (GObject *object, |
10892 | guint prop_id, |
10893 | const GValue *value, |
10894 | GParamSpec *pspec) |
10895 | { |
10896 | FMDirectoryView *directory_view; |
10897 | BaulWindowSlotInfo *slot; |
10898 | BaulWindowInfo *window; |
10899 | |
10900 | directory_view = FM_DIRECTORY_VIEW (object)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), (fm_directory_view_get_type()))))); |
10901 | |
10902 | switch (prop_id) { |
10903 | case PROP_WINDOW_SLOT: |
10904 | g_assert (directory_view->details->slot == NULL)do { if (directory_view->details->slot == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10904, ((const char*) (__func__)), "directory_view->details->slot == NULL" ); } while (0); |
10905 | |
10906 | slot = BAUL_WINDOW_SLOT_INFO (g_value_get_object (value))((((BaulWindowSlotInfo*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((g_value_get_object (value))), ((baul_window_slot_info_get_type ())))))); |
10907 | window = baul_window_slot_info_get_window (slot); |
10908 | |
10909 | directory_view->details->slot = slot; |
10910 | directory_view->details->window = window; |
10911 | |
10912 | g_signal_connect_object (directory_view->details->slot, |
10913 | "active", G_CALLBACK (slot_active)((GCallback) (slot_active)), |
10914 | directory_view, 0); |
10915 | g_signal_connect_object (directory_view->details->slot, |
10916 | "inactive", G_CALLBACK (slot_inactive)((GCallback) (slot_inactive)), |
10917 | directory_view, 0); |
10918 | |
10919 | g_signal_connect_object (directory_view->details->window, |
10920 | "hidden-files-mode-changed", G_CALLBACK (hidden_files_mode_changed)((GCallback) (hidden_files_mode_changed)), |
10921 | directory_view, 0); |
10922 | fm_directory_view_init_show_hidden_files (directory_view); |
10923 | |
10924 | g_signal_connect_object (directory_view->details->window, |
10925 | "backup-files-mode-changed", G_CALLBACK (backup_files_mode_changed)((GCallback) (backup_files_mode_changed)), |
10926 | directory_view, 0); |
10927 | fm_directory_view_init_show_backup_files (directory_view); |
10928 | |
10929 | break; |
10930 | default: |
10931 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "fm-directory-view.c", 10931, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
10932 | break; |
10933 | } |
10934 | } |
10935 | |
10936 | |
10937 | gboolean |
10938 | fm_directory_view_handle_scroll_event (FMDirectoryView *directory_view, |
10939 | CdkEventScroll *event) |
10940 | { |
10941 | static gdouble total_delta_y = 0; |
10942 | gdouble delta_x, delta_y; |
10943 | |
10944 | if (event->state & CDK_CONTROL_MASK) { |
10945 | switch (event->direction) { |
10946 | case CDK_SCROLL_UP: |
10947 | /* Zoom In */ |
10948 | fm_directory_view_bump_zoom_level (directory_view, 1); |
10949 | return TRUE(!(0)); |
10950 | |
10951 | case CDK_SCROLL_DOWN: |
10952 | /* Zoom Out */ |
10953 | fm_directory_view_bump_zoom_level (directory_view, -1); |
10954 | return TRUE(!(0)); |
10955 | |
10956 | case CDK_SCROLL_SMOOTH: |
10957 | cdk_event_get_scroll_deltas ((const CdkEvent *) event, |
10958 | &delta_x, &delta_y); |
10959 | |
10960 | /* try to emulate a normal scrolling event by summing deltas */ |
10961 | total_delta_y += delta_y; |
10962 | |
10963 | if (total_delta_y >= 1) { |
10964 | total_delta_y = 0; |
10965 | /* emulate scroll down */ |
10966 | fm_directory_view_bump_zoom_level (directory_view, -1); |
10967 | return TRUE(!(0)); |
10968 | } else if (total_delta_y <= - 1) { |
10969 | total_delta_y = 0; |
10970 | /* emulate scroll up */ |
10971 | fm_directory_view_bump_zoom_level (directory_view, 1); |
10972 | return TRUE(!(0)); |
10973 | } else { |
10974 | /* eat event */ |
10975 | return TRUE(!(0)); |
10976 | } |
10977 | |
10978 | case CDK_SCROLL_LEFT: |
10979 | case CDK_SCROLL_RIGHT: |
10980 | break; |
10981 | |
10982 | default: |
10983 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 10983, ((const char*) (__func__)), ((void*)0)); } while (0); |
10984 | } |
10985 | } |
10986 | |
10987 | return FALSE(0); |
10988 | } |
10989 | |
10990 | /* handle Shift+Scroll, which will cause a zoom-in/out */ |
10991 | static gboolean |
10992 | fm_directory_view_scroll_event (CtkWidget *widget, |
10993 | CdkEventScroll *event) |
10994 | { |
10995 | FMDirectoryView *directory_view; |
10996 | |
10997 | directory_view = FM_DIRECTORY_VIEW (widget)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), (fm_directory_view_get_type()))))); |
10998 | if (fm_directory_view_handle_scroll_event (directory_view, event)) { |
10999 | return TRUE(!(0)); |
11000 | } |
11001 | |
11002 | return CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((parent_class)), ((ctk_widget_get_type ()))))))->scroll_event (widget, event); |
11003 | } |
11004 | |
11005 | |
11006 | static void |
11007 | fm_directory_view_parent_set (CtkWidget *widget, |
11008 | CtkWidget *old_parent) |
11009 | { |
11010 | FMDirectoryView *view; |
11011 | CtkWidget *parent; |
11012 | |
11013 | view = FM_DIRECTORY_VIEW (widget)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), (fm_directory_view_get_type()))))); |
11014 | |
11015 | parent = ctk_widget_get_parent (widget); |
11016 | g_assert (parent == NULL || old_parent == NULL)do { if (parent == ((void*)0) || old_parent == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c" , 11016, ((const char*) (__func__)), "parent == NULL || old_parent == NULL" ); } while (0); |
11017 | |
11018 | if (CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((parent_class)), ((ctk_widget_get_type ()))))))->parent_set != NULL((void*)0)) { |
11019 | CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((parent_class)), ((ctk_widget_get_type ()))))))->parent_set (widget, old_parent); |
11020 | } |
11021 | |
11022 | if (parent != NULL((void*)0)) { |
11023 | g_assert (old_parent == NULL)do { if (old_parent == ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c", 11023, ((const char*) ( __func__)), "old_parent == NULL"); } while (0); |
11024 | |
11025 | if (view->details->slot == |
11026 | baul_window_info_get_active_slot (view->details->window)) { |
11027 | view->details->active = TRUE(!(0)); |
11028 | |
11029 | fm_directory_view_merge_menus (view); |
11030 | schedule_update_menus (view); |
11031 | } |
11032 | } else { |
11033 | fm_directory_view_unmerge_menus (view); |
11034 | remove_update_menus_timeout_callback (view); |
11035 | } |
11036 | } |
11037 | |
11038 | static void |
11039 | fm_directory_view_class_init (FMDirectoryViewClass *klass) |
11040 | { |
11041 | CtkWidgetClass *widget_class; |
11042 | CtkScrolledWindowClass *scrolled_window_class; |
11043 | CtkBindingSet *binding_set; |
11044 | |
11045 | widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_widget_get_type ())))))); |
11046 | scrolled_window_class = CTK_SCROLLED_WINDOW_CLASS (klass)((((CtkScrolledWindowClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((klass)), ((ctk_scrolled_window_get_type ()) ))))); |
11047 | |
11048 | G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2))))))))->set_property = fm_directory_view_set_property; |
11049 | G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2))))))))->finalize = fm_directory_view_finalize; |
11050 | |
11051 | widget_class->destroy = fm_directory_view_destroy; |
11052 | |
11053 | widget_class->scroll_event = fm_directory_view_scroll_event; |
11054 | widget_class->parent_set = fm_directory_view_parent_set; |
11055 | |
11056 | /* Get rid of the strange 3-pixel gap that CtkScrolledWindow |
11057 | * uses by default. It does us no good. |
11058 | */ |
11059 | scrolled_window_class->scrollbar_spacing = 0; |
11060 | |
11061 | signals[ADD_FILE] = |
11062 | g_signal_new ("add_file", |
11063 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11064 | G_SIGNAL_RUN_LAST, |
11065 | G_STRUCT_OFFSET (FMDirectoryViewClass, add_file)((glong) __builtin_offsetof(FMDirectoryViewClass, add_file)), |
11066 | NULL((void*)0), NULL((void*)0), |
11067 | fm_marshal_VOID__OBJECT_OBJECT, |
11068 | G_TYPE_NONE((GType) ((1) << (2))), 2, BAUL_TYPE_FILEbaul_file_get_type(), BAUL_TYPE_DIRECTORYbaul_directory_get_type()); |
11069 | signals[BEGIN_FILE_CHANGES] = |
11070 | g_signal_new ("begin_file_changes", |
11071 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11072 | G_SIGNAL_RUN_LAST, |
11073 | G_STRUCT_OFFSET (FMDirectoryViewClass, begin_file_changes)((glong) __builtin_offsetof(FMDirectoryViewClass, begin_file_changes )), |
11074 | NULL((void*)0), NULL((void*)0), |
11075 | g_cclosure_marshal_VOID__VOID, |
11076 | G_TYPE_NONE((GType) ((1) << (2))), 0); |
11077 | signals[BEGIN_LOADING] = |
11078 | g_signal_new ("begin_loading", |
11079 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11080 | G_SIGNAL_RUN_LAST, |
11081 | G_STRUCT_OFFSET (FMDirectoryViewClass, begin_loading)((glong) __builtin_offsetof(FMDirectoryViewClass, begin_loading )), |
11082 | NULL((void*)0), NULL((void*)0), |
11083 | g_cclosure_marshal_VOID__VOID, |
11084 | G_TYPE_NONE((GType) ((1) << (2))), 0); |
11085 | signals[CLEAR] = |
11086 | g_signal_new ("clear", |
11087 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11088 | G_SIGNAL_RUN_LAST, |
11089 | G_STRUCT_OFFSET (FMDirectoryViewClass, clear)((glong) __builtin_offsetof(FMDirectoryViewClass, clear)), |
11090 | NULL((void*)0), NULL((void*)0), |
11091 | g_cclosure_marshal_VOID__VOID, |
11092 | G_TYPE_NONE((GType) ((1) << (2))), 0); |
11093 | signals[END_FILE_CHANGES] = |
11094 | g_signal_new ("end_file_changes", |
11095 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11096 | G_SIGNAL_RUN_LAST, |
11097 | G_STRUCT_OFFSET (FMDirectoryViewClass, end_file_changes)((glong) __builtin_offsetof(FMDirectoryViewClass, end_file_changes )), |
11098 | NULL((void*)0), NULL((void*)0), |
11099 | g_cclosure_marshal_VOID__VOID, |
11100 | G_TYPE_NONE((GType) ((1) << (2))), 0); |
11101 | signals[FLUSH_ADDED_FILES] = |
11102 | g_signal_new ("flush_added_files", |
11103 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11104 | G_SIGNAL_RUN_LAST, |
11105 | G_STRUCT_OFFSET (FMDirectoryViewClass, flush_added_files)((glong) __builtin_offsetof(FMDirectoryViewClass, flush_added_files )), |
11106 | NULL((void*)0), NULL((void*)0), |
11107 | g_cclosure_marshal_VOID__VOID, |
11108 | G_TYPE_NONE((GType) ((1) << (2))), 0); |
11109 | signals[END_LOADING] = |
11110 | g_signal_new ("end_loading", |
11111 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11112 | G_SIGNAL_RUN_LAST, |
11113 | G_STRUCT_OFFSET (FMDirectoryViewClass, end_loading)((glong) __builtin_offsetof(FMDirectoryViewClass, end_loading )), |
11114 | NULL((void*)0), NULL((void*)0), |
11115 | g_cclosure_marshal_VOID__BOOLEAN, |
11116 | G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_BOOLEAN((GType) ((5) << (2)))); |
11117 | signals[FILE_CHANGED] = |
11118 | g_signal_new ("file_changed", |
11119 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11120 | G_SIGNAL_RUN_LAST, |
11121 | G_STRUCT_OFFSET (FMDirectoryViewClass, file_changed)((glong) __builtin_offsetof(FMDirectoryViewClass, file_changed )), |
11122 | NULL((void*)0), NULL((void*)0), |
11123 | fm_marshal_VOID__OBJECT_OBJECT, |
11124 | G_TYPE_NONE((GType) ((1) << (2))), 2, BAUL_TYPE_FILEbaul_file_get_type(), BAUL_TYPE_DIRECTORYbaul_directory_get_type()); |
11125 | signals[LOAD_ERROR] = |
11126 | g_signal_new ("load_error", |
11127 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11128 | G_SIGNAL_RUN_LAST, |
11129 | G_STRUCT_OFFSET (FMDirectoryViewClass, load_error)((glong) __builtin_offsetof(FMDirectoryViewClass, load_error) ), |
11130 | NULL((void*)0), NULL((void*)0), |
11131 | g_cclosure_marshal_VOID__POINTER, |
11132 | G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_POINTER((GType) ((17) << (2)))); |
11133 | signals[REMOVE_FILE] = |
11134 | g_signal_new ("remove_file", |
11135 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11136 | G_SIGNAL_RUN_LAST, |
11137 | G_STRUCT_OFFSET (FMDirectoryViewClass, remove_file)((glong) __builtin_offsetof(FMDirectoryViewClass, remove_file )), |
11138 | NULL((void*)0), NULL((void*)0), |
11139 | fm_marshal_VOID__OBJECT_OBJECT, |
11140 | G_TYPE_NONE((GType) ((1) << (2))), 2, BAUL_TYPE_FILEbaul_file_get_type(), BAUL_TYPE_DIRECTORYbaul_directory_get_type()); |
11141 | |
11142 | klass->accepts_dragged_files = real_accepts_dragged_files; |
11143 | klass->file_still_belongs = real_file_still_belongs; |
11144 | klass->get_emblem_names_to_exclude = real_get_emblem_names_to_exclude; |
11145 | klass->get_selected_icon_locations = real_get_selected_icon_locations; |
11146 | klass->is_read_only = real_is_read_only; |
11147 | klass->load_error = real_load_error; |
11148 | klass->can_rename_file = can_rename_file; |
11149 | klass->start_renaming_file = start_renaming_file; |
11150 | klass->supports_creating_files = real_supports_creating_files; |
11151 | klass->supports_properties = real_supports_properties; |
11152 | klass->supports_zooming = real_supports_zooming; |
11153 | klass->using_manual_layout = real_using_manual_layout; |
11154 | klass->merge_menus = real_merge_menus; |
11155 | klass->unmerge_menus = real_unmerge_menus; |
11156 | klass->update_menus = real_update_menus; |
11157 | klass->set_is_active = real_set_is_active; |
11158 | /* Function pointers that subclasses must override */ |
11159 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, add_file)* (void (**)(void)) & (klass)->add_file = fm_directory_view_unimplemented_add_file; |
11160 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, bump_zoom_level)* (void (**)(void)) & (klass)->bump_zoom_level = fm_directory_view_unimplemented_bump_zoom_level; |
11161 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, can_zoom_in)* (void (**)(void)) & (klass)->can_zoom_in = fm_directory_view_unimplemented_can_zoom_in; |
11162 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, can_zoom_out)* (void (**)(void)) & (klass)->can_zoom_out = fm_directory_view_unimplemented_can_zoom_out; |
11163 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, clear)* (void (**)(void)) & (klass)->clear = fm_directory_view_unimplemented_clear; |
11164 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, file_changed)* (void (**)(void)) & (klass)->file_changed = fm_directory_view_unimplemented_file_changed; |
11165 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_background_widget)* (void (**)(void)) & (klass)->get_background_widget = fm_directory_view_unimplemented_get_background_widget; |
11166 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_selection)* (void (**)(void)) & (klass)->get_selection = fm_directory_view_unimplemented_get_selection; |
11167 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_selection_for_file_transfer)* (void (**)(void)) & (klass)->get_selection_for_file_transfer = fm_directory_view_unimplemented_get_selection_for_file_transfer; |
11168 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_item_count)* (void (**)(void)) & (klass)->get_item_count = fm_directory_view_unimplemented_get_item_count; |
11169 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, is_empty)* (void (**)(void)) & (klass)->is_empty = fm_directory_view_unimplemented_is_empty; |
11170 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, reset_to_defaults)* (void (**)(void)) & (klass)->reset_to_defaults = fm_directory_view_unimplemented_reset_to_defaults; |
11171 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, restore_default_zoom_level)* (void (**)(void)) & (klass)->restore_default_zoom_level = fm_directory_view_unimplemented_restore_default_zoom_level; |
11172 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, select_all)* (void (**)(void)) & (klass)->select_all = fm_directory_view_unimplemented_select_all; |
11173 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, set_selection)* (void (**)(void)) & (klass)->set_selection = fm_directory_view_unimplemented_set_selection; |
11174 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, invert_selection)* (void (**)(void)) & (klass)->invert_selection = fm_directory_view_unimplemented_invert_selection; |
11175 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, zoom_to_level)* (void (**)(void)) & (klass)->zoom_to_level = fm_directory_view_unimplemented_zoom_to_level; |
11176 | EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_zoom_level)* (void (**)(void)) & (klass)->get_zoom_level = fm_directory_view_unimplemented_get_zoom_level; |
11177 | |
11178 | copied_files_atom = cdk_atom_intern ("x-special/cafe-copied-files", FALSE(0)); |
11179 | |
11180 | g_object_class_install_property (G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))), |
11181 | PROP_WINDOW_SLOT, |
11182 | g_param_spec_object ("window-slot", |
11183 | "Window Slot", |
11184 | "The parent window slot reference", |
11185 | BAUL_TYPE_WINDOW_SLOT_INFO(baul_window_slot_info_get_type ()), |
11186 | G_PARAM_WRITABLE | |
11187 | G_PARAM_CONSTRUCT_ONLY)); |
11188 | |
11189 | signals[TRASH] = |
11190 | g_signal_new ("trash", |
11191 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11192 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
11193 | G_STRUCT_OFFSET (FMDirectoryViewClass, trash)((glong) __builtin_offsetof(FMDirectoryViewClass, trash)), |
11194 | g_signal_accumulator_true_handled, NULL((void*)0), |
11195 | fm_marshal_BOOLEAN__VOID, |
11196 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 0); |
11197 | signals[DELETE] = |
11198 | g_signal_new ("delete", |
11199 | G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type), |
11200 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
11201 | G_STRUCT_OFFSET (FMDirectoryViewClass, delete)((glong) __builtin_offsetof(FMDirectoryViewClass, delete)), |
11202 | g_signal_accumulator_true_handled, NULL((void*)0), |
11203 | fm_marshal_BOOLEAN__VOID, |
11204 | G_TYPE_BOOLEAN((GType) ((5) << (2))), 0); |
11205 | |
11206 | binding_set = ctk_binding_set_by_class (klass); |
11207 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_Delete0xffff, 0, |
11208 | "trash", 0); |
11209 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Delete0xff9f, 0, |
11210 | "trash", 0); |
11211 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_Delete0xffff, CDK_SHIFT_MASK, |
11212 | "delete", 0); |
11213 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Delete0xff9f, CDK_SHIFT_MASK, |
11214 | "delete", 0); |
11215 | |
11216 | klass->trash = real_trash; |
11217 | klass->delete = real_delete; |
11218 | } |
11219 | |
11220 | static void |
11221 | undo_redo_menu_update_callback (BaulUndoStackManager *manager G_GNUC_UNUSED__attribute__ ((__unused__)), |
11222 | gpointer arg, |
11223 | gpointer data) |
11224 | { |
11225 | FMDirectoryView *view; |
11226 | view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data)), (fm_directory_view_get_type()))))); |
11227 | |
11228 | BaulUndoStackMenuData* menudata = (BaulUndoStackMenuData*) arg; |
11229 | |
11230 | g_free(view->details->undo_action_label); |
11231 | g_free(view->details->undo_action_description); |
11232 | g_free(view->details->redo_action_label); |
11233 | g_free(view->details->redo_action_description); |
11234 | |
11235 | view->details->undo_active = menudata->undo_label ? TRUE(!(0)) : FALSE(0); |
11236 | view->details->redo_active = menudata->redo_label ? TRUE(!(0)) : FALSE(0); |
11237 | |
11238 | view->details->undo_action_label = g_strdup (menudata->undo_label)g_strdup_inline (menudata->undo_label); |
11239 | view->details->undo_action_description = g_strdup (menudata->undo_description)g_strdup_inline (menudata->undo_description); |
11240 | view->details->redo_action_label = g_strdup (menudata->redo_label)g_strdup_inline (menudata->redo_label); |
11241 | view->details->redo_action_description = g_strdup (menudata->redo_description)g_strdup_inline (menudata->redo_description); |
11242 | |
11243 | schedule_update_menus (view); |
11244 | } |
11245 | |
11246 | static void |
11247 | undo_update_menu (FMDirectoryView *view) |
11248 | { |
11249 | CtkAction *action; |
11250 | gboolean available = FALSE(0); |
11251 | gchar* label; |
11252 | gchar* tooltip; |
11253 | |
11254 | /* Update undo entry */ |
11255 | action = ctk_action_group_get_action (view->details->dir_action_group, |
11256 | FM_ACTION_UNDO"Undo"); |
11257 | available = view->details->undo_active; |
11258 | if (available) { |
11259 | label = view->details->undo_action_label; |
11260 | tooltip = view->details->undo_action_description; |
11261 | } else { |
11262 | /* Reset to default info */ |
11263 | label = _("Undo")gettext ("Undo"); |
11264 | tooltip = _("Undo the last action")gettext ("Undo the last action"); |
11265 | } |
11266 | g_object_set (action, |
11267 | "label", label, |
11268 | "tooltip", tooltip, |
11269 | NULL((void*)0)); |
11270 | ctk_action_set_sensitive (action, available); |
11271 | |
11272 | /* Update redo entry */ |
11273 | action = ctk_action_group_get_action (view->details->dir_action_group, |
11274 | FM_ACTION_REDO"Redo"); |
11275 | available = view->details->redo_active; |
11276 | if (available) { |
11277 | label = view->details->redo_action_label; |
11278 | tooltip = view->details->redo_action_description; |
11279 | } else { |
11280 | /* Reset to default info */ |
11281 | label = _("Redo")gettext ("Redo"); |
11282 | tooltip = _("Redo the last undone action")gettext ("Redo the last undone action"); |
11283 | } |
11284 | g_object_set (action, |
11285 | "label", label, |
11286 | "tooltip", tooltip, |
11287 | NULL((void*)0)); |
11288 | ctk_action_set_sensitive (action, available); |
11289 | } |