Bug Summary

File:src/file-manager/fm-directory-view.c
Warning:line 4728, column 2
Value stored to 'num_applications' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name fm-directory-view.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src/file-manager -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I ../.. -I ../.. -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/cafe-desktop-2.0 -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cail-3.0 -I /usr/include/libxml2 -D BAUL_DATADIR="/usr/share/baul" -D DATADIR="/usr/share" -D G_DISABLE_DEPRECATED -D GDK_PIXBUF_DISABLE_DEPRECATED -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/src/file-manager -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-07-10-192015-28295-1 -x c fm-directory-view.c
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
133enum {
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
150enum
151{
152 PROP_0,
153 PROP_WINDOW_SLOT
154};
155
156
157static guint signals[LAST_SIGNAL] = { 0 };
158
159static CdkAtom copied_files_atom;
160
161static char *scripts_directory_uri;
162static int scripts_directory_uri_length;
163
164struct 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
273typedef struct {
274 BaulFile *file;
275 BaulDirectory *directory;
276} FileAndDirectory;
277
278/* forward declarations */
279
280static gboolean display_selection_info_idle_callback (gpointer data);
281static void fm_directory_view_class_init (FMDirectoryViewClass *klass);
282static void fm_directory_view_init (FMDirectoryView *view);
283static void fm_directory_view_duplicate_selection (FMDirectoryView *view,
284 GList *files,
285 GArray *item_locations);
286static void fm_directory_view_create_links_for_files (FMDirectoryView *view,
287 GList *files,
288 GArray *item_locations);
289static void trash_or_delete_files (CtkWindow *parent_window,
290 const GList *files,
291 gboolean delete_if_all_already_in_trash,
292 FMDirectoryView *view);
293static void load_directory (FMDirectoryView *view,
294 BaulDirectory *directory);
295static void fm_directory_view_merge_menus (FMDirectoryView *view);
296static void fm_directory_view_unmerge_menus (FMDirectoryView *view);
297static void fm_directory_view_init_show_hidden_files (FMDirectoryView *view);
298static void fm_directory_view_init_show_backup_files (FMDirectoryView *view);
299static void fm_directory_view_load_location (BaulView *baul_view,
300 const char *location);
301static void fm_directory_view_stop_loading (BaulView *baul_view);
302static void fm_directory_view_drop_proxy_received_uris (FMDirectoryView *view,
303 const GList *source_uri_list,
304 const char *target_uri,
305 CdkDragAction action);
306static void fm_directory_view_drop_proxy_received_netscape_url (FMDirectoryView *view,
307 const char *netscape_url,
308 const char *target_uri,
309 CdkDragAction action);
310static void clipboard_changed_callback (BaulClipboardMonitor *monitor,
311 FMDirectoryView *view);
312static void open_one_in_new_window (gpointer data,
313 gpointer callback_data);
314static void open_one_in_folder_window (gpointer data,
315 gpointer callback_data);
316static void schedule_update_menus (FMDirectoryView *view);
317static void schedule_update_menus_callback (gpointer callback_data);
318static void remove_update_menus_timeout_callback (FMDirectoryView *view);
319static void schedule_update_status (FMDirectoryView *view);
320static void remove_update_status_idle_callback (FMDirectoryView *view);
321static void reset_update_interval (FMDirectoryView *view);
322static void schedule_idle_display_of_pending_files (FMDirectoryView *view);
323static void unschedule_display_of_pending_files (FMDirectoryView *view);
324static void disconnect_model_handlers (FMDirectoryView *view);
325static void metadata_for_directory_as_file_ready_callback (BaulFile *file,
326 gpointer callback_data);
327static void metadata_for_files_in_directory_ready_callback (BaulDirectory *directory,
328 GList *files,
329 gpointer callback_data);
330static void fm_directory_view_trash_state_changed_callback (BaulTrashMonitor *trash,
331 gboolean state,
332 gpointer callback_data);
333static void fm_directory_view_select_file (FMDirectoryView *view,
334 BaulFile *file);
335
336static CdkDragAction ask_link_action (FMDirectoryView *view);
337static void update_templates_directory (FMDirectoryView *view);
338static void user_dirs_changed (FMDirectoryView *view);
339static void fm_directory_view_set_is_active (FMDirectoryView *view,
340 gboolean is_active);
341
342static gboolean file_list_all_are_folders (GList *file_list);
343
344static void action_open_scripts_folder_callback (CtkAction *action,
345 gpointer callback_data);
346static void action_cut_files_callback (CtkAction *action,
347 gpointer callback_data);
348static void action_copy_files_callback (CtkAction *action,
349 gpointer callback_data);
350static void action_paste_files_callback (CtkAction *action,
351 gpointer callback_data);
352static void action_copy_to_next_pane_callback (CtkAction *action,
353 gpointer callback_data);
354static void action_move_to_next_pane_callback (CtkAction *action,
355 gpointer callback_data);
356static void action_rename_callback (CtkAction *action,
357 gpointer callback_data);
358static void action_rename_select_all_callback (CtkAction *action,
359 gpointer callback_data);
360static void action_paste_files_into_callback (CtkAction *action,
361 gpointer callback_data);
362static void action_connect_to_server_link_callback (CtkAction *action,
363 gpointer data);
364static void action_mount_volume_callback (CtkAction *action,
365 gpointer data);
366static void action_unmount_volume_callback (CtkAction *action,
367 gpointer data);
368static void action_format_volume_callback (CtkAction *action,
369 gpointer data);
370static void action_start_volume_callback (CtkAction *action,
371 gpointer data);
372static void action_stop_volume_callback (CtkAction *action,
373 gpointer data);
374static void action_detect_media_callback (CtkAction *action,
375 gpointer data);
376
377/* location popup-related actions */
378
379static void action_location_open_alternate_callback (CtkAction *action,
380 gpointer callback_data);
381static void action_location_open_folder_window_callback (CtkAction *action,
382 gpointer callback_data);
383
384static void action_location_cut_callback (CtkAction *action,
385 gpointer callback_data);
386static void action_location_copy_callback (CtkAction *action,
387 gpointer callback_data);
388static void action_location_trash_callback (CtkAction *action,
389 gpointer callback_data);
390static void action_location_delete_callback (CtkAction *action,
391 gpointer callback_data);
392static void action_location_properties_callback (CtkAction *action,
393 gpointer callback_data);
394
395static void unschedule_pop_up_location_context_menu (FMDirectoryView *view);
396
397static inline void fm_directory_view_widget_to_file_operation_position (FMDirectoryView *view,
398 CdkPoint *position);
399static void fm_directory_view_widget_to_file_operation_position_xy (FMDirectoryView *view,
400 int *x, int *y);
401
402/* undo-related actions */
403
404static void undo_redo_menu_update_callback (BaulUndoStackManager* manager, gpointer arg1, gpointer data);
405
406static void undo_update_menu (FMDirectoryView *view);
407
408static void finish_undoredo_callback (gpointer data);
409
410static void real_action_undo (FMDirectoryView *view);
411
412static void real_action_redo (FMDirectoryView *view);
413
414static void action_undo_callback (CtkAction *action, gpointer callback_data);
415
416static void action_redo_callback (CtkAction *action, gpointer callback_data);
417
418EEL_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
420EEL_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"); }
421EEL_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"); }
422EEL_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"); }
423EEL_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"); }
424EEL_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"
); }
425EEL_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"); }
426EEL_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"); }
427EEL_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"); }
428EEL_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"); }
429EEL_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"); }
430EEL_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"); }
431EEL_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"); }
432EEL_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"); }
433EEL_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"); }
434EEL_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"); }
435EEL_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"); }
436EEL_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"); }
437EEL_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
439typedef struct {
440 GAppInfo *application;
441 GList *files;
442 FMDirectoryView *directory_view;
443} ApplicationLaunchParameters;
444
445typedef struct {
446 BaulFile *file;
447 FMDirectoryView *directory_view;
448} ScriptLaunchParameters;
449
450typedef struct {
451 BaulFile *file;
452 FMDirectoryView *directory_view;
453} CreateTemplateParameters;
454
455static ApplicationLaunchParameters *
456application_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
474static void
475application_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
487static GList *
488file_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
502static GList *
503file_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
518static void
519file_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
527static void
528file_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
539static gboolean
540file_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
551static guint
552file_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
563static ScriptLaunchParameters *
564script_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
578static void
579script_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
586static CreateTemplateParameters *
587create_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
601static void
602create_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
609BaulWindowInfo *
610fm_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
617BaulWindowSlotInfo *
618fm_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 */
629CtkWindow *
630fm_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
644static gboolean
645fm_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
677static gboolean
678selection_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
696static gboolean
697selection_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
714static char *
715get_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
734void
735fm_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
755void
756fm_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
774static void
775action_open_callback (CtkAction *action,
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
792static void
793action_open_close_parent_callback (CtkAction *action,
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
811static void
812action_open_alternate_callback (CtkAction *action,
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
831static void
832action_open_new_tab_callback (CtkAction *action,
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
855static void
856action_open_folder_window_callback (CtkAction *action,
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
875static void
876open_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
896static void
897application_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
915static void
916choose_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
951static void
952open_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
967static void
968action_other_application_callback (CtkAction *action,
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
976static void
977trash_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
995static gboolean
996real_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
1010static void
1011action_trash_callback (CtkAction *action,
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
1017static void
1018delete_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
1042static void
1043action_delete_callback (CtkAction *action,
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
1049static void
1050action_restore_from_trash_callback (CtkAction *action,
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
1066static gboolean
1067real_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
1081static void
1082action_duplicate_callback (CtkAction *action,
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
1107static void
1108action_create_link_callback (CtkAction *action,
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
1129static void
1130action_select_all_callback (CtkAction *action,
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
1138static void
1139action_invert_selection_callback (CtkAction *action,
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
1148static void
1149pattern_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
1194static void
1195select_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
1271static void
1272action_select_pattern_callback (CtkAction *action,
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
1280static void
1281action_reset_to_defaults_callback (CtkAction *action,
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
1290static void
1291hidden_files_mode_changed (BaulWindow *window,
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
1301static void
1302backup_files_mode_changed (BaulWindow *window,
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
1312static void
1313action_save_search_callback (CtkAction *action,
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
1332static void
1333query_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
1346static void
1347action_save_search_as_callback (CtkAction *action,
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
1460static void
1461action_empty_trash_callback (CtkAction *action,
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
1469static void
1470action_new_folder_callback (CtkAction *action,
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
1478static void
1479action_new_empty_file_callback (CtkAction *action,
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
1487static void
1488action_new_launcher_callback (CtkAction *action,
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
1513static void
1514action_properties_callback (CtkAction *action,
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
1540static void
1541action_location_properties_callback (CtkAction *action,
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
1559static gboolean
1560all_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
1576static gboolean
1577all_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
1593static gboolean
1594we_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 */
1620static void
1621text_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
1632static void
1633image_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
1644static void
1645click_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
1656gboolean
1657fm_directory_view_should_sort_directories_first (FMDirectoryView *view)
1658{
1659 return view->details->sort_directories_first;
1660}
1661
1662static void
1663sort_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
1681static 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
1742static void
1743scripts_added_or_changed_callback (BaulDirectory *directory,
1744 GList *files,
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
1757static void
1758templates_added_or_changed_callback (BaulDirectory *directory,
1759 GList *files,
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
1772static void
1773add_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
1801static void
1802remove_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
1819static void
1820add_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
1828static void
1829remove_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
1837static void
1838add_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
1846static void
1847remove_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
1855static void
1856slot_active (BaulWindowSlot *slot,
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
1866static void
1867slot_inactive (BaulWindowSlot *slot,
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
1878static void
1879fm_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
1889static void
1890view_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
1895static CtkWidget *
1896fm_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
1901static int
1902fm_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
1915static GList *
1916fm_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
1934static GList *
1935file_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
1949static void
1950fm_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
1980void
1981fm_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
2008static void
2009fm_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
2108static void
2109real_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
2136static void
2137fm_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
2201static void
2202fm_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 **/
2240void
2241fm_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
2477void
2478fm_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
2485gboolean
2486fm_directory_view_get_allow_moves (FMDirectoryView *view)
2487{
2488 return view->details->allow_moves;
2489}
2490
2491static void
2492fm_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
2511static void
2512fm_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
2517static gboolean
2518reveal_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
2530static void
2531done_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
2593typedef struct {
2594 GHashTable *debuting_files;
2595 GList *added_files;
2596} DebutingFilesData;
2597
2598static void
2599debuting_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 */
2610static void
2611debuting_files_add_file_callback (FMDirectoryView *view,
2612 BaulFile *new_file,
2613 BaulDirectory *directory,
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
2636typedef struct {
2637 GList *added_files;
2638 FMDirectoryView *directory_view;
2639} CopyMoveDoneData;
2640
2641static void
2642copy_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
2651static void
2652pre_copy_move_add_file_callback (FMDirectoryView *view,
2653 BaulFile *new_file,
2654 BaulDirectory *directory,
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 */
2666static CopyMoveDoneData *
2667pre_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 (&copy_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 */
2689static gboolean
2690copy_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
2702static gboolean
2703remove_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 */
2730static void
2731copy_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 &copy_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
2797static gboolean
2798real_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
2808static gboolean
2809still_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
2815static gboolean
2816ready_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
2822static int
2823compare_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}
2840static void
2841sort_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 */
2852static void
2853process_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
2934static void
2935process_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
2991static void
2992display_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
3010void
3011fm_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
3018void
3019fm_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
3033static gboolean
3034display_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
3053static void
3054remove_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
3062static void
3063update_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
3073static gboolean
3074update_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
3090static gboolean
3091display_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
3108static void
3109schedule_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
3122static void
3123schedule_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
3134static void
3135unschedule_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
3144static void
3145queue_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
3180static void
3181remove_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
3189static void
3190reset_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
3200static gboolean
3201changes_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
3233static void
3234schedule_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
3249static void
3250action_undo_callback (CtkAction *action,
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
3256static void
3257action_redo_callback (CtkAction *action,
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
3263static void
3264files_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
3290static void
3291files_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
3322static void
3323done_loading_callback (BaulDirectory *directory,
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
3341static void
3342load_error_callback (BaulDirectory *directory,
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
3362static void
3363real_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
3380void
3381fm_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
3415void
3416fm_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 **/
3445void
3446fm_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 **/
3462void
3463fm_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 **/
3479void
3480fm_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 **/
3495gboolean
3496fm_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 **/
3509void
3510fm_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 **/
3529void
3530fm_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
3545BaulZoomLevel
3546fm_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 **/
3565void
3566fm_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 **/
3588gboolean
3589fm_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 **/
3611static gboolean
3612fm_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 **/
3628gboolean
3629fm_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
3642CtkWidget *
3643fm_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
3652EelBackground *
3653fm_directory_view_get_background (FMDirectoryView *view)
3654{
3655 return eel_get_widget_background (fm_directory_view_get_background_widget (view));
3656}
3657
3658static void
3659real_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
3668static void
3669fm_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 **/
3690GList *
3691fm_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
3700void
3701fm_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
3710GList *
3711fm_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
3720guint
3721fm_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
3730CtkUIManager *
3731fm_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 **/
3748BaulDirectory *
3749fm_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
3756CdkAtom
3757fm_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
3764static void
3765prepend_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
3778static void
3779offset_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
3794static void
3795fm_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
3829static void
3830fm_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
3868static gboolean
3869special_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
3901static gboolean
3902desktop_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
3931static void
3932trash_or_delete_done_cb (GHashTable *debuting_uris,
3933 gboolean user_cancel,
3934 FMDirectoryView *view)
3935{
3936 if (user_cancel) {
3937 view->details->selection_was_removed = FALSE(0);
3938 }
3939}
3940
3941static void
3942trash_or_delete_files (CtkWindow *parent_window,
3943 const GList *files,
3944 gboolean delete_if_all_already_in_trash,
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
3965static gboolean
3966can_rename_file (FMDirectoryView *view, BaulFile *file)
3967{
3968 return baul_file_can_rename (file);
3969}
3970
3971static void
3972start_renaming_file (FMDirectoryView *view,
3973 BaulFile *file,
3974 gboolean select_all)
3975{
3976 if (file != NULL((void*)0)) {
3977 fm_directory_view_select_file (view, file);
3978 }
3979}
3980
3981typedef struct {
3982 FMDirectoryView *view;
3983 BaulFile *new_file;
3984} RenameData;
3985
3986static gboolean
3987delayed_rename_file_hack_callback (RenameData *data)
3988{
3989 FMDirectoryView *view;
3990 BaulFile *new_file;
3991
3992 view = data->view;
3993 new_file = data->new_file;
3994
3995 if (view->details->window != NULL((void*)0) &&
3996 view->details->active) {
3997 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)
;
3998 fm_directory_view_reveal_selection (view);
3999 }
4000
4001 return FALSE(0);
4002}
4003
4004static void
4005delayed_rename_file_hack_removed (RenameData *data)
4006{
4007 g_object_unref (data->view);
4008 baul_file_unref (data->new_file);
4009 g_free (data);
4010}
4011
4012
4013static void
4014rename_file (FMDirectoryView *view, BaulFile *new_file)
4015{
4016 /* HACK!!!!
4017 This is a work around bug in listview. After the rename is
4018 enabled we will get file changes due to info about the new
4019 file being read, which will cause the model to change. When
4020 the model changes CtkTreeView clears the editing. This hack just
4021 delays editing for some time to try to avoid this problem.
4022 A major problem is that the selection of the row causes us
4023 to load the slow mimetype for the file, which leads to a
4024 file_changed. So, before we delay we select the row.
4025 */
4026 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; }))))
) {
4027 RenameData *data;
4028
4029 fm_directory_view_select_file (view, new_file);
4030
4031 data = g_new (RenameData, 1)((RenameData *) g_malloc_n ((1), sizeof (RenameData)));
4032 data->view = g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view));
4033 data->new_file = baul_file_ref (new_file);
4034 if (view->details->delayed_rename_file_id != 0) {
4035 g_source_remove (view->details->delayed_rename_file_id);
4036 }
4037 view->details->delayed_rename_file_id =
4038 g_timeout_add_full (G_PRIORITY_DEFAULT0,
4039 100, (GSourceFunc)delayed_rename_file_hack_callback,
4040 data, (GDestroyNotify) delayed_rename_file_hack_removed);
4041
4042 return;
4043 }
4044
4045 /* no need to select because start_renaming_file selects
4046 * fm_directory_view_select_file (view, new_file);
4047 */
4048 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)
;
4049 fm_directory_view_reveal_selection (view);
4050}
4051
4052static void
4053reveal_newly_added_folder (FMDirectoryView *view, BaulFile *new_file,
4054 BaulDirectory *directory, GFile *target_location)
4055{
4056 GFile *location;
4057
4058 location = baul_file_get_location (new_file);
4059 if (g_file_equal (location, target_location)) {
4060 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
))
4061 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
))
4062 (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
))
;
4063 rename_file (view, new_file);
4064 }
4065 g_object_unref (location);
4066}
4067
4068typedef struct {
4069 FMDirectoryView *directory_view;
4070 GHashTable *added_locations;
4071} NewFolderData;
4072
4073
4074static void
4075track_newly_added_locations (FMDirectoryView *view, BaulFile *new_file,
4076 BaulDirectory *directory, gpointer user_data)
4077{
4078 NewFolderData *data;
4079
4080 data = user_data;
4081
4082 g_hash_table_insert (data->added_locations, baul_file_get_location (new_file), NULL((void*)0));
4083}
4084
4085static void
4086new_folder_done (GFile *new_folder, gpointer user_data)
4087{
4088 FMDirectoryView *directory_view;
4089 BaulFile *file;
4090 char screen_string[32];
4091 CdkScreen *screen;
4092 NewFolderData *data;
4093
4094 data = (NewFolderData *)user_data;
4095
4096 directory_view = data->directory_view;
4097
4098 if (directory_view == NULL((void*)0)) {
4099 goto fail;
4100 }
4101
4102 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
))
4103 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
))
4104 (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
))
;
4105
4106 if (new_folder == NULL((void*)0)) {
4107 goto fail;
4108 }
4109
4110 screen = ctk_widget_get_screen (CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((directory_view)), ((ctk_widget_get_type ()))))))
);
4111 g_snprintf (screen_string, sizeof (screen_string), "%d", cdk_x11_screen_get_screen_number (screen));
4112
4113
4114 file = baul_file_get (new_folder);
4115 baul_file_set_metadata
4116 (file, BAUL_METADATA_KEY_SCREEN"screen",
4117 NULL((void*)0),
4118 screen_string);
4119
4120 if (g_hash_table_lookup_extended (data->added_locations, new_folder, NULL((void*)0), NULL((void*)0))) {
4121 /* The file was already added */
4122 rename_file (directory_view, file);
4123 } else {
4124 /* We need to run after the default handler adds the folder we want to
4125 * operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we
4126 * must use connect_after.
4127 */
4128 g_signal_connect_data (directory_view,
4129 "add_file",
4130 G_CALLBACK (reveal_newly_added_folder)((GCallback) (reveal_newly_added_folder)),
4131 g_object_ref (new_folder)((__typeof__ (new_folder)) (g_object_ref) (new_folder)),
4132 (GClosureNotify)g_object_unref,
4133 G_CONNECT_AFTER);
4134 }
4135 baul_file_unref (file);
4136
4137 fail:
4138 g_hash_table_destroy (data->added_locations);
4139 eel_remove_weak_pointer (&data->directory_view);
4140 g_free (data);
4141}
4142
4143
4144static NewFolderData *
4145new_folder_data_new (FMDirectoryView *directory_view)
4146{
4147 NewFolderData *data;
4148
4149 data = g_new (NewFolderData, 1)((NewFolderData *) g_malloc_n ((1), sizeof (NewFolderData)));
4150 data->directory_view = directory_view;
4151 data->added_locations = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal,
4152 g_object_unref, NULL((void*)0));
4153 eel_add_weak_pointer (&data->directory_view);
4154
4155 return data;
4156}
4157
4158static CdkPoint *
4159context_menu_to_file_operation_position (FMDirectoryView *directory_view)
4160{
4161 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)
;
4162
4163 if (fm_directory_view_using_manual_layout (directory_view)
4164 && directory_view->details->context_menu_position.x >= 0
4165 && directory_view->details->context_menu_position.y >= 0) {
4166 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)
4167 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)
4168 (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)
;
4169 return &directory_view->details->context_menu_position;
4170 } else {
4171 return NULL((void*)0);
4172 }
4173}
4174
4175static void
4176update_context_menu_position_from_event (FMDirectoryView *view,
4177 CdkEventButton *event)
4178{
4179 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)
;
4180
4181 if (event != NULL((void*)0)) {
4182 view->details->context_menu_position.x = event->x;
4183 view->details->context_menu_position.y = event->y;
4184 } else {
4185 view->details->context_menu_position.x = -1;
4186 view->details->context_menu_position.y = -1;
4187 }
4188}
4189
4190void
4191fm_directory_view_new_folder (FMDirectoryView *directory_view)
4192{
4193 char *parent_uri;
4194 NewFolderData *data;
4195 CdkPoint *pos;
4196
4197 data = new_folder_data_new (directory_view);
4198
4199 g_signal_connect_data (directory_view,
4200 "add_file",
4201 G_CALLBACK (track_newly_added_locations)((GCallback) (track_newly_added_locations)),
4202 data,
4203 (GClosureNotify)NULL((void*)0),
4204 G_CONNECT_AFTER);
4205
4206 pos = context_menu_to_file_operation_position (directory_view);
4207
4208 parent_uri = fm_directory_view_get_backing_uri (directory_view);
4209 baul_file_operations_new_folder (CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((directory_view)), ((ctk_widget_get_type ()))))))
,
4210 pos, parent_uri,
4211 new_folder_done, data);
4212
4213 g_free (parent_uri);
4214}
4215
4216static NewFolderData *
4217setup_new_folder_data (FMDirectoryView *directory_view)
4218{
4219 NewFolderData *data;
4220
4221 data = new_folder_data_new (directory_view);
4222
4223 g_signal_connect_data (directory_view,
4224 "add_file",
4225 G_CALLBACK (track_newly_added_locations)((GCallback) (track_newly_added_locations)),
4226 data,
4227 (GClosureNotify)NULL((void*)0),
4228 G_CONNECT_AFTER);
4229
4230 return data;
4231}
4232
4233static void
4234fm_directory_view_new_file_with_initial_contents (FMDirectoryView *directory_view,
4235 const char *parent_uri,
4236 const char *filename,
4237 const char *initial_contents,
4238 int length,
4239 CdkPoint *pos)
4240{
4241 NewFolderData *data;
4242
4243 g_assert (parent_uri != NULL)do { if (parent_uri != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 4243, ((const char*) (
__func__)), "parent_uri != NULL"); } while (0)
;
4244
4245 data = setup_new_folder_data (directory_view);
4246
4247 if (pos == NULL((void*)0)) {
4248 pos = context_menu_to_file_operation_position (directory_view);
4249 }
4250
4251 baul_file_operations_new_file (CTK_WIDGET (directory_view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((directory_view)), ((ctk_widget_get_type ()))))))
,
4252 pos, parent_uri, filename,
4253 initial_contents, length,
4254 new_folder_done, data);
4255}
4256
4257void
4258fm_directory_view_new_file (FMDirectoryView *directory_view,
4259 const char *parent_uri,
4260 BaulFile *source)
4261{
4262 CdkPoint *pos;
4263 NewFolderData *data;
4264 char *source_uri;
4265 char *container_uri;
4266
4267 container_uri = NULL((void*)0);
4268 if (parent_uri == NULL((void*)0)) {
4269 container_uri = fm_directory_view_get_backing_uri (directory_view);
4270 g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 4270, ((const char*) (
__func__)), "container_uri != NULL"); } while (0)
;
4271 }
4272
4273 if (source == NULL((void*)0)) {
4274 fm_directory_view_new_file_with_initial_contents (directory_view,
4275 parent_uri != NULL((void*)0) ? parent_uri : container_uri,
4276 NULL((void*)0),
4277 NULL((void*)0),
4278 0,
4279 NULL((void*)0));
4280 g_free (container_uri);
4281 return;
4282 }
4283
4284 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)
;
4285
4286 pos = context_menu_to_file_operation_position (directory_view);
4287
4288 data = setup_new_folder_data (directory_view);
4289
4290 source_uri = baul_file_get_uri (source);
4291
4292 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 ()))))))
,
4293 pos,
4294 parent_uri != NULL((void*)0) ? parent_uri : container_uri,
4295 NULL((void*)0),
4296 source_uri,
4297 new_folder_done, data);
4298
4299 g_free (source_uri);
4300 g_free (container_uri);
4301}
4302
4303/* handle the open command */
4304
4305static void
4306open_one_in_new_window (gpointer data, gpointer callback_data)
4307{
4308 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"
, 4308, ((const char*) (__func__)), "BAUL_IS_FILE (data)"); }
while (0)
;
4309 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"
, 4309, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)"
); } while (0)
;
4310
4311 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())))))
,
4312 BAUL_FILE (data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (baul_file_get_type())))))
,
4313 BAUL_WINDOW_OPEN_IN_NAVIGATION,
4314 0);
4315}
4316
4317static void
4318open_one_in_folder_window (gpointer data, gpointer callback_data)
4319{
4320 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"
, 4320, ((const char*) (__func__)), "BAUL_IS_FILE (data)"); }
while (0)
;
4321 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"
, 4321, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (callback_data)"
); } while (0)
;
4322
4323 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())))))
,
4324 BAUL_FILE (data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (baul_file_get_type())))))
,
4325 BAUL_WINDOW_OPEN_IN_SPATIAL,
4326 0);
4327}
4328
4329BaulFile *
4330fm_directory_view_get_directory_as_file (FMDirectoryView *view)
4331{
4332 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"
, 4332, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
4333
4334 return view->details->directory_as_file;
4335}
4336
4337static void
4338open_with_launch_application_callback (CtkAction *action,
4339 gpointer callback_data)
4340{
4341 ApplicationLaunchParameters *launch_parameters;
4342
4343 launch_parameters = (ApplicationLaunchParameters *) callback_data;
4344 baul_launch_application
4345 (launch_parameters->application,
4346 launch_parameters->files,
4347 fm_directory_view_get_containing_window (launch_parameters->directory_view));
4348}
4349
4350static void
4351open_parent_folder_callback (CtkAction *action,
4352 gpointer callback_data)
4353{
4354 gchar *uri;
4355
4356 uri = (gchar *) callback_data;
4357 g_app_info_launch_default_for_uri (uri, NULL((void*)0), NULL((void*)0));
4358}
4359
4360static char *
4361escape_action_name (const char *action_name,
4362 const char *prefix)
4363{
4364 GString *s;
4365
4366 if (action_name == NULL((void*)0)) {
4367 return NULL((void*)0);
4368 }
4369
4370 s = g_string_new (prefix);
4371
4372 while (*action_name != 0) {
4373 switch (*action_name) {
4374 case '\\':
4375 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))
;
4376 break;
4377 case '/':
4378 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))
;
4379 break;
4380 case '&':
4381 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))
;
4382 break;
4383 case '"':
4384 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))
;
4385 break;
4386 default:
4387 g_string_append_c (s, *action_name)g_string_append_c_inline (s, *action_name);
4388 }
4389
4390 action_name ++;
4391 }
4392 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))))
;
4393}
4394
4395static char *
4396escape_action_path (const char *action_path)
4397{
4398 GString *s;
4399
4400 if (action_path == NULL((void*)0)) {
4401 return NULL((void*)0);
4402 }
4403
4404 s = g_string_sized_new (strlen (action_path) + 2);
4405
4406 while (*action_path != 0) {
4407 switch (*action_path) {
4408 case '\\':
4409 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))
;
4410 break;
4411 case '&':
4412 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))
;
4413 break;
4414 case '"':
4415 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))
;
4416 break;
4417 default:
4418 g_string_append_c (s, *action_path)g_string_append_c_inline (s, *action_path);
4419 }
4420
4421 action_path ++;
4422 }
4423 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))))
;
4424}
4425
4426
4427static void
4428add_submenu (CtkUIManager *ui_manager,
4429 CtkActionGroup *action_group,
4430 guint merge_id,
4431 const char *parent_path,
4432 const char *uri,
4433 const char *label,
4434 cairo_surface_t *surface,
4435 gboolean add_action)
4436{
4437 if (parent_path != NULL((void*)0)) {
4438 char *escaped_label;
4439 char *action_name;
4440 char *submenu_name;
4441 char *escaped_submenu_name;
4442
4443 action_name = escape_action_name (uri, "submenu_");
4444 submenu_name = g_path_get_basename (uri);
4445 escaped_submenu_name = escape_action_path (submenu_name);
4446 escaped_label = eel_str_double_underscores (label);
4447
4448 if (add_action) {
4449 CtkAction *action;
4450
4451 action = ctk_action_new (action_name,
4452 escaped_label,
4453 NULL((void*)0),
4454 NULL((void*)0));
4455 if (surface != NULL((void*)0)) {
4456 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "menu-icon",
4457 cairo_surface_reference (surface),
4458 (GDestroyNotify)cairo_surface_destroy);
4459 }
4460
4461 g_object_set (action, "hide-if-empty", FALSE(0), NULL((void*)0));
4462
4463 ctk_action_group_add_action (action_group,
4464 action);
4465 g_object_unref (action);
4466 }
4467
4468 ctk_ui_manager_add_ui (ui_manager,
4469 merge_id,
4470 parent_path,
4471 escaped_submenu_name,
4472 action_name,
4473 CTK_UI_MANAGER_MENU,
4474 FALSE(0));
4475 g_free (action_name);
4476 g_free (escaped_label);
4477 g_free (submenu_name);
4478 g_free (escaped_submenu_name);
4479 }
4480}
4481
4482static void
4483add_application_to_open_with_menu (FMDirectoryView *view,
4484 GAppInfo *application,
4485 GList *files,
4486 int index,
4487 const char *menu_placeholder,
4488 const char *popup_placeholder,
4489 const gboolean submenu)
4490{
4491 ApplicationLaunchParameters *launch_parameters;
4492 char *tip;
4493 char *label;
4494 char *action_name;
4495 char *escaped_app;
4496 char *path;
4497 CtkAction *action;
4498 GIcon *app_icon;
4499 CtkWidget *menuitem;
4500
4501 launch_parameters = application_launch_parameters_new
4502 (application, files, view);
4503 escaped_app = eel_str_double_underscores (g_app_info_get_display_name (application));
4504 if (submenu)
4505 label = g_strdup_printf ("%s", escaped_app);
4506 else
4507 label = g_strdup_printf (_("Open With %s")gettext ("Open With %s"), escaped_app);
4508
4509 tip = g_strdup_printf (ngettext ("Use \"%s\" to open the selected item",
4510 "Use \"%s\" to open the selected items",
4511 g_list_length (files)),
4512 escaped_app);
4513 g_free (escaped_app);
4514
4515 action_name = g_strdup_printf ("open_with_%d", index);
4516
4517 action = ctk_action_new (action_name,
4518 label,
4519 tip,
4520 NULL((void*)0));
4521
4522 app_icon = g_app_info_get_icon (application);
4523 if (app_icon != NULL((void*)0)) {
4524 g_object_ref (app_icon)((__typeof__ (app_icon)) (g_object_ref) (app_icon));
4525 } else {
4526 app_icon = g_themed_icon_new ("application-x-executable");
4527 }
4528
4529 ctk_action_set_gicon (action, app_icon);
4530 g_object_unref (app_icon);
4531
4532 g_signal_connect_data (action, "activate",
4533 G_CALLBACK (open_with_launch_application_callback)((GCallback) (open_with_launch_application_callback)),
4534 launch_parameters,
4535 (GClosureNotify)application_launch_parameters_free, 0);
4536
4537 ctk_action_group_add_action (view->details->open_with_action_group,
4538 action);
4539 g_object_unref (action);
4540
4541 ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window),
4542 view->details->open_with_merge_id,
4543 menu_placeholder,
4544 action_name,
4545 action_name,
4546 CTK_UI_MANAGER_MENUITEM,
4547 FALSE(0));
4548
4549 path = g_strdup_printf ("%s/%s", menu_placeholder, action_name);
4550 menuitem = ctk_ui_manager_get_widget (
4551 baul_window_info_get_ui_manager (view->details->window),
4552 path);
4553 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)));
4554 g_free (path);
4555
4556 ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window),
4557 view->details->open_with_merge_id,
4558 popup_placeholder,
4559 action_name,
4560 action_name,
4561 CTK_UI_MANAGER_MENUITEM,
4562 FALSE(0));
4563
4564 path = g_strdup_printf ("%s/%s", popup_placeholder, action_name);
4565 menuitem = ctk_ui_manager_get_widget (
4566 baul_window_info_get_ui_manager (view->details->window),
4567 path);
4568 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)));
4569
4570 g_free (path);
4571 g_free (action_name);
4572 g_free (label);
4573 g_free (tip);
4574}
4575
4576static void
4577add_parent_folder_to_open_menu (FMDirectoryView *view,
4578 GList *files,
4579 const char *menu_placeholder,
4580 const char *popup_placeholder)
4581{
4582 BaulFile *file;
4583 gchar *uri;
4584 char *tip;
4585 char *label;
4586 char *action_name;
4587 char *path;
4588 CtkAction *action;
4589 CtkWidget *menuitem;
4590
4591 file = g_list_first(files)->data;
4592
4593 if (baul_file_is_directory (file))
4594 return;
4595
4596 uri = baul_file_get_parent_uri (file);
4597
4598 label = g_strdup (_("Open parent location"))g_strdup_inline (gettext ("Open parent location"));
4599 tip = g_strdup (_("Open parent location for the selected item"))g_strdup_inline (gettext ("Open parent location for the selected item"
))
;
4600 action_name = g_strdup ("open_location")g_strdup_inline ("open_location");
4601
4602 action = ctk_action_new (action_name,
4603 label,
4604 tip,
4605 NULL((void*)0));
4606
4607 ctk_action_set_icon_name (action, "folder");
4608
4609 g_signal_connect_data (action, "activate",
4610 G_CALLBACK (open_parent_folder_callback)((GCallback) (open_parent_folder_callback)),
4611 uri, (GClosureNotify)g_free, 0);
4612
4613 ctk_action_group_add_action (view->details->open_with_action_group,
4614 action);
4615 g_object_unref (action);
4616
4617 ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window),
4618 view->details->open_with_merge_id,
4619 menu_placeholder,
4620 action_name,
4621 action_name,
4622 CTK_UI_MANAGER_MENUITEM,
4623 FALSE(0));
4624
4625 path = g_strdup_printf ("%s/%s", menu_placeholder, action_name);
4626 menuitem = ctk_ui_manager_get_widget (
4627 baul_window_info_get_ui_manager (view->details->window),
4628 path);
4629 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)));
4630 g_free (path);
4631
4632 ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window),
4633 view->details->open_with_merge_id,
4634 popup_placeholder,
4635 action_name,
4636 action_name,
4637 CTK_UI_MANAGER_MENUITEM,
4638 FALSE(0));
4639
4640 path = g_strdup_printf ("%s/%s", popup_placeholder, action_name);
4641 menuitem = ctk_ui_manager_get_widget (
4642 baul_window_info_get_ui_manager (view->details->window),
4643 path);
4644 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)));
4645
4646 g_free (path);
4647 g_free (action_name);
4648 g_free (label);
4649 g_free (tip);
4650}
4651
4652static void
4653get_x_content_async_callback (char **content,
4654 gpointer user_data)
4655{
4656 FMDirectoryView *view;
4657
4658 view = FM_DIRECTORY_VIEW (user_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (fm_directory_view_get_type())))))
;
4659
4660 if (view->details->window != NULL((void*)0)) {
4661 schedule_update_menus (view);
4662 }
4663 g_object_unref (view);
4664}
4665
4666static void
4667add_x_content_apps (FMDirectoryView *view, BaulFile *file, GList **applications)
4668{
4669 GMount *mount;
4670 char **x_content_types;
4671
4672 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)
;
4673
4674 mount = baul_file_get_mount (file);
4675
4676 if (mount == NULL((void*)0)) {
4677 return;
4678 }
4679
4680 x_content_types = baul_autorun_get_cached_x_content_types_for_mount (mount);
4681 if (x_content_types != NULL((void*)0)) {
4682 unsigned int n;
4683
4684 for (n = 0; x_content_types[n] != NULL((void*)0); n++) {
4685 char *x_content_type = x_content_types[n];
4686 GList *app_info_for_x_content_type;
4687
4688 app_info_for_x_content_type = g_app_info_get_all_for_type (x_content_type);
4689 *applications = g_list_concat (*applications, app_info_for_x_content_type);
4690 }
4691 g_strfreev (x_content_types);
4692 } else {
4693 baul_autorun_get_x_content_types_for_mount_async (mount,
4694 get_x_content_async_callback,
4695 NULL((void*)0),
4696 g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)));
4697
4698 }
4699
4700 g_object_unref (mount);
4701}
4702
4703static void
4704reset_open_with_menu (FMDirectoryView *view, GList *selection)
4705{
4706 GList *applications, *node;
4707 gboolean submenu_visible, filter_default;
4708 int num_applications;
4709 int index;
4710 gboolean other_applications_visible;
4711 gboolean open_with_chooser_visible;
4712 CtkUIManager *ui_manager;
4713 CtkAction *action;
4714 GAppInfo *default_app;
4715
4716 /* Clear any previous inserted items in the applications and viewers placeholders */
4717
4718 ui_manager = baul_window_info_get_ui_manager (view->details->window);
4719 baul_ui_unmerge_ui (ui_manager,
4720 &view->details->open_with_merge_id,
4721 &view->details->open_with_action_group);
4722
4723 baul_ui_prepare_merge_ui (ui_manager,
4724 "OpenWithGroup",
4725 &view->details->open_with_merge_id,
4726 &view->details->open_with_action_group);
4727
4728 num_applications = 0;
Value stored to 'num_applications' is never read
4729
4730 other_applications_visible = (selection != NULL((void*)0));
4731 filter_default = (selection != NULL((void*)0));
4732
4733 default_app = NULL((void*)0);
4734 if (filter_default) {
4735 default_app = baul_mime_get_default_application_for_files (selection);
4736 }
4737
4738 applications = NULL((void*)0);
4739 if (other_applications_visible) {
4740 applications = baul_mime_get_applications_for_files (selection);
4741 }
4742
4743 if (g_list_length (selection) == 1) {
4744 add_x_content_apps (view, BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
, &applications);
4745 }
4746
4747
4748 num_applications = g_list_length (applications);
4749
4750 if (file_list_all_are_folders (selection)) {
4751 submenu_visible = (num_applications > 2);
4752 } else {
4753 submenu_visible = (num_applications > 3);
4754 }
4755
4756 for (node = applications, index = 0; node != NULL((void*)0); node = node->next, index++) {
4757 GAppInfo *application;
4758 char *menu_path;
4759 char *popup_path;
4760
4761 application = node->data;
4762
4763 if (default_app != NULL((void*)0) && g_app_info_equal (default_app, application)) {
4764 continue;
4765 }
4766
4767 if (submenu_visible) {
4768 menu_path = FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER"/MenuBar/File/Open Placeholder/Open With/Applications Placeholder";
4769 popup_path = FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER"/selection/Open Placeholder/Open With/Applications Placeholder";
4770 } else {
4771 menu_path = FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER"/MenuBar/File/Open Placeholder/Applications Placeholder";
4772 popup_path = FM_DIRECTORY_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER"/selection/Open Placeholder/Applications Placeholder";
4773 }
4774
4775 ctk_ui_manager_add_ui (baul_window_info_get_ui_manager (view->details->window),
4776 view->details->open_with_merge_id,
4777 menu_path,
4778 "separator",
4779 NULL((void*)0),
4780 CTK_UI_MANAGER_SEPARATOR,
4781 FALSE(0));
4782
4783 add_application_to_open_with_menu (view,
4784 node->data,
4785 selection,
4786 index,
4787 menu_path, popup_path, submenu_visible);
4788
4789 }
4790 g_list_free_full (applications, g_object_unref);
4791 if (default_app != NULL((void*)0)) {
4792 g_object_unref (default_app);
4793 }
4794
4795 /* Show open parent folder action if we are in search mode */
4796 if (eel_uri_is_search (fm_directory_view_get_uri (view)) && g_list_length (selection) == 1)
4797 add_parent_folder_to_open_menu (view,
4798 selection,
4799 FM_DIRECTORY_VIEW_MENU_PATH_OPEN"/MenuBar/File/Open Placeholder/Open",
4800 FM_DIRECTORY_VIEW_POPUP_PATH_OPEN"/selection/Open Placeholder/Open");
4801
4802 open_with_chooser_visible = other_applications_visible &&
4803 g_list_length (selection) == 1;
4804
4805 if (submenu_visible) {
4806 action = ctk_action_group_get_action (view->details->dir_action_group,
4807 FM_ACTION_OTHER_APPLICATION1"OtherApplication1");
4808 ctk_action_set_visible (action, open_with_chooser_visible);
4809 action = ctk_action_group_get_action (view->details->dir_action_group,
4810 FM_ACTION_OTHER_APPLICATION2"OtherApplication2");
4811 ctk_action_set_visible (action, FALSE(0));
4812 } else {
4813 action = ctk_action_group_get_action (view->details->dir_action_group,
4814 FM_ACTION_OTHER_APPLICATION1"OtherApplication1");
4815 ctk_action_set_visible (action, FALSE(0));
4816 action = ctk_action_group_get_action (view->details->dir_action_group,
4817 FM_ACTION_OTHER_APPLICATION2"OtherApplication2");
4818 ctk_action_set_visible (action, open_with_chooser_visible);
4819 }
4820}
4821
4822static GList *
4823get_all_extension_menu_items (CtkWidget *window,
4824 GList *selection)
4825{
4826 GList *items;
4827 GList *providers;
4828 GList *l;
4829
4830 providers = baul_extensions_get_for_type (BAUL_TYPE_MENU_PROVIDER(baul_menu_provider_get_type ()));
4831 items = NULL((void*)0);
4832
4833 for (l = providers; l != NULL((void*)0); l = l->next) {
4834 BaulMenuProvider *provider;
4835 GList *file_items;
4836
4837 provider = BAUL_MENU_PROVIDER (l->data)((((BaulMenuProvider*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((l->data)), ((baul_menu_provider_get_type
()))))))
;
4838 file_items = baul_menu_provider_get_file_items (provider,
4839 window,
4840 selection);
4841 items = g_list_concat (items, file_items);
4842 }
4843
4844 baul_module_extension_list_free (providers);
4845
4846 return items;
4847}
4848
4849typedef struct
4850{
4851 BaulMenuItem *item;
4852 FMDirectoryView *view;
4853 GList *selection;
4854 CtkAction *action;
4855} ExtensionActionCallbackData;
4856
4857
4858static void
4859extension_action_callback_data_free (ExtensionActionCallbackData *data)
4860{
4861 g_object_unref (data->item);
4862 baul_file_list_free (data->selection);
4863
4864 g_free (data);
4865}
4866
4867static gboolean
4868search_in_menu_items (GList* items, const char *item_name)
4869{
4870 GList* list;
4871
4872 for (list = items; list != NULL((void*)0); list = list->next) {
4873 BaulMenu* menu;
4874 char *name;
4875
4876 g_object_get (list->data, "name", &name, NULL((void*)0));
4877 if (strcmp (name, item_name) == 0) {
4878 g_free (name);
4879 return TRUE(!(0));
4880 }
4881 g_free (name);
4882
4883 menu = NULL((void*)0);
4884 g_object_get (list->data, "menu", &menu, NULL((void*)0));
4885 if (menu != NULL((void*)0)) {
4886 gboolean ret;
4887 GList* submenus;
4888
4889 submenus = baul_menu_get_items (menu);
4890 ret = search_in_menu_items (submenus, item_name);
4891 baul_menu_item_list_free (submenus);
4892 g_object_unref (menu);
4893 if (ret) {
4894 return TRUE(!(0));
4895 }
4896 }
4897 }
4898 return FALSE(0);
4899}
4900
4901static void
4902extension_action_callback (CtkAction *action,
4903 gpointer callback_data)
4904{
4905 ExtensionActionCallbackData *data;
4906 char *item_name;
4907 gboolean is_valid;
4908 GList *l;
4909 GList *items;
4910
4911 data = callback_data;
4912
4913 /* Make sure the selected menu item is valid for the final sniffed
4914 * mime type */
4915 g_object_get (data->item, "name", &item_name, NULL((void*)0));
4916 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 ()))))))
),
4917 data->selection);
4918
4919 is_valid = search_in_menu_items (items, item_name);
4920
4921 for (l = items; l != NULL((void*)0); l = l->next) {
4922 g_object_unref (l->data);
4923 }
4924 g_list_free (items);
4925
4926 g_free (item_name);
4927
4928 if (is_valid) {
4929 baul_menu_item_activate (data->item);
4930 }
4931}
4932
4933static cairo_surface_t *
4934get_menu_icon (const char *icon_name,
4935 CtkWidget *widget)
4936{
4937 BaulIconInfo *info;
4938 cairo_surface_t *surface;
4939 int size, scale;
4940
4941 size = baul_get_icon_size_for_stock_size (CTK_ICON_SIZE_MENU);
4942 scale = ctk_widget_get_scale_factor (widget);
4943
4944 if (g_path_is_absolute (icon_name)) {
4945 info = baul_icon_info_lookup_from_path (icon_name, size, scale);
4946 } else {
4947 info = baul_icon_info_lookup_from_name (icon_name, size, scale);
4948 }
4949 surface = baul_icon_info_get_surface_nodefault_at_size (info, size);
4950 g_object_unref (info);
4951
4952 return surface;
4953}
4954
4955static cairo_surface_t *
4956get_menu_icon_for_file (BaulFile *file,
4957 CtkWidget *widget)
4958{
4959 BaulIconInfo *info;
4960 cairo_surface_t *surface;
4961 int size, scale;
4962
4963 size = baul_get_icon_size_for_stock_size (CTK_ICON_SIZE_MENU);
4964 scale = ctk_widget_get_scale_factor (widget);
4965
4966 info = baul_file_get_icon (file, size, scale, 0);
4967 surface = baul_icon_info_get_surface_nodefault_at_size (info, size);
4968 g_object_unref (info);
4969
4970 return surface;
4971}
4972
4973static CtkAction *
4974add_extension_action_for_files (FMDirectoryView *view,
4975 BaulMenuItem *item,
4976 GList *files)
4977{
4978 char *name, *label, *tip, *icon;
4979 gboolean sensitive, priority;
4980 CtkAction *action;
4981 ExtensionActionCallbackData *data;
4982
4983 g_object_get (G_OBJECT (item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((item)), (((GType) ((20) << (2))))))))
,
4984 "name", &name, "label", &label,
4985 "tip", &tip, "icon", &icon,
4986 "sensitive", &sensitive,
4987 "priority", &priority,
4988 NULL((void*)0));
4989
4990 action = ctk_action_new (name,
4991 label,
4992 tip,
4993 icon);
4994
4995 if (icon != NULL((void*)0)) {
4996 cairo_surface_t *surface;
4997
4998 surface = get_menu_icon (icon, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
);
4999
5000 if (surface != NULL((void*)0)) {
5001 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "menu-icon",
5002 surface,
5003 (GDestroyNotify)cairo_surface_destroy);
5004 }
5005 }
5006
5007 ctk_action_set_sensitive (action, sensitive);
5008 g_object_set (action, "is-important", priority, NULL((void*)0));
5009
5010 data = g_new0 (ExtensionActionCallbackData, 1)((ExtensionActionCallbackData *) g_malloc0_n ((1), sizeof (ExtensionActionCallbackData
)))
;
5011 data->item = g_object_ref (item)((__typeof__ (item)) (g_object_ref) (item));
5012 data->view = view;
5013 data->selection = baul_file_list_copy (files);
5014 data->action = action;
5015
5016 g_signal_connect_data (action, "activate",
5017 G_CALLBACK (extension_action_callback)((GCallback) (extension_action_callback)),
5018 data,
5019 (GClosureNotify)extension_action_callback_data_free, 0);
5020
5021 ctk_action_group_add_action (view->details->extensions_menu_action_group,
5022 CTK_ACTION (action)((((CtkAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((ctk_action_get_type ()))))))
);
5023 g_object_unref (action);
5024
5025 g_free (name);
5026 g_free (label);
5027 g_free (tip);
5028 g_free (icon);
5029
5030 return action;
5031}
5032
5033static void
5034add_extension_menu_items (FMDirectoryView *view,
5035 GList *files,
5036 GList *menu_items,
5037 const char *subdirectory)
5038{
5039 CtkUIManager *ui_manager;
5040 GList *l;
5041
5042 ui_manager = baul_window_info_get_ui_manager (view->details->window);
5043
5044 for (l = menu_items; l; l = l->next) {
5045 BaulMenuItem *item;
5046 BaulMenu *menu;
5047 CtkAction *action;
5048 const gchar *action_name;
5049 char *path;
5050
5051 item = BAUL_MENU_ITEM (l->data)((((BaulMenuItem*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), ((baul_menu_item_get_type()))))))
;
5052
5053 g_object_get (item, "menu", &menu, NULL((void*)0));
5054
5055 action = add_extension_action_for_files (view, item, files);
5056
5057 path = g_build_path ("/", FM_DIRECTORY_VIEW_POPUP_PATH_EXTENSION_ACTIONS"/selection/Extension Actions", subdirectory, NULL((void*)0));
5058 action_name = ctk_action_get_name (action);
5059
5060 ctk_ui_manager_add_ui (ui_manager,
5061 view->details->extensions_menu_merge_id,
5062 path,
5063 action_name,
5064 action_name,
5065 (menu != NULL((void*)0)) ? CTK_UI_MANAGER_MENU : CTK_UI_MANAGER_MENUITEM,
5066 FALSE(0));
5067 g_free (path);
5068
5069 path = g_build_path ("/", FM_DIRECTORY_VIEW_MENU_PATH_EXTENSION_ACTIONS_PLACEHOLDER"/MenuBar/Edit/Extension Actions", subdirectory, NULL((void*)0));
5070 ctk_ui_manager_add_ui (ui_manager,
5071 view->details->extensions_menu_merge_id,
5072 path,
5073 action_name,
5074 action_name,
5075 (menu != NULL((void*)0)) ? CTK_UI_MANAGER_MENU : CTK_UI_MANAGER_MENUITEM,
5076 FALSE(0));
5077 g_free (path);
5078
5079 /* recursively fill the menu */
5080 if (menu != NULL((void*)0)) {
5081 char *subdir;
5082 GList *children;
5083
5084 children = baul_menu_get_items (menu);
5085
5086 subdir = g_build_path ("/", subdirectory, ctk_action_get_name (action), NULL((void*)0));
5087 add_extension_menu_items (view,
5088 files,
5089 children,
5090 subdir);
5091
5092 baul_menu_item_list_free (children);
5093 g_free (subdir);
5094 }
5095 }
5096}
5097
5098static void
5099reset_extension_actions_menu (FMDirectoryView *view, GList *selection)
5100{
5101 GList *items;
5102 CtkUIManager *ui_manager;
5103
5104 /* Clear any previous inserted items in the extension actions placeholder */
5105 ui_manager = baul_window_info_get_ui_manager (view->details->window);
5106
5107 baul_ui_unmerge_ui (ui_manager,
5108 &view->details->extensions_menu_merge_id,
5109 &view->details->extensions_menu_action_group);
5110
5111 baul_ui_prepare_merge_ui (ui_manager,
5112 "DirExtensionsMenuGroup",
5113 &view->details->extensions_menu_merge_id,
5114 &view->details->extensions_menu_action_group);
5115
5116 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 ()))))))
),
5117 selection);
5118 if (items != NULL((void*)0)) {
5119 add_extension_menu_items (view, selection, items, "");
5120
5121 g_list_free_full (items, g_object_unref);
5122 }
5123}
5124
5125static char *
5126change_to_view_directory (FMDirectoryView *view)
5127{
5128 char *path;
5129 char *old_path;
5130
5131 old_path = g_get_current_dir ();
5132
5133 path = get_view_directory (view);
5134
5135 /* FIXME: What to do about non-local directories? */
5136 if (path != NULL((void*)0)) {
5137 g_chdir (path);
5138 }
5139
5140 g_free (path);
5141
5142 return old_path;
5143}
5144
5145static char **
5146get_file_names_as_parameter_array (GList *selection,
5147 BaulDirectory *model)
5148{
5149 char **parameters;
5150 GList *node;
5151 GFile *model_location;
5152 int i;
5153 BaulFile *file = NULL((void*)0);
5154 GFile *file_location = NULL((void*)0);
5155
5156 if (model == NULL((void*)0)) {
5157 return NULL((void*)0);
5158 }
5159
5160 parameters = g_new (char *, g_list_length (selection) + 1)((char * *) g_malloc_n ((g_list_length (selection) + 1), sizeof
(char *)))
;
5161
5162 model_location = baul_directory_get_location (model);
5163
5164 for (node = selection, i = 0; node != NULL((void*)0); node = node->next, i++) {
5165 file = BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((node->data)), (baul_file_get_type())))))
;
5166
5167 if (!baul_file_is_local (file)) {
5168 parameters[i] = NULL((void*)0);
5169 g_strfreev (parameters);
5170 return NULL((void*)0);
5171 }
5172
5173 file_location = baul_file_get_location (BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((node->data)), (baul_file_get_type())))))
);
5174 parameters[i] = g_file_get_relative_path (model_location, file_location);
5175 if (parameters[i] == NULL((void*)0)) {
5176 parameters[i] = g_file_get_path (file_location);
5177 }
5178 g_object_unref (file_location);
5179 }
5180
5181 g_object_unref (model_location);
5182
5183 parameters[i] = NULL((void*)0);
5184 return parameters;
5185}
5186
5187static char *
5188get_file_paths_or_uris_as_newline_delimited_string (GList *selection, gboolean get_paths)
5189{
5190 char *path;
5191 char *result;
5192 BaulDesktopLink *link;
5193 GString *expanding_string;
5194 GList *node;
5195 GFile *location;
5196
5197 expanding_string = g_string_new ("");
5198 for (node = selection; node != NULL((void*)0); node = node->next) {
5199 char *uri;
5200
5201 uri = NULL((void*)0);
5202
5203 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; }))))
) {
5204 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
())))))
);
5205 if (link != NULL((void*)0)) {
5206 location = baul_desktop_link_get_activation_location (link);
5207 uri = g_file_get_uri (location);
5208 g_object_unref (location);
5209 g_object_unref (G_OBJECT (link)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((link)), (((GType) ((20) << (2))))))))
);
5210 }
5211 } else {
5212 uri = baul_file_get_uri (BAUL_FILE (node->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((node->data)), (baul_file_get_type())))))
);
5213 }
5214 if (uri == NULL((void*)0)) {
5215 continue;
5216 }
5217
5218 if (get_paths) {
5219 path = g_filename_from_uri (uri, NULL((void*)0), NULL((void*)0));
5220 if (path != NULL((void*)0)) {
5221 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))
;
5222 g_free (path);
5223 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))
;
5224 }
5225 } else {
5226 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))
;
5227 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))
;
5228 }
5229 g_free (uri);
5230 }
5231
5232 result = expanding_string->str;
5233 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))))
;
5234
5235 return result;
5236}
5237
5238static char *
5239get_file_paths_as_newline_delimited_string (GList *selection)
5240{
5241 return get_file_paths_or_uris_as_newline_delimited_string (selection, TRUE(!(0)));
5242}
5243
5244static char *
5245get_file_uris_as_newline_delimited_string (GList *selection)
5246{
5247 return get_file_paths_or_uris_as_newline_delimited_string (selection, FALSE(0));
5248}
5249
5250/* returns newly allocated strings for setting the environment variables */
5251static void
5252get_strings_for_environment_variables (FMDirectoryView *view, GList *selected_files,
5253 char **file_paths, char **uris, char **uri)
5254{
5255 char *directory_uri;
5256
5257 /* We need to check that the directory uri starts with "file:" since
5258 * baul_directory_is_local returns FALSE for nfs.
5259 */
5260 directory_uri = baul_directory_get_uri (view->details->model);
5261 if (eel_str_has_prefix (directory_uri, "file:") ||
5262 eel_uri_is_desktop (directory_uri) ||
5263 eel_uri_is_trash (directory_uri)) {
5264 *file_paths = get_file_paths_as_newline_delimited_string (selected_files);
5265 } else {
5266 *file_paths = g_strdup ("")g_strdup_inline ("");
5267 }
5268 g_free (directory_uri);
5269
5270 *uris = get_file_uris_as_newline_delimited_string (selected_files);
5271
5272 *uri = baul_directory_get_uri (view->details->model);
5273 if (eel_uri_is_desktop (*uri)) {
5274 g_free (*uri);
5275 *uri = baul_get_desktop_directory_uri ();
5276 }
5277}
5278
5279static FMDirectoryView *
5280get_directory_view_of_extra_pane (FMDirectoryView *view)
5281{
5282 BaulWindowSlotInfo *slot;
5283
5284 slot = baul_window_info_get_extra_slot (fm_directory_view_get_baul_window (view));
5285 if (slot != NULL((void*)0)) {
5286 BaulView *next_view;
5287
5288 next_view = baul_window_slot_info_get_current_view (slot);
5289
5290 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; }))))
) {
5291 return FM_DIRECTORY_VIEW (next_view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((next_view)), (fm_directory_view_get_type())))))
;
5292 }
5293 }
5294 return NULL((void*)0);
5295}
5296
5297/*
5298 * Set up some environment variables that scripts can use
5299 * to take advantage of the current Baul state.
5300 */
5301static void set_script_environment_variables(FMDirectoryView* view, GList* selected_files)
5302{
5303 char* file_paths;
5304 char* uris;
5305 char* uri;
5306 char* geometry_string;
5307 FMDirectoryView* next_view;
5308
5309 get_strings_for_environment_variables(view, selected_files, &file_paths, &uris, &uri);
5310
5311 g_setenv("BAUL_SCRIPT_SELECTED_FILE_PATHS", file_paths, TRUE(!(0)));
5312 g_setenv("NAUTILUS_SCRIPT_SELECTED_FILE_PATHS", file_paths, TRUE(!(0))); // compatibilidad GNOME
5313
5314 g_free(file_paths);
5315
5316 g_setenv("BAUL_SCRIPT_SELECTED_URIS", uris, TRUE(!(0)));
5317 g_setenv("NAUTILUS_SCRIPT_SELECTED_URIS", uris, TRUE(!(0))); // compatibilidad GNOME
5318
5319 g_free(uris);
5320
5321 g_setenv("BAUL_SCRIPT_CURRENT_URI", uri, TRUE(!(0)));
5322 g_setenv("NAUTILUS_SCRIPT_CURRENT_URI", uri, TRUE(!(0))); // compatibilidad GNOME
5323
5324
5325 g_free(uri);
5326
5327 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
()))))))
);
5328
5329 g_setenv("BAUL_SCRIPT_WINDOW_GEOMETRY", geometry_string, TRUE(!(0)));
5330 g_setenv("NAUTILUS_SCRIPT_WINDOW_GEOMETRY", geometry_string, TRUE(!(0))); // compatibilidad GNOME
5331
5332 g_free(geometry_string);
5333
5334 /* next pane */
5335 next_view = get_directory_view_of_extra_pane(view);
5336
5337 if (next_view)
5338 {
5339 GList* next_pane_selected_files = fm_directory_view_get_selection (next_view);
5340
5341 get_strings_for_environment_variables(next_view, next_pane_selected_files, &file_paths, &uris, &uri);
5342
5343 baul_file_list_free(next_pane_selected_files);
5344 }
5345 else
5346 {
5347 file_paths = g_strdup("")g_strdup_inline ("");
5348 uris = g_strdup("")g_strdup_inline ("");
5349 uri = g_strdup("")g_strdup_inline ("");
5350 }
5351
5352 g_setenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS", file_paths, TRUE(!(0)));
5353 g_setenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS", file_paths, TRUE(!(0))); // compatibilidad GNOME
5354 g_free(file_paths);
5355
5356 g_setenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS", uris, TRUE(!(0)));
5357 g_setenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_URIS", uris, TRUE(!(0))); // compatibilidad GNOME
5358 g_free(uris);
5359
5360 g_setenv("BAUL_SCRIPT_NEXT_PANE_CURRENT_URI", uri, TRUE(!(0)));
5361 g_setenv("NAUTILUS_SCRIPT_NEXT_PANE_CURRENT_URI", uri, TRUE(!(0))); // compatibilidad GNOME
5362 g_free(uri);
5363}
5364
5365/* Unset all the special script environment variables. */
5366static void unset_script_environment_variables(void)
5367{
5368 g_unsetenv("BAUL_SCRIPT_SELECTED_FILE_PATHS");
5369 g_unsetenv("NAUTILUS_SCRIPT_SELECTED_FILE_PATHS");
5370
5371 g_unsetenv("BAUL_SCRIPT_SELECTED_URIS");
5372 g_unsetenv("NAUTILUS_SCRIPT_SELECTED_URIS");
5373
5374 g_unsetenv("BAUL_SCRIPT_CURRENT_URI");
5375 g_unsetenv("NAUTILUS_SCRIPT_CURRENT_URI");
5376
5377 g_unsetenv("BAUL_SCRIPT_WINDOW_GEOMETRY");
5378 g_unsetenv("NAUTILUS_SCRIPT_WINDOW_GEOMETRY");
5379
5380 g_unsetenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS");
5381 g_unsetenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS");
5382
5383 g_unsetenv("BAUL_SCRIPT_NEXT_PANE_SELECTED_URIS");
5384 g_unsetenv("NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_URIS");
5385
5386 g_unsetenv("BAUL_SCRIPT_NEXT_PANE_CURRENT_URI");
5387 g_unsetenv("NAUTILUS_SCRIPT_NEXT_PANE_CURRENT_URI");
5388}
5389
5390static void
5391run_script_callback (CtkAction *action, gpointer callback_data)
5392{
5393 ScriptLaunchParameters *launch_parameters;
5394 CdkScreen *screen;
5395 GList *selected_files;
5396 char *file_uri;
5397 char *local_file_path;
5398 char *quoted_path;
5399 char *old_working_dir;
5400 char **parameters, *name;
5401 CtkWindow *window;
5402
5403 launch_parameters = (ScriptLaunchParameters *) callback_data;
5404
5405 file_uri = baul_file_get_uri (launch_parameters->file);
5406 local_file_path = g_filename_from_uri (file_uri, NULL((void*)0), NULL((void*)0));
5407 g_assert (local_file_path != NULL)do { if (local_file_path != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 5407, ((const char*) (
__func__)), "local_file_path != NULL"); } while (0)
;
5408 g_free (file_uri);
5409
5410 quoted_path = g_shell_quote (local_file_path);
5411
5412 old_working_dir = change_to_view_directory (launch_parameters->directory_view);
5413
5414 selected_files = fm_directory_view_get_selection (launch_parameters->directory_view);
5415 set_script_environment_variables (launch_parameters->directory_view, selected_files);
5416
5417 parameters = get_file_names_as_parameter_array (selected_files,
5418 launch_parameters->directory_view->details->model);
5419
5420 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
()))))))
);
5421
5422 name = baul_file_get_name (launch_parameters->file);
5423 /* FIXME: handle errors with dialog? Or leave up to each script? */
5424 window = fm_directory_view_get_containing_window (launch_parameters->directory_view);
5425 baul_debug_log (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER",
5426 "directory view run_script_callback, window=%p, name=\"%s\", script_path=\"%s\" (omitting script parameters)",
5427 window, name, local_file_path);
5428 baul_launch_application_from_command_array (screen, name, quoted_path, FALSE(0),
5429 (const char * const *) parameters);
5430 g_free (local_file_path);
5431 g_free (name);
5432 g_strfreev (parameters);
5433
5434 baul_file_list_free (selected_files);
5435 unset_script_environment_variables ();
5436 g_chdir (old_working_dir);
5437 g_free (old_working_dir);
5438 g_free (quoted_path);
5439}
5440
5441static void
5442add_script_to_scripts_menus (FMDirectoryView *directory_view,
5443 BaulFile *file,
5444 const char *menu_path,
5445 const char *popup_path,
5446 const char *popup_bg_path)
5447{
5448 ScriptLaunchParameters *launch_parameters;
5449 char *tip;
5450 char *name;
5451 char *uri;
5452 char *action_name;
5453 char *escaped_label;
5454 cairo_surface_t *surface;
5455 CtkUIManager *ui_manager;
5456 CtkAction *action;
5457
5458 name = baul_file_get_display_name (file);
5459 uri = baul_file_get_uri (file);
5460 tip = g_strdup_printf (_("Run \"%s\" on any selected items")gettext ("Run \"%s\" on any selected items"), name);
5461
5462 launch_parameters = script_launch_parameters_new (file, directory_view);
5463
5464 action_name = escape_action_name (uri, "script_");
5465 escaped_label = eel_str_double_underscores (name);
5466
5467 action = ctk_action_new (action_name,
5468 escaped_label,
5469 tip,
5470 NULL((void*)0));
5471
5472 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 ()))))))
);
5473 if (surface != NULL((void*)0)) {
5474 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "menu-icon",
5475 surface,
5476 (GDestroyNotify)cairo_surface_destroy);
5477 }
5478
5479 g_signal_connect_data (action, "activate",
5480 G_CALLBACK (run_script_callback)((GCallback) (run_script_callback)),
5481 launch_parameters,
5482 (GClosureNotify)script_launch_parameters_free, 0);
5483
5484 ctk_action_group_add_action_with_accel (directory_view->details->scripts_action_group,
5485 action, NULL((void*)0));
5486 g_object_unref (action);
5487
5488 ui_manager = baul_window_info_get_ui_manager (directory_view->details->window);
5489
5490 ctk_ui_manager_add_ui (ui_manager,
5491 directory_view->details->scripts_merge_id,
5492 menu_path,
5493 action_name,
5494 action_name,
5495 CTK_UI_MANAGER_MENUITEM,
5496 FALSE(0));
5497 ctk_ui_manager_add_ui (ui_manager,
5498 directory_view->details->scripts_merge_id,
5499 popup_path,
5500 action_name,
5501 action_name,
5502 CTK_UI_MANAGER_MENUITEM,
5503 FALSE(0));
5504 ctk_ui_manager_add_ui (ui_manager,
5505 directory_view->details->scripts_merge_id,
5506 popup_bg_path,
5507 action_name,
5508 action_name,
5509 CTK_UI_MANAGER_MENUITEM,
5510 FALSE(0));
5511
5512 g_free (name);
5513 g_free (uri);
5514 g_free (tip);
5515 g_free (action_name);
5516 g_free (escaped_label);
5517}
5518
5519static void
5520add_submenu_to_directory_menus (FMDirectoryView *directory_view,
5521 CtkActionGroup *action_group,
5522 guint merge_id,
5523 BaulFile *file,
5524 const char *menu_path,
5525 const char *popup_path,
5526 const char *popup_bg_path)
5527{
5528 char *name;
5529 cairo_surface_t *surface;
5530 char *uri;
5531 CtkUIManager *ui_manager;
5532
5533 ui_manager = baul_window_info_get_ui_manager (directory_view->details->window);
5534 uri = baul_file_get_uri (file);
5535 name = baul_file_get_display_name (file);
5536 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 ()))))))
);
5537 add_submenu (ui_manager, action_group, merge_id, menu_path, uri, name, surface, TRUE(!(0)));
5538 add_submenu (ui_manager, action_group, merge_id, popup_path, uri, name, surface, FALSE(0));
5539 add_submenu (ui_manager, action_group, merge_id, popup_bg_path, uri, name, surface, FALSE(0));
5540 if (surface) {
5541 cairo_surface_destroy (surface);
5542 }
5543 g_free (name);
5544 g_free (uri);
5545}
5546
5547static gboolean
5548directory_belongs_in_scripts_menu (const char *uri)
5549{
5550 int num_levels;
5551 int i;
5552
5553 if (!eel_str_has_prefix (uri, scripts_directory_uri)) {
5554 return FALSE(0);
5555 }
5556
5557 num_levels = 0;
5558 for (i = scripts_directory_uri_length; uri[i] != '\0'; i++) {
5559 if (uri[i] == '/') {
5560 num_levels++;
5561 }
5562 }
5563
5564 if (num_levels > MAX_MENU_LEVELS5) {
5565 return FALSE(0);
5566 }
5567
5568 return TRUE(!(0));
5569}
5570
5571static gboolean
5572update_directory_in_scripts_menu (FMDirectoryView *view, BaulDirectory *directory)
5573{
5574 char *menu_path, *popup_path, *popup_bg_path;
5575 GList *file_list, *filtered, *node;
5576 gboolean any_scripts;
5577 BaulDirectory *dir;
5578 char *uri;
5579 char *escaped_path;
5580 BaulFile *file = NULL((void*)0);
5581
5582 uri = baul_directory_get_uri (directory);
5583 escaped_path = escape_action_path (uri + scripts_directory_uri_length);
5584 g_free (uri);
5585 menu_path = g_strconcat (FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER"/MenuBar/File/Open Placeholder/Scripts/Scripts Placeholder",
5586 escaped_path,
5587 NULL((void*)0));
5588 popup_path = g_strconcat (FM_DIRECTORY_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER"/selection/Open Placeholder/Scripts/Scripts Placeholder",
5589 escaped_path,
5590 NULL((void*)0));
5591 popup_bg_path = g_strconcat (FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND_SCRIPTS_PLACEHOLDER"/background/Before Zoom Items/New Object Items/Scripts/Scripts Placeholder",
5592 escaped_path,
5593 NULL((void*)0));
5594 g_free (escaped_path);
5595
5596 file_list = baul_directory_get_file_list (directory);
5597 filtered = baul_file_list_filter_hidden (file_list, FALSE(0));
5598 baul_file_list_free (file_list);
5599
5600 file_list = baul_file_list_sort_by_display_name (filtered);
5601
5602 any_scripts = FALSE(0);
5603 for (node = file_list; node != NULL((void*)0); node = node->next) {
5604 file = node->data;
5605
5606 if (baul_file_is_launchable (file)) {
5607 add_script_to_scripts_menus (view, file, menu_path, popup_path, popup_bg_path);
5608 any_scripts = TRUE(!(0));
5609 } else if (baul_file_is_directory (file)) {
5610 uri = baul_file_get_uri (file);
5611 if (directory_belongs_in_scripts_menu (uri)) {
5612 dir = baul_directory_get_by_uri (uri);
5613 add_directory_to_scripts_directory_list (view, dir);
5614 baul_directory_unref (dir);
5615
5616 add_submenu_to_directory_menus (view,
5617 view->details->scripts_action_group,
5618 view->details->scripts_merge_id,
5619 file, menu_path, popup_path, popup_bg_path);
5620
5621 any_scripts = TRUE(!(0));
5622 }
5623 g_free (uri);
5624 }
5625 }
5626
5627 baul_file_list_free (file_list);
5628
5629 g_free (popup_path);
5630 g_free (popup_bg_path);
5631 g_free (menu_path);
5632
5633 return any_scripts;
5634}
5635
5636static void
5637update_scripts_menu (FMDirectoryView *view)
5638{
5639 gboolean any_scripts;
5640 GList *sorted_copy, *node;
5641 CtkUIManager *ui_manager;
5642 CtkAction *action;
5643 BaulDirectory *directory = NULL((void*)0);
5644
5645 /* There is a race condition here. If we don't mark the scripts menu as
5646 valid before we begin our task then we can lose script menu updates that
5647 occur before we finish. */
5648 view->details->scripts_invalid = FALSE(0);
5649
5650 ui_manager = baul_window_info_get_ui_manager (view->details->window);
5651 baul_ui_unmerge_ui (ui_manager,
5652 &view->details->scripts_merge_id,
5653 &view->details->scripts_action_group);
5654
5655 baul_ui_prepare_merge_ui (ui_manager,
5656 "ScriptsGroup",
5657 &view->details->scripts_merge_id,
5658 &view->details->scripts_action_group);
5659
5660 /* As we walk through the directories, remove any that no longer belong. */
5661 any_scripts = FALSE(0);
5662 sorted_copy = baul_directory_list_sort_by_uri
5663 (baul_directory_list_copy (view->details->scripts_directory_list));
5664 for (node = sorted_copy; node != NULL((void*)0); node = node->next) {
5665 char *uri;
5666
5667 directory = node->data;
5668
5669 uri = baul_directory_get_uri (directory);
5670 if (!directory_belongs_in_scripts_menu (uri)) {
5671 remove_directory_from_scripts_directory_list (view, directory);
5672 } else if (update_directory_in_scripts_menu (view, directory)) {
5673 any_scripts = TRUE(!(0));
5674 }
5675 g_free (uri);
5676 }
5677 baul_directory_list_free (sorted_copy);
5678
5679 action = ctk_action_group_get_action (view->details->dir_action_group, FM_ACTION_SCRIPTS"Scripts");
5680 ctk_action_set_visible (action, any_scripts);
5681}
5682
5683static void
5684create_template_callback (CtkAction *action, gpointer callback_data)
5685{
5686 CreateTemplateParameters *parameters;
5687
5688 parameters = callback_data;
5689
5690 fm_directory_view_new_file (parameters->directory_view, NULL((void*)0), parameters->file);
5691}
5692
5693static void
5694add_template_to_templates_menus (FMDirectoryView *directory_view,
5695 BaulFile *file,
5696 const char *menu_path,
5697 const char *popup_bg_path)
5698{
5699 char *tmp, *tip, *uri, *name;
5700 char *escaped_label;
5701 cairo_surface_t *surface;
5702 char *action_name;
5703 CreateTemplateParameters *parameters;
5704 CtkUIManager *ui_manager;
5705 CtkAction *action;
5706
5707 tmp = baul_file_get_display_name (file);
5708 name = eel_filename_strip_extension (tmp);
5709 g_free (tmp);
5710
5711 uri = baul_file_get_uri (file);
5712 tip = g_strdup_printf (_("Create Document from template \"%s\"")gettext ("Create Document from template \"%s\""), name);
5713
5714 action_name = escape_action_name (uri, "template_");
5715 escaped_label = eel_str_double_underscores (name);
5716
5717 parameters = create_template_parameters_new (file, directory_view);
5718
5719 action = ctk_action_new (action_name,
5720 escaped_label,
5721 tip,
5722 NULL((void*)0));
5723
5724 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 ()))))))
);
5725 if (surface != NULL((void*)0)) {
5726 g_object_set_data_full (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
, "menu-icon",
5727 surface,
5728 (GDestroyNotify)cairo_surface_destroy);
5729 }
5730
5731 g_signal_connect_data (action, "activate",
5732 G_CALLBACK (create_template_callback)((GCallback) (create_template_callback)),
5733 parameters,
5734 (GClosureNotify)create_templates_parameters_free, 0);
5735
5736 ctk_action_group_add_action (directory_view->details->templates_action_group,
5737 action);
5738 g_object_unref (action);
5739
5740 ui_manager = baul_window_info_get_ui_manager (directory_view->details->window);
5741
5742 ctk_ui_manager_add_ui (ui_manager,
5743 directory_view->details->templates_merge_id,
5744 menu_path,
5745 action_name,
5746 action_name,
5747 CTK_UI_MANAGER_MENUITEM,
5748 FALSE(0));
5749
5750 ctk_ui_manager_add_ui (ui_manager,
5751 directory_view->details->templates_merge_id,
5752 popup_bg_path,
5753 action_name,
5754 action_name,
5755 CTK_UI_MANAGER_MENUITEM,
5756 FALSE(0));
5757
5758 g_free (escaped_label);
5759 g_free (name);
5760 g_free (tip);
5761 g_free (uri);
5762 g_free (action_name);
5763}
5764
5765static void
5766update_templates_directory (FMDirectoryView *view)
5767{
5768 GList *node, *next;
5769
5770 for (node = view->details->templates_directory_list; node != NULL((void*)0); node = next) {
5771 next = node->next;
5772 remove_directory_from_templates_directory_list (view, node->data);
5773 }
5774
5775 if (baul_should_use_templates_directory ()) {
5776 BaulDirectory *templates_directory;
5777 char *templates_uri;
5778
5779 templates_uri = baul_get_templates_directory_uri ();
5780 templates_directory = baul_directory_get_by_uri (templates_uri);
5781 g_free (templates_uri);
5782 add_directory_to_templates_directory_list (view, templates_directory);
5783 baul_directory_unref (templates_directory);
5784 }
5785}
5786
5787static void
5788user_dirs_changed (FMDirectoryView *view)
5789{
5790 update_templates_directory (view);
5791 view->details->templates_invalid = TRUE(!(0));
5792 schedule_update_menus (view);
5793}
5794
5795static gboolean
5796directory_belongs_in_templates_menu (const char *templates_directory_uri,
5797 const char *uri)
5798{
5799 int num_levels;
5800 int i;
5801
5802 if (templates_directory_uri == NULL((void*)0)) {
5803 return FALSE(0);
5804 }
5805
5806 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
) )
) {
5807 return FALSE(0);
5808 }
5809
5810 num_levels = 0;
5811 for (i = strlen (templates_directory_uri); uri[i] != '\0'; i++) {
5812 if (uri[i] == '/') {
5813 num_levels++;
5814 }
5815 }
5816
5817 if (num_levels > MAX_MENU_LEVELS5) {
5818 return FALSE(0);
5819 }
5820
5821 return TRUE(!(0));
5822}
5823
5824static gboolean
5825update_directory_in_templates_menu (FMDirectoryView *view,
5826 const char *templates_directory_uri,
5827 BaulDirectory *directory)
5828{
5829 char *menu_path, *popup_bg_path;
5830 GList *file_list, *filtered, *node;
5831 gboolean any_templates;
5832 BaulDirectory *dir;
5833 char *escaped_path;
5834 char *uri;
5835 int num;
5836 BaulFile *file = NULL((void*)0);
5837
5838 /* We know this directory belongs to the template dir, so it must exist */
5839 g_assert (templates_directory_uri)do { if (templates_directory_uri) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 5839, ((const char*) (
__func__)), "templates_directory_uri"); } while (0)
;
5840
5841 uri = baul_directory_get_uri (directory);
5842 escaped_path = escape_action_path (uri + strlen (templates_directory_uri));
5843 g_free (uri);
5844 menu_path = g_strconcat (FM_DIRECTORY_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER"/MenuBar/File/New Items Placeholder/New Documents/New Documents Placeholder",
5845 escaped_path,
5846 NULL((void*)0));
5847 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",
5848 escaped_path,
5849 NULL((void*)0));
5850 g_free (escaped_path);
5851
5852 file_list = baul_directory_get_file_list (directory);
5853 filtered = baul_file_list_filter_hidden (file_list, FALSE(0));
5854 baul_file_list_free (file_list);
5855
5856 file_list = baul_file_list_sort_by_display_name (filtered);
5857
5858 num = 0;
5859 any_templates = FALSE(0);
5860 for (node = file_list; num < TEMPLATE_LIMIT30 && node != NULL((void*)0); node = node->next, num++) {
5861 file = node->data;
5862
5863 if (baul_file_is_directory (file)) {
5864 uri = baul_file_get_uri (file);
5865 if (directory_belongs_in_templates_menu (templates_directory_uri, uri)) {
5866 dir = baul_directory_get_by_uri (uri);
5867 add_directory_to_templates_directory_list (view, dir);
5868 baul_directory_unref (dir);
5869
5870 add_submenu_to_directory_menus (view,
5871 view->details->templates_action_group,
5872 view->details->templates_merge_id,
5873 file, menu_path, NULL((void*)0), popup_bg_path);
5874
5875 any_templates = TRUE(!(0));
5876 }
5877 g_free (uri);
5878 } else if (baul_file_can_read (file)) {
5879 add_template_to_templates_menus (view, file, menu_path, popup_bg_path);
5880 any_templates = TRUE(!(0));
5881 }
5882 }
5883
5884 baul_file_list_free (file_list);
5885
5886 g_free (popup_bg_path);
5887 g_free (menu_path);
5888
5889 return any_templates;
5890}
5891
5892
5893
5894static void
5895update_templates_menu (FMDirectoryView *view)
5896{
5897 gboolean any_templates;
5898 GList *sorted_copy, *node;
5899 CtkUIManager *ui_manager;
5900 CtkAction *action;
5901 char *templates_directory_uri;
5902 BaulDirectory *directory = NULL((void*)0);
5903
5904 if (baul_should_use_templates_directory ()) {
5905 templates_directory_uri = baul_get_templates_directory_uri ();
5906 } else {
5907 templates_directory_uri = NULL((void*)0);
5908 }
5909
5910 /* There is a race condition here. If we don't mark the scripts menu as
5911 valid before we begin our task then we can lose template menu updates that
5912 occur before we finish. */
5913 view->details->templates_invalid = FALSE(0);
5914
5915 ui_manager = baul_window_info_get_ui_manager (view->details->window);
5916 baul_ui_unmerge_ui (ui_manager,
5917 &view->details->templates_merge_id,
5918 &view->details->templates_action_group);
5919
5920 baul_ui_prepare_merge_ui (ui_manager,
5921 "TemplatesGroup",
5922 &view->details->templates_merge_id,
5923 &view->details->templates_action_group);
5924
5925 /* As we walk through the directories, remove any that no longer belong. */
5926 any_templates = FALSE(0);
5927 sorted_copy = baul_directory_list_sort_by_uri
5928 (baul_directory_list_copy (view->details->templates_directory_list));
5929 for (node = sorted_copy; node != NULL((void*)0); node = node->next) {
5930 char *uri;
5931
5932 directory = node->data;
5933
5934 uri = baul_directory_get_uri (directory);
5935 if (!directory_belongs_in_templates_menu (templates_directory_uri, uri)) {
5936 remove_directory_from_templates_directory_list (view, directory);
5937 } else if (update_directory_in_templates_menu (view,
5938 templates_directory_uri,
5939 directory)) {
5940 any_templates = TRUE(!(0));
5941 }
5942 g_free (uri);
5943 }
5944 baul_directory_list_free (sorted_copy);
5945
5946 action = ctk_action_group_get_action (view->details->dir_action_group, FM_ACTION_NO_TEMPLATES"No Templates");
5947 ctk_action_set_visible (action, !any_templates);
5948
5949 g_free (templates_directory_uri);
5950}
5951
5952
5953static void
5954action_open_scripts_folder_callback (CtkAction *action,
5955 gpointer callback_data)
5956{
5957 FMDirectoryView *view;
5958
5959 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
5960
5961 open_location (view, scripts_directory_uri, BAUL_WINDOW_OPEN_ACCORDING_TO_MODE, 0);
5962
5963 eel_show_info_dialog_with_details
5964 (_("All executable files in this folder will appear in the "gettext ("All executable files in this folder will appear in the "
"Scripts menu.")
5965 "Scripts menu.")gettext ("All executable files in this folder will appear in the "
"Scripts menu.")
,
5966 _("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."
)
5967 "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."
)
,
5968 _("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"
)
5969 "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"
)
5970 "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"
)
5971 "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"
)
5972 "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"
)
5973 "(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"
)
5974 "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"
)
5975 "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"
)
5976 "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"
)
5977 "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"
)
5978 "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"
)
5979 "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"
)
5980 "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"
)
5981 "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"
)
5982 "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"
)
5983 "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"
)
,
5984 fm_directory_view_get_containing_window (view));
5985}
5986
5987static CtkMenu *
5988create_popup_menu (FMDirectoryView *view, const char *popup_path)
5989{
5990 CtkWidget *menu;
5991
5992 menu = ctk_ui_manager_get_widget (baul_window_info_get_ui_manager (view->details->window),
5993 popup_path);
5994 ctk_menu_set_screen (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
,
5995 ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
));
5996 ctk_widget_show (CTK_WIDGET (menu)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_widget_get_type ()))))))
);
5997
5998 return CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu)), ((ctk_menu_get_type ()))))))
;
5999}
6000
6001static void
6002copy_or_cut_files (FMDirectoryView *view,
6003 GList *clipboard_contents,
6004 gboolean cut)
6005{
6006 int count;
6007 char *status_string;
6008 BaulClipboardInfo info;
6009 CtkTargetList *target_list;
6010 CtkTargetEntry *targets;
6011 int n_targets;
6012
6013 info.files = clipboard_contents;
6014 info.cut = cut;
6015
6016 target_list = ctk_target_list_new (NULL((void*)0), 0);
6017 ctk_target_list_add (target_list, copied_files_atom, 0, 0);
6018 ctk_target_list_add_uri_targets (target_list, 0);
6019 ctk_target_list_add_text_targets (target_list, 0);
6020
6021 targets = ctk_target_table_new_from_list (target_list, &n_targets);
6022 ctk_target_list_unref (target_list);
6023
6024 ctk_clipboard_set_with_data (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
),
6025 targets, n_targets,
6026 baul_get_clipboard_callback, baul_clear_clipboard_callback,
6027 NULL((void*)0));
6028 ctk_target_table_free (targets, n_targets);
6029
6030 baul_clipboard_monitor_set_clipboard_info (baul_clipboard_monitor_get (), &info);
6031
6032 count = g_list_length (clipboard_contents);
6033 if (count == 1) {
6034 char *name;
6035
6036 name = baul_file_get_display_name (clipboard_contents->data);
6037 if (cut) {
6038 status_string = g_strdup_printf (_("\"%s\" will be moved "gettext ("\"%s\" will be moved " "if you select the Paste command"
)
6039 "if you select the Paste command")gettext ("\"%s\" will be moved " "if you select the Paste command"
)
,
6040 name);
6041 } else {
6042 status_string = g_strdup_printf (_("\"%s\" will be copied "gettext ("\"%s\" will be copied " "if you select the Paste command"
)
6043 "if you select the Paste command")gettext ("\"%s\" will be copied " "if you select the Paste command"
)
,
6044 name);
6045 }
6046 g_free (name);
6047 } else {
6048 if (cut) {
6049 status_string = g_strdup_printf (ngettext("The %'d selected item will be moved "
6050 "if you select the Paste command",
6051 "The %'d selected items will be moved "
6052 "if you select the Paste command",
6053 count),
6054 count);
6055 } else {
6056 status_string = g_strdup_printf (ngettext("The %'d selected item will be copied "
6057 "if you select the Paste command",
6058 "The %'d selected items will be copied "
6059 "if you select the Paste command",
6060 count),
6061 count);
6062 }
6063 }
6064
6065 baul_window_slot_info_set_status (view->details->slot,
6066 status_string);
6067 g_free (status_string);
6068}
6069
6070static void
6071action_copy_files_callback (CtkAction *action,
6072 gpointer callback_data)
6073{
6074 FMDirectoryView *view;
6075 GList *selection;
6076
6077 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6078
6079 selection = fm_directory_view_get_selection_for_file_transfer (view);
6080 copy_or_cut_files (view, selection, FALSE(0));
6081 baul_file_list_free (selection);
6082}
6083
6084static void
6085move_copy_selection_to_location (FMDirectoryView *view,
6086 int copy_action,
6087 char *target_uri)
6088{
6089 GList *selection, *uris, *l;
6090
6091 selection = fm_directory_view_get_selection_for_file_transfer (view);
6092 if (selection == NULL((void*)0)) {
6093 return;
6094 }
6095
6096 uris = NULL((void*)0);
6097 for (l = selection; l != NULL((void*)0); l = l->next) {
6098 uris = g_list_prepend (uris,
6099 baul_file_get_uri ((BaulFile *) l->data));
6100 }
6101 uris = g_list_reverse (uris);
6102
6103 fm_directory_view_move_copy_items (uris, NULL((void*)0), target_uri,
6104 copy_action,
6105 0, 0,
6106 view);
6107
6108 g_list_free_full (uris, g_free);
6109 baul_file_list_free (selection);
6110}
6111
6112static void
6113move_copy_selection_to_next_pane (FMDirectoryView *view,
6114 int copy_action)
6115{
6116 BaulWindowSlotInfo *slot;
6117 char *dest_location;
6118
6119 slot = baul_window_info_get_extra_slot (fm_directory_view_get_baul_window (view));
6120 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)
;
6121
6122 dest_location = baul_window_slot_info_get_current_location (slot);
6123 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)
;
6124
6125 move_copy_selection_to_location (view, copy_action, dest_location);
6126}
6127
6128static void
6129action_copy_to_next_pane_callback (CtkAction *action, gpointer callback_data)
6130{
6131 FMDirectoryView *view;
6132
6133 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6134 move_copy_selection_to_next_pane (view,
6135 CDK_ACTION_COPY);
6136}
6137
6138static void
6139action_move_to_next_pane_callback (CtkAction *action, gpointer callback_data)
6140{
6141 BaulWindowSlotInfo *slot;
6142 char *dest_location;
6143 FMDirectoryView *view;
6144
6145 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6146
6147 slot = baul_window_info_get_extra_slot (fm_directory_view_get_baul_window (view));
6148 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)
;
6149
6150 dest_location = baul_window_slot_info_get_current_location (slot);
6151 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)
;
6152
6153 move_copy_selection_to_location (view, CDK_ACTION_MOVE, dest_location);
6154}
6155
6156static void
6157action_copy_to_home_callback (CtkAction *action, gpointer callback_data)
6158{
6159 FMDirectoryView *view;
6160 char *dest_location;
6161
6162 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6163
6164 dest_location = baul_get_home_directory_uri ();
6165 move_copy_selection_to_location (view, CDK_ACTION_COPY, dest_location);
6166 g_free (dest_location);
6167}
6168
6169static void
6170action_move_to_home_callback (CtkAction *action, gpointer callback_data)
6171{
6172 FMDirectoryView *view;
6173 char *dest_location;
6174
6175 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6176
6177 dest_location = baul_get_home_directory_uri ();
6178 move_copy_selection_to_location (view, CDK_ACTION_MOVE, dest_location);
6179 g_free (dest_location);
6180}
6181
6182static void
6183action_copy_to_desktop_callback (CtkAction *action, gpointer callback_data)
6184{
6185 FMDirectoryView *view;
6186 char *dest_location;
6187
6188 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6189
6190 dest_location = baul_get_desktop_directory_uri ();
6191 move_copy_selection_to_location (view, CDK_ACTION_COPY, dest_location);
6192 g_free (dest_location);
6193}
6194
6195static void
6196action_move_to_desktop_callback (CtkAction *action, gpointer callback_data)
6197{
6198 FMDirectoryView *view;
6199 char *dest_location;
6200
6201 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6202
6203 dest_location = baul_get_desktop_directory_uri ();
6204 move_copy_selection_to_location (view, CDK_ACTION_MOVE, dest_location);
6205 g_free (dest_location);
6206}
6207
6208static void
6209action_cut_files_callback (CtkAction *action,
6210 gpointer callback_data)
6211{
6212 FMDirectoryView *view;
6213 GList *selection;
6214
6215 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6216
6217 selection = fm_directory_view_get_selection_for_file_transfer (view);
6218 copy_or_cut_files (view, selection, TRUE(!(0)));
6219 baul_file_list_free (selection);
6220}
6221
6222static void
6223paste_clipboard_data (FMDirectoryView *view,
6224 CtkSelectionData *selection_data,
6225 char *destination_uri)
6226{
6227 gboolean cut;
6228 GList *item_uris;
6229
6230 cut = FALSE(0);
6231 item_uris = baul_clipboard_get_uri_list_from_selection_data (selection_data, &cut,
6232 copied_files_atom);
6233
6234 if (item_uris == NULL((void*)0)|| destination_uri == NULL((void*)0)) {
6235 baul_window_slot_info_set_status (view->details->slot,
6236 _("There is nothing on the clipboard to paste.")gettext ("There is nothing on the clipboard to paste."));
6237 } else {
6238 fm_directory_view_move_copy_items (item_uris, NULL((void*)0), destination_uri,
6239 cut ? CDK_ACTION_MOVE : CDK_ACTION_COPY,
6240 0, 0,
6241 view);
6242
6243 /* If items are cut then remove from clipboard */
6244 if (cut) {
6245 ctk_clipboard_clear (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
));
6246 }
6247
6248 g_list_free_full (item_uris, g_free);
6249 }
6250}
6251
6252static void
6253paste_clipboard_received_callback (CtkClipboard *clipboard,
6254 CtkSelectionData *selection_data,
6255 gpointer data)
6256{
6257 FMDirectoryView *view;
6258 char *view_uri;
6259
6260 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6261
6262 view_uri = fm_directory_view_get_backing_uri (view);
6263
6264 if (view->details->window != NULL((void*)0)) {
6265 paste_clipboard_data (view, selection_data, view_uri);
6266 }
6267
6268 g_free (view_uri);
6269
6270 g_object_unref (view);
6271}
6272
6273typedef struct {
6274 FMDirectoryView *view;
6275 BaulFile *target;
6276} PasteIntoData;
6277
6278static void
6279paste_into_clipboard_received_callback (CtkClipboard *clipboard,
6280 CtkSelectionData *selection_data,
6281 gpointer callback_data)
6282{
6283 PasteIntoData *data;
6284 FMDirectoryView *view;
6285
6286 data = (PasteIntoData *) callback_data;
6287
6288 view = FM_DIRECTORY_VIEW (data->view)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data->view)), (fm_directory_view_get_type())))))
;
6289
6290 if (view->details->window != NULL((void*)0)) {
6291 char *directory_uri;
6292
6293 directory_uri = baul_file_get_activation_uri (data->target);
6294
6295 paste_clipboard_data (view, selection_data, directory_uri);
6296
6297 g_free (directory_uri);
6298 }
6299
6300 g_object_unref (view);
6301 baul_file_unref (data->target);
6302 g_free (data);
6303}
6304
6305static void
6306action_paste_files_callback (CtkAction *action,
6307 gpointer callback_data)
6308{
6309 FMDirectoryView *view;
6310
6311 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6312
6313 g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view));
6314 ctk_clipboard_request_contents (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
),
6315 copied_files_atom,
6316 paste_clipboard_received_callback,
6317 view);
6318}
6319
6320static void
6321paste_into (FMDirectoryView *view,
6322 BaulFile *target)
6323{
6324 PasteIntoData *data;
6325
6326 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"
, 6326, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
6327 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"
, 6327, ((const char*) (__func__)), "BAUL_IS_FILE (target)");
} while (0)
;
6328
6329 data = g_new (PasteIntoData, 1)((PasteIntoData *) g_malloc_n ((1), sizeof (PasteIntoData)));
6330
6331 data->view = g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view));
6332 data->target = baul_file_ref (target);
6333
6334 ctk_clipboard_request_contents (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
),
6335 copied_files_atom,
6336 paste_into_clipboard_received_callback,
6337 data);
6338}
6339
6340static void
6341action_paste_files_into_callback (CtkAction *action,
6342 gpointer callback_data)
6343{
6344 FMDirectoryView *view;
6345 GList *selection;
6346
6347 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6348 selection = fm_directory_view_get_selection (view);
6349 if (selection != NULL((void*)0)) {
6350 paste_into (view, BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
);
6351 baul_file_list_free (selection);
6352 }
6353
6354}
6355
6356static void
6357real_action_undo (FMDirectoryView *view)
6358{
6359 BaulUndoStackManager *manager = baul_undostack_manager_instance ();
6360
6361 /* Disable menus because they are in an untrustworthy status */
6362 view->details->undo_active = FALSE(0);
6363 view->details->redo_active = FALSE(0);
6364 fm_directory_view_update_menus (view);
6365
6366 baul_undostack_manager_undo (manager, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
, finish_undoredo_callback);
6367}
6368
6369static void
6370real_action_redo (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_redo (manager, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
, finish_undoredo_callback);
6380}
6381
6382static void
6383real_action_rename (FMDirectoryView *view,
6384 gboolean select_all)
6385{
6386 GList *selection;
6387
6388 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"
, 6388, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
6389
6390 selection = fm_directory_view_get_selection (view);
6391
6392 if (selection_not_empty_in_menu_callback (view, selection)) {
6393 BaulFile *file;
6394
6395 file = BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
;
6396
6397 if (!select_all) {
6398 /* directories don't have a file extension, so
6399 * they are always pre-selected as a whole */
6400 select_all = baul_file_is_directory (file);
6401 }
6402 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)
;
6403 }
6404
6405 baul_file_list_free (selection);
6406}
6407
6408static void
6409action_rename_callback (CtkAction *action,
6410 gpointer callback_data)
6411{
6412 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));
6413}
6414
6415static void
6416action_rename_select_all_callback (CtkAction *action,
6417 gpointer callback_data)
6418{
6419 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)));
6420}
6421
6422static void
6423file_mount_callback (BaulFile *file,
6424 GFile *result_location,
6425 GError *error,
6426 gpointer callback_data)
6427{
6428 if (error != NULL((void*)0) &&
6429 (error->domain != G_IO_ERRORg_io_error_quark() ||
6430 (error->code != G_IO_ERROR_CANCELLED &&
6431 error->code != G_IO_ERROR_FAILED_HANDLED &&
6432 error->code != G_IO_ERROR_ALREADY_MOUNTED))) {
6433 eel_show_error_dialog (_("Unable to mount location")gettext ("Unable to mount location"),
6434 error->message, NULL((void*)0));
6435 }
6436}
6437
6438static void
6439file_unmount_callback (BaulFile *file,
6440 GFile *result_location,
6441 GError *error,
6442 gpointer callback_data)
6443{
6444 FMDirectoryView *view;
6445
6446 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6447 fm_directory_view_set_initiated_unmount (view, FALSE(0));
6448 g_object_unref (view);
6449
6450 if (error != NULL((void*)0) &&
6451 (error->domain != G_IO_ERRORg_io_error_quark() ||
6452 (error->code != G_IO_ERROR_CANCELLED &&
6453 error->code != G_IO_ERROR_FAILED_HANDLED))) {
6454 eel_show_error_dialog (_("Unable to unmount location")gettext ("Unable to unmount location"),
6455 error->message, NULL((void*)0));
6456 }
6457}
6458
6459static void
6460file_eject_callback (BaulFile *file,
6461 GFile *result_location,
6462 GError *error,
6463 gpointer callback_data)
6464{
6465 FMDirectoryView *view;
6466
6467 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
6468 fm_directory_view_set_initiated_unmount (view, FALSE(0));
6469 g_object_unref (view);
6470
6471 if (error != NULL((void*)0) &&
6472 (error->domain != G_IO_ERRORg_io_error_quark() ||
6473 (error->code != G_IO_ERROR_CANCELLED &&
6474 error->code != G_IO_ERROR_FAILED_HANDLED))) {
6475 eel_show_error_dialog (_("Unable to eject location")gettext ("Unable to eject location"),
6476 error->message, NULL((void*)0));
6477 }
6478}
6479
6480static void
6481file_stop_callback (BaulFile *file,
6482 GFile *result_location,
6483 GError *error,
6484 gpointer callback_data)
6485{
6486 if (error != NULL((void*)0) &&
6487 (error->domain != G_IO_ERRORg_io_error_quark() ||
6488 (error->code != G_IO_ERROR_CANCELLED &&
6489 error->code != G_IO_ERROR_FAILED_HANDLED))) {
6490 eel_show_error_dialog (_("Unable to stop drive")gettext ("Unable to stop drive"),
6491 error->message, NULL((void*)0));
6492 }
6493}
6494
6495static void
6496action_mount_volume_callback (CtkAction *action,
6497 gpointer data)
6498{
6499 GList *selection, *l;
6500 FMDirectoryView *view;
6501 GMountOperation *mount_op;
6502 BaulFile *file = NULL((void*)0);
6503
6504 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6505
6506 selection = fm_directory_view_get_selection (view);
6507 for (l = selection; l != NULL((void*)0); l = l->next) {
6508 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
6509
6510 if (baul_file_can_mount (file)) {
6511 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6512 g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
6513 baul_file_mount (file, mount_op, NULL((void*)0),
6514 file_mount_callback, NULL((void*)0));
6515 g_object_unref (mount_op);
6516 }
6517 }
6518 baul_file_list_free (selection);
6519}
6520
6521static void
6522action_unmount_volume_callback (CtkAction *action,
6523 gpointer data)
6524{
6525 GList *selection, *l;
6526 FMDirectoryView *view;
6527 BaulFile *file = NULL((void*)0);
6528
6529 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6530
6531 selection = fm_directory_view_get_selection (view);
6532
6533 for (l = selection; l != NULL((void*)0); l = l->next) {
6534 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
6535 if (baul_file_can_unmount (file)) {
6536 GMountOperation *mount_op;
6537 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6538 fm_directory_view_set_initiated_unmount (view, TRUE(!(0)));
6539 baul_file_unmount (file, mount_op, NULL((void*)0),
6540 file_unmount_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)));
6541 g_object_unref (mount_op);
6542 }
6543 }
6544 baul_file_list_free (selection);
6545}
6546
6547static void
6548action_format_volume_callback (CtkAction *action,
6549 gpointer data)
6550{
6551#ifdef TODO_GIO
6552 GList *selection, *l;
6553 FMDirectoryView *view;
6554 BaulFile *file = NULL((void*)0);
6555
6556 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6557
6558 selection = fm_directory_view_get_selection (view);
6559 for (l = selection; l != NULL((void*)0); l = l->next) {
6560 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
6561
6562 if (something) {
6563 g_spawn_command_line_async ("gfloppy", NULL((void*)0));
6564 }
6565 }
6566 baul_file_list_free (selection);
6567#endif
6568}
6569
6570static void
6571action_eject_volume_callback (CtkAction *action,
6572 gpointer data)
6573{
6574 GList *selection, *l;
6575 FMDirectoryView *view;
6576 BaulFile *file = NULL((void*)0);
6577
6578 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6579
6580 selection = fm_directory_view_get_selection (view);
6581 for (l = selection; l != NULL((void*)0); l = l->next) {
6582 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
6583
6584 if (baul_file_can_eject (file)) {
6585 GMountOperation *mount_op;
6586 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6587 fm_directory_view_set_initiated_unmount (view, TRUE(!(0)));
6588 baul_file_eject (file, mount_op, NULL((void*)0),
6589 file_eject_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)));
6590 g_object_unref (mount_op);
6591 }
6592 }
6593 baul_file_list_free (selection);
6594}
6595
6596static void
6597file_start_callback (BaulFile *file,
6598 GFile *result_location,
6599 GError *error,
6600 gpointer callback_data)
6601{
6602 if (error != NULL((void*)0) &&
6603 (error->domain != G_IO_ERRORg_io_error_quark() ||
6604 (error->code != G_IO_ERROR_CANCELLED &&
6605 error->code != G_IO_ERROR_FAILED_HANDLED &&
6606 error->code != G_IO_ERROR_ALREADY_MOUNTED))) {
6607 eel_show_error_dialog (_("Unable to start location")gettext ("Unable to start location"),
6608 error->message, NULL((void*)0));
6609 }
6610}
6611
6612static void
6613action_start_volume_callback (CtkAction *action,
6614 gpointer data)
6615{
6616 GList *selection, *l;
6617 FMDirectoryView *view;
6618 GMountOperation *mount_op;
6619 BaulFile *file = NULL((void*)0);
6620
6621 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6622
6623 selection = fm_directory_view_get_selection (view);
6624 for (l = selection; l != NULL((void*)0); l = l->next) {
6625 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
6626
6627 if (baul_file_can_start (file) || baul_file_can_start_degraded (file)) {
6628 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6629 baul_file_start (file, mount_op, NULL((void*)0),
6630 file_start_callback, NULL((void*)0));
6631 g_object_unref (mount_op);
6632 }
6633 }
6634 baul_file_list_free (selection);
6635}
6636
6637static void
6638action_stop_volume_callback (CtkAction *action,
6639 gpointer data)
6640{
6641 GList *selection, *l;
6642 FMDirectoryView *view;
6643 BaulFile *file = NULL((void*)0);
6644
6645 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6646
6647 selection = fm_directory_view_get_selection (view);
6648 for (l = selection; l != NULL((void*)0); l = l->next) {
6649 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
6650
6651 if (baul_file_can_stop (file)) {
6652 GMountOperation *mount_op;
6653 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6654 baul_file_stop (file, mount_op, NULL((void*)0),
6655 file_stop_callback, NULL((void*)0));
6656 g_object_unref (mount_op);
6657 }
6658 }
6659 baul_file_list_free (selection);
6660}
6661
6662static void
6663action_detect_media_callback (CtkAction *action,
6664 gpointer data)
6665{
6666 GList *selection, *l;
6667 FMDirectoryView *view;
6668 BaulFile *file = NULL((void*)0);
6669
6670 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6671
6672 selection = fm_directory_view_get_selection (view);
6673 for (l = selection; l != NULL((void*)0); l = l->next) {
6674 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
6675
6676 if (baul_file_can_poll_for_media (file) && !baul_file_is_media_check_automatic (file)) {
6677 baul_file_poll_for_media (file);
6678 }
6679 }
6680 baul_file_list_free (selection);
6681}
6682
6683static void
6684action_self_mount_volume_callback (CtkAction *action,
6685 gpointer data)
6686{
6687 BaulFile *file;
6688 FMDirectoryView *view;
6689 GMountOperation *mount_op;
6690
6691 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6692
6693 file = fm_directory_view_get_directory_as_file (view);
6694 if (file == NULL((void*)0)) {
6695 return;
6696 }
6697
6698 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6699 g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
6700 baul_file_mount (file, mount_op, NULL((void*)0), file_mount_callback, NULL((void*)0));
6701 g_object_unref (mount_op);
6702}
6703
6704static void
6705action_self_unmount_volume_callback (CtkAction *action,
6706 gpointer data)
6707{
6708 BaulFile *file;
6709 FMDirectoryView *view;
6710 GMountOperation *mount_op;
6711
6712 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6713
6714 file = fm_directory_view_get_directory_as_file (view);
6715 if (file == NULL((void*)0)) {
6716 return;
6717 }
6718
6719 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6720 fm_directory_view_set_initiated_unmount (view, TRUE(!(0)));
6721 baul_file_unmount (file, mount_op, NULL((void*)0), file_unmount_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)));
6722 g_object_unref (mount_op);
6723}
6724
6725static void
6726action_self_eject_volume_callback (CtkAction *action,
6727 gpointer data)
6728{
6729 BaulFile *file;
6730 FMDirectoryView *view;
6731 GMountOperation *mount_op;
6732
6733 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6734
6735 file = fm_directory_view_get_directory_as_file (view);
6736 if (file == NULL((void*)0)) {
6737 return;
6738 }
6739
6740 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6741 fm_directory_view_set_initiated_unmount (view, TRUE(!(0)));
6742 baul_file_eject (file, mount_op, NULL((void*)0), file_eject_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)));
6743 g_object_unref (mount_op);
6744}
6745
6746static void
6747action_self_format_volume_callback (CtkAction *action,
6748 gpointer data)
6749{
6750 BaulFile *file;
6751 FMDirectoryView *view;
6752
6753 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6754
6755 file = fm_directory_view_get_directory_as_file (view);
6756 if (file == NULL((void*)0)) {
6757 return;
6758 }
6759
6760#ifdef TODO_GIO
6761 if (something) {
6762 g_spawn_command_line_async ("gfloppy", NULL((void*)0));
6763 }
6764#endif
6765}
6766
6767static void
6768action_self_start_volume_callback (CtkAction *action,
6769 gpointer data)
6770{
6771 BaulFile *file;
6772 FMDirectoryView *view;
6773 GMountOperation *mount_op;
6774
6775 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6776
6777 file = fm_directory_view_get_directory_as_file (view);
6778 if (file == NULL((void*)0)) {
6779 return;
6780 }
6781
6782 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6783 baul_file_start (file, mount_op, NULL((void*)0), file_start_callback, NULL((void*)0));
6784 g_object_unref (mount_op);
6785}
6786
6787static void
6788action_self_stop_volume_callback (CtkAction *action,
6789 gpointer data)
6790{
6791 BaulFile *file;
6792 FMDirectoryView *view;
6793 GMountOperation *mount_op;
6794
6795 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6796
6797 file = fm_directory_view_get_directory_as_file (view);
6798 if (file == NULL((void*)0)) {
6799 return;
6800 }
6801
6802 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6803 baul_file_stop (file, mount_op, NULL((void*)0),
6804 file_stop_callback, NULL((void*)0));
6805 g_object_unref (mount_op);
6806}
6807
6808static void
6809action_self_detect_media_callback (CtkAction *action,
6810 gpointer data)
6811{
6812 BaulFile *file;
6813 FMDirectoryView *view;
6814
6815 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6816
6817 file = fm_directory_view_get_directory_as_file (view);
6818 if (file == NULL((void*)0)) {
6819 return;
6820 }
6821
6822 baul_file_poll_for_media (file);
6823}
6824
6825static void
6826action_location_mount_volume_callback (CtkAction *action,
6827 gpointer data)
6828{
6829 BaulFile *file;
6830 FMDirectoryView *view;
6831 GMountOperation *mount_op;
6832
6833 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6834
6835 file = view->details->location_popup_directory_as_file;
6836 if (file == NULL((void*)0)) {
6837 return;
6838 }
6839
6840 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6841 g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
6842 baul_file_mount (file, mount_op, NULL((void*)0), file_mount_callback, NULL((void*)0));
6843 g_object_unref (mount_op);
6844}
6845
6846static void
6847action_location_unmount_volume_callback (CtkAction *action,
6848 gpointer data)
6849{
6850 BaulFile *file;
6851 FMDirectoryView *view;
6852 GMountOperation *mount_op;
6853
6854 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6855
6856 file = view->details->location_popup_directory_as_file;
6857 if (file == NULL((void*)0)) {
6858 return;
6859 }
6860
6861 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6862 fm_directory_view_set_initiated_unmount (view, TRUE(!(0)));
6863 baul_file_unmount (file, mount_op, NULL((void*)0),
6864 file_unmount_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)));
6865 g_object_unref (mount_op);
6866}
6867
6868static void
6869action_location_eject_volume_callback (CtkAction *action,
6870 gpointer data)
6871{
6872 BaulFile *file;
6873 FMDirectoryView *view;
6874 GMountOperation *mount_op;
6875
6876 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6877
6878 file = view->details->location_popup_directory_as_file;
6879 if (file == NULL((void*)0)) {
6880 return;
6881 }
6882
6883 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6884 fm_directory_view_set_initiated_unmount (view, TRUE(!(0)));
6885 baul_file_eject (file, mount_op, NULL((void*)0),
6886 file_eject_callback, g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)));
6887 g_object_unref (mount_op);
6888}
6889
6890static void
6891action_location_format_volume_callback (CtkAction *action,
6892 gpointer data)
6893{
6894 BaulFile *file;
6895 FMDirectoryView *view;
6896
6897 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6898
6899 file = view->details->location_popup_directory_as_file;
6900 if (file == NULL((void*)0)) {
6901 return;
6902 }
6903
6904#ifdef TODO_GIO
6905 if (something) {
6906 g_spawn_command_line_async ("gfloppy", NULL((void*)0));
6907 }
6908#endif
6909}
6910
6911static void
6912action_location_start_volume_callback (CtkAction *action,
6913 gpointer data)
6914{
6915 BaulFile *file;
6916 FMDirectoryView *view;
6917 GMountOperation *mount_op;
6918
6919 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6920
6921 file = view->details->location_popup_directory_as_file;
6922 if (file == NULL((void*)0)) {
6923 return;
6924 }
6925
6926 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6927 baul_file_start (file, mount_op, NULL((void*)0), file_start_callback, NULL((void*)0));
6928 g_object_unref (mount_op);
6929}
6930
6931static void
6932action_location_stop_volume_callback (CtkAction *action,
6933 gpointer data)
6934{
6935 BaulFile *file;
6936 FMDirectoryView *view;
6937 GMountOperation *mount_op;
6938
6939 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6940
6941 file = view->details->location_popup_directory_as_file;
6942 if (file == NULL((void*)0)) {
6943 return;
6944 }
6945
6946 mount_op = ctk_mount_operation_new (fm_directory_view_get_containing_window (view));
6947 baul_file_stop (file, mount_op, NULL((void*)0),
6948 file_stop_callback, NULL((void*)0));
6949 g_object_unref (mount_op);
6950}
6951
6952static void
6953action_location_detect_media_callback (CtkAction *action,
6954 gpointer data)
6955{
6956 BaulFile *file;
6957 FMDirectoryView *view;
6958
6959 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
6960
6961 file = view->details->location_popup_directory_as_file;
6962 if (file == NULL((void*)0)) {
6963 return;
6964 }
6965
6966 baul_file_poll_for_media (file);
6967}
6968
6969static void
6970connect_to_server_response_callback (CtkDialog *dialog,
6971 int response_id,
6972 gpointer data)
6973{
6974#ifdef GIO_CONVERSION_DONE
6975 CtkEntry *entry;
6976 char *uri;
6977 const char *name;
6978 char *icon;
6979
6980 entry = CTK_ENTRY (data)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), ((ctk_entry_get_type ()))))))
;
6981
6982 switch (response_id) {
6983 case CTK_RESPONSE_OK:
6984 uri = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "link-uri");
6985 icon = g_object_get_data (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), (((GType) ((20) << (2))))))))
, "link-icon");
6986 name = ctk_entry_get_text (entry);
6987 cafe_vfs_connect_to_server (uri, (char *)name, icon);
6988 ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
6989 break;
6990 case CTK_RESPONSE_NONE:
6991 case CTK_RESPONSE_DELETE_EVENT:
6992 case CTK_RESPONSE_CANCEL:
6993 ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
6994 break;
6995 default :
6996 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c"
, 6996, ((const char*) (__func__)), ((void*)0)); } while (0)
;
6997 }
6998#endif
6999 /* FIXME: the above code should make a server connection permanent */
7000 ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_widget_get_type ()))))))
);
7001}
7002
7003static void
7004entry_activate_callback (CtkEntry *entry,
7005 gpointer user_data)
7006{
7007 CtkDialog *dialog;
7008
7009 dialog = CTK_DIALOG (user_data)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), ((ctk_dialog_get_type ()))))))
;
7010 ctk_dialog_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, CTK_RESPONSE_OK);
7011}
7012
7013static void
7014action_connect_to_server_link_callback (CtkAction *action,
7015 gpointer data)
7016{
7017 BaulFile *file;
7018 GList *selection;
7019 FMDirectoryView *view;
7020 char *uri;
7021 BaulIconInfo *icon;
7022 const char *icon_name;
7023 char *name;
7024 gint scale;
7025
7026 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
7027
7028 selection = fm_directory_view_get_selection (view);
7029
7030 if (!eel_g_list_exactly_one_item (selection)) {
7031 baul_file_list_free (selection);
7032 return;
7033 }
7034
7035 file = BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
;
7036 scale = ctk_widget_get_scale_factor (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
);
7037
7038 uri = baul_file_get_activation_uri (file);
7039 icon = baul_file_get_icon (file, BAUL_ICON_SIZE_STANDARD48, scale, 0);
7040 icon_name = baul_icon_info_get_used_name (icon);
7041 name = baul_file_get_display_name (file);
7042
7043 if (uri != NULL((void*)0)) {
7044 CtkWidget *dialog;
7045 CtkWidget *label;
7046 CtkWidget *entry;
7047 CtkWidget *box;
7048 char *title;
7049
7050 title = g_strdup_printf (_("Connect to Server %s")gettext ("Connect to Server %s"), name);
7051
7052 dialog = ctk_dialog_new ();
7053 ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, title);
7054 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));
7055
7056 eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
7057 _("_Cancel")gettext ("_Cancel"),
7058 "process-stop",
7059 CTK_RESPONSE_CANCEL);
7060
7061 ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
7062 _("_Connect")gettext ("_Connect"),
7063 CTK_RESPONSE_OK);
7064
7065 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);
7066 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);
7067
7068 ctk_container_set_border_width (CTK_CONTAINER (dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_container_get_type ()))))))
, 5);
7069 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);
7070
7071 box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12);
7072 ctk_widget_show (box);
7073 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 ()))))))
,
7074 box, TRUE(!(0)), TRUE(!(0)), 0);
7075
7076 label = ctk_label_new_with_mnemonic (_("Link _name:")gettext ("Link _name:"));
7077 ctk_widget_show (label);
7078
7079 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);
7080
7081 entry = ctk_entry_new ();
7082 if (name) {
7083 ctk_entry_set_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((entry)), ((ctk_entry_get_type ()))))))
, name);
7084 }
7085 g_signal_connect (entry,g_signal_connect_data ((entry), ("activate"), (((GCallback) (
entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags
) 0)
7086 "activate",g_signal_connect_data ((entry), ("activate"), (((GCallback) (
entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags
) 0)
7087 G_CALLBACK (entry_activate_callback),g_signal_connect_data ((entry), ("activate"), (((GCallback) (
entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags
) 0)
7088 dialog)g_signal_connect_data ((entry), ("activate"), (((GCallback) (
entry_activate_callback))), (dialog), ((void*)0), (GConnectFlags
) 0)
;
7089
7090 ctk_widget_show (entry);
7091 ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((label)), ((ctk_label_get_type ()))))))
, entry);
7092
7093 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);
7094
7095 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
7096 CTK_RESPONSE_OK);
7097 g_signal_connect (dialog, "response",g_signal_connect_data ((dialog), ("response"), (((GCallback) (
connect_to_server_response_callback))), (entry), ((void*)0), (
GConnectFlags) 0)
7098 G_CALLBACK (connect_to_server_response_callback),g_signal_connect_data ((dialog), ("response"), (((GCallback) (
connect_to_server_response_callback))), (entry), ((void*)0), (
GConnectFlags) 0)
7099 entry)g_signal_connect_data ((dialog), ("response"), (((GCallback) (
connect_to_server_response_callback))), (entry), ((void*)0), (
GConnectFlags) 0)
;
7100 ctk_widget_show (dialog);
7101 }
7102
7103 g_free (uri);
7104 g_object_unref (icon);
7105 g_free (name);
7106}
7107
7108static void
7109action_location_open_alternate_callback (CtkAction *action,
7110 gpointer callback_data)
7111{
7112 FMDirectoryView *view;
7113 BaulFile *file;
7114
7115 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7116
7117 file = view->details->location_popup_directory_as_file;
7118 if (file == NULL((void*)0)) {
7119 return;
7120 }
7121
7122 fm_directory_view_activate_file (view,
7123 file,
7124 BAUL_WINDOW_OPEN_IN_NAVIGATION,
7125 0);
7126}
7127
7128static void
7129action_location_open_in_new_tab_callback (CtkAction *action,
7130 gpointer callback_data)
7131{
7132 FMDirectoryView *view;
7133 BaulFile *file;
7134
7135 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7136
7137 file = view->details->location_popup_directory_as_file;
7138 if (file == NULL((void*)0)) {
7139 return;
7140 }
7141
7142 fm_directory_view_activate_file (view,
7143 file,
7144 BAUL_WINDOW_OPEN_ACCORDING_TO_MODE,
7145 BAUL_WINDOW_OPEN_FLAG_NEW_TAB);
7146}
7147
7148static void
7149action_location_open_folder_window_callback (CtkAction *action,
7150 gpointer callback_data)
7151{
7152 FMDirectoryView *view;
7153 BaulFile *file;
7154
7155 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7156
7157 file = view->details->location_popup_directory_as_file;
7158 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)
;
7159
7160 fm_directory_view_activate_file (view,
7161 file,
7162 BAUL_WINDOW_OPEN_IN_SPATIAL,
7163 0);
7164}
7165
7166static void
7167action_location_cut_callback (CtkAction *action,
7168 gpointer callback_data)
7169{
7170 FMDirectoryView *view;
7171 BaulFile *file;
7172 GList *files;
7173
7174 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7175
7176 file = view->details->location_popup_directory_as_file;
7177 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)
;
7178
7179 files = g_list_append (NULL((void*)0), file);
7180 copy_or_cut_files (view, files, TRUE(!(0)));
7181 g_list_free (files);
7182}
7183
7184static void
7185action_location_copy_callback (CtkAction *action,
7186 gpointer callback_data)
7187{
7188 FMDirectoryView *view;
7189 BaulFile *file;
7190 GList *files;
7191
7192 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7193
7194 file = view->details->location_popup_directory_as_file;
7195 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)
;
7196
7197 files = g_list_append (NULL((void*)0), file);
7198 copy_or_cut_files (view, files, FALSE(0));
7199 g_list_free (files);
7200}
7201
7202static void
7203action_location_paste_files_into_callback (CtkAction *action,
7204 gpointer callback_data)
7205{
7206 FMDirectoryView *view;
7207 BaulFile *file;
7208
7209 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7210
7211 file = view->details->location_popup_directory_as_file;
7212 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)
;
7213
7214 paste_into (view, file);
7215}
7216
7217static void
7218action_location_trash_callback (CtkAction *action,
7219 gpointer callback_data)
7220{
7221 FMDirectoryView *view;
7222 BaulFile *file;
7223 GList *files;
7224
7225 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7226
7227 file = view->details->location_popup_directory_as_file;
7228 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)
;
7229
7230 files = g_list_append (NULL((void*)0), file);
7231 trash_or_delete_files (fm_directory_view_get_containing_window (view),
7232 files, TRUE(!(0)),
7233 view);
7234 g_list_free (files);
7235}
7236
7237static void
7238action_location_delete_callback (CtkAction *action,
7239 gpointer callback_data)
7240{
7241 FMDirectoryView *view;
7242 BaulFile *file;
7243 GFile *location;
7244 GList *files;
7245
7246 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7247
7248 file = view->details->location_popup_directory_as_file;
7249 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)
;
7250
7251 location = baul_file_get_location (file);
7252
7253 files = g_list_append (NULL((void*)0), location);
7254 baul_file_operations_delete (files, fm_directory_view_get_containing_window (view),
7255 NULL((void*)0), NULL((void*)0));
7256
7257 g_list_free_full (files, g_object_unref);
7258}
7259
7260static void
7261action_location_restore_from_trash_callback (CtkAction *action,
7262 gpointer callback_data)
7263{
7264 FMDirectoryView *view;
7265 BaulFile *file;
7266 GList l;
7267
7268 view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
7269 file = view->details->location_popup_directory_as_file;
7270
7271 l.prev = NULL((void*)0);
7272 l.next = NULL((void*)0);
7273 l.data = file;
7274 baul_restore_files_from_trash (&l,
7275 fm_directory_view_get_containing_window (view));
7276}
7277
7278static void
7279fm_directory_view_init_show_hidden_files (FMDirectoryView *view)
7280{
7281 BaulWindowShowHiddenFilesMode mode;
7282 gboolean show_hidden_changed;
7283 gboolean show_hidden_default_setting;
7284
7285 if (view->details->ignore_hidden_file_preferences) {
7286 return;
7287 }
7288
7289 show_hidden_changed = FALSE(0);
7290 mode = baul_window_info_get_hidden_files_mode (view->details->window);
7291
7292 if (mode == BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) {
7293 show_hidden_default_setting = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_SHOW_HIDDEN_FILES"show-hidden-files");
7294 if (show_hidden_default_setting != view->details->show_hidden_files) {
7295 view->details->show_hidden_files = show_hidden_default_setting;
7296 show_hidden_changed = TRUE(!(0));
7297 }
7298 } else {
7299 if (mode == BAUL_WINDOW_SHOW_HIDDEN_FILES_ENABLE) {
7300 show_hidden_changed = !view->details->show_hidden_files;
7301 view->details->show_hidden_files = TRUE(!(0));
7302 } else {
7303 show_hidden_changed = view->details->show_hidden_files;
7304 view->details->show_hidden_files = FALSE(0);
7305 }
7306 }
7307
7308 if (show_hidden_changed && (view->details->model != NULL((void*)0))) {
7309 load_directory (view, view->details->model);
7310 }
7311
7312}
7313
7314static void
7315fm_directory_view_init_show_backup_files (FMDirectoryView *view)
7316{
7317 BaulWindowShowBackupFilesMode mode;
7318 gboolean show_backup_changed;
7319 gboolean show_backup_default_setting;
7320
7321 show_backup_changed = FALSE(0);
7322 mode = baul_window_info_get_backup_files_mode (view->details->window);
7323
7324 if (mode == BAUL_WINDOW_SHOW_BACKUP_FILES_DEFAULT) {
7325 show_backup_default_setting = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_SHOW_BACKUP_FILES"show-backup-files");
7326 if (show_backup_default_setting != view->details->show_backup_files) {
7327 view->details->show_backup_files = show_backup_default_setting;
7328 show_backup_changed = TRUE(!(0));
7329 }
7330 } else {
7331 if (mode == BAUL_WINDOW_SHOW_BACKUP_FILES_ENABLE) {
7332 show_backup_changed = !view->details->show_backup_files;
7333 view->details->show_backup_files = TRUE(!(0));
7334 } else {
7335 show_backup_changed = view->details->show_backup_files;
7336 view->details->show_backup_files = FALSE(0);
7337 }
7338 }
7339
7340 if (show_backup_changed && (view->details->model != NULL((void*)0))) {
7341 load_directory (view, view->details->model);
7342 }
7343
7344}
7345
7346static const CtkActionEntry directory_view_entries[] = {
7347 /* name, icon name, label */ { "New Documents", "document-new", N_("Create _Document")("Create _Document") },
7348 /* name, icon name, label */ { "Open With", NULL((void*)0), N_("Open Wit_h")("Open Wit_h"),
7349 NULL((void*)0), N_("Choose a program with which to open the selected item")("Choose a program with which to open the selected item") },
7350 /* name, icon name */ { "Properties", "document-properties",
7351 /* label, accelerator */ N_("_Properties")("_Properties"), "<alt>Return",
7352 /* tooltip */ N_("View or modify the properties of each selected item")("View or modify the properties of each selected item"),
7353 G_CALLBACK (action_properties_callback)((GCallback) (action_properties_callback)) },
7354 /* name, icon name */ { "PropertiesAccel", NULL((void*)0),
7355 /* label, accelerator */ "PropertiesAccel", "<control>I",
7356 /* tooltip */ NULL((void*)0),
7357 G_CALLBACK (action_properties_callback)((GCallback) (action_properties_callback)) },
7358 /* name, icon name */ { "New Folder", "folder-new",
7359 /* label, accelerator */ N_("Create _Folder")("Create _Folder"), "<control><shift>N",
7360 /* tooltip */ N_("Create a new empty folder inside this folder")("Create a new empty folder inside this folder"),
7361 G_CALLBACK (action_new_folder_callback)((GCallback) (action_new_folder_callback)) },
7362 /* name, icon name, label */ { "No Templates", NULL((void*)0), N_("No templates installed")("No templates installed") },
7363 /* name, icon name */ { "New Empty File", NULL((void*)0),
7364 /* Translators: this is used to indicate that a file doesn't contain anything */
7365 /* label, accelerator */ N_("_Empty File")("_Empty File"), NULL((void*)0),
7366 /* tooltip */ N_("Create a new empty file inside this folder")("Create a new empty file inside this folder"),
7367 G_CALLBACK (action_new_empty_file_callback)((GCallback) (action_new_empty_file_callback)) },
7368 /* name, icon name */ { "New Launcher", NULL((void*)0),
7369 /* label, accelerator */ N_("Create L_auncher...")("Create L_auncher..."), NULL((void*)0),
7370 /* tooltip */ N_("Create a new launcher")("Create a new launcher"),
7371 G_CALLBACK (action_new_launcher_callback)((GCallback) (action_new_launcher_callback)) },
7372 /* name, icon name */ { "Open", NULL((void*)0),
7373 /* label, accelerator */ N_("_Open")("_Open"), "<control>o",
7374 /* tooltip */ N_("Open the selected item in this window")("Open the selected item in this window"),
7375 G_CALLBACK (action_open_callback)((GCallback) (action_open_callback)) },
7376 /* name, icon name */ { "OpenAccel", NULL((void*)0),
7377 /* label, accelerator */ "OpenAccel", "<alt>Down",
7378 /* tooltip */ NULL((void*)0),
7379 G_CALLBACK (action_open_callback)((GCallback) (action_open_callback)) },
7380 /* name, icon name */ { "OpenAlternate", NULL((void*)0),
7381 /* label, accelerator */ N_("Open in Navigation Window")("Open in Navigation Window"), "<control><shift>w",
7382 /* tooltip */ N_("Open each selected item in a navigation window")("Open each selected item in a navigation window"),
7383 G_CALLBACK (action_open_alternate_callback)((GCallback) (action_open_alternate_callback)) },
7384 /* name, icon name */ { "OpenInNewTab", NULL((void*)0),
7385 /* label, accelerator */ N_("Open in New _Tab")("Open in New _Tab"), "<control><shift>o",
7386 /* tooltip */ N_("Open each selected item in a new tab")("Open each selected item in a new tab"),
7387 G_CALLBACK (action_open_new_tab_callback)((GCallback) (action_open_new_tab_callback)) },
7388 /* name, icon name */ { "OpenFolderWindow", NULL((void*)0),
7389 /* label, accelerator */ N_("Open in _Folder Window")("Open in _Folder Window"), NULL((void*)0),
7390 /* tooltip */ N_("Open each selected item in a folder window")("Open each selected item in a folder window"),
7391 G_CALLBACK (action_open_folder_window_callback)((GCallback) (action_open_folder_window_callback)) },
7392 /* name, icon name */ { "OtherApplication1", NULL((void*)0),
7393 /* label, accelerator */ N_("Other _Application...")("Other _Application..."), NULL((void*)0),
7394 /* tooltip */ N_("Choose another application with which to open the selected item")("Choose another application with which to open the selected item"
)
,
7395 G_CALLBACK (action_other_application_callback)((GCallback) (action_other_application_callback)) },
7396 /* name, icon name */ { "OtherApplication2", NULL((void*)0),
7397 /* label, accelerator */ N_("Open With Other _Application...")("Open With Other _Application..."), NULL((void*)0),
7398 /* tooltip */ N_("Choose another application with which to open the selected item")("Choose another application with which to open the selected item"
)
,
7399 G_CALLBACK (action_other_application_callback)((GCallback) (action_other_application_callback)) },
7400 /* name, icon name */ { "Open Scripts Folder", NULL((void*)0),
7401 /* label, accelerator */ N_("_Open Scripts Folder")("_Open Scripts Folder"), NULL((void*)0),
7402 /* tooltip */ N_("Show the folder containing the scripts that appear in this menu")("Show the folder containing the scripts that appear in this menu"
)
,
7403 G_CALLBACK (action_open_scripts_folder_callback)((GCallback) (action_open_scripts_folder_callback)) },
7404 /* name, icon name */ { "Empty Trash", BAUL_ICON_TRASH"user-trash",
7405 /* label, accelerator */ N_("E_mpty Trash")("E_mpty Trash"), NULL((void*)0),
7406 /* tooltip */ N_("Delete all items in the Trash")("Delete all items in the Trash"),
7407 G_CALLBACK (action_empty_trash_callback)((GCallback) (action_empty_trash_callback)) },
7408 /* name, icon name */ { "Cut", "edit-cut",
7409 /* label, accelerator */ N_("Cu_t")("Cu_t"), "<control>X",
7410 /* tooltip */ N_("Prepare the selected files to be moved with a Paste command")("Prepare the selected files to be moved with a Paste command"
)
,
7411 G_CALLBACK (action_cut_files_callback)((GCallback) (action_cut_files_callback)) },
7412 /* name, icon name */ { "Copy", "edit-copy",
7413 /* label, accelerator */ N_("_Copy")("_Copy"), "<control>C",
7414 /* tooltip */ N_("Prepare the selected files to be copied with a Paste command")("Prepare the selected files to be copied with a Paste command"
)
,
7415 G_CALLBACK (action_copy_files_callback)((GCallback) (action_copy_files_callback)) },
7416 /* name, icon name */ { "Paste", "edit-paste",
7417 /* label, accelerator */ N_("_Paste")("_Paste"), "<control>V",
7418 /* 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"
)
,
7419 G_CALLBACK (action_paste_files_callback)((GCallback) (action_paste_files_callback)) },
7420 /* We make accelerator "" instead of null here to not inherit the stock
7421 accelerator for paste */
7422 /* name, icon name */ { "Paste Files Into", "edit-paste",
7423 /* label, accelerator */ N_("_Paste Into Folder")("_Paste Into Folder"), "",
7424 /* 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"
)
,
7425 G_CALLBACK (action_paste_files_into_callback)((GCallback) (action_paste_files_into_callback)) },
7426 /* name, icon name, label */ { "CopyToMenu", NULL((void*)0), N_("Cop_y to")("Cop_y to") },
7427 /* name, icon name, label */ { "MoveToMenu", NULL((void*)0), N_("M_ove to")("M_ove to") },
7428 /* name, icon name */ { "Select All", NULL((void*)0),
7429 /* label, accelerator */ N_("Select _All")("Select _All"), "<control>A",
7430 /* tooltip */ N_("Select all items in this window")("Select all items in this window"),
7431 G_CALLBACK (action_select_all_callback)((GCallback) (action_select_all_callback)) },
7432 /* name, icon name */ { "Select Pattern", NULL((void*)0),
7433 /* label, accelerator */ N_("Select I_tems Matching...")("Select I_tems Matching..."), "<control>S",
7434 /* tooltip */ N_("Select items in this window matching a given pattern")("Select items in this window matching a given pattern"),
7435 G_CALLBACK (action_select_pattern_callback)((GCallback) (action_select_pattern_callback)) },
7436 /* name, icon name */ { "Invert Selection", NULL((void*)0),
7437 /* label, accelerator */ N_("_Invert Selection")("_Invert Selection"), "<control><shift>I",
7438 /* tooltip */ N_("Select all and only the items that are not currently selected")("Select all and only the items that are not currently selected"
)
,
7439 G_CALLBACK (action_invert_selection_callback)((GCallback) (action_invert_selection_callback)) },
7440 /* name, icon name */ { "Duplicate", NULL((void*)0),
7441 /* label, accelerator */ N_("D_uplicate")("D_uplicate"), NULL((void*)0),
7442 /* tooltip */ N_("Duplicate each selected item")("Duplicate each selected item"),
7443 G_CALLBACK (action_duplicate_callback)((GCallback) (action_duplicate_callback)) },
7444 /* name, icon name */ { "Create Link", NULL((void*)0),
7445 /* label, accelerator */ N_("Ma_ke Link")("Ma_ke Link"), "<control>M",
7446 /* tooltip */ N_("Create a symbolic link for each selected item")("Create a symbolic link for each selected item"),
7447 G_CALLBACK (action_create_link_callback)((GCallback) (action_create_link_callback)) },
7448 /* name, icon name */ { "Rename", NULL((void*)0),
7449 /* label, accelerator */ N_("_Rename...")("_Rename..."), "F2",
7450 /* tooltip */ N_("Rename selected item")("Rename selected item"),
7451 G_CALLBACK (action_rename_callback)((GCallback) (action_rename_callback)) },
7452 /* name, icon name */ { "RenameSelectAll", NULL((void*)0),
7453 /* label, accelerator */ "RenameSelectAll", "<shift>F2",
7454 /* tooltip */ NULL((void*)0),
7455 G_CALLBACK (action_rename_select_all_callback)((GCallback) (action_rename_select_all_callback)) },
7456 /* name, icon name */ { "Trash", NULL((void*)0),
7457 /* label, accelerator */ N_("Mo_ve to Trash")("Mo_ve to Trash"), NULL((void*)0),
7458 /* tooltip */ N_("Move each selected item to the Trash")("Move each selected item to the Trash"),
7459 G_CALLBACK (action_trash_callback)((GCallback) (action_trash_callback)) },
7460 /* name, icon name */ { "Delete", NULL((void*)0),
7461 /* label, accelerator */ N_("_Delete")("_Delete"), NULL((void*)0),
7462 /* tooltip */ N_("Delete each selected item, without moving to the Trash")("Delete each selected item, without moving to the Trash"),
7463 G_CALLBACK (action_delete_callback)((GCallback) (action_delete_callback)) },
7464 /* name, icon name */ { "Restore From Trash", NULL((void*)0),
7465 /* label, accelerator */ N_("_Restore")("_Restore"), NULL((void*)0),
7466 NULL((void*)0),
7467 G_CALLBACK (action_restore_from_trash_callback)((GCallback) (action_restore_from_trash_callback)) },
7468 /* name, icon name */ { FM_ACTION_UNDO"Undo", "edit-undo",
7469 /* label, accelerator */ N_("_Undo")("_Undo"), "<control>Z",
7470 /* tooltip */ N_("Undo the last action")("Undo the last action"),
7471 G_CALLBACK (action_undo_callback)((GCallback) (action_undo_callback)) },
7472 /* name, icon name */ { FM_ACTION_REDO"Redo", "edit-redo",
7473 /* label, accelerator */ N_("_Redo")("_Redo"), "<control>Y",
7474 /* tooltip */ N_("Redo the last undone action")("Redo the last undone action"),
7475 G_CALLBACK (action_redo_callback)((GCallback) (action_redo_callback)) },
7476
7477 /*
7478 * multiview-TODO: decide whether "Reset to Defaults" should
7479 * be window-wide, and not just view-wide.
7480 * Since this also resets the "Show hidden files" mode,
7481 * it is a mixture of both ATM.
7482 */
7483 /* name, icon name */ { "Reset to Defaults", NULL((void*)0),
7484 /* label, accelerator */ N_("Reset View to _Defaults")("Reset View to _Defaults"), NULL((void*)0),
7485 /* 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"
)
,
7486 G_CALLBACK (action_reset_to_defaults_callback)((GCallback) (action_reset_to_defaults_callback)) },
7487 /* name, icon name */ { "Connect To Server Link", NULL((void*)0),
7488 /* label, accelerator */ N_("Connect To This Server")("Connect To This Server"), NULL((void*)0),
7489 /* tooltip */ N_("Make a permanent connection to this server")("Make a permanent connection to this server"),
7490 G_CALLBACK (action_connect_to_server_link_callback)((GCallback) (action_connect_to_server_link_callback)) },
7491 /* name, icon name */ { "Mount Volume", NULL((void*)0),
7492 /* label, accelerator */ N_("_Mount")("_Mount"), NULL((void*)0),
7493 /* tooltip */ N_("Mount the selected volume")("Mount the selected volume"),
7494 G_CALLBACK (action_mount_volume_callback)((GCallback) (action_mount_volume_callback)) },
7495 /* name, icon name */ { "Unmount Volume", NULL((void*)0),
7496 /* label, accelerator */ N_("_Unmount")("_Unmount"), NULL((void*)0),
7497 /* tooltip */ N_("Unmount the selected volume")("Unmount the selected volume"),
7498 G_CALLBACK (action_unmount_volume_callback)((GCallback) (action_unmount_volume_callback)) },
7499 /* name, icon name */ { "Eject Volume", NULL((void*)0),
7500 /* label, accelerator */ N_("_Eject")("_Eject"), NULL((void*)0),
7501 /* tooltip */ N_("Eject the selected volume")("Eject the selected volume"),
7502 G_CALLBACK (action_eject_volume_callback)((GCallback) (action_eject_volume_callback)) },
7503 /* name, icon name */ { "Format Volume", NULL((void*)0),
7504 /* label, accelerator */ N_("_Format")("_Format"), NULL((void*)0),
7505 /* tooltip */ N_("Format the selected volume")("Format the selected volume"),
7506 G_CALLBACK (action_format_volume_callback)((GCallback) (action_format_volume_callback)) },
7507 /* name, icon name */ { "Start Volume", NULL((void*)0),
7508 /* label, accelerator */ N_("_Start")("_Start"), NULL((void*)0),
7509 /* tooltip */ N_("Start the selected volume")("Start the selected volume"),
7510 G_CALLBACK (action_start_volume_callback)((GCallback) (action_start_volume_callback)) },
7511 /* name, icon name */ { "Stop Volume", NULL((void*)0),
7512 /* label, accelerator */ N_("_Stop")("_Stop"), NULL((void*)0),
7513 /* tooltip */ N_("Stop the selected volume")("Stop the selected volume"),
7514 G_CALLBACK (action_stop_volume_callback)((GCallback) (action_stop_volume_callback)) },
7515 /* name, icon name */ { "Poll", NULL((void*)0),
7516 /* label, accelerator */ N_("_Detect Media")("_Detect Media"), NULL((void*)0),
7517 /* tooltip */ N_("Detect media in the selected drive")("Detect media in the selected drive"),
7518 G_CALLBACK (action_detect_media_callback)((GCallback) (action_detect_media_callback)) },
7519 /* name, icon name */ { "Self Mount Volume", NULL((void*)0),
7520 /* label, accelerator */ N_("_Mount")("_Mount"), NULL((void*)0),
7521 /* tooltip */ N_("Mount the volume associated with the open folder")("Mount the volume associated with the open folder"),
7522 G_CALLBACK (action_self_mount_volume_callback)((GCallback) (action_self_mount_volume_callback)) },
7523 /* name, icon name */ { "Self Unmount Volume", NULL((void*)0),
7524 /* label, accelerator */ N_("_Unmount")("_Unmount"), NULL((void*)0),
7525 /* tooltip */ N_("Unmount the volume associated with the open folder")("Unmount the volume associated with the open folder"),
7526 G_CALLBACK (action_self_unmount_volume_callback)((GCallback) (action_self_unmount_volume_callback)) },
7527 /* name, icon name */ { "Self Eject Volume", NULL((void*)0),
7528 /* label, accelerator */ N_("_Eject")("_Eject"), NULL((void*)0),
7529 /* tooltip */ N_("Eject the volume associated with the open folder")("Eject the volume associated with the open folder"),
7530 G_CALLBACK (action_self_eject_volume_callback)((GCallback) (action_self_eject_volume_callback)) },
7531 /* name, icon name */ { "Self Format Volume", NULL((void*)0),
7532 /* label, accelerator */ N_("_Format")("_Format"), NULL((void*)0),
7533 /* tooltip */ N_("Format the volume associated with the open folder")("Format the volume associated with the open folder"),
7534 G_CALLBACK (action_self_format_volume_callback)((GCallback) (action_self_format_volume_callback)) },
7535 /* name, icon name */ { "Self Start Volume", NULL((void*)0),
7536 /* label, accelerator */ N_("_Start")("_Start"), NULL((void*)0),
7537 /* tooltip */ N_("Start the volume associated with the open folder")("Start the volume associated with the open folder"),
7538 G_CALLBACK (action_self_start_volume_callback)((GCallback) (action_self_start_volume_callback)) },
7539 /* name, icon name */ { "Self Stop Volume", NULL((void*)0),
7540 /* label, accelerator */ N_("_Stop")("_Stop"), NULL((void*)0),
7541 /* tooltip */ N_("Stop the volume associated with the open folder")("Stop the volume associated with the open folder"),
7542 G_CALLBACK (action_self_stop_volume_callback)((GCallback) (action_self_stop_volume_callback)) },
7543 /* name, icon name */ { "Self Poll", NULL((void*)0),
7544 /* label, accelerator */ N_("_Detect Media")("_Detect Media"), NULL((void*)0),
7545 /* tooltip */ N_("Detect media in the selected drive")("Detect media in the selected drive"),
7546 G_CALLBACK (action_self_detect_media_callback)((GCallback) (action_self_detect_media_callback)) },
7547 /* name, icon name */ { "OpenCloseParent", NULL((void*)0),
7548 /* label, accelerator */ N_("Open File and Close window")("Open File and Close window"), "<alt><shift>Down",
7549 /* tooltip */ NULL((void*)0),
7550 G_CALLBACK (action_open_close_parent_callback)((GCallback) (action_open_close_parent_callback)) },
7551 /* name, icon name */ { "Save Search", NULL((void*)0),
7552 /* label, accelerator */ N_("Sa_ve Search")("Sa_ve Search"), NULL((void*)0),
7553 /* tooltip */ N_("Save the edited search")("Save the edited search"),
7554 G_CALLBACK (action_save_search_callback)((GCallback) (action_save_search_callback)) },
7555 /* name, icon name */ { "Save Search As", NULL((void*)0),
7556 /* label, accelerator */ N_("Sa_ve Search As...")("Sa_ve Search As..."), NULL((void*)0),
7557 /* tooltip */ N_("Save the current search as a file")("Save the current search as a file"),
7558 G_CALLBACK (action_save_search_as_callback)((GCallback) (action_save_search_as_callback)) },
7559
7560 /* Location-specific actions */
7561 /* name, icon name */ { FM_ACTION_LOCATION_OPEN_ALTERNATE"LocationOpenAlternate", NULL((void*)0),
7562 /* label, accelerator */ N_("Open in Navigation Window")("Open in Navigation Window"), "",
7563 /* tooltip */ N_("Open this folder in a navigation window")("Open this folder in a navigation window"),
7564 G_CALLBACK (action_location_open_alternate_callback)((GCallback) (action_location_open_alternate_callback)) },
7565 /* name, icon name */ { FM_ACTION_LOCATION_OPEN_IN_NEW_TAB"LocationOpenInNewTab", NULL((void*)0),
7566 /* label, accelerator */ N_("Open in New _Tab")("Open in New _Tab"), "",
7567 /* tooltip */ N_("Open this folder in a new tab")("Open this folder in a new tab"),
7568 G_CALLBACK (action_location_open_in_new_tab_callback)((GCallback) (action_location_open_in_new_tab_callback)) },
7569
7570 /* name, icon name */ { FM_ACTION_LOCATION_OPEN_FOLDER_WINDOW"LocationOpenFolderWindow", NULL((void*)0),
7571 /* label, accelerator */ N_("Open in _Folder Window")("Open in _Folder Window"), "",
7572 /* tooltip */ N_("Open this folder in a folder window")("Open this folder in a folder window"),
7573 G_CALLBACK (action_location_open_folder_window_callback)((GCallback) (action_location_open_folder_window_callback)) },
7574
7575 /* name, icon name */ { FM_ACTION_LOCATION_CUT"LocationCut", "edit-cut",
7576 /* label, accelerator */ N_("Cu_t")("Cu_t"), "",
7577 /* tooltip */ N_("Prepare this folder to be moved with a Paste command")("Prepare this folder to be moved with a Paste command"),
7578 G_CALLBACK (action_location_cut_callback)((GCallback) (action_location_cut_callback)) },
7579 /* name, icon name */ { FM_ACTION_LOCATION_COPY"LocationCopy", "edit-copy",
7580 /* label, accelerator */ N_("_Copy")("_Copy"), "",
7581 /* tooltip */ N_("Prepare this folder to be copied with a Paste command")("Prepare this folder to be copied with a Paste command"),
7582 G_CALLBACK (action_location_copy_callback)((GCallback) (action_location_copy_callback)) },
7583 /* name, icon name */ { FM_ACTION_LOCATION_PASTE_FILES_INTO"LocationPasteFilesInto", "edit-paste",
7584 /* label, accelerator */ N_("_Paste Into Folder")("_Paste Into Folder"), "",
7585 /* 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"
)
,
7586 G_CALLBACK (action_location_paste_files_into_callback)((GCallback) (action_location_paste_files_into_callback)) },
7587
7588 /* name, icon name */ { FM_ACTION_LOCATION_TRASH"LocationTrash", NULL((void*)0),
7589 /* label, accelerator */ N_("Mo_ve to Trash")("Mo_ve to Trash"), "",
7590 /* tooltip */ N_("Move this folder to the Trash")("Move this folder to the Trash"),
7591 G_CALLBACK (action_location_trash_callback)((GCallback) (action_location_trash_callback)) },
7592 /* name, icon name */ { FM_ACTION_LOCATION_DELETE"LocationDelete", BAUL_ICON_DELETE"edit-delete",
7593 /* label, accelerator */ N_("_Delete")("_Delete"), "",
7594 /* tooltip */ N_("Delete this folder, without moving to the Trash")("Delete this folder, without moving to the Trash"),
7595 G_CALLBACK (action_location_delete_callback)((GCallback) (action_location_delete_callback)) },
7596 /* name, icon name */ { FM_ACTION_LOCATION_RESTORE_FROM_TRASH"LocationRestoreFromTrash", NULL((void*)0),
7597 /* label, accelerator */ N_("_Restore")("_Restore"), NULL((void*)0), NULL((void*)0),
7598 G_CALLBACK (action_location_restore_from_trash_callback)((GCallback) (action_location_restore_from_trash_callback)) },
7599
7600 /* name, icon name */ { "Location Mount Volume", NULL((void*)0),
7601 /* label, accelerator */ N_("_Mount")("_Mount"), NULL((void*)0),
7602 /* tooltip */ N_("Mount the volume associated with this folder")("Mount the volume associated with this folder"),
7603 G_CALLBACK (action_location_mount_volume_callback)((GCallback) (action_location_mount_volume_callback)) },
7604 /* name, icon name */ { "Location Unmount Volume", NULL((void*)0),
7605 /* label, accelerator */ N_("_Unmount")("_Unmount"), NULL((void*)0),
7606 /* tooltip */ N_("Unmount the volume associated with this folder")("Unmount the volume associated with this folder"),
7607 G_CALLBACK (action_location_unmount_volume_callback)((GCallback) (action_location_unmount_volume_callback)) },
7608 /* name, icon name */ { "Location Eject Volume", NULL((void*)0),
7609 /* label, accelerator */ N_("_Eject")("_Eject"), NULL((void*)0),
7610 /* tooltip */ N_("Eject the volume associated with this folder")("Eject the volume associated with this folder"),
7611 G_CALLBACK (action_location_eject_volume_callback)((GCallback) (action_location_eject_volume_callback)) },
7612 /* name, icon name */ { "Location Format Volume", NULL((void*)0),
7613 /* label, accelerator */ N_("_Format")("_Format"), NULL((void*)0),
7614 /* tooltip */ N_("Format the volume associated with this folder")("Format the volume associated with this folder"),
7615 G_CALLBACK (action_location_format_volume_callback)((GCallback) (action_location_format_volume_callback)) },
7616 /* name, icon name */ { "Location Start Volume", NULL((void*)0),
7617 /* label, accelerator */ N_("_Start")("_Start"), NULL((void*)0),
7618 /* tooltip */ N_("Start the volume associated with this folder")("Start the volume associated with this folder"),
7619 G_CALLBACK (action_location_start_volume_callback)((GCallback) (action_location_start_volume_callback)) },
7620 /* name, icon name */ { "Location Stop Volume", NULL((void*)0),
7621 /* label, accelerator */ N_("_Stop")("_Stop"), NULL((void*)0),
7622 /* tooltip */ N_("Stop the volume associated with this folder")("Stop the volume associated with this folder"),
7623 G_CALLBACK (action_location_stop_volume_callback)((GCallback) (action_location_stop_volume_callback)) },
7624 /* name, icon name */ { "Location Poll", NULL((void*)0),
7625 /* label, accelerator */ N_("_Detect Media")("_Detect Media"), NULL((void*)0),
7626 /* tooltip */ N_("Detect media in the selected drive")("Detect media in the selected drive"),
7627 G_CALLBACK (action_location_detect_media_callback)((GCallback) (action_location_detect_media_callback)) },
7628
7629 /* name, icon name */ { "LocationProperties", "document-properties",
7630 /* label, accelerator */ N_("_Properties")("_Properties"), NULL((void*)0),
7631 /* tooltip */ N_("View or modify the properties of this folder")("View or modify the properties of this folder"),
7632 G_CALLBACK (action_location_properties_callback)((GCallback) (action_location_properties_callback)) },
7633
7634 /* name, icon name, label */ {FM_ACTION_COPY_TO_NEXT_PANE"Copy to next pane", NULL((void*)0), N_("_Other pane")("_Other pane"),
7635 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"
)
,
7636 G_CALLBACK (action_copy_to_next_pane_callback)((GCallback) (action_copy_to_next_pane_callback)) },
7637 /* name, icon name, label */ {FM_ACTION_MOVE_TO_NEXT_PANE"Move to next pane", NULL((void*)0), N_("_Other pane")("_Other pane"),
7638 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"
)
,
7639 G_CALLBACK (action_move_to_next_pane_callback)((GCallback) (action_move_to_next_pane_callback)) },
7640 /* name, icon name, label */ {FM_ACTION_COPY_TO_HOME"Copy to Home", BAUL_ICON_HOME"user-home",
7641 N_("_Home Folder")("_Home Folder"), NULL((void*)0),
7642 N_("Copy the current selection to the home folder")("Copy the current selection to the home folder"),
7643 G_CALLBACK (action_copy_to_home_callback)((GCallback) (action_copy_to_home_callback)) },
7644 /* name, icon name, label */ {FM_ACTION_MOVE_TO_HOME"Move to Home", BAUL_ICON_HOME"user-home",
7645 N_("_Home Folder")("_Home Folder"), NULL((void*)0),
7646 N_("Move the current selection to the home folder")("Move the current selection to the home folder"),
7647 G_CALLBACK (action_move_to_home_callback)((GCallback) (action_move_to_home_callback)) },
7648 /* name, icon name, label */ {FM_ACTION_COPY_TO_DESKTOP"Copy to Desktop", BAUL_ICON_DESKTOP"user-desktop",
7649 N_("_Desktop")("_Desktop"), NULL((void*)0),
7650 N_("Copy the current selection to the desktop")("Copy the current selection to the desktop"),
7651 G_CALLBACK (action_copy_to_desktop_callback)((GCallback) (action_copy_to_desktop_callback)) },
7652 /* name, icon name, label */ {FM_ACTION_MOVE_TO_DESKTOP"Move to Desktop", BAUL_ICON_DESKTOP"user-desktop",
7653 N_("_Desktop")("_Desktop"), NULL((void*)0),
7654 N_("Move the current selection to the desktop")("Move the current selection to the desktop"),
7655 G_CALLBACK (action_move_to_desktop_callback)((GCallback) (action_move_to_desktop_callback)) },
7656};
7657
7658static void
7659connect_proxy (FMDirectoryView *view,
7660 CtkAction *action,
7661 CtkWidget *proxy,
7662 CtkActionGroup *action_group)
7663{
7664 const gchar *action_name;
7665
7666 action_name = ctk_action_get_name (action);
7667
7668 if (strcmp (action_name, FM_ACTION_NEW_EMPTY_FILE"New Empty File") == 0 &&
7669 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; }))))
) {
7670 cairo_surface_t *surface;
7671
7672 surface = get_menu_icon ("text-x-generic", CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
);
7673
7674 if (surface != NULL((void*)0)) {
7675 CtkWidget *image;
7676
7677 image = ctk_image_new_from_surface (surface);
7678 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);
7679
7680 cairo_surface_destroy (surface);
7681 }
7682 }
7683}
7684
7685static void
7686pre_activate (FMDirectoryView *view,
7687 CtkAction *action,
7688 CtkActionGroup *action_group)
7689{
7690 CdkEvent *event;
7691 CtkWidget *proxy;
7692 gboolean activated_from_popup;
7693
7694 /* check whether action was activated through a popup menu.
7695 * If not, unset the last stored context menu popup position */
7696 activated_from_popup = FALSE(0);
7697
7698 event = ctk_get_current_event ();
7699 proxy = ctk_get_event_widget (event);
7700
7701 if (proxy != NULL((void*)0)) {
7702 CtkWidget *toplevel;
7703 CdkWindowTypeHint hint;
7704
7705 toplevel = ctk_widget_get_toplevel (proxy);
7706
7707 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; }))))
) {
7708 hint = ctk_window_get_type_hint (CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((toplevel)), ((ctk_window_get_type ()))))))
);
7709
7710 if (hint == CDK_WINDOW_TYPE_HINT_POPUP_MENU) {
7711 activated_from_popup = TRUE(!(0));
7712 }
7713 }
7714 }
7715
7716 if (!activated_from_popup) {
7717 update_context_menu_position_from_event (view, NULL((void*)0));
7718 }
7719}
7720
7721static void
7722real_merge_menus (FMDirectoryView *view)
7723{
7724 CtkActionGroup *action_group;
7725 CtkUIManager *ui_manager;
7726 CtkAction *action;
7727 const char *ui;
7728 char *tooltip;
7729
7730 ui_manager = baul_window_info_get_ui_manager (view->details->window);
7731
7732 action_group = ctk_action_group_new ("DirViewActions");
7733 ctk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"baul");
7734 view->details->dir_action_group = action_group;
7735 ctk_action_group_add_actions (action_group,
7736 directory_view_entries, G_N_ELEMENTS (directory_view_entries)(sizeof (directory_view_entries) / sizeof ((directory_view_entries
)[0]))
,
7737 view);
7738
7739 /* Translators: %s is a directory */
7740 tooltip = g_strdup_printf(_("Run or manage scripts from %s")gettext ("Run or manage scripts from %s"), "~/.config/baul/scripts");
7741 /* Create a script action here specially because its tooltip is dynamic */
7742 action = ctk_action_new ("Scripts", _("_Scripts")gettext ("_Scripts"), tooltip, NULL((void*)0));
7743 ctk_action_group_add_action (action_group, action);
7744 g_object_unref (action);
7745 g_free (tooltip);
7746
7747 action = ctk_action_group_get_action (action_group, FM_ACTION_NO_TEMPLATES"No Templates");
7748 ctk_action_set_sensitive (action, FALSE(0));
7749
7750 g_signal_connect_object (action_group, "connect-proxy",
7751 G_CALLBACK (connect_proxy)((GCallback) (connect_proxy)), G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), (((GType) ((20) << (2))))))))
,
7752 G_CONNECT_SWAPPED);
7753 g_signal_connect_object (action_group, "pre-activate",
7754 G_CALLBACK (pre_activate)((GCallback) (pre_activate)), G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), (((GType) ((20) << (2))))))))
,
7755 G_CONNECT_SWAPPED);
7756
7757 /* Insert action group at end so clipboard action group ends up before it */
7758 ctk_ui_manager_insert_action_group (ui_manager, action_group, -1);
7759 g_object_unref (action_group); /* owned by ui manager */
7760
7761 ui = baul_ui_string_get ("baul-directory-view-ui.xml");
7762 view->details->dir_merge_id = ctk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL((void*)0));
7763 g_signal_connect_object (fm_directory_view_get_background (view), "settings_changed",
7764 G_CALLBACK (schedule_update_menus)((GCallback) (schedule_update_menus)), G_OBJECT (view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), (((GType) ((20) << (2))))))))
,
7765 G_CONNECT_SWAPPED);
7766 view->details->scripts_invalid = TRUE(!(0));
7767 view->details->templates_invalid = TRUE(!(0));
7768}
7769
7770
7771static gboolean
7772can_paste_into_file (BaulFile *file)
7773{
7774 if (baul_file_is_directory (file) &&
7775 baul_file_can_write (file)) {
7776 return TRUE(!(0));
7777 }
7778 if (baul_file_has_activation_uri (file)) {
7779 GFile *location;
7780 BaulFile *activation_file;
7781 gboolean res;
7782
7783 location = baul_file_get_activation_location (file);
7784 activation_file = baul_file_get (location);
7785 g_object_unref (location);
7786
7787 /* The target location might not have data for it read yet,
7788 and we can't want to do sync I/O, so treat the unknown
7789 case as can-write */
7790 res = (baul_file_get_file_type (activation_file) == G_FILE_TYPE_UNKNOWN) ||
7791 (baul_file_get_file_type (activation_file) == G_FILE_TYPE_DIRECTORY &&
7792 baul_file_can_write (activation_file));
7793
7794 baul_file_unref (activation_file);
7795
7796 return res;
7797 }
7798
7799 return FALSE(0);
7800}
7801
7802static void
7803clipboard_targets_received (CtkClipboard *clipboard,
7804 CdkAtom *targets,
7805 int n_targets,
7806 gpointer user_data)
7807{
7808 FMDirectoryView *view;
7809 gboolean can_paste;
7810 GList *selection;
7811 int count;
7812 CtkAction *action;
7813
7814 view = FM_DIRECTORY_VIEW (user_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (fm_directory_view_get_type())))))
;
7815 can_paste = FALSE(0);
7816
7817 if (view->details->window == NULL((void*)0) ||
7818 !view->details->active) {
7819 /* We've been destroyed or became inactive since call */
7820 g_object_unref (view);
7821 return;
7822 }
7823
7824 if (targets) {
7825 int i;
7826
7827 for (i=0; i < n_targets; i++) {
7828 if (targets[i] == copied_files_atom) {
7829 can_paste = TRUE(!(0));
7830 }
7831 }
7832 }
7833
7834
7835 selection = fm_directory_view_get_selection (view);
7836 count = g_list_length (selection);
7837
7838 action = ctk_action_group_get_action (view->details->dir_action_group,
7839 FM_ACTION_PASTE"Paste");
7840 ctk_action_set_sensitive (action,
7841 can_paste && !fm_directory_view_is_read_only (view));
7842
7843 action = ctk_action_group_get_action (view->details->dir_action_group,
7844 FM_ACTION_PASTE_FILES_INTO"Paste Files Into");
7845 ctk_action_set_sensitive (action,
7846 can_paste && count == 1 &&
7847 can_paste_into_file (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
));
7848
7849 action = ctk_action_group_get_action (view->details->dir_action_group,
7850 FM_ACTION_LOCATION_PASTE_FILES_INTO"LocationPasteFilesInto");
7851 g_object_set_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
,
7852 "can-paste-according-to-clipboard",
7853 GINT_TO_POINTER (can_paste)((gpointer) (glong) (can_paste)));
7854 ctk_action_set_sensitive (action,
7855 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")))
7856 "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")))
&&
7857 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")))
7858 "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")))
);
7859
7860 baul_file_list_free (selection);
7861
7862 g_object_unref (view);
7863}
7864
7865static gboolean
7866showing_trash_directory (FMDirectoryView *view)
7867{
7868 BaulFile *file;
7869
7870 file = fm_directory_view_get_directory_as_file (view);
7871 if (file != NULL((void*)0)) {
7872 return baul_file_is_in_trash (file);
7873 }
7874 return FALSE(0);
7875}
7876
7877static gboolean
7878should_show_empty_trash (FMDirectoryView *view)
7879{
7880 return (showing_trash_directory (view) || baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION);
7881}
7882
7883static gboolean
7884file_list_all_are_folders (GList *file_list)
7885{
7886 GList *l;
7887 char *activation_uri;
7888 gboolean is_dir;
7889 BaulFile *linked_file;
7890 BaulFile *file = NULL((void*)0);
7891
7892 for (l = file_list; l != NULL((void*)0); l = l->next) {
7893 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
7894 if (baul_file_is_baul_link (file) &&
7895 !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; }))))
) {
7896 if (baul_file_is_launcher (file)) {
7897 return FALSE(0);
7898 }
7899
7900 activation_uri = baul_file_get_activation_uri (file);
7901
7902 if (activation_uri == NULL((void*)0)) {
7903 g_free (activation_uri);
7904 return FALSE(0);
7905 }
7906
7907 linked_file = baul_file_get_existing_by_uri (activation_uri);
7908
7909 /* We might not actually know the type of the linked file yet,
7910 * however we don't want to schedule a read, since that might do things
7911 * like ask for password etc. This is a bit unfortunate, but I don't
7912 * know any way around it, so we do various heuristics here
7913 * to get things mostly right
7914 */
7915 is_dir =
7916 (linked_file != NULL((void*)0) &&
7917 baul_file_is_directory (linked_file)) ||
7918 (activation_uri != NULL((void*)0) &&
7919 activation_uri[strlen (activation_uri) - 1] == '/');
7920
7921 baul_file_unref (linked_file);
7922 g_free (activation_uri);
7923
7924 if (!is_dir) {
7925 return FALSE(0);
7926 }
7927 } else if (!(baul_file_is_directory (file) ||
7928 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; }))))
)) {
7929 return FALSE(0);
7930 }
7931 }
7932 return TRUE(!(0));
7933}
7934
7935static void
7936file_should_show_foreach (BaulFile *file,
7937 gboolean *show_mount,
7938 gboolean *show_unmount,
7939 gboolean *show_eject,
7940 gboolean *show_connect,
7941 gboolean *show_format,
7942 gboolean *show_start,
7943 gboolean *show_stop,
7944 gboolean *show_poll,
7945 GDriveStartStopType *start_stop_type)
7946{
7947 *show_mount = FALSE(0);
7948 *show_unmount = FALSE(0);
7949 *show_eject = FALSE(0);
7950 *show_connect = FALSE(0);
7951 *show_format = FALSE(0);
7952 *show_start = FALSE(0);
7953 *show_stop = FALSE(0);
7954 *show_poll = FALSE(0);
7955
7956 if (baul_file_can_eject (file)) {
7957 *show_eject = TRUE(!(0));
7958 }
7959
7960 if (baul_file_can_mount (file)) {
7961 *show_mount = TRUE(!(0));
7962
7963#ifdef TODO_GIO
7964 if (something &&
7965 g_find_program_in_path ("gfloppy")) {
7966 *show_format = TRUE(!(0));
7967 }
7968#endif
7969 }
7970
7971 if (baul_file_can_start (file) || baul_file_can_start_degraded (file)) {
7972 *show_start = TRUE(!(0));
7973 }
7974
7975 if (baul_file_can_stop (file)) {
7976 *show_stop = TRUE(!(0));
7977 }
7978
7979 /* Dot not show both Unmount and Eject/Safe Removal; too confusing to
7980 * have too many menu entries */
7981 if (baul_file_can_unmount (file) && !*show_eject && !*show_stop) {
7982 *show_unmount = TRUE(!(0));
7983 }
7984
7985 if (baul_file_can_poll_for_media (file) && !baul_file_is_media_check_automatic (file)) {
7986 *show_poll = TRUE(!(0));
7987 }
7988
7989 *start_stop_type = baul_file_get_start_stop_type (file);
7990
7991 if (baul_file_is_baul_link (file)) {
7992 char *uri;
7993
7994 uri = baul_file_get_activation_uri (file);
7995 if (uri != NULL((void*)0) &&
7996 (eel_istr_has_prefix (uri, "ftp:") ||
7997 eel_istr_has_prefix (uri, "ssh:") ||
7998 eel_istr_has_prefix (uri, "sftp:") ||
7999 eel_istr_has_prefix (uri, "dav:") ||
8000 eel_istr_has_prefix (uri, "davs:"))) {
8001 *show_connect = TRUE(!(0));
8002 }
8003 g_free (uri);
8004 }
8005}
8006
8007static void
8008file_should_show_self (BaulFile *file,
8009 gboolean *show_mount,
8010 gboolean *show_unmount,
8011 gboolean *show_eject,
8012 gboolean *show_format,
8013 gboolean *show_start,
8014 gboolean *show_stop,
8015 gboolean *show_poll,
8016 GDriveStartStopType *start_stop_type)
8017{
8018 *show_mount = FALSE(0);
8019 *show_unmount = FALSE(0);
8020 *show_eject = FALSE(0);
8021 *show_format = FALSE(0);
8022 *show_start = FALSE(0);
8023 *show_stop = FALSE(0);
8024 *show_poll = FALSE(0);
8025
8026 if (file == NULL((void*)0)) {
8027 return;
8028 }
8029
8030 if (baul_file_can_eject (file)) {
8031 *show_eject = TRUE(!(0));
8032 }
8033
8034 if (baul_file_can_mount (file)) {
8035 *show_mount = TRUE(!(0));
8036 }
8037
8038#ifdef TODO_GIO
8039 if (something && g_find_program_in_path ("gfloppy")) {
8040 *show_format = TRUE(!(0));
8041 }
8042#endif
8043
8044 if (baul_file_can_start (file) || baul_file_can_start_degraded (file)) {
8045 *show_start = TRUE(!(0));
8046 }
8047
8048 if (baul_file_can_stop (file)) {
8049 *show_stop = TRUE(!(0));
8050 }
8051
8052 /* Dot not show both Unmount and Eject/Safe Removal; too confusing to
8053 * have too many menu entries */
8054 if (baul_file_can_unmount (file) && !*show_eject && !*show_stop) {
8055 *show_unmount = TRUE(!(0));
8056 }
8057
8058 if (baul_file_can_poll_for_media (file) && !baul_file_is_media_check_automatic (file)) {
8059 *show_poll = TRUE(!(0));
8060 }
8061
8062 *start_stop_type = baul_file_get_start_stop_type (file);
8063
8064}
8065
8066static gboolean
8067files_are_all_directories (GList *files)
8068{
8069 GList *l;
8070 gboolean all_directories;
8071 BaulFile *file = NULL((void*)0);
8072
8073 all_directories = TRUE(!(0));
8074
8075 for (l = files; l != NULL((void*)0); l = l->next) {
8076 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
8077 all_directories &= baul_file_is_directory (file);
8078 }
8079
8080 return all_directories;
8081}
8082
8083static gboolean
8084files_is_none_directory (GList *files)
8085{
8086 GList *l;
8087 gboolean no_directory;
8088 BaulFile *file = NULL((void*)0);
8089
8090 no_directory = TRUE(!(0));
8091
8092 for (l = files; l != NULL((void*)0); l = l->next) {
8093 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
8094 no_directory &= !baul_file_is_directory (file);
8095 }
8096
8097 return no_directory;
8098}
8099
8100static void
8101update_restore_from_trash_action (CtkAction *action,
8102 GList *files,
8103 gboolean is_self)
8104{
8105 BaulFile *original_file;
8106 BaulFile *original_dir;
8107 GHashTable *original_dirs_hash;
8108 GList *original_dirs;
8109 GFile *original_location;
8110 char *original_name;
8111
8112 original_file = NULL((void*)0);
8113 original_dir = NULL((void*)0);
8114 original_dirs = NULL((void*)0);
8115 original_dirs_hash = NULL((void*)0);
8116 original_location = NULL((void*)0);
8117 original_name = NULL((void*)0);
8118
8119 if (files != NULL((void*)0)) {
8120 if (g_list_length (files) == 1) {
8121 original_file = baul_file_get_trash_original_file (files->data);
8122 } else {
8123 original_dirs_hash = baul_trashed_files_get_original_directories (files, NULL((void*)0));
8124 if (original_dirs_hash != NULL((void*)0)) {
8125 original_dirs = g_hash_table_get_keys (original_dirs_hash);
8126 if (g_list_length (original_dirs) == 1) {
8127 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())))))
);
8128 }
8129 }
8130 }
8131 }
8132
8133 if (original_file != NULL((void*)0) || original_dirs != NULL((void*)0)) {
8134 char *tooltip;
8135
8136 ctk_action_set_visible (action, TRUE(!(0)));
8137
8138 if (original_file != NULL((void*)0)) {
8139 original_location = baul_file_get_location (original_file);
8140 } else if (original_dir != NULL((void*)0)) {
8141 original_location = baul_file_get_location (original_dir);
8142 }
8143
8144 if (original_location != NULL((void*)0)) {
8145 original_name = g_file_get_parse_name (original_location);
8146 }
8147
8148 if (is_self) {
8149 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", 8149, ((const char*) (
__func__)), "g_list_length (files) == 1"); } while (0)
;
8150 g_assert (original_location != NULL)do { if (original_location != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 8150, ((const char*) (
__func__)), "original_location != NULL"); } while (0)
;
8151 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);
8152 } else if (files_are_all_directories (files)) {
8153 if (original_name != NULL((void*)0)) {
8154 tooltip = g_strdup_printf (ngettext ("Move the selected folder out of the trash to \"%s\"",
8155 "Move the selected folders out of the trash to \"%s\"",
8156 g_list_length (files)), original_name);
8157 } else {
8158 tooltip = g_strdup_printf (ngettext ("Move the selected folder out of the trash",
8159 "Move the selected folders out of the trash",
8160 g_list_length (files)));
8161 }
8162 } else if (files_is_none_directory (files)) {
8163 if (original_name != NULL((void*)0)) {
8164 tooltip = g_strdup_printf (ngettext ("Move the selected file out of the trash to \"%s\"",
8165 "Move the selected files out of the trash to \"%s\"",
8166 g_list_length (files)), original_name);
8167 } else {
8168 tooltip = g_strdup_printf (ngettext ("Move the selected file out of the trash",
8169 "Move the selected files out of the trash",
8170 g_list_length (files)));
8171 }
8172 } else {
8173 if (original_name != NULL((void*)0)) {
8174 tooltip = g_strdup_printf (ngettext ("Move the selected item out of the trash to \"%s\"",
8175 "Move the selected items out of the trash to \"%s\"",
8176 g_list_length (files)), original_name);
8177 } else {
8178 tooltip = g_strdup_printf (ngettext ("Move the selected item out of the trash",
8179 "Move the selected items out of the trash",
8180 g_list_length (files)));
8181 }
8182 }
8183 g_free (original_name);
8184
8185 g_object_set (action, "tooltip", tooltip, NULL((void*)0));
8186
8187 if (original_location != NULL((void*)0)) {
8188 g_object_unref (original_location);
8189 }
8190 } else {
8191 ctk_action_set_visible (action, FALSE(0));
8192 }
8193
8194 baul_file_unref (original_file);
8195 baul_file_unref (original_dir);
8196 g_list_free (original_dirs);
8197
8198 if (original_dirs_hash != NULL((void*)0)) {
8199 g_hash_table_destroy (original_dirs_hash);
8200 }
8201}
8202
8203static void
8204real_update_menus_volumes (FMDirectoryView *view,
8205 GList *selection,
8206 gint selection_count)
8207{
8208 GList *l;
8209 BaulFile *file;
8210 gboolean show_mount;
8211 gboolean show_unmount;
8212 gboolean show_eject;
8213 gboolean show_connect;
8214 gboolean show_format;
8215 gboolean show_start;
8216 gboolean show_stop;
8217 gboolean show_poll;
8218 GDriveStartStopType start_stop_type;
8219 gboolean show_self_mount;
8220 gboolean show_self_unmount;
8221 gboolean show_self_eject;
8222 gboolean show_self_format;
8223 gboolean show_self_start;
8224 gboolean show_self_stop;
8225 gboolean show_self_poll;
8226 GDriveStartStopType self_start_stop_type;
8227 CtkAction *action;
8228
8229 show_mount = (selection != NULL((void*)0));
8230 show_unmount = (selection != NULL((void*)0));
8231 show_eject = (selection != NULL((void*)0));
8232 show_connect = (selection != NULL((void*)0) && selection_count == 1);
8233 show_format = (selection != NULL((void*)0) && selection_count == 1);
8234 show_start = (selection != NULL((void*)0) && selection_count == 1);
8235 show_stop = (selection != NULL((void*)0) && selection_count == 1);
8236 show_poll = (selection != NULL((void*)0) && selection_count == 1);
8237 start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN;
8238 self_start_stop_type = G_DRIVE_START_STOP_TYPE_UNKNOWN;
8239
8240 for (l = selection; l != NULL((void*)0) && (show_mount || show_unmount
8241 || show_eject || show_connect
8242 || show_format || show_start
8243 || show_stop || show_poll);
8244 l = l->next) {
8245 gboolean show_mount_one;
8246 gboolean show_unmount_one;
8247 gboolean show_eject_one;
8248 gboolean show_connect_one;
8249 gboolean show_format_one;
8250 gboolean show_start_one;
8251 gboolean show_stop_one;
8252 gboolean show_poll_one;
8253
8254 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
8255 file_should_show_foreach (file,
8256 &show_mount_one,
8257 &show_unmount_one,
8258 &show_eject_one,
8259 &show_connect_one,
8260 &show_format_one,
8261 &show_start_one,
8262 &show_stop_one,
8263 &show_poll_one,
8264 &start_stop_type);
8265
8266 show_mount &= show_mount_one;
8267 show_unmount &= show_unmount_one;
8268 show_eject &= show_eject_one;
8269 show_connect &= show_connect_one;
8270 show_format &= show_format_one;
8271 show_start &= show_start_one;
8272 show_stop &= show_stop_one;
8273 show_poll &= show_poll_one;
8274 }
8275
8276 action = ctk_action_group_get_action (view->details->dir_action_group,
8277 FM_ACTION_CONNECT_TO_SERVER_LINK"Connect To Server Link");
8278 ctk_action_set_visible (action, show_connect);
8279
8280 action = ctk_action_group_get_action (view->details->dir_action_group,
8281 FM_ACTION_MOUNT_VOLUME"Mount Volume");
8282 ctk_action_set_visible (action, show_mount);
8283
8284 action = ctk_action_group_get_action (view->details->dir_action_group,
8285 FM_ACTION_UNMOUNT_VOLUME"Unmount Volume");
8286 ctk_action_set_visible (action, show_unmount);
8287
8288 action = ctk_action_group_get_action (view->details->dir_action_group,
8289 FM_ACTION_EJECT_VOLUME"Eject Volume");
8290 ctk_action_set_visible (action, show_eject);
8291
8292 action = ctk_action_group_get_action (view->details->dir_action_group,
8293 FM_ACTION_FORMAT_VOLUME"Format Volume");
8294 ctk_action_set_visible (action, show_format);
8295
8296 action = ctk_action_group_get_action (view->details->dir_action_group,
8297 FM_ACTION_START_VOLUME"Start Volume");
8298 ctk_action_set_visible (action, show_start);
8299 if (show_start) {
8300 switch (start_stop_type) {
8301 default:
8302 case G_DRIVE_START_STOP_TYPE_UNKNOWN:
8303 ctk_action_set_label (action, _("_Start")gettext ("_Start"));
8304 ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive"));
8305 break;
8306 case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
8307 ctk_action_set_label (action, _("_Start")gettext ("_Start"));
8308 ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive"));
8309 break;
8310 case G_DRIVE_START_STOP_TYPE_NETWORK:
8311 ctk_action_set_label (action, _("_Connect")gettext ("_Connect"));
8312 ctk_action_set_tooltip (action, _("Connect to the selected drive")gettext ("Connect to the selected drive"));
8313 break;
8314 case G_DRIVE_START_STOP_TYPE_MULTIDISK:
8315 ctk_action_set_label (action, _("_Start Multi-disk Drive")gettext ("_Start Multi-disk Drive"));
8316 ctk_action_set_tooltip (action, _("Start the selected multi-disk drive")gettext ("Start the selected multi-disk drive"));
8317 break;
8318 case G_DRIVE_START_STOP_TYPE_PASSWORD:
8319 ctk_action_set_label (action, _("U_nlock Drive")gettext ("U_nlock Drive"));
8320 ctk_action_set_tooltip (action, _("Unlock the selected drive")gettext ("Unlock the selected drive"));
8321 break;
8322 }
8323 }
8324
8325 action = ctk_action_group_get_action (view->details->dir_action_group,
8326 FM_ACTION_STOP_VOLUME"Stop Volume");
8327 ctk_action_set_visible (action, show_stop);
8328 if (show_stop) {
8329 switch (start_stop_type) {
8330 default:
8331 case G_DRIVE_START_STOP_TYPE_UNKNOWN:
8332 ctk_action_set_label (action, _("_Stop")gettext ("_Stop"));
8333 ctk_action_set_tooltip (action, _("Stop the selected drive")gettext ("Stop the selected drive"));
8334 break;
8335 case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
8336 ctk_action_set_label (action, _("_Safely Remove Drive")gettext ("_Safely Remove Drive"));
8337 ctk_action_set_tooltip (action, _("Safely remove the selected drive")gettext ("Safely remove the selected drive"));
8338 break;
8339 case G_DRIVE_START_STOP_TYPE_NETWORK:
8340 ctk_action_set_label (action, _("_Disconnect")gettext ("_Disconnect"));
8341 ctk_action_set_tooltip (action, _("Disconnect the selected drive")gettext ("Disconnect the selected drive"));
8342 break;
8343 case G_DRIVE_START_STOP_TYPE_MULTIDISK:
8344 ctk_action_set_label (action, _("_Stop Multi-disk Drive")gettext ("_Stop Multi-disk Drive"));
8345 ctk_action_set_tooltip (action, _("Stop the selected multi-disk drive")gettext ("Stop the selected multi-disk drive"));
8346 break;
8347 case G_DRIVE_START_STOP_TYPE_PASSWORD:
8348 ctk_action_set_label (action, _("_Lock Drive")gettext ("_Lock Drive"));
8349 ctk_action_set_tooltip (action, _("Lock the selected drive")gettext ("Lock the selected drive"));
8350 break;
8351 }
8352 }
8353
8354 action = ctk_action_group_get_action (view->details->dir_action_group,
8355 FM_ACTION_POLL"Poll");
8356 ctk_action_set_visible (action, show_poll);
8357
8358 show_self_mount = show_self_unmount = show_self_eject =
8359 show_self_format = show_self_start = show_self_stop = show_self_poll = FALSE(0);
8360
8361 file = fm_directory_view_get_directory_as_file (view);
8362 file_should_show_self (file,
8363 &show_self_mount,
8364 &show_self_unmount,
8365 &show_self_eject,
8366 &show_self_format,
8367 &show_self_start,
8368 &show_self_stop,
8369 &show_self_poll,
8370 &self_start_stop_type);
8371
8372 action = ctk_action_group_get_action (view->details->dir_action_group,
8373 FM_ACTION_SELF_MOUNT_VOLUME"Self Mount Volume");
8374 ctk_action_set_visible (action, show_self_mount);
8375
8376 action = ctk_action_group_get_action (view->details->dir_action_group,
8377 FM_ACTION_SELF_UNMOUNT_VOLUME"Self Unmount Volume");
8378 ctk_action_set_visible (action, show_self_unmount);
8379
8380 action = ctk_action_group_get_action (view->details->dir_action_group,
8381 FM_ACTION_SELF_EJECT_VOLUME"Self Eject Volume");
8382 ctk_action_set_visible (action, show_self_eject);
8383
8384 action = ctk_action_group_get_action (view->details->dir_action_group,
8385 FM_ACTION_SELF_FORMAT_VOLUME"Self Format Volume");
8386 ctk_action_set_visible (action, show_self_format);
8387
8388 action = ctk_action_group_get_action (view->details->dir_action_group,
8389 FM_ACTION_SELF_START_VOLUME"Self Start Volume");
8390 ctk_action_set_visible (action, show_self_start);
8391 if (show_self_start) {
8392 switch (self_start_stop_type) {
8393 default:
8394 case G_DRIVE_START_STOP_TYPE_UNKNOWN:
8395 ctk_action_set_label (action, _("_Start")gettext ("_Start"));
8396 ctk_action_set_tooltip (action, _("Start the drive associated with the open folder")gettext ("Start the drive associated with the open folder"));
8397 break;
8398 case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
8399 ctk_action_set_label (action, _("_Start")gettext ("_Start"));
8400 ctk_action_set_tooltip (action, _("Start the drive associated with the open folder")gettext ("Start the drive associated with the open folder"));
8401 break;
8402 case G_DRIVE_START_STOP_TYPE_NETWORK:
8403 ctk_action_set_label (action, _("_Connect")gettext ("_Connect"));
8404 ctk_action_set_tooltip (action, _("Connect to the drive associated with the open folder")gettext ("Connect to the drive associated with the open folder"
)
);
8405 break;
8406 case G_DRIVE_START_STOP_TYPE_MULTIDISK:
8407 ctk_action_set_label (action, _("_Start Multi-disk Drive")gettext ("_Start Multi-disk Drive"));
8408 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"
)
);
8409 break;
8410 case G_DRIVE_START_STOP_TYPE_PASSWORD:
8411 ctk_action_set_label (action, _("_Unlock Drive")gettext ("_Unlock Drive"));
8412 ctk_action_set_tooltip (action, _("Unlock the drive associated with the open folder")gettext ("Unlock the drive associated with the open folder"));
8413 break;
8414 }
8415 }
8416
8417 action = ctk_action_group_get_action (view->details->dir_action_group,
8418 FM_ACTION_SELF_STOP_VOLUME"Self Stop Volume");
8419 ctk_action_set_visible (action, show_self_stop);
8420 if (show_self_stop) {
8421 switch (self_start_stop_type) {
8422 default:
8423 case G_DRIVE_START_STOP_TYPE_UNKNOWN:
8424 ctk_action_set_label (action, _("_Stop")gettext ("_Stop"));
8425 ctk_action_set_tooltip (action, _("_Stop the drive associated with the open folder")gettext ("_Stop the drive associated with the open folder"));
8426 break;
8427 case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
8428 ctk_action_set_label (action, _("_Safely Remove Drive")gettext ("_Safely Remove Drive"));
8429 ctk_action_set_tooltip (action, _("Safely remove the drive associated with the open folder")gettext ("Safely remove the drive associated with the open folder"
)
);
8430 break;
8431 case G_DRIVE_START_STOP_TYPE_NETWORK:
8432 ctk_action_set_label (action, _("_Disconnect")gettext ("_Disconnect"));
8433 ctk_action_set_tooltip (action, _("Disconnect the drive associated with the open folder")gettext ("Disconnect the drive associated with the open folder"
)
);
8434 break;
8435 case G_DRIVE_START_STOP_TYPE_MULTIDISK:
8436 ctk_action_set_label (action, _("_Stop Multi-disk Drive")gettext ("_Stop Multi-disk Drive"));
8437 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"
)
);
8438 break;
8439 case G_DRIVE_START_STOP_TYPE_PASSWORD:
8440 ctk_action_set_label (action, _("_Lock Drive")gettext ("_Lock Drive"));
8441 ctk_action_set_tooltip (action, _("Lock the drive associated with the open folder")gettext ("Lock the drive associated with the open folder"));
8442 break;
8443 }
8444 }
8445
8446 action = ctk_action_group_get_action (view->details->dir_action_group,
8447 FM_ACTION_SELF_POLL"Self Poll");
8448 ctk_action_set_visible (action, show_self_poll);
8449
8450}
8451
8452static void
8453real_update_location_menu_volumes (FMDirectoryView *view)
8454{
8455 CtkAction *action;
8456 BaulFile *file;
8457 gboolean show_mount;
8458 gboolean show_unmount;
8459 gboolean show_eject;
8460 gboolean show_connect;
8461 gboolean show_format;
8462 gboolean show_start;
8463 gboolean show_stop;
8464 gboolean show_poll;
8465 GDriveStartStopType start_stop_type;
8466
8467 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"
, 8467, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
8468 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", 8468, ((const char*) (__func__
)), "BAUL_IS_FILE (view->details->location_popup_directory_as_file)"
); } while (0)
;
8469
8470 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())))))
;
8471 file_should_show_foreach (file,
8472 &show_mount,
8473 &show_unmount,
8474 &show_eject,
8475 &show_connect,
8476 &show_format,
8477 &show_start,
8478 &show_stop,
8479 &show_poll,
8480 &start_stop_type);
8481
8482 action = ctk_action_group_get_action (view->details->dir_action_group,
8483 FM_ACTION_LOCATION_MOUNT_VOLUME"Location Mount Volume");
8484 ctk_action_set_visible (action, show_mount);
8485
8486 action = ctk_action_group_get_action (view->details->dir_action_group,
8487 FM_ACTION_LOCATION_UNMOUNT_VOLUME"Location Unmount Volume");
8488 ctk_action_set_visible (action, show_unmount);
8489
8490 action = ctk_action_group_get_action (view->details->dir_action_group,
8491 FM_ACTION_LOCATION_EJECT_VOLUME"Location Eject Volume");
8492 ctk_action_set_visible (action, show_eject);
8493
8494 action = ctk_action_group_get_action (view->details->dir_action_group,
8495 FM_ACTION_LOCATION_FORMAT_VOLUME"Location Format Volume");
8496 ctk_action_set_visible (action, show_format);
8497
8498 action = ctk_action_group_get_action (view->details->dir_action_group,
8499 FM_ACTION_LOCATION_START_VOLUME"Location Start Volume");
8500 ctk_action_set_visible (action, show_start);
8501 if (show_start) {
8502 switch (start_stop_type) {
8503 default:
8504 case G_DRIVE_START_STOP_TYPE_UNKNOWN:
8505 ctk_action_set_label (action, _("_Start")gettext ("_Start"));
8506 ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive"));
8507 break;
8508 case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
8509 ctk_action_set_label (action, _("_Start")gettext ("_Start"));
8510 ctk_action_set_tooltip (action, _("Start the selected drive")gettext ("Start the selected drive"));
8511 break;
8512 case G_DRIVE_START_STOP_TYPE_NETWORK:
8513 ctk_action_set_label (action, _("_Connect")gettext ("_Connect"));
8514 ctk_action_set_tooltip (action, _("Connect to the selected drive")gettext ("Connect to the selected drive"));
8515 break;
8516 case G_DRIVE_START_STOP_TYPE_MULTIDISK:
8517 ctk_action_set_label (action, _("_Start Multi-disk Drive")gettext ("_Start Multi-disk Drive"));
8518 ctk_action_set_tooltip (action, _("Start the selected multi-disk drive")gettext ("Start the selected multi-disk drive"));
8519 break;
8520 case G_DRIVE_START_STOP_TYPE_PASSWORD:
8521 ctk_action_set_label (action, _("_Unlock Drive")gettext ("_Unlock Drive"));
8522 ctk_action_set_tooltip (action, _("Unlock the selected drive")gettext ("Unlock the selected drive"));
8523 break;
8524 }
8525 }
8526
8527 action = ctk_action_group_get_action (view->details->dir_action_group,
8528 FM_ACTION_LOCATION_STOP_VOLUME"Location Stop Volume");
8529 ctk_action_set_visible (action, show_stop);
8530 if (show_stop) {
8531 switch (start_stop_type) {
8532 default:
8533 case G_DRIVE_START_STOP_TYPE_UNKNOWN:
8534 ctk_action_set_label (action, _("_Stop")gettext ("_Stop"));
8535 ctk_action_set_tooltip (action, _("Stop the selected volume")gettext ("Stop the selected volume"));
8536 break;
8537 case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
8538 ctk_action_set_label (action, _("_Safely Remove Drive")gettext ("_Safely Remove Drive"));
8539 ctk_action_set_tooltip (action, _("Safely remove the selected drive")gettext ("Safely remove the selected drive"));
8540 break;
8541 case G_DRIVE_START_STOP_TYPE_NETWORK:
8542 ctk_action_set_label (action, _("_Disconnect")gettext ("_Disconnect"));
8543 ctk_action_set_tooltip (action, _("Disconnect the selected drive")gettext ("Disconnect the selected drive"));
8544 break;
8545 case G_DRIVE_START_STOP_TYPE_MULTIDISK:
8546 ctk_action_set_label (action, _("_Stop Multi-disk Drive")gettext ("_Stop Multi-disk Drive"));
8547 ctk_action_set_tooltip (action, _("Stop the selected multi-disk drive")gettext ("Stop the selected multi-disk drive"));
8548 break;
8549 case G_DRIVE_START_STOP_TYPE_PASSWORD:
8550 ctk_action_set_label (action, _("_Lock Drive")gettext ("_Lock Drive"));
8551 ctk_action_set_tooltip (action, _("Lock the selected drive")gettext ("Lock the selected drive"));
8552 break;
8553 }
8554 }
8555
8556 action = ctk_action_group_get_action (view->details->dir_action_group,
8557 FM_ACTION_LOCATION_POLL"Location Poll");
8558 ctk_action_set_visible (action, show_poll);
8559}
8560
8561/* TODO: we should split out this routine into two functions:
8562 * Update on clipboard changes
8563 * Update on selection changes
8564 */
8565static void
8566real_update_paste_menu (FMDirectoryView *view,
8567 GList *selection,
8568 gint selection_count)
8569{
8570 gboolean can_paste_files_into;
8571 gboolean selection_is_read_only;
8572 gboolean is_read_only;
8573 CtkAction *action;
8574
8575 selection_is_read_only = selection_count == 1 &&
8576 (!baul_file_can_write (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
) &&
8577 !baul_file_has_activation_uri (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
));
8578
8579 is_read_only = fm_directory_view_is_read_only (view);
8580
8581 can_paste_files_into = (selection_count == 1 &&
8582 can_paste_into_file (BAUL_FILE (selection->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((selection->data)), (baul_file_get_type())))))
));
8583
8584 action = ctk_action_group_get_action (view->details->dir_action_group,
8585 FM_ACTION_PASTE"Paste");
8586 ctk_action_set_sensitive (action, !is_read_only);
8587
8588 action = ctk_action_group_get_action (view->details->dir_action_group,
8589 FM_ACTION_PASTE_FILES_INTO"Paste Files Into");
8590 ctk_action_set_visible (action, can_paste_files_into);
8591 ctk_action_set_sensitive (action, !selection_is_read_only);
8592
8593 /* Ask the clipboard */
8594 g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view)); /* Need to keep the object alive until we get the reply */
8595 ctk_clipboard_request_targets (baul_clipboard_get (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
),
8596 clipboard_targets_received,
8597 view);
8598}
8599
8600static void
8601real_update_location_menu (FMDirectoryView *view)
8602{
8603 CtkAction *action;
8604 BaulFile *file;
8605 gboolean is_special_link;
8606 gboolean is_desktop_or_home_dir;
8607 gboolean can_delete_file, show_delete;
8608 gboolean show_separate_delete_command;
8609 gboolean show_open_folder_window;
8610 gboolean show_open_in_new_tab;
8611 GList l;
8612 char *label;
8613 char *tip;
8614
8615 show_open_folder_window = FALSE(0);
8616 show_open_in_new_tab = FALSE(0);
8617
8618 if (baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION) {
8619 if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) {
8620 label = _("Open in New _Window")gettext ("Open in New _Window");
8621 } else {
8622 label = _("Browse in New _Window")gettext ("Browse in New _Window");
8623 show_open_folder_window = TRUE(!(0));
8624 }
8625
8626 show_open_in_new_tab = TRUE(!(0));
8627 } else {
8628 label = g_strdup (ngettext ("_Browse Folder",g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders"
, 1))
8629 "_Browse Folders", 1))g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders"
, 1))
;
8630 }
8631 action = ctk_action_group_get_action (view->details->dir_action_group,
8632 FM_ACTION_LOCATION_OPEN_ALTERNATE"LocationOpenAlternate");
8633 g_object_set (action,
8634 "label", label,
8635 NULL((void*)0));
8636
8637 action = ctk_action_group_get_action (view->details->dir_action_group,
8638 FM_ACTION_LOCATION_OPEN_IN_NEW_TAB"LocationOpenInNewTab");
8639 ctk_action_set_visible (action, show_open_in_new_tab);
8640
8641 if (show_open_in_new_tab) {
8642 if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) {
8643 label = _("Open in New _Tab")gettext ("Open in New _Tab");
8644 } else {
8645 label = _("Browse in New _Tab")gettext ("Browse in New _Tab");
8646 }
8647 g_object_set (action,
8648 "label", label,
8649 NULL((void*)0));
8650 }
8651
8652 action = ctk_action_group_get_action (view->details->dir_action_group,
8653 FM_ACTION_LOCATION_OPEN_FOLDER_WINDOW"LocationOpenFolderWindow");
8654 ctk_action_set_visible (action, show_open_folder_window);
8655
8656 file = view->details->location_popup_directory_as_file;
8657 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"
, 8657, ((const char*) (__func__)), "BAUL_IS_FILE (file)"); }
while (0)
;
8658 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"
, 8660, ((const char*) (__func__)), "baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)"
); } while (0)
8659 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"
, 8660, ((const char*) (__func__)), "baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)"
); } while (0)
8660 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"
, 8660, ((const char*) (__func__)), "baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_MOUNT | BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)"
); } while (0)
;
8661
8662 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; }))))
;
8663 is_desktop_or_home_dir = baul_file_is_home (file)
8664 || baul_file_is_desktop_directory (file);
8665
8666 can_delete_file =
8667 baul_file_can_delete (file) &&
8668 !is_special_link &&
8669 !is_desktop_or_home_dir;
8670
8671 action = ctk_action_group_get_action (view->details->dir_action_group,
8672 FM_ACTION_LOCATION_CUT"LocationCut");
8673 ctk_action_set_sensitive (action, can_delete_file);
8674
8675 action = ctk_action_group_get_action (view->details->dir_action_group,
8676 FM_ACTION_LOCATION_PASTE_FILES_INTO"LocationPasteFilesInto");
8677 g_object_set_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), (((GType) ((20) << (2))))))))
,
8678 "can-paste-according-to-destination",
8679 GINT_TO_POINTER (can_paste_into_file (file))((gpointer) (glong) (can_paste_into_file (file))));
8680 ctk_action_set_sensitive (action,
8681 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")))
8682 "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")))
&&
8683 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")))
8684 "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")))
);
8685
8686 show_delete = TRUE(!(0));
8687
8688 if (file != NULL((void*)0) &&
8689 baul_file_is_in_trash (file)) {
8690 if (baul_file_is_self_owned (file)) {
8691 show_delete = FALSE(0);
8692 }
8693
8694 label = _("_Delete Permanently")gettext ("_Delete Permanently");
8695 tip = _("Delete the open folder permanently")gettext ("Delete the open folder permanently");
8696 show_separate_delete_command = FALSE(0);
8697 } else {
8698 label = _("Mo_ve to Trash")gettext ("Mo_ve to Trash");
8699 tip = _("Move the open folder to the Trash")gettext ("Move the open folder to the Trash");
8700 show_separate_delete_command = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ENABLE_DELETE"enable-delete");
8701 }
8702
8703 action = ctk_action_group_get_action (view->details->dir_action_group,
8704 FM_ACTION_LOCATION_TRASH"LocationTrash");
8705 g_object_set (action,
8706 "label", label,
8707 "tooltip", tip,
8708 "icon-name", (file != NULL((void*)0) &&
8709 baul_file_is_in_trash (file)) ?
8710 BAUL_ICON_DELETE"edit-delete" : BAUL_ICON_TRASH_FULL"user-trash-full",
8711 NULL((void*)0));
8712 ctk_action_set_sensitive (action, can_delete_file);
8713 ctk_action_set_visible (action, show_delete);
8714
8715 action = ctk_action_group_get_action (view->details->dir_action_group,
8716 FM_ACTION_LOCATION_DELETE"LocationDelete");
8717 ctk_action_set_visible (action, show_separate_delete_command);
8718 if (show_separate_delete_command) {
8719 ctk_action_set_sensitive (action, can_delete_file);
8720 g_object_set (action,
8721 "icon-name", BAUL_ICON_DELETE"edit-delete",
8722 "sensitive", can_delete_file,
8723 NULL((void*)0));
8724 }
8725
8726 action = ctk_action_group_get_action (view->details->dir_action_group,
8727 FM_ACTION_LOCATION_RESTORE_FROM_TRASH"LocationRestoreFromTrash");
8728 l.prev = NULL((void*)0);
8729 l.next = NULL((void*)0);
8730 l.data = file;
8731 update_restore_from_trash_action (action, &l, TRUE(!(0)));
8732
8733 real_update_location_menu_volumes (view);
8734
8735 /* we silently assume that fm_directory_view_supports_properties always returns the same value.
8736 * Therefore, we don't update the sensitivity of FM_ACTION_LOCATION_PROPERTIES */
8737}
8738
8739static void
8740clipboard_changed_callback (BaulClipboardMonitor *monitor, FMDirectoryView *view)
8741{
8742 GList *selection;
8743 gint selection_count;
8744
8745 if (!view->details->active) {
8746 return;
8747 }
8748
8749 selection = fm_directory_view_get_selection (view);
8750 selection_count = g_list_length (selection);
8751
8752 real_update_paste_menu (view, selection, selection_count);
8753
8754 baul_file_list_free (selection);
8755
8756}
8757
8758static gboolean
8759can_delete_all (GList *files)
8760{
8761 GList *l;
8762 BaulFile *file = NULL((void*)0);
8763
8764 for (l = files; l != NULL((void*)0); l = l->next) {
8765 file = l->data;
8766 if (!baul_file_can_delete (file)) {
8767 return FALSE(0);
8768 }
8769 }
8770 return TRUE(!(0));
8771}
8772
8773static gboolean
8774has_writable_extra_pane (FMDirectoryView *view)
8775{
8776 FMDirectoryView *other_view;
8777
8778 other_view = get_directory_view_of_extra_pane (view);
8779 if (other_view != NULL((void*)0)) {
8780 return !fm_directory_view_is_read_only (other_view);
8781 }
8782 return FALSE(0);
8783}
8784
8785static void
8786real_update_menus (FMDirectoryView *view)
8787{
8788 GList *selection, *l;
8789 gint selection_count;
8790 const char *tip, *label;
8791 char *label_with_underscore;
8792 gboolean selection_contains_special_link;
8793 gboolean selection_contains_desktop_or_home_dir;
8794 gboolean can_create_files;
8795 gboolean can_delete_files;
8796 gboolean can_copy_files;
8797 gboolean can_link_files;
8798 gboolean can_duplicate_files;
8799 gboolean show_separate_delete_command;
8800 gboolean vfolder_directory;
8801 gboolean disable_command_line;
8802 gboolean show_open_alternate;
8803 gboolean can_open;
8804 gboolean show_app;
8805 gboolean show_save_search;
8806 gboolean save_search_sensitive;
8807 gboolean show_save_search_as;
8808 gboolean show_open_folder_window;
8809 CtkAction *action;
8810 GAppInfo *app;
8811 GIcon *app_icon;
8812 CtkWidget *menuitem;
8813 gboolean next_pane_is_writable;
8814 gboolean show_properties;
8815
8816 selection = fm_directory_view_get_selection (view);
8817 selection_count = g_list_length (selection);
8818
8819 selection_contains_special_link = special_link_in_selection (view);
8820 selection_contains_desktop_or_home_dir = desktop_or_home_dir_in_selection (view);
8821
8822 can_create_files = fm_directory_view_supports_creating_files (view);
8823 can_delete_files =
8824 can_delete_all (selection) &&
8825 selection_count != 0 &&
8826 !selection_contains_special_link &&
8827 !selection_contains_desktop_or_home_dir;
8828 can_copy_files = selection_count != 0
8829 && !selection_contains_special_link;
8830
8831 can_duplicate_files = can_create_files && can_copy_files;
8832 can_link_files = can_create_files && can_copy_files;
8833
8834 vfolder_directory = we_are_in_vfolder_desktop_dir (view);
8835
8836 action = ctk_action_group_get_action (view->details->dir_action_group,
8837 FM_ACTION_RENAME"Rename");
8838 ctk_action_set_sensitive (action,
8839 selection_count == 1 &&
8840 fm_directory_view_can_rename_file (view, selection->data));
8841
8842 action = ctk_action_group_get_action (view->details->dir_action_group,
8843 FM_ACTION_NEW_FOLDER"New Folder");
8844 ctk_action_set_sensitive (action, can_create_files);
8845
8846 action = ctk_action_group_get_action (view->details->dir_action_group,
8847 FM_ACTION_OPEN"Open");
8848 ctk_action_set_sensitive (action, selection_count != 0);
8849
8850 can_open = show_app = selection_count != 0;
8851
8852 for (l = selection; l != NULL((void*)0); l = l->next) {
8853 BaulFile *file;
8854
8855 file = BAUL_FILE (l->data)((((BaulFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((l->data)), (baul_file_get_type())))))
;
8856
8857 /* Double-check if the files' MIME types have changed before we
8858 commit to a choice of applications for them. This can happen
8859 if, for instance, a file was originally created with 0 bytes
8860 and then content was added to it later-- it will change from
8861 plaintext to something else. */
8862 baul_file_refresh_info (file);
8863
8864 if (!baul_mime_file_opens_in_external_app (file)) {
8865 show_app = FALSE(0);
8866 }
8867
8868 if (!show_app) {
8869 break;
8870 }
8871 }
8872
8873 label_with_underscore = NULL((void*)0);
8874
8875 app = NULL((void*)0);
8876 app_icon = NULL((void*)0);
8877
8878 if (can_open && show_app) {
8879 app = baul_mime_get_default_application_for_files (selection);
8880 }
8881
8882 if (app != NULL((void*)0)) {
8883 char *escaped_app;
8884
8885 escaped_app = eel_str_double_underscores (g_app_info_get_display_name (app));
8886 label_with_underscore = g_strdup_printf (_("_Open With %s")gettext ("_Open With %s"),
8887 escaped_app);
8888
8889 app_icon = g_app_info_get_icon (app);
8890 if (app_icon != NULL((void*)0)) {
8891 g_object_ref (app_icon)((__typeof__ (app_icon)) (g_object_ref) (app_icon));
8892 }
8893
8894 g_free (escaped_app);
8895 g_object_unref (app);
8896 }
8897
8898 g_object_set (action, "label",
8899 label_with_underscore ? label_with_underscore : _("_Open")gettext ("_Open"),
8900 NULL((void*)0));
8901
8902 menuitem = ctk_ui_manager_get_widget (
8903 baul_window_info_get_ui_manager (view->details->window),
8904 FM_DIRECTORY_VIEW_MENU_PATH_OPEN"/MenuBar/File/Open Placeholder/Open");
8905
8906 /* Only force displaying the icon if it is an application icon */
8907 ctk_image_menu_item_set_always_show_image (
8908 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));
8909
8910 menuitem = ctk_ui_manager_get_widget (
8911 baul_window_info_get_ui_manager (view->details->window),
8912 FM_DIRECTORY_VIEW_POPUP_PATH_OPEN"/selection/Open Placeholder/Open");
8913
8914 /* Only force displaying the icon if it is an application icon */
8915 ctk_image_menu_item_set_always_show_image (
8916 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));
8917
8918 if (app_icon == NULL((void*)0)) {
8919 app_icon = g_themed_icon_new ("document-open");
8920 }
8921
8922 ctk_action_set_gicon (action, app_icon);
8923 g_object_unref (app_icon);
8924
8925 ctk_action_set_visible (action, can_open);
8926
8927 g_free (label_with_underscore);
8928
8929 show_open_alternate = file_list_all_are_folders (selection) &&
8930 selection_count > 0 &&
8931 !(baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_DESKTOP &&
8932 g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser"));
8933 show_open_folder_window = FALSE(0);
8934 if (baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION) {
8935 if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) {
8936 if (selection_count == 0 || selection_count == 1) {
8937 label_with_underscore = g_strdup (_("Open in New _Window"))g_strdup_inline (gettext ("Open in New _Window"));
8938 } else {
8939 label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Window",
8940 "Open in %'d New _Windows",
8941 selection_count),
8942 selection_count);
8943 }
8944 } else {
8945 if (selection_count == 0 || selection_count == 1) {
8946 label_with_underscore = g_strdup (_("Browse in New _Window"))g_strdup_inline (gettext ("Browse in New _Window"));
8947 } else {
8948 label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Window",
8949 "Browse in %'d New _Windows",
8950 selection_count),
8951 selection_count);
8952 }
8953 show_open_folder_window = show_open_alternate;
8954 }
8955 } else {
8956 label_with_underscore = g_strdup (ngettext ("_Browse Folder",g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders"
, selection_count))
8957 "_Browse Folders",g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders"
, selection_count))
8958 selection_count))g_strdup_inline (ngettext ("_Browse Folder", "_Browse Folders"
, selection_count))
;
8959 }
8960
8961 action = ctk_action_group_get_action (view->details->dir_action_group,
8962 FM_ACTION_OPEN_ALTERNATE"OpenAlternate");
8963 g_object_set (action, "label",
8964 label_with_underscore,
8965 NULL((void*)0));
8966 g_free (label_with_underscore);
8967
8968 ctk_action_set_sensitive (action, selection_count != 0);
8969 ctk_action_set_visible (action, show_open_alternate);
8970
8971 /* Open in New Tab action */
8972 if (baul_window_info_get_window_type (view->details->window) == BAUL_WINDOW_NAVIGATION) {
8973
8974 if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) {
8975 if (selection_count == 0 || selection_count == 1) {
8976 label_with_underscore = g_strdup (_("Open in New _Tab"))g_strdup_inline (gettext ("Open in New _Tab"));
8977 } else {
8978 label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Tab",
8979 "Open in %'d New _Tabs",
8980 selection_count),
8981 selection_count);
8982 }
8983 } else {
8984 if (selection_count == 0 || selection_count == 1) {
8985 label_with_underscore = g_strdup (_("Browse in New _Tab"))g_strdup_inline (gettext ("Browse in New _Tab"));
8986 } else {
8987 label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Tab",
8988 "Browse in %'d New _Tabs",
8989 selection_count),
8990 selection_count);
8991 }
8992 }
8993 action = ctk_action_group_get_action (view->details->dir_action_group,
8994 FM_ACTION_OPEN_IN_NEW_TAB"OpenInNewTab");
8995 ctk_action_set_sensitive (action, selection_count != 0);
8996 ctk_action_set_visible (action, show_open_alternate);
8997 g_object_set (action, "label",
8998 label_with_underscore,
8999 NULL((void*)0));
9000 g_free (label_with_underscore);
9001 } else {
9002 action = ctk_action_group_get_action (view->details->dir_action_group,
9003 FM_ACTION_OPEN_IN_NEW_TAB"OpenInNewTab");
9004 ctk_action_set_visible (action, FALSE(0));
9005 }
9006
9007 /* next pane actions, only in navigation mode */
9008 if (baul_window_info_get_window_type (view->details->window) != BAUL_WINDOW_NAVIGATION) {
9009 action = ctk_action_group_get_action (view->details->dir_action_group,
9010 FM_ACTION_COPY_TO_NEXT_PANE"Copy to next pane");
9011 ctk_action_set_visible (action, FALSE(0));
9012 action = ctk_action_group_get_action (view->details->dir_action_group,
9013 FM_ACTION_MOVE_TO_NEXT_PANE"Move to next pane");
9014 ctk_action_set_visible (action, FALSE(0));
9015 }
9016
9017 action = ctk_action_group_get_action (view->details->dir_action_group,
9018 FM_ACTION_OPEN_FOLDER_WINDOW"OpenFolderWindow");
9019 ctk_action_set_visible (action, show_open_folder_window);
9020
9021 /* Broken into its own function just for convenience */
9022 reset_open_with_menu (view, selection);
9023 reset_extension_actions_menu (view, selection);
9024
9025 if (all_selected_items_in_trash (view)) {
9026 label = _("_Delete Permanently")gettext ("_Delete Permanently");
9027 tip = _("Delete all selected items permanently")gettext ("Delete all selected items permanently");
9028 show_separate_delete_command = FALSE(0);
9029 } else {
9030 label = _("Mo_ve to Trash")gettext ("Mo_ve to Trash");
9031 tip = _("Move each selected item to the Trash")gettext ("Move each selected item to the Trash");
9032 show_separate_delete_command = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ENABLE_DELETE"enable-delete");
9033 }
9034
9035 action = ctk_action_group_get_action (view->details->dir_action_group,
9036 FM_ACTION_TRASH"Trash");
9037 g_object_set (action,
9038 "label", label,
9039 "tooltip", tip,
9040 "icon-name", all_selected_items_in_trash (view) ?
9041 BAUL_ICON_DELETE"edit-delete" : BAUL_ICON_TRASH_FULL"user-trash-full",
9042 NULL((void*)0));
9043 ctk_action_set_sensitive (action, can_delete_files);
9044
9045 action = ctk_action_group_get_action (view->details->dir_action_group,
9046 FM_ACTION_DELETE"Delete");
9047 ctk_action_set_visible (action, show_separate_delete_command);
9048
9049 if (show_separate_delete_command) {
9050 g_object_set (action,
9051 "label", _("_Delete")gettext ("_Delete"),
9052 "icon-name", BAUL_ICON_DELETE"edit-delete",
9053 NULL((void*)0));
9054 }
9055 ctk_action_set_sensitive (action, can_delete_files);
9056
9057
9058 action = ctk_action_group_get_action (view->details->dir_action_group,
9059 FM_ACTION_RESTORE_FROM_TRASH"Restore From Trash");
9060 update_restore_from_trash_action (action, selection, FALSE(0));
9061
9062 action = ctk_action_group_get_action (view->details->dir_action_group,
9063 FM_ACTION_DUPLICATE"Duplicate");
9064 ctk_action_set_sensitive (action, can_duplicate_files);
9065
9066 action = ctk_action_group_get_action (view->details->dir_action_group,
9067 FM_ACTION_CREATE_LINK"Create Link");
9068 ctk_action_set_sensitive (action, can_link_files);
9069 g_object_set (action, "label",
9070 ngettext ("Ma_ke Link",
9071 "Ma_ke Links",
9072 selection_count),
9073 NULL((void*)0));
9074
9075 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) &&
9076 fm_directory_view_supports_properties (view);
9077
9078 action = ctk_action_group_get_action (view->details->dir_action_group,
9079 FM_ACTION_PROPERTIES"Properties");
9080
9081 ctk_action_set_sensitive (action, show_properties);
9082
9083 if (selection_count == 0) {
9084 ctk_action_set_tooltip (action, _("View or modify the properties of the open folder")gettext ("View or modify the properties of the open folder"));
9085 } else {
9086 ctk_action_set_tooltip (action, _("View or modify the properties of each selected item")gettext ("View or modify the properties of each selected item"
)
);
9087 }
9088
9089 ctk_action_set_visible (action, show_properties);
9090
9091 action = ctk_action_group_get_action (view->details->dir_action_group,
9092 FM_ACTION_PROPERTIES_ACCEL"PropertiesAccel");
9093
9094 ctk_action_set_sensitive (action, show_properties);
9095
9096 action = ctk_action_group_get_action (view->details->dir_action_group,
9097 FM_ACTION_EMPTY_TRASH"Empty Trash");
9098 g_object_set (action,
9099 "label", _("E_mpty Trash")gettext ("E_mpty Trash"),
9100 NULL((void*)0));
9101 ctk_action_set_sensitive (action, !baul_trash_monitor_is_empty ());
9102 ctk_action_set_visible (action, should_show_empty_trash (view));
9103
9104 show_save_search = FALSE(0);
9105 save_search_sensitive = FALSE(0);
9106 show_save_search_as = FALSE(0);
9107 if (view->details->model &&
9108 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; }))))
) {
9109 BaulSearchDirectory *search;
9110
9111 search = BAUL_SEARCH_DIRECTORY (view->details->model)((((BaulSearchDirectory*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((view->details->model)), (baul_search_directory_get_type
())))))
;
9112 if (baul_search_directory_is_saved_search (search)) {
9113 show_save_search = TRUE(!(0));
9114 save_search_sensitive = baul_search_directory_is_modified (search);
9115 } else {
9116 show_save_search_as = TRUE(!(0));
9117 }
9118 }
9119 action = ctk_action_group_get_action (view->details->dir_action_group,
9120 FM_ACTION_SAVE_SEARCH"Save Search");
9121 ctk_action_set_visible (action, show_save_search);
9122 ctk_action_set_sensitive (action, save_search_sensitive);
9123 action = ctk_action_group_get_action (view->details->dir_action_group,
9124 FM_ACTION_SAVE_SEARCH_AS"Save Search As");
9125 ctk_action_set_visible (action, show_save_search_as);
9126
9127
9128 action = ctk_action_group_get_action (view->details->dir_action_group,
9129 FM_ACTION_SELECT_ALL"Select All");
9130 ctk_action_set_sensitive (action, !fm_directory_view_is_empty (view));
9131
9132 action = ctk_action_group_get_action (view->details->dir_action_group,
9133 FM_ACTION_SELECT_PATTERN"Select Pattern");
9134 ctk_action_set_sensitive (action, !fm_directory_view_is_empty (view));
9135
9136 action = ctk_action_group_get_action (view->details->dir_action_group,
9137 FM_ACTION_INVERT_SELECTION"Invert Selection");
9138 ctk_action_set_sensitive (action, !fm_directory_view_is_empty (view));
9139
9140 action = ctk_action_group_get_action (view->details->dir_action_group,
9141 FM_ACTION_CUT"Cut");
9142 ctk_action_set_sensitive (action, can_delete_files);
9143
9144 action = ctk_action_group_get_action (view->details->dir_action_group,
9145 FM_ACTION_COPY"Copy");
9146 ctk_action_set_sensitive (action, can_copy_files);
9147
9148 real_update_paste_menu (view, selection, selection_count);
9149
9150 disable_command_line = g_settings_get_boolean (cafe_lockdown_preferences, BAUL_PREFERENCES_LOCKDOWN_COMMAND_LINE"disable-command-line");
9151 action = ctk_action_group_get_action (view->details->dir_action_group,
9152 FM_ACTION_NEW_LAUNCHER"New Launcher");
9153 ctk_action_set_visible (action, vfolder_directory && !disable_command_line);
9154 ctk_action_set_sensitive (action, can_create_files);
9155
9156 real_update_menus_volumes (view, selection, selection_count);
9157
9158 undo_update_menu (view);
9159
9160 baul_file_list_free (selection);
9161
9162 if (view->details->scripts_invalid) {
9163 update_scripts_menu (view);
9164 }
9165
9166 action = ctk_action_group_get_action (view->details->dir_action_group,
9167 FM_ACTION_NEW_DOCUMENTS"New Documents");
9168 ctk_action_set_sensitive (action, can_create_files);
9169
9170 if (can_create_files && view->details->templates_invalid) {
9171 update_templates_menu (view);
9172 }
9173
9174 next_pane_is_writable = has_writable_extra_pane (view);
9175
9176 /* next pane: works if file is copyable, and next pane is writable */
9177 action = ctk_action_group_get_action (view->details->dir_action_group,
9178 FM_ACTION_COPY_TO_NEXT_PANE"Copy to next pane");
9179 ctk_action_set_sensitive (action, can_copy_files && next_pane_is_writable);
9180
9181 /* move to next pane: works if file is cuttable, and next pane is writable */
9182 action = ctk_action_group_get_action (view->details->dir_action_group,
9183 FM_ACTION_MOVE_TO_NEXT_PANE"Move to next pane");
9184 ctk_action_set_sensitive (action, can_delete_files && next_pane_is_writable);
9185
9186
9187 action = ctk_action_group_get_action (view->details->dir_action_group,
9188 FM_ACTION_COPY_TO_HOME"Copy to Home");
9189 ctk_action_set_sensitive (action, can_copy_files);
9190 action = ctk_action_group_get_action (view->details->dir_action_group,
9191 FM_ACTION_COPY_TO_DESKTOP"Copy to Desktop");
9192 ctk_action_set_sensitive (action, can_copy_files);
9193
9194 action = ctk_action_group_get_action (view->details->dir_action_group,
9195 FM_ACTION_MOVE_TO_HOME"Move to Home");
9196 ctk_action_set_sensitive (action, can_delete_files);
9197 action = ctk_action_group_get_action (view->details->dir_action_group,
9198 FM_ACTION_MOVE_TO_DESKTOP"Move to Desktop");
9199 ctk_action_set_sensitive (action, can_delete_files);
9200
9201 action = ctk_action_group_get_action (view->details->dir_action_group,
9202 "CopyToMenu");
9203 ctk_action_set_sensitive (action, can_copy_files);
9204 action = ctk_action_group_get_action (view->details->dir_action_group,
9205 "MoveToMenu");
9206 ctk_action_set_sensitive (action, can_delete_files);
9207}
9208
9209/**
9210 * fm_directory_view_pop_up_selection_context_menu
9211 *
9212 * Pop up a context menu appropriate to the selected items.
9213 * @view: FMDirectoryView of interest.
9214 * @event: The event that triggered this context menu.
9215 *
9216 * Return value: BaulDirectory for this view.
9217 *
9218 **/
9219void
9220fm_directory_view_pop_up_selection_context_menu (FMDirectoryView *view,
9221 CdkEventButton *event)
9222{
9223 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"
, 9223, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9224
9225 /* Make the context menu items not flash as they update to proper disabled,
9226 * etc. states by forcing menus to update now.
9227 */
9228 update_menus_if_pending (view);
9229
9230 update_context_menu_position_from_event (view, event);
9231
9232 /* FIXME: passing event from here won't work
9233 * for ctk_menu_popup_at_pointer (in eel_pop_up_context_menu() )
9234 * if the menu is being triggered from here by the menu key
9235 */
9236 eel_pop_up_context_menu (create_popup_menu
9237 (view, FM_DIRECTORY_VIEW_POPUP_PATH_SELECTION"/selection"),
9238 NULL((void*)0));
9239}
9240
9241/**
9242 * fm_directory_view_pop_up_background_context_menu
9243 *
9244 * Pop up a context menu appropriate to the view globally at the last right click location.
9245 * @view: FMDirectoryView of interest.
9246 *
9247 * Return value: BaulDirectory for this view.
9248 *
9249 **/
9250void
9251fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view,
9252 CdkEventButton *event)
9253{
9254 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"
, 9254, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9255
9256 /* Make the context menu items not flash as they update to proper disabled,
9257 * etc. states by forcing menus to update now.
9258 */
9259 update_menus_if_pending (view);
9260
9261 update_context_menu_position_from_event (view, event);
9262
9263 eel_pop_up_context_menu (create_popup_menu
9264 (view, FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND"/background"),
9265 event);
9266}
9267
9268static void
9269real_pop_up_location_context_menu (FMDirectoryView *view)
9270{
9271 /* always update the menu before showing it. Shouldn't be too expensive. */
9272 real_update_location_menu (view);
9273
9274 update_context_menu_position_from_event (view, view->details->location_popup_event);
9275
9276 eel_pop_up_context_menu (create_popup_menu
9277 (view, FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION"/location"),
9278 view->details->location_popup_event);
9279}
9280
9281static void
9282location_popup_file_attributes_ready (BaulFile *file,
9283 gpointer data)
9284{
9285 FMDirectoryView *view;
9286
9287 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
9288 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"
, 9288, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9289
9290 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"
, 9290, ((const char*) (__func__)), "file == view->details->location_popup_directory_as_file"
); } while (0)
;
9291
9292 real_pop_up_location_context_menu (view);
9293}
9294
9295static void
9296unschedule_pop_up_location_context_menu (FMDirectoryView *view)
9297{
9298 if (view->details->location_popup_directory_as_file != NULL((void*)0)) {
9299 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", 9299, ((const char*) (__func__
)), "BAUL_IS_FILE (view->details->location_popup_directory_as_file)"
); } while (0)
;
9300 baul_file_cancel_call_when_ready (view->details->location_popup_directory_as_file,
9301 location_popup_file_attributes_ready,
9302 view);
9303 baul_file_unref (view->details->location_popup_directory_as_file);
9304 view->details->location_popup_directory_as_file = NULL((void*)0);
9305 }
9306}
9307
9308static void
9309schedule_pop_up_location_context_menu (FMDirectoryView *view,
9310 CdkEventButton *event,
9311 BaulFile *file)
9312{
9313 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"
, 9313, ((const char*) (__func__)), "BAUL_IS_FILE (file)"); }
while (0)
;
9314
9315 if (view->details->location_popup_event != NULL((void*)0)) {
9316 cdk_event_free ((CdkEvent *) view->details->location_popup_event);
9317 }
9318 view->details->location_popup_event = (CdkEventButton *) cdk_event_copy ((CdkEvent *)event);
9319
9320 if (file == view->details->location_popup_directory_as_file) {
9321 if (baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO |
9322 BAUL_FILE_ATTRIBUTE_MOUNT |
9323 BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO)) {
9324 real_pop_up_location_context_menu (view);
9325 }
9326 } else {
9327 unschedule_pop_up_location_context_menu (view);
9328
9329 view->details->location_popup_directory_as_file = baul_file_ref (file);
9330 baul_file_call_when_ready (view->details->location_popup_directory_as_file,
9331 BAUL_FILE_ATTRIBUTE_INFO |
9332 BAUL_FILE_ATTRIBUTE_MOUNT |
9333 BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO,
9334 location_popup_file_attributes_ready,
9335 view);
9336 }
9337}
9338
9339/**
9340 * fm_directory_view_pop_up_location_context_menu
9341 *
9342 * Pop up a context menu appropriate to the view globally.
9343 * @view: FMDirectoryView of interest.
9344 * @event: CdkEventButton triggering the popup.
9345 * @location: The location the popup-menu should be created for,
9346 * or NULL for the currently displayed location.
9347 *
9348 **/
9349void
9350fm_directory_view_pop_up_location_context_menu (FMDirectoryView *view,
9351 CdkEventButton *event,
9352 const char *location)
9353{
9354 BaulFile *file;
9355
9356 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"
, 9356, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9357
9358 if (location != NULL((void*)0)) {
9359 file = baul_file_get_by_uri (location);
9360 } else {
9361 file = baul_file_ref (view->details->directory_as_file);
9362 }
9363
9364 if (file != NULL((void*)0)) {
9365 schedule_pop_up_location_context_menu (view, event, file);
9366 baul_file_unref (file);
9367 }
9368}
9369
9370static void
9371fm_directory_view_drop_proxy_received_uris (FMDirectoryView *view,
9372 const GList *source_uri_list,
9373 const char *target_uri,
9374 CdkDragAction action)
9375{
9376 char *container_uri;
9377
9378 container_uri = NULL((void*)0);
9379 if (target_uri == NULL((void*)0)) {
9380 container_uri = fm_directory_view_get_backing_uri (view);
9381 g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 9381, ((const char*) (
__func__)), "container_uri != NULL"); } while (0)
;
9382 }
9383
9384 if (action == CDK_ACTION_ASK) {
9385 action = baul_drag_drop_action_ask
9386 (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
,
9387 CDK_ACTION_MOVE | CDK_ACTION_COPY | CDK_ACTION_LINK);
9388 if (action == 0) {
9389 return;
9390 }
9391 }
9392
9393 baul_clipboard_clear_if_colliding_uris (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
,
9394 source_uri_list,
9395 fm_directory_view_get_copied_files_atom (view));
9396
9397 fm_directory_view_move_copy_items (source_uri_list, NULL((void*)0),
9398 target_uri != NULL((void*)0) ? target_uri : container_uri,
9399 action, 0, 0, view);
9400
9401 g_free (container_uri);
9402}
9403
9404static void
9405fm_directory_view_drop_proxy_received_netscape_url (FMDirectoryView *view,
9406 const char *netscape_url,
9407 const char *target_uri,
9408 CdkDragAction action)
9409{
9410 fm_directory_view_handle_netscape_url_drop (view,
9411 netscape_url,
9412 target_uri,
9413 action, 0, 0);
9414}
9415
9416static void
9417schedule_update_menus (FMDirectoryView *view)
9418{
9419 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"
, 9419, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9420
9421 /* Don't schedule updates after destroy (#349551),
9422 * or if we are not active.
9423 */
9424 if (view->details->window == NULL((void*)0) ||
9425 !view->details->active) {
9426 return;
9427 }
9428
9429 view->details->menu_states_untrustworthy = TRUE(!(0));
9430
9431 /* Schedule a menu update with the current update interval */
9432 if (view->details->update_menus_timeout_id == 0) {
9433 view->details->update_menus_timeout_id
9434 = g_timeout_add (view->details->update_interval, update_menus_timeout_callback, view);
9435 }
9436}
9437
9438static void
9439remove_update_status_idle_callback (FMDirectoryView *view)
9440{
9441 if (view->details->update_status_idle_id != 0) {
9442 g_source_remove (view->details->update_status_idle_id);
9443 view->details->update_status_idle_id = 0;
9444 }
9445}
9446
9447static gboolean
9448update_status_idle_callback (gpointer data)
9449{
9450 FMDirectoryView *view;
9451
9452 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
9453 fm_directory_view_display_selection_info (view);
9454 view->details->update_status_idle_id = 0;
9455 return FALSE(0);
9456}
9457
9458static void
9459schedule_update_status (FMDirectoryView *view)
9460{
9461 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"
, 9461, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9462
9463 /* Make sure we haven't already destroyed it */
9464 if (view->details->window == NULL((void*)0)) {
9465 return;
9466 }
9467
9468 if (view->details->loading) {
9469 /* Don't update status bar while loading the dir */
9470 return;
9471 }
9472
9473 if (view->details->update_status_idle_id == 0) {
9474 view->details->update_status_idle_id =
9475 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE200 - 20,
9476 update_status_idle_callback, view, NULL((void*)0));
9477 }
9478}
9479
9480/**
9481 * fm_directory_view_notify_selection_changed:
9482 *
9483 * Notify this view that the selection has changed. This is normally
9484 * called only by subclasses.
9485 * @view: FMDirectoryView whose selection has changed.
9486 *
9487 **/
9488void
9489fm_directory_view_notify_selection_changed (FMDirectoryView *view)
9490{
9491 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)
;
9492
9493 if (baul_debug_log_is_domain_enabled (BAUL_DEBUG_LOG_DOMAIN_USER"USER")) {
9494 GList *selection;
9495 CtkWindow *window;
9496
9497 selection = fm_directory_view_get_selection (view);
9498
9499 window = fm_directory_view_get_containing_window (view);
9500 baul_debug_log_with_file_list (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER", selection,
9501 "selection changed in window %p",
9502 window);
9503 baul_file_list_free (selection);
9504 }
9505
9506 view->details->selection_was_removed = FALSE(0);
9507
9508 if (!view->details->selection_change_is_due_to_shell) {
9509 view->details->send_selection_change_to_shell = TRUE(!(0));
9510 }
9511
9512 /* Schedule a display of the new selection. */
9513 if (view->details->display_selection_idle_id == 0) {
9514 view->details->display_selection_idle_id
9515 = g_idle_add (display_selection_info_idle_callback,
9516 view);
9517 }
9518
9519 if (view->details->batching_selection_level != 0) {
9520 view->details->selection_changed_while_batched = TRUE(!(0));
9521 } else {
9522 /* Here is the work we do only when we're not
9523 * batching selection changes. In other words, it's the slower
9524 * stuff that we don't want to slow down selection techniques
9525 * such as rubberband-selecting in icon view.
9526 */
9527
9528 /* Schedule an update of menu item states to match selection */
9529 schedule_update_menus (view);
9530 }
9531}
9532
9533static void
9534file_changed_callback (BaulFile *file, gpointer callback_data)
9535{
9536 FMDirectoryView *view = FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
;
9537
9538 schedule_changes (view);
9539
9540 schedule_update_menus (view);
9541 schedule_update_status (view);
9542
9543 /* We might have different capabilities, so we need to update
9544 * relative icon emblems . (Writeable etc).
9545 * Don't do this for trash, as it never changes writability
9546 * but does change a lot for the file count attribute.
9547 */
9548 if (!baul_file_is_in_trash (file)) {
9549 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)
9550 (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)
;
9551 }
9552}
9553
9554/**
9555 * load_directory:
9556 *
9557 * Switch the displayed location to a new uri. If the uri is not valid,
9558 * the location will not be switched; user feedback will be provided instead.
9559 * @view: FMDirectoryView whose location will be changed.
9560 * @uri: A string representing the uri to switch to.
9561 *
9562 **/
9563static void
9564load_directory (FMDirectoryView *view,
9565 BaulDirectory *directory)
9566{
9567 BaulDirectory *old_directory;
9568 BaulFile *old_file;
9569 BaulFileAttributes attributes;
9570
9571 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"
, 9571, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9572 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"
, 9572, ((const char*) (__func__)), "BAUL_IS_DIRECTORY (directory)"
); } while (0)
;
9573
9574 fm_directory_view_stop (view);
9575 fm_directory_view_clear (view);
9576
9577 view->details->loading = TRUE(!(0));
9578
9579 /* Update menus when directory is empty, before going to new
9580 * location, so they won't have any false lingering knowledge
9581 * of old selection.
9582 */
9583 schedule_update_menus (view);
9584
9585 while (view->details->subdirectory_list != NULL((void*)0)) {
9586 fm_directory_view_remove_subdirectory (view,
9587 view->details->subdirectory_list->data);
9588 }
9589
9590 disconnect_model_handlers (view);
9591
9592 old_directory = view->details->model;
9593 baul_directory_ref (directory);
9594 view->details->model = directory;
9595 baul_directory_unref (old_directory);
9596
9597 old_file = view->details->directory_as_file;
9598 view->details->directory_as_file =
9599 baul_directory_get_corresponding_file (directory);
9600 baul_file_unref (old_file);
9601
9602 view->details->reported_load_error = FALSE(0);
9603
9604 /* FIXME bugzilla.gnome.org 45062: In theory, we also need to monitor metadata here (as
9605 * well as doing a call when ready), in case external forces
9606 * change the directory's file metadata.
9607 */
9608 attributes =
9609 BAUL_FILE_ATTRIBUTE_INFO |
9610 BAUL_FILE_ATTRIBUTE_MOUNT |
9611 BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO;
9612 view->details->metadata_for_directory_as_file_pending = TRUE(!(0));
9613 view->details->metadata_for_files_in_directory_pending = TRUE(!(0));
9614 baul_file_call_when_ready
9615 (view->details->directory_as_file,
9616 attributes,
9617 metadata_for_directory_as_file_ready_callback, view);
9618 baul_directory_call_when_ready
9619 (view->details->model,
9620 attributes,
9621 FALSE(0),
9622 metadata_for_files_in_directory_ready_callback, view);
9623
9624 /* If capabilities change, then we need to update the menus
9625 * because of New Folder, and relative emblems.
9626 */
9627 attributes =
9628 BAUL_FILE_ATTRIBUTE_INFO |
9629 BAUL_FILE_ATTRIBUTE_FILESYSTEM_INFO;
9630 baul_file_monitor_add (view->details->directory_as_file,
9631 &view->details->directory_as_file,
9632 attributes);
9633
9634 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)
9635 (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)
9636 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)
;
9637}
9638
9639static void
9640finish_loading (FMDirectoryView *view)
9641{
9642 BaulFileAttributes attributes;
9643
9644 baul_window_info_report_load_underway (view->details->window,
9645 BAUL_VIEW (view)((((BaulView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((baul_view_get_type ()))))))
);
9646
9647 /* Tell interested parties that we've begun loading this directory now.
9648 * Subclasses use this to know that the new metadata is now available.
9649 */
9650 fm_directory_view_begin_loading (view);
9651
9652 /* Assume we have now all information to show window */
9653 baul_window_info_view_visible (view->details->window, BAUL_VIEW (view)((((BaulView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((baul_view_get_type ()))))))
);
9654
9655 if (baul_directory_are_all_files_seen (view->details->model)) {
9656 /* Unschedule a pending update and schedule a new one with the minimal
9657 * update interval. This gives the view a short chance at gathering the
9658 * (cached) deep counts.
9659 */
9660 unschedule_display_of_pending_files (view);
9661 schedule_timeout_display_of_pending_files (view, UPDATE_INTERVAL_MIN100);
9662 }
9663
9664 /* Start loading. */
9665
9666 /* Connect handlers to learn about loading progress. */
9667 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)
9668 (view->details->model, "done_loading",g_signal_connect_data ((view->details->model), ("done_loading"
), (((GCallback) (done_loading_callback))), (view), ((void*)0
), (GConnectFlags) 0)
9669 G_CALLBACK (done_loading_callback), view)g_signal_connect_data ((view->details->model), ("done_loading"
), (((GCallback) (done_loading_callback))), (view), ((void*)0
), (GConnectFlags) 0)
;
9670 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)
9671 (view->details->model, "load_error",g_signal_connect_data ((view->details->model), ("load_error"
), (((GCallback) (load_error_callback))), (view), ((void*)0),
(GConnectFlags) 0)
9672 G_CALLBACK (load_error_callback), view)g_signal_connect_data ((view->details->model), ("load_error"
), (((GCallback) (load_error_callback))), (view), ((void*)0),
(GConnectFlags) 0)
;
9673
9674 /* Monitor the things needed to get the right icon. Also
9675 * monitor a directory's item count because the "size"
9676 * attribute is based on that, and the file's metadata
9677 * and possible custom name.
9678 */
9679 attributes =
9680 BAUL_FILE_ATTRIBUTES_FOR_ICON(BAUL_FILE_ATTRIBUTE_INFO | BAUL_FILE_ATTRIBUTE_LINK_INFO | BAUL_FILE_ATTRIBUTE_THUMBNAIL
)
|
9681 BAUL_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
9682 BAUL_FILE_ATTRIBUTE_INFO |
9683 BAUL_FILE_ATTRIBUTE_LINK_INFO |
9684 BAUL_FILE_ATTRIBUTE_MOUNT |
9685 BAUL_FILE_ATTRIBUTE_EXTENSION_INFO;
9686
9687 baul_directory_file_monitor_add (view->details->model,
9688 &view->details->model,
9689 view->details->show_hidden_files,
9690 attributes,
9691 files_added_callback, view);
9692
9693 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)
9694 (view->details->model, "files_added",g_signal_connect_data ((view->details->model), ("files_added"
), (((GCallback) (files_added_callback))), (view), ((void*)0)
, (GConnectFlags) 0)
9695 G_CALLBACK (files_added_callback), view)g_signal_connect_data ((view->details->model), ("files_added"
), (((GCallback) (files_added_callback))), (view), ((void*)0)
, (GConnectFlags) 0)
;
9696 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)
9697 (view->details->model, "files_changed",g_signal_connect_data ((view->details->model), ("files_changed"
), (((GCallback) (files_changed_callback))), (view), ((void*)
0), (GConnectFlags) 0)
9698 G_CALLBACK (files_changed_callback), view)g_signal_connect_data ((view->details->model), ("files_changed"
), (((GCallback) (files_changed_callback))), (view), ((void*)
0), (GConnectFlags) 0)
;
9699}
9700
9701static void
9702finish_loading_if_all_metadata_loaded (FMDirectoryView *view)
9703{
9704 if (!view->details->metadata_for_directory_as_file_pending &&
9705 !view->details->metadata_for_files_in_directory_pending) {
9706 finish_loading (view);
9707 }
9708}
9709
9710static void
9711metadata_for_directory_as_file_ready_callback (BaulFile *file,
9712 gpointer callback_data)
9713{
9714 FMDirectoryView *view;
9715
9716 view = callback_data;
9717
9718 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"
, 9718, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9719 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"
, 9719, ((const char*) (__func__)), "view->details->directory_as_file == file"
); } while (0)
;
9720 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"
, 9720, ((const char*) (__func__)), "view->details->metadata_for_directory_as_file_pending"
); } while (0)
;
9721
9722 view->details->metadata_for_directory_as_file_pending = FALSE(0);
9723
9724 finish_loading_if_all_metadata_loaded (view);
9725}
9726
9727static void
9728metadata_for_files_in_directory_ready_callback (BaulDirectory *directory,
9729 GList *files,
9730 gpointer callback_data)
9731{
9732 FMDirectoryView *view;
9733
9734 view = callback_data;
9735
9736 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"
, 9736, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9737 g_assert (view->details->model == directory)do { if (view->details->model == directory) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 9737, ((const char*) (
__func__)), "view->details->model == directory"); } while
(0)
;
9738 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"
, 9738, ((const char*) (__func__)), "view->details->metadata_for_files_in_directory_pending"
); } while (0)
;
9739
9740 view->details->metadata_for_files_in_directory_pending = FALSE(0);
9741
9742 finish_loading_if_all_metadata_loaded (view);
9743}
9744
9745static void
9746finish_undoredo_callback (gpointer data)
9747{
9748}
9749
9750char **
9751fm_directory_view_get_emblem_names_to_exclude (FMDirectoryView *view)
9752{
9753 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)
;
9754
9755 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))
9756 (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))
9757 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))
;
9758}
9759
9760static char **
9761real_get_emblem_names_to_exclude (FMDirectoryView *view)
9762{
9763 char **excludes;
9764 int i;
9765
9766 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"
, 9766, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
9767
9768 excludes = g_new (char *, 3)((char * *) g_malloc_n ((3), sizeof (char *)));
9769
9770 i = 0;
9771 excludes[i++] = g_strdup (BAUL_FILE_EMBLEM_NAME_TRASH)g_strdup_inline ("trash");
9772
9773 if (!baul_file_can_write (view->details->directory_as_file)) {
9774 excludes[i++] = g_strdup (BAUL_FILE_EMBLEM_NAME_CANT_WRITE)g_strdup_inline ("nowrite");
9775 }
9776
9777 excludes[i++] = NULL((void*)0);
9778
9779 return excludes;
9780}
9781
9782/**
9783 * fm_directory_view_merge_menus:
9784 *
9785 * Add this view's menus to the window's menu bar.
9786 * @view: FMDirectoryView in question.
9787 */
9788static void
9789fm_directory_view_merge_menus (FMDirectoryView *view)
9790{
9791 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)
;
9792
9793 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)
9794 (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)
9795 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)
;
9796}
9797
9798static void
9799fm_directory_view_unmerge_menus (FMDirectoryView *view)
9800{
9801 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)
;
9802
9803 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)
9804 (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)
9805 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)
;
9806}
9807
9808static void
9809disconnect_handler (GObject *object, guint *id)
9810{
9811 if (*id != 0) {
9812 g_signal_handler_disconnect (object, *id);
9813 *id = 0;
9814 }
9815}
9816
9817static void
9818disconnect_directory_handler (FMDirectoryView *view, guint *id)
9819{
9820 disconnect_handler (G_OBJECT (view->details->model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view->details->model)), (((GType) ((20) << (
2))))))))
, id);
9821}
9822
9823static void
9824disconnect_directory_as_file_handler (FMDirectoryView *view, guint *id)
9825{
9826 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);
9827}
9828
9829static void
9830disconnect_model_handlers (FMDirectoryView *view)
9831{
9832 if (view->details->model == NULL((void*)0)) {
9833 return;
9834 }
9835 disconnect_directory_handler (view, &view->details->files_added_handler_id);
9836 disconnect_directory_handler (view, &view->details->files_changed_handler_id);
9837 disconnect_directory_handler (view, &view->details->done_loading_handler_id);
9838 disconnect_directory_handler (view, &view->details->load_error_handler_id);
9839 disconnect_directory_as_file_handler (view, &view->details->file_changed_handler_id);
9840 baul_file_cancel_call_when_ready (view->details->directory_as_file,
9841 metadata_for_directory_as_file_ready_callback,
9842 view);
9843 baul_directory_cancel_callback (view->details->model,
9844 metadata_for_files_in_directory_ready_callback,
9845 view);
9846 baul_directory_file_monitor_remove (view->details->model,
9847 &view->details->model);
9848 baul_file_monitor_remove (view->details->directory_as_file,
9849 &view->details->directory_as_file);
9850}
9851
9852/**
9853 * fm_directory_view_reset_to_defaults:
9854 *
9855 * set sorting order, zoom level, etc. to match defaults
9856 *
9857 **/
9858void
9859fm_directory_view_reset_to_defaults (FMDirectoryView *view)
9860{
9861 BaulWindowShowHiddenFilesMode mode;
9862
9863 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)
;
9864
9865 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)
9866 (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)
9867 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)
;
9868 mode = baul_window_info_get_hidden_files_mode (view->details->window);
9869 if (mode != BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) {
9870 baul_window_info_set_hidden_files_mode (view->details->window,
9871 BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT);
9872 }
9873}
9874
9875/**
9876 * fm_directory_view_select_all:
9877 *
9878 * select all the items in the view
9879 *
9880 **/
9881void
9882fm_directory_view_select_all (FMDirectoryView *view)
9883{
9884 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)
;
9885
9886 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)
9887 (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)
9888 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)
;
9889}
9890
9891/**
9892 * fm_directory_view_set_selection:
9893 *
9894 * set the selection to the items identified in @selection. @selection
9895 * should be a list of BaulFiles
9896 *
9897 **/
9898void
9899fm_directory_view_set_selection (FMDirectoryView *view, GList *selection)
9900{
9901 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)
;
9902
9903 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)
9904 (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)
9905 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)
;
9906}
9907
9908static void
9909fm_directory_view_select_file (FMDirectoryView *view, BaulFile *file)
9910{
9911 GList file_list;
9912
9913 file_list.data = file;
9914 file_list.next = NULL((void*)0);
9915 file_list.prev = NULL((void*)0);
9916 fm_directory_view_set_selection (view, &file_list);
9917}
9918
9919/**
9920 * fm_directory_view_get_selected_icon_locations:
9921 *
9922 * return an array of locations of selected icons if available
9923 * Return value: GArray of CdkPoints
9924 *
9925 **/
9926GArray *
9927fm_directory_view_get_selected_icon_locations (FMDirectoryView *view)
9928{
9929 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)
;
9930
9931 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))
9932 (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))
9933 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))
;
9934}
9935
9936/**
9937 * fm_directory_view_reveal_selection:
9938 *
9939 * Scroll as necessary to reveal the selected items.
9940 **/
9941void
9942fm_directory_view_reveal_selection (FMDirectoryView *view)
9943{
9944 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)
;
9945
9946 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)
9947 (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)
9948 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)
;
9949}
9950
9951/**
9952 * fm_directory_view_stop:
9953 *
9954 * Stop the current ongoing process, such as switching to a new uri.
9955 * @view: FMDirectoryView in question.
9956 *
9957 **/
9958void
9959fm_directory_view_stop (FMDirectoryView *view)
9960{
9961 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)
;
9962
9963 unschedule_display_of_pending_files (view);
9964 reset_update_interval (view);
9965
9966 /* Free extra undisplayed files */
9967 file_and_directory_list_free (view->details->new_added_files);
9968 view->details->new_added_files = NULL((void*)0);
9969 file_and_directory_list_free (view->details->new_changed_files);
9970 view->details->new_changed_files = NULL((void*)0);
9971 g_hash_table_remove_all (view->details->non_ready_files);
9972 file_and_directory_list_free (view->details->old_added_files);
9973 view->details->old_added_files = NULL((void*)0);
9974 file_and_directory_list_free (view->details->old_changed_files);
9975 view->details->old_changed_files = NULL((void*)0);
9976 g_list_free_full (view->details->pending_locations_selected, g_object_unref);
9977 view->details->pending_locations_selected = NULL((void*)0);
9978
9979 if (view->details->model != NULL((void*)0)) {
9980 baul_directory_file_monitor_remove (view->details->model, view);
9981 }
9982 done_loading (view, FALSE(0));
9983}
9984
9985gboolean
9986fm_directory_view_is_read_only (FMDirectoryView *view)
9987{
9988 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)
;
9989
9990 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))
9991 (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))
9992 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))
;
9993}
9994
9995gboolean
9996fm_directory_view_is_empty (FMDirectoryView *view)
9997{
9998 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)
;
9999
10000 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))
10001 (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))
10002 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))
;
10003}
10004
10005gboolean
10006fm_directory_view_is_editable (FMDirectoryView *view)
10007{
10008 BaulDirectory *directory;
10009
10010 directory = fm_directory_view_get_model (view);
10011
10012 if (directory != NULL((void*)0)) {
10013 return baul_directory_is_editable (directory);
10014 }
10015
10016 return TRUE(!(0));
10017}
10018
10019void
10020fm_directory_view_set_initiated_unmount (FMDirectoryView *view,
10021 gboolean initiated_unmount)
10022{
10023 if (view->details->window != NULL((void*)0)) {
10024 baul_window_info_set_initiated_unmount(view->details->window,
10025 initiated_unmount);
10026 }
10027}
10028
10029static gboolean
10030real_is_read_only (FMDirectoryView *view)
10031{
10032 BaulFile *file;
10033
10034 if (!fm_directory_view_is_editable (view)) {
10035 return TRUE(!(0));
10036 }
10037
10038 file = fm_directory_view_get_directory_as_file (view);
10039 if (file != NULL((void*)0)) {
10040 return !baul_file_can_write (file);
10041 }
10042 return FALSE(0);
10043}
10044
10045gboolean
10046fm_directory_view_supports_creating_files (FMDirectoryView *view)
10047{
10048 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)
;
10049
10050 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))
10051 (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))
10052 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))
;
10053}
10054
10055gboolean
10056fm_directory_view_accepts_dragged_files (FMDirectoryView *view)
10057{
10058 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)
;
10059
10060 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))
10061 (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))
10062 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))
;
10063}
10064
10065/**
10066 * fm_directory_view_should_show_file
10067 *
10068 * Returns whether or not this file should be displayed based on
10069 * current filtering options.
10070 */
10071gboolean
10072fm_directory_view_should_show_file (FMDirectoryView *view, BaulFile *file)
10073{
10074 return baul_file_should_show (file,
10075 view->details->show_hidden_files,
10076 view->details->show_foreign_files,
10077 view->details->show_backup_files);
10078}
10079
10080static gboolean
10081real_supports_creating_files (FMDirectoryView *view)
10082{
10083 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)
;
10084
10085 return !fm_directory_view_is_read_only (view) && !showing_trash_directory (view);
10086}
10087
10088static gboolean
10089real_accepts_dragged_files (FMDirectoryView *view)
10090{
10091 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)
;
10092
10093 return !fm_directory_view_is_read_only (view);
10094}
10095
10096gboolean
10097fm_directory_view_supports_properties (FMDirectoryView *view)
10098{
10099 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)
;
10100
10101 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))
10102 (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))
10103 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))
;
10104}
10105
10106static gboolean
10107real_supports_properties (FMDirectoryView *view)
10108{
10109 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)
;
10110
10111 return TRUE(!(0));
10112}
10113
10114gboolean
10115fm_directory_view_supports_zooming (FMDirectoryView *view)
10116{
10117 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)
;
10118
10119 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))
10120 (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))
10121 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))
;
10122}
10123
10124static gboolean
10125real_supports_zooming (FMDirectoryView *view)
10126{
10127 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)
;
10128
10129 return TRUE(!(0));
10130}
10131
10132gboolean
10133fm_directory_view_using_manual_layout (FMDirectoryView *view)
10134{
10135 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)
;
10136
10137 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))
10138 (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))
10139 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))
;
10140}
10141
10142static gboolean
10143real_using_manual_layout (FMDirectoryView *view)
10144{
10145 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)
;
10146
10147 return FALSE(0);
10148}
10149
10150/**
10151 * fm_directory_view_update_menus:
10152 *
10153 * Update the sensitivity and wording of dynamic menu items.
10154 * @view: FMDirectoryView in question.
10155 */
10156void
10157fm_directory_view_update_menus (FMDirectoryView *view)
10158{
10159 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)
;
10160
10161 if (!view->details->active) {
10162 return;
10163 }
10164
10165
10166 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)
10167 (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)
10168 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)
;
10169
10170 view->details->menu_states_untrustworthy = FALSE(0);
10171}
10172
10173static void
10174schedule_update_menus_callback (gpointer callback_data)
10175{
10176 schedule_update_menus (FM_DIRECTORY_VIEW (callback_data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((callback_data)), (fm_directory_view_get_type())))))
);
10177}
10178
10179void
10180fm_directory_view_ignore_hidden_file_preferences (FMDirectoryView *view)
10181{
10182 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)
;
10183
10184 if (view->details->ignore_hidden_file_preferences) {
10185 return;
10186 }
10187
10188 view->details->show_hidden_files = FALSE(0);
10189 view->details->ignore_hidden_file_preferences = TRUE(!(0));
10190}
10191
10192void
10193fm_directory_view_set_show_foreign (FMDirectoryView *view,
10194 gboolean show_foreign)
10195{
10196 view->details->show_foreign_files = show_foreign;
10197}
10198
10199char *
10200fm_directory_view_get_uri (FMDirectoryView *view)
10201{
10202 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)
;
10203 if (view->details->model == NULL((void*)0)) {
10204 return NULL((void*)0);
10205 }
10206 return baul_directory_get_uri (view->details->model);
10207}
10208
10209/* Get the real directory where files will be stored and created */
10210char *
10211fm_directory_view_get_backing_uri (FMDirectoryView *view)
10212{
10213 BaulDirectory *directory;
10214 char *uri;
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
10218 if (view->details->model == NULL((void*)0)) {
10219 return NULL((void*)0);
10220 }
10221
10222 directory = view->details->model;
10223
10224 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; }
))))
) {
10225 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
())))))
);
10226 } else {
10227 baul_directory_ref (directory);
10228 }
10229
10230 uri = baul_directory_get_uri (directory);
10231
10232 baul_directory_unref (directory);
10233
10234 return uri;
10235}
10236
10237void
10238fm_directory_view_move_copy_items (const GList *item_uris,
10239 GArray *relative_item_points,
10240 const char *target_uri,
10241 int copy_action,
10242 int x, int y,
10243 FMDirectoryView *view)
10244{
10245 BaulFile *target_file;
10246
10247 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"
, 10249, ((const char*) (__func__)), "relative_item_points == NULL || relative_item_points->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points->len"
); } while (0)
10248 || 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"
, 10249, ((const char*) (__func__)), "relative_item_points == NULL || relative_item_points->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points->len"
); } while (0)
10249 || 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"
, 10249, ((const char*) (__func__)), "relative_item_points == NULL || relative_item_points->len == 0 || g_list_length ((GList *)item_uris) == relative_item_points->len"
); } while (0)
;
10250
10251 /* add the drop location to the icon offsets */
10252 offset_drop_points (relative_item_points, x, y);
10253
10254 target_file = baul_file_get_existing_by_uri (target_uri);
10255 /* special-case "command:" here instead of starting a move/copy */
10256 if (target_file != NULL((void*)0) && baul_file_is_launcher (target_file)) {
10257 baul_file_unref (target_file);
10258 baul_launch_desktop_file (
10259 ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
),
10260 target_uri, item_uris,
10261 fm_directory_view_get_containing_window (view));
10262 return;
10263 } else if (copy_action == CDK_ACTION_COPY &&
10264 baul_is_grapa_installed () &&
10265 target_file != NULL((void*)0) &&
10266 baul_file_is_archive (target_file)) {
10267 char *command, *quoted_uri, *tmp;
10268 const GList *l;
10269 CdkScreen *screen;
10270
10271 /* Handle dropping onto a grapa archiver file, instead of starting a move/copy */
10272
10273 baul_file_unref (target_file);
10274
10275 quoted_uri = g_shell_quote (target_uri);
10276 command = g_strconcat ("grapa -a ", quoted_uri, NULL((void*)0));
10277 g_free (quoted_uri);
10278
10279 for (l = item_uris; l != NULL((void*)0); l = l->next) {
10280 quoted_uri = g_shell_quote ((char *) l->data);
10281
10282 tmp = g_strconcat (command, " ", quoted_uri, NULL((void*)0));
10283 g_free (command);
10284 command = tmp;
10285
10286 g_free (quoted_uri);
10287 }
10288
10289 screen = ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
);
10290 if (screen == NULL((void*)0)) {
10291 screen = cdk_screen_get_default ();
10292 }
10293
10294 cafe_cdk_spawn_command_line_on_screen(screen, command, NULL((void*)0));
10295 g_free (command);
10296
10297 return;
10298 }
10299 baul_file_unref (target_file);
10300
10301 baul_file_operations_copy_move
10302 (item_uris, relative_item_points,
10303 target_uri, copy_action, CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
,
10304 copy_move_done_callback, pre_copy_move (view));
10305}
10306
10307gboolean
10308fm_directory_view_can_accept_item (BaulFile *target_item,
10309 const char *item_uri,
10310 FMDirectoryView *view)
10311{
10312 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)
;
10313 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)
;
10314 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)
;
10315
10316 return baul_drag_can_accept_item (target_item, item_uri);
10317}
10318
10319static void
10320fm_directory_view_trash_state_changed_callback (BaulTrashMonitor *trash_monitor,
10321 gboolean state, gpointer callback_data)
10322{
10323 FMDirectoryView *view;
10324
10325 view = (FMDirectoryView *) callback_data;
10326 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"
, 10326, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
10327
10328 schedule_update_menus (view);
10329}
10330
10331void
10332fm_directory_view_start_batching_selection_changes (FMDirectoryView *view)
10333{
10334 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)
;
10335
10336 ++view->details->batching_selection_level;
10337 view->details->selection_changed_while_batched = FALSE(0);
10338}
10339
10340void
10341fm_directory_view_stop_batching_selection_changes (FMDirectoryView *view)
10342{
10343 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)
;
10344 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)
;
10345
10346 if (--view->details->batching_selection_level == 0) {
10347 if (view->details->selection_changed_while_batched) {
10348 fm_directory_view_notify_selection_changed (view);
10349 }
10350 }
10351}
10352
10353static void
10354revert_slashes (char *string)
10355{
10356 while (*string != 0) {
10357 if (*string == '/') {
10358 *string = '\\';
10359 }
10360 string++;
10361 }
10362}
10363
10364
10365static CdkDragAction
10366ask_link_action (FMDirectoryView *view)
10367{
10368 int button_pressed;
10369 CdkDragAction result;
10370 CtkWindow *parent_window;
10371 CtkWidget *dialog;
10372
10373 parent_window = NULL((void*)0);
10374
10375 /* Don't use desktop window as parent, since that means
10376 we show up an all desktops etc */
10377 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; }))))
) {
10378 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
()))))))
;
10379 }
10380
10381 dialog = ctk_message_dialog_new (parent_window,
10382 CTK_DIALOG_DESTROY_WITH_PARENT,
10383 CTK_MESSAGE_QUESTION,
10384 CTK_BUTTONS_NONE,
10385 _("Download location?")gettext ("Download location?"));
10386
10387 ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ())
)))))
,
10388 _("You can download it or make a link to it.")gettext ("You can download it or make a link to it."));
10389
10390 ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
10391 _("Make a _Link")gettext ("Make a _Link"), 0);
10392
10393 eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
10394 _("_Cancel")gettext ("_Cancel"),
10395 "process-stop", 1);
10396
10397 ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
,
10398 _("_Download")gettext ("_Download"), 2);
10399
10400 ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, ""); /* as per HIG */
10401 ctk_window_set_focus_on_map (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
10402 ctk_dialog_set_default_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
, 2);
10403
10404 ctk_window_present (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_window_get_type ()))))))
);
10405
10406 button_pressed = ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((dialog)), ((ctk_dialog_get_type ()))))))
);
10407
10408 ctk_widget_destroy (dialog);
10409
10410 switch (button_pressed) {
10411 case 0:
10412 result = CDK_ACTION_LINK;
10413 break;
10414 case 1:
10415 case CTK_RESPONSE_DELETE_EVENT:
10416 result = 0;
10417 break;
10418 case 2:
10419 result = CDK_ACTION_COPY;
10420 break;
10421 default:
10422 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c"
, 10422, ((const char*) (__func__)), ((void*)0)); } while (0)
;
10423 result = 0;
10424 }
10425
10426 return result;
10427}
10428
10429typedef struct {
10430 FMDirectoryView *view;
10431 GCancellable *cancellable;
10432 char *encoded_url;
10433 char *target_uri;
10434 int x;
10435 int y;
10436 guint timeout;
10437} NetscapeUrlDropAsk;
10438
10439static void
10440handle_netscape_url_drop_ask_cb (GObject *source_object,
10441 GAsyncResult *res,
10442 gpointer user_data)
10443{
10444 NetscapeUrlDropAsk *data;
10445 CdkDragAction action;
10446 GFileInfo *info;
10447 GFile *f;
10448 const char *mime_type;
10449
10450 data = user_data;
10451 f = G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source_object)), ((g_file_get_type ()))))))
;
10452
10453 info = g_file_query_info_finish (f, res, NULL((void*)0));
10454 mime_type = NULL((void*)0);
10455
10456 if (info) {
10457 mime_type = g_file_info_get_content_type (info);
10458 }
10459
10460 if (mime_type != NULL((void*)0) &&
10461 (g_content_type_equals (mime_type, "text/html") ||
10462 g_content_type_equals (mime_type, "text/xml") ||
10463 g_content_type_equals (mime_type, "application/xhtml+xml"))) {
10464 action = CDK_ACTION_LINK;
10465 } else if (mime_type != NULL((void*)0) &&
10466 g_content_type_equals (mime_type, "text/plain")) {
10467 action = ask_link_action (data->view);
10468 } else {
10469 action = CDK_ACTION_COPY;
10470 }
10471 if (info) {
10472 g_object_unref (info);
10473 }
10474
10475 if (action != 0) {
10476 fm_directory_view_handle_netscape_url_drop (data->view,
10477 data->encoded_url,
10478 data->target_uri,
10479 action,
10480 data->x, data->y);
10481 }
10482
10483 g_object_unref (data->view);
10484 g_object_unref (data->cancellable);
10485 if (data->timeout != 0) {
10486 g_source_remove (data->timeout);
10487 }
10488 g_free (data->encoded_url);
10489 g_free (data->target_uri);
10490 g_free (data);
10491}
10492
10493static gboolean
10494handle_netscape_url_drop_timeout (gpointer user_data)
10495{
10496 NetscapeUrlDropAsk *data;
10497
10498 data = user_data;
10499
10500 g_cancellable_cancel (data->cancellable);
10501 data->timeout = 0;
10502
10503 return FALSE(0);
10504}
10505
10506static inline void
10507fm_directory_view_widget_to_file_operation_position (FMDirectoryView *view,
10508 CdkPoint *position)
10509{
10510 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)
10511 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)
10512 (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)
;
10513}
10514
10515static void
10516fm_directory_view_widget_to_file_operation_position_xy (FMDirectoryView *view,
10517 int *x, int *y)
10518{
10519 CdkPoint position;
10520
10521 position.x = *x;
10522 position.y = *y;
10523 fm_directory_view_widget_to_file_operation_position (view, &position);
10524 *x = position.x;
10525 *y = position.y;
10526}
10527
10528void
10529fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view,
10530 const char *encoded_url,
10531 const char *target_uri,
10532 CdkDragAction action,
10533 int x,
10534 int y)
10535{
10536 CdkPoint point;
10537 char *url, *title;
10538 char *container_uri;
10539 char **bits;
10540 GList *uri_list = NULL((void*)0);
10541 GFile *f;
10542
10543 if (encoded_url == NULL((void*)0)) {
10544 return;
10545 }
10546
10547 container_uri = NULL((void*)0);
10548 if (target_uri == NULL((void*)0)) {
10549 container_uri = fm_directory_view_get_backing_uri (view);
10550 g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 10550, ((const char*) (
__func__)), "container_uri != NULL"); } while (0)
;
10551 }
10552
10553 f = g_file_new_for_uri (target_uri != NULL((void*)0) ? target_uri : container_uri);
10554 if (!g_file_is_native (f)) {
10555 eel_show_warning_dialog (_("Drag and drop is not supported.")gettext ("Drag and drop is not supported."),
10556 _("Drag and drop is only supported on local file systems.")gettext ("Drag and drop is only supported on local file systems."
)
,
10557 fm_directory_view_get_containing_window (view));
10558 g_object_unref (f);
10559 g_free (container_uri);
10560 return;
10561 }
10562 g_object_unref (f);
10563
10564 /* _NETSCAPE_URL_ works like this: $URL\n$TITLE */
10565 bits = g_strsplit (encoded_url, "\n", 0);
10566 switch (g_strv_length (bits)) {
10567 case 0:
10568 g_strfreev (bits);
10569 g_free (container_uri);
10570 return;
10571 case 1:
10572 url = bits[0];
10573 title = NULL((void*)0);
10574 break;
10575 default:
10576 url = bits[0];
10577 title = bits[1];
10578 }
10579
10580 if (action == CDK_ACTION_ASK) {
10581 NetscapeUrlDropAsk *data;
10582
10583 f = g_file_new_for_uri (url);
10584 data = g_new0 (NetscapeUrlDropAsk, 1)((NetscapeUrlDropAsk *) g_malloc0_n ((1), sizeof (NetscapeUrlDropAsk
)))
;
10585 data->view = g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view));
10586 data->cancellable = g_cancellable_new ();
10587 data->encoded_url = g_strdup (encoded_url)g_strdup_inline (encoded_url);
10588 data->target_uri = g_strdup (target_uri)g_strdup_inline (target_uri);
10589 data->x = x;
10590 data->y = y;
10591 /* Ensure we wait at most 1 second for mimetype */
10592 data->timeout = g_timeout_add (1000,
10593 handle_netscape_url_drop_timeout,
10594 data);
10595 g_file_query_info_async (f,
10596 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE"standard::content-type", 0,
10597 0, data->cancellable,
10598 handle_netscape_url_drop_ask_cb,
10599 data);
10600
10601 g_strfreev (bits);
10602 g_free (container_uri);
10603 return;
10604 }
10605
10606 fm_directory_view_widget_to_file_operation_position_xy (view, &x, &y);
10607
10608 /* We don't support CDK_ACTION_ASK or CDK_ACTION_PRIVATE
10609 * and we don't support combinations either. */
10610 if ((action != CDK_ACTION_DEFAULT) &&
10611 (action != CDK_ACTION_COPY) &&
10612 (action != CDK_ACTION_MOVE) &&
10613 (action != CDK_ACTION_LINK)) {
10614 eel_show_warning_dialog (_("Drag and drop is not supported.")gettext ("Drag and drop is not supported."),
10615 _("An invalid drag type was used.")gettext ("An invalid drag type was used."),
10616 fm_directory_view_get_containing_window (view));
10617 g_strfreev (bits);
10618 g_free (container_uri);
10619 return;
10620 }
10621
10622 if (action == CDK_ACTION_LINK) {
10623 char *link_name;
10624
10625 if (eel_str_is_empty (title)) {
10626 GFile *f;
10627
10628 f = g_file_new_for_uri (url);
10629 link_name = g_file_get_basename (f);
10630 g_object_unref (f);
10631 } else {
10632 link_name = g_strdup (title)g_strdup_inline (title);
10633 }
10634
10635 if (!eel_str_is_empty (link_name)) {
10636 CdkScreen *screen;
10637 int screen_num;
10638 char *link_display_name;
10639
10640 link_display_name = g_strdup_printf (_("Link to %s")gettext ("Link to %s"), link_name);
10641
10642 /* The filename can't contain slashes, strip em.
10643 (the basename of http://foo/ is http://foo/) */
10644 revert_slashes (link_name);
10645
10646 point.x = x;
10647 point.y = y;
10648
10649 screen = ctk_widget_get_screen (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
);
10650 screen_num = cdk_x11_screen_get_screen_number (screen);
10651
10652 baul_link_local_create (target_uri != NULL((void*)0) ? target_uri : container_uri,
10653 link_name,
10654 link_display_name,
10655 "cafe-fs-bookmark",
10656 url,
10657 &point,
10658 screen_num,
10659 TRUE(!(0)));
10660
10661 g_free (link_display_name);
10662 }
10663 g_free (link_name);
10664 } else {
10665 GArray *points;
10666
10667 CdkPoint tmp_point = { 0, 0 };
10668
10669 /* pass in a 1-item array of icon positions, relative to x, y */
10670 points = g_array_new (FALSE(0), TRUE(!(0)), sizeof (CdkPoint));
10671 g_array_append_val (points, tmp_point)g_array_append_vals (points, &(tmp_point), 1);
10672
10673 uri_list = g_list_append (uri_list, url);
10674
10675 fm_directory_view_move_copy_items (uri_list, points,
10676 target_uri != NULL((void*)0) ? target_uri : container_uri,
10677 action, x, y, view);
10678
10679 g_list_free (uri_list);
10680 g_array_free (points, TRUE(!(0)));
10681 }
10682
10683 g_strfreev (bits);
10684 g_free (container_uri);
10685}
10686
10687void
10688fm_directory_view_handle_uri_list_drop (FMDirectoryView *view,
10689 const char *item_uris,
10690 const char *target_uri,
10691 CdkDragAction action,
10692 int x,
10693 int y)
10694{
10695 gchar **uri_list;
10696 GList *real_uri_list = NULL((void*)0);
10697 char *container_uri;
10698 int n_uris, i;
10699 GArray *points;
10700
10701 if (item_uris == NULL((void*)0)) {
10702 return;
10703 }
10704
10705 container_uri = NULL((void*)0);
10706 if (target_uri == NULL((void*)0)) {
10707 container_uri = fm_directory_view_get_backing_uri (view);
10708 g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 10708, ((const char*) (
__func__)), "container_uri != NULL"); } while (0)
;
10709 }
10710
10711 if (action == CDK_ACTION_ASK) {
10712 action = baul_drag_drop_action_ask
10713 (CTK_WIDGET (view)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((view)), ((ctk_widget_get_type ()))))))
,
10714 CDK_ACTION_MOVE | CDK_ACTION_COPY | CDK_ACTION_LINK);
10715 if (action == 0) {
10716 g_free (container_uri);
10717 return;
10718 }
10719 }
10720
10721 /* We don't support CDK_ACTION_ASK or CDK_ACTION_PRIVATE
10722 * and we don't support combinations either. */
10723 if ((action != CDK_ACTION_DEFAULT) &&
10724 (action != CDK_ACTION_COPY) &&
10725 (action != CDK_ACTION_MOVE) &&
10726 (action != CDK_ACTION_LINK)) {
10727 eel_show_warning_dialog (_("Drag and drop is not supported.")gettext ("Drag and drop is not supported."),
10728 _("An invalid drag type was used.")gettext ("An invalid drag type was used."),
10729 fm_directory_view_get_containing_window (view));
10730 g_free (container_uri);
10731 return;
10732 }
10733
10734 n_uris = 0;
10735 uri_list = g_uri_list_extract_uris (item_uris);
10736 for (i = 0; uri_list[i] != NULL((void*)0); i++) {
10737 real_uri_list = g_list_append (real_uri_list, uri_list[i]);
10738 n_uris++;
10739 }
10740 g_free (uri_list);
10741
10742 /* do nothing if no real uris are left */
10743 if (n_uris == 0) {
10744 g_free (container_uri);
10745 return;
10746 }
10747
10748 if (n_uris == 1) {
10749 CdkPoint tmp_point = { 0, 0 };
10750
10751 /* pass in a 1-item array of icon positions, relative to x, y */
10752 points = g_array_new (FALSE(0), TRUE(!(0)), sizeof (CdkPoint));
10753 g_array_append_val (points, tmp_point)g_array_append_vals (points, &(tmp_point), 1);
10754 } else {
10755 points = NULL((void*)0);
10756 }
10757
10758 fm_directory_view_widget_to_file_operation_position_xy (view, &x, &y);
10759
10760 fm_directory_view_move_copy_items (real_uri_list, points,
10761 target_uri != NULL((void*)0) ? target_uri : container_uri,
10762 action, x, y, view);
10763
10764 g_list_free_full (real_uri_list, g_free);
10765
10766 if (points != NULL((void*)0))
10767 g_array_free (points, TRUE(!(0)));
10768
10769 g_free (container_uri);
10770}
10771
10772void
10773fm_directory_view_handle_text_drop (FMDirectoryView *view,
10774 const char *text,
10775 const char *target_uri,
10776 CdkDragAction action,
10777 int x,
10778 int y)
10779{
10780 int length;
10781 char *container_uri;
10782 CdkPoint pos;
10783
10784 if (text == NULL((void*)0)) {
10785 return;
10786 }
10787
10788 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)
;
10789
10790 container_uri = NULL((void*)0);
10791 if (target_uri == NULL((void*)0)) {
10792 container_uri = fm_directory_view_get_backing_uri (view);
10793 g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 10793, ((const char*) (
__func__)), "container_uri != NULL"); } while (0)
;
10794 }
10795
10796 length = strlen (text);
10797
10798 pos.x = x;
10799 pos.y = y;
10800 fm_directory_view_widget_to_file_operation_position (view, &pos);
10801
10802 fm_directory_view_new_file_with_initial_contents (
10803 view, target_uri != NULL((void*)0) ? target_uri : container_uri,
10804 /* Translators: This is the filename used for when you dnd text to a directory */
10805 _("dropped text.txt")gettext ("dropped text.txt"),
10806 text, length, &pos);
10807
10808 g_free (container_uri);
10809}
10810
10811void
10812fm_directory_view_handle_raw_drop (FMDirectoryView *view,
10813 const char *raw_data,
10814 int length,
10815 const char *target_uri,
10816 const char *direct_save_uri,
10817 CdkDragAction action,
10818 int x,
10819 int y)
10820{
10821 char *container_uri, *filename;
10822 CdkPoint pos;
10823
10824 if (raw_data == NULL((void*)0)) {
10825 return;
10826 }
10827
10828 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)
;
10829
10830 container_uri = NULL((void*)0);
10831 if (target_uri == NULL((void*)0)) {
10832 container_uri = fm_directory_view_get_backing_uri (view);
10833 g_assert (container_uri != NULL)do { if (container_uri != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 10833, ((const char*) (
__func__)), "container_uri != NULL"); } while (0)
;
10834 }
10835
10836 pos.x = x;
10837 pos.y = y;
10838 fm_directory_view_widget_to_file_operation_position (view, &pos);
10839
10840 filename = NULL((void*)0);
10841 if (direct_save_uri != NULL((void*)0)) {
10842 GFile *direct_save_full;
10843
10844 direct_save_full = g_file_new_for_uri (direct_save_uri);
10845 filename = g_file_get_basename (direct_save_full);
10846 }
10847 if (filename == NULL((void*)0)) {
10848 /* Translators: This is the filename used for when you dnd raw
10849 * data to a directory, if the source didn't supply a name.
10850 */
10851 filename = _("dropped data")gettext ("dropped data");
10852 }
10853
10854 fm_directory_view_new_file_with_initial_contents (
10855 view, target_uri != NULL((void*)0) ? target_uri : container_uri,
10856 filename, raw_data, length, &pos);
10857
10858 g_free (container_uri);
10859}
10860
10861gboolean
10862fm_directory_view_get_active (FMDirectoryView *view)
10863{
10864 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"
, 10864, ((const char*) (__func__)), "FM_IS_DIRECTORY_VIEW (view)"
); } while (0)
;
10865 return view->details->active;
10866}
10867
10868static GArray *
10869real_get_selected_icon_locations (FMDirectoryView *view)
10870{
10871 /* By default, just return an empty list. */
10872 return g_array_new (FALSE(0), TRUE(!(0)), sizeof (CdkPoint));
10873}
10874
10875static void
10876fm_directory_view_set_property (GObject *object,
10877 guint prop_id,
10878 const GValue *value,
10879 GParamSpec *pspec)
10880{
10881 FMDirectoryView *directory_view;
10882 BaulWindowSlotInfo *slot;
10883 BaulWindowInfo *window;
10884
10885 directory_view = FM_DIRECTORY_VIEW (object)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), (fm_directory_view_get_type())))))
;
10886
10887 switch (prop_id) {
10888 case PROP_WINDOW_SLOT:
10889 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"
, 10889, ((const char*) (__func__)), "directory_view->details->slot == NULL"
); } while (0)
;
10890
10891 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
()))))))
;
10892 window = baul_window_slot_info_get_window (slot);
10893
10894 directory_view->details->slot = slot;
10895 directory_view->details->window = window;
10896
10897 g_signal_connect_object (directory_view->details->slot,
10898 "active", G_CALLBACK (slot_active)((GCallback) (slot_active)),
10899 directory_view, 0);
10900 g_signal_connect_object (directory_view->details->slot,
10901 "inactive", G_CALLBACK (slot_inactive)((GCallback) (slot_inactive)),
10902 directory_view, 0);
10903
10904 g_signal_connect_object (directory_view->details->window,
10905 "hidden-files-mode-changed", G_CALLBACK (hidden_files_mode_changed)((GCallback) (hidden_files_mode_changed)),
10906 directory_view, 0);
10907 fm_directory_view_init_show_hidden_files (directory_view);
10908
10909 g_signal_connect_object (directory_view->details->window,
10910 "backup-files-mode-changed", G_CALLBACK (backup_files_mode_changed)((GCallback) (backup_files_mode_changed)),
10911 directory_view, 0);
10912 fm_directory_view_init_show_backup_files (directory_view);
10913
10914 break;
10915 default:
10916 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", 10916, ("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)
;
10917 break;
10918 }
10919}
10920
10921
10922gboolean
10923fm_directory_view_handle_scroll_event (FMDirectoryView *directory_view,
10924 CdkEventScroll *event)
10925{
10926 static gdouble total_delta_y = 0;
10927 gdouble delta_x, delta_y;
10928
10929 if (event->state & CDK_CONTROL_MASK) {
10930 switch (event->direction) {
10931 case CDK_SCROLL_UP:
10932 /* Zoom In */
10933 fm_directory_view_bump_zoom_level (directory_view, 1);
10934 return TRUE(!(0));
10935
10936 case CDK_SCROLL_DOWN:
10937 /* Zoom Out */
10938 fm_directory_view_bump_zoom_level (directory_view, -1);
10939 return TRUE(!(0));
10940
10941 case CDK_SCROLL_SMOOTH:
10942 cdk_event_get_scroll_deltas ((const CdkEvent *) event,
10943 &delta_x, &delta_y);
10944
10945 /* try to emulate a normal scrolling event by summing deltas */
10946 total_delta_y += delta_y;
10947
10948 if (total_delta_y >= 1) {
10949 total_delta_y = 0;
10950 /* emulate scroll down */
10951 fm_directory_view_bump_zoom_level (directory_view, -1);
10952 return TRUE(!(0));
10953 } else if (total_delta_y <= - 1) {
10954 total_delta_y = 0;
10955 /* emulate scroll up */
10956 fm_directory_view_bump_zoom_level (directory_view, 1);
10957 return TRUE(!(0));
10958 } else {
10959 /* eat event */
10960 return TRUE(!(0));
10961 }
10962
10963 case CDK_SCROLL_LEFT:
10964 case CDK_SCROLL_RIGHT:
10965 break;
10966
10967 default:
10968 g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "fm-directory-view.c"
, 10968, ((const char*) (__func__)), ((void*)0)); } while (0)
;
10969 }
10970 }
10971
10972 return FALSE(0);
10973}
10974
10975/* handle Shift+Scroll, which will cause a zoom-in/out */
10976static gboolean
10977fm_directory_view_scroll_event (CtkWidget *widget,
10978 CdkEventScroll *event)
10979{
10980 FMDirectoryView *directory_view;
10981
10982 directory_view = FM_DIRECTORY_VIEW (widget)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (fm_directory_view_get_type())))))
;
10983 if (fm_directory_view_handle_scroll_event (directory_view, event)) {
10984 return TRUE(!(0));
10985 }
10986
10987 return CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->scroll_event (widget, event);
10988}
10989
10990
10991static void
10992fm_directory_view_parent_set (CtkWidget *widget,
10993 CtkWidget *old_parent)
10994{
10995 FMDirectoryView *view;
10996 CtkWidget *parent;
10997
10998 view = FM_DIRECTORY_VIEW (widget)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (fm_directory_view_get_type())))))
;
10999
11000 parent = ctk_widget_get_parent (widget);
11001 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"
, 11001, ((const char*) (__func__)), "parent == NULL || old_parent == NULL"
); } while (0)
;
11002
11003 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)) {
11004 CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((ctk_widget_get_type ()))))))
->parent_set (widget, old_parent);
11005 }
11006
11007 if (parent != NULL((void*)0)) {
11008 g_assert (old_parent == NULL)do { if (old_parent == ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "fm-directory-view.c", 11008, ((const char*) (
__func__)), "old_parent == NULL"); } while (0)
;
11009
11010 if (view->details->slot ==
11011 baul_window_info_get_active_slot (view->details->window)) {
11012 view->details->active = TRUE(!(0));
11013
11014 fm_directory_view_merge_menus (view);
11015 schedule_update_menus (view);
11016 }
11017 } else {
11018 fm_directory_view_unmerge_menus (view);
11019 remove_update_menus_timeout_callback (view);
11020 }
11021}
11022
11023static void
11024fm_directory_view_class_init (FMDirectoryViewClass *klass)
11025{
11026 CtkWidgetClass *widget_class;
11027 CtkScrolledWindowClass *scrolled_window_class;
11028 CtkBindingSet *binding_set;
11029
11030 widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_widget_get_type ()))))))
;
11031 scrolled_window_class = CTK_SCROLLED_WINDOW_CLASS (klass)((((CtkScrolledWindowClass*) (void *) g_type_check_class_cast
((GTypeClass*) ((klass)), ((ctk_scrolled_window_get_type ())
)))))
;
11032
11033 G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
->set_property = fm_directory_view_set_property;
11034 G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
->finalize = fm_directory_view_finalize;
11035
11036 widget_class->destroy = fm_directory_view_destroy;
11037
11038 widget_class->scroll_event = fm_directory_view_scroll_event;
11039 widget_class->parent_set = fm_directory_view_parent_set;
11040
11041 /* Get rid of the strange 3-pixel gap that CtkScrolledWindow
11042 * uses by default. It does us no good.
11043 */
11044 scrolled_window_class->scrollbar_spacing = 0;
11045
11046 signals[ADD_FILE] =
11047 g_signal_new ("add_file",
11048 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11049 G_SIGNAL_RUN_LAST,
11050 G_STRUCT_OFFSET (FMDirectoryViewClass, add_file)((glong) __builtin_offsetof(FMDirectoryViewClass, add_file)),
11051 NULL((void*)0), NULL((void*)0),
11052 fm_marshal_VOID__OBJECT_OBJECT,
11053 G_TYPE_NONE((GType) ((1) << (2))), 2, BAUL_TYPE_FILEbaul_file_get_type(), BAUL_TYPE_DIRECTORYbaul_directory_get_type());
11054 signals[BEGIN_FILE_CHANGES] =
11055 g_signal_new ("begin_file_changes",
11056 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11057 G_SIGNAL_RUN_LAST,
11058 G_STRUCT_OFFSET (FMDirectoryViewClass, begin_file_changes)((glong) __builtin_offsetof(FMDirectoryViewClass, begin_file_changes
))
,
11059 NULL((void*)0), NULL((void*)0),
11060 g_cclosure_marshal_VOID__VOID,
11061 G_TYPE_NONE((GType) ((1) << (2))), 0);
11062 signals[BEGIN_LOADING] =
11063 g_signal_new ("begin_loading",
11064 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11065 G_SIGNAL_RUN_LAST,
11066 G_STRUCT_OFFSET (FMDirectoryViewClass, begin_loading)((glong) __builtin_offsetof(FMDirectoryViewClass, begin_loading
))
,
11067 NULL((void*)0), NULL((void*)0),
11068 g_cclosure_marshal_VOID__VOID,
11069 G_TYPE_NONE((GType) ((1) << (2))), 0);
11070 signals[CLEAR] =
11071 g_signal_new ("clear",
11072 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11073 G_SIGNAL_RUN_LAST,
11074 G_STRUCT_OFFSET (FMDirectoryViewClass, clear)((glong) __builtin_offsetof(FMDirectoryViewClass, clear)),
11075 NULL((void*)0), NULL((void*)0),
11076 g_cclosure_marshal_VOID__VOID,
11077 G_TYPE_NONE((GType) ((1) << (2))), 0);
11078 signals[END_FILE_CHANGES] =
11079 g_signal_new ("end_file_changes",
11080 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11081 G_SIGNAL_RUN_LAST,
11082 G_STRUCT_OFFSET (FMDirectoryViewClass, end_file_changes)((glong) __builtin_offsetof(FMDirectoryViewClass, end_file_changes
))
,
11083 NULL((void*)0), NULL((void*)0),
11084 g_cclosure_marshal_VOID__VOID,
11085 G_TYPE_NONE((GType) ((1) << (2))), 0);
11086 signals[FLUSH_ADDED_FILES] =
11087 g_signal_new ("flush_added_files",
11088 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11089 G_SIGNAL_RUN_LAST,
11090 G_STRUCT_OFFSET (FMDirectoryViewClass, flush_added_files)((glong) __builtin_offsetof(FMDirectoryViewClass, flush_added_files
))
,
11091 NULL((void*)0), NULL((void*)0),
11092 g_cclosure_marshal_VOID__VOID,
11093 G_TYPE_NONE((GType) ((1) << (2))), 0);
11094 signals[END_LOADING] =
11095 g_signal_new ("end_loading",
11096 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11097 G_SIGNAL_RUN_LAST,
11098 G_STRUCT_OFFSET (FMDirectoryViewClass, end_loading)((glong) __builtin_offsetof(FMDirectoryViewClass, end_loading
))
,
11099 NULL((void*)0), NULL((void*)0),
11100 g_cclosure_marshal_VOID__BOOLEAN,
11101 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
11102 signals[FILE_CHANGED] =
11103 g_signal_new ("file_changed",
11104 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11105 G_SIGNAL_RUN_LAST,
11106 G_STRUCT_OFFSET (FMDirectoryViewClass, file_changed)((glong) __builtin_offsetof(FMDirectoryViewClass, file_changed
))
,
11107 NULL((void*)0), NULL((void*)0),
11108 fm_marshal_VOID__OBJECT_OBJECT,
11109 G_TYPE_NONE((GType) ((1) << (2))), 2, BAUL_TYPE_FILEbaul_file_get_type(), BAUL_TYPE_DIRECTORYbaul_directory_get_type());
11110 signals[LOAD_ERROR] =
11111 g_signal_new ("load_error",
11112 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11113 G_SIGNAL_RUN_LAST,
11114 G_STRUCT_OFFSET (FMDirectoryViewClass, load_error)((glong) __builtin_offsetof(FMDirectoryViewClass, load_error)
)
,
11115 NULL((void*)0), NULL((void*)0),
11116 g_cclosure_marshal_VOID__POINTER,
11117 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_POINTER((GType) ((17) << (2))));
11118 signals[REMOVE_FILE] =
11119 g_signal_new ("remove_file",
11120 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11121 G_SIGNAL_RUN_LAST,
11122 G_STRUCT_OFFSET (FMDirectoryViewClass, remove_file)((glong) __builtin_offsetof(FMDirectoryViewClass, remove_file
))
,
11123 NULL((void*)0), NULL((void*)0),
11124 fm_marshal_VOID__OBJECT_OBJECT,
11125 G_TYPE_NONE((GType) ((1) << (2))), 2, BAUL_TYPE_FILEbaul_file_get_type(), BAUL_TYPE_DIRECTORYbaul_directory_get_type());
11126
11127 klass->accepts_dragged_files = real_accepts_dragged_files;
11128 klass->file_still_belongs = real_file_still_belongs;
11129 klass->get_emblem_names_to_exclude = real_get_emblem_names_to_exclude;
11130 klass->get_selected_icon_locations = real_get_selected_icon_locations;
11131 klass->is_read_only = real_is_read_only;
11132 klass->load_error = real_load_error;
11133 klass->can_rename_file = can_rename_file;
11134 klass->start_renaming_file = start_renaming_file;
11135 klass->supports_creating_files = real_supports_creating_files;
11136 klass->supports_properties = real_supports_properties;
11137 klass->supports_zooming = real_supports_zooming;
11138 klass->using_manual_layout = real_using_manual_layout;
11139 klass->merge_menus = real_merge_menus;
11140 klass->unmerge_menus = real_unmerge_menus;
11141 klass->update_menus = real_update_menus;
11142 klass->set_is_active = real_set_is_active;
11143 /* Function pointers that subclasses must override */
11144 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, add_file)* (void (**)(void)) & (klass)->add_file = fm_directory_view_unimplemented_add_file;
11145 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;
11146 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;
11147 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;
11148 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, clear)* (void (**)(void)) & (klass)->clear = fm_directory_view_unimplemented_clear;
11149 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, file_changed)* (void (**)(void)) & (klass)->file_changed = fm_directory_view_unimplemented_file_changed;
11150 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
;
11151 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, get_selection)* (void (**)(void)) & (klass)->get_selection = fm_directory_view_unimplemented_get_selection;
11152 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
;
11153 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;
11154 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, is_empty)* (void (**)(void)) & (klass)->is_empty = fm_directory_view_unimplemented_is_empty;
11155 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;
11156 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
;
11157 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, select_all)* (void (**)(void)) & (klass)->select_all = fm_directory_view_unimplemented_select_all;
11158 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, set_selection)* (void (**)(void)) & (klass)->set_selection = fm_directory_view_unimplemented_set_selection;
11159 EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, fm_directory_view, invert_selection)* (void (**)(void)) & (klass)->invert_selection = fm_directory_view_unimplemented_invert_selection;
11160 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;
11161 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;
11162
11163 copied_files_atom = cdk_atom_intern ("x-special/cafe-copied-files", FALSE(0));
11164
11165 g_object_class_install_property (G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
,
11166 PROP_WINDOW_SLOT,
11167 g_param_spec_object ("window-slot",
11168 "Window Slot",
11169 "The parent window slot reference",
11170 BAUL_TYPE_WINDOW_SLOT_INFO(baul_window_slot_info_get_type ()),
11171 G_PARAM_WRITABLE |
11172 G_PARAM_CONSTRUCT_ONLY));
11173
11174 signals[TRASH] =
11175 g_signal_new ("trash",
11176 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11177 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
11178 G_STRUCT_OFFSET (FMDirectoryViewClass, trash)((glong) __builtin_offsetof(FMDirectoryViewClass, trash)),
11179 g_signal_accumulator_true_handled, NULL((void*)0),
11180 fm_marshal_BOOLEAN__VOID,
11181 G_TYPE_BOOLEAN((GType) ((5) << (2))), 0);
11182 signals[DELETE] =
11183 g_signal_new ("delete",
11184 G_TYPE_FROM_CLASS (klass)(((GTypeClass*) (klass))->g_type),
11185 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
11186 G_STRUCT_OFFSET (FMDirectoryViewClass, delete)((glong) __builtin_offsetof(FMDirectoryViewClass, delete)),
11187 g_signal_accumulator_true_handled, NULL((void*)0),
11188 fm_marshal_BOOLEAN__VOID,
11189 G_TYPE_BOOLEAN((GType) ((5) << (2))), 0);
11190
11191 binding_set = ctk_binding_set_by_class (klass);
11192 ctk_binding_entry_add_signal (binding_set, CDK_KEY_Delete0xffff, 0,
11193 "trash", 0);
11194 ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Delete0xff9f, 0,
11195 "trash", 0);
11196 ctk_binding_entry_add_signal (binding_set, CDK_KEY_Delete0xffff, CDK_SHIFT_MASK,
11197 "delete", 0);
11198 ctk_binding_entry_add_signal (binding_set, CDK_KEY_KP_Delete0xff9f, CDK_SHIFT_MASK,
11199 "delete", 0);
11200
11201 klass->trash = real_trash;
11202 klass->delete = real_delete;
11203}
11204
11205static void
11206undo_redo_menu_update_callback (BaulUndoStackManager* manager, gpointer arg, gpointer data)
11207{
11208 FMDirectoryView *view;
11209 view = FM_DIRECTORY_VIEW (data)((((FMDirectoryView*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((data)), (fm_directory_view_get_type())))))
;
11210
11211 BaulUndoStackMenuData* menudata = (BaulUndoStackMenuData*) arg;
11212
11213 g_free(view->details->undo_action_label);
11214 g_free(view->details->undo_action_description);
11215 g_free(view->details->redo_action_label);
11216 g_free(view->details->redo_action_description);
11217
11218 view->details->undo_active = menudata->undo_label ? TRUE(!(0)) : FALSE(0);
11219 view->details->redo_active = menudata->redo_label ? TRUE(!(0)) : FALSE(0);
11220
11221 view->details->undo_action_label = g_strdup (menudata->undo_label)g_strdup_inline (menudata->undo_label);
11222 view->details->undo_action_description = g_strdup (menudata->undo_description)g_strdup_inline (menudata->undo_description);
11223 view->details->redo_action_label = g_strdup (menudata->redo_label)g_strdup_inline (menudata->redo_label);
11224 view->details->redo_action_description = g_strdup (menudata->redo_description)g_strdup_inline (menudata->redo_description);
11225
11226 schedule_update_menus (view);
11227}
11228
11229static void
11230undo_update_menu (FMDirectoryView *view)
11231{
11232 CtkAction *action;
11233 gboolean available = FALSE(0);
11234 gchar* label;
11235 gchar* tooltip;
11236
11237 /* Update undo entry */
11238 action = ctk_action_group_get_action (view->details->dir_action_group,
11239 FM_ACTION_UNDO"Undo");
11240 available = view->details->undo_active;
11241 if (available) {
11242 label = view->details->undo_action_label;
11243 tooltip = view->details->undo_action_description;
11244 } else {
11245 /* Reset to default info */
11246 label = _("Undo")gettext ("Undo");
11247 tooltip = _("Undo the last action")gettext ("Undo the last action");
11248 }
11249 g_object_set (action,
11250 "label", label,
11251 "tooltip", tooltip,
11252 NULL((void*)0));
11253 ctk_action_set_sensitive (action, available);
11254
11255 /* Update redo entry */
11256 action = ctk_action_group_get_action (view->details->dir_action_group,
11257 FM_ACTION_REDO"Redo");
11258 available = view->details->redo_active;
11259 if (available) {
11260 label = view->details->redo_action_label;
11261 tooltip = view->details->redo_action_description;
11262 } else {
11263 /* Reset to default info */
11264 label = _("Redo")gettext ("Redo");
11265 tooltip = _("Redo the last undone action")gettext ("Redo the last undone action");
11266 }
11267 g_object_set (action,
11268 "label", label,
11269 "tooltip", tooltip,
11270 NULL((void*)0));
11271 ctk_action_set_sensitive (action, available);
11272}