-
Notifications
You must be signed in to change notification settings - Fork 344
Expand file tree
/
Copy pathnemo-view.c
More file actions
11261 lines (9310 loc) · 325 KB
/
nemo-view.c
File metadata and controls
11261 lines (9310 loc) · 325 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nemo-view.c
*
* Copyright (C) 1999, 2000 Free Software Foundation
* Copyright (C) 2000, 2001 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street - Suite 500,
* Boston, MA 02110-1335, USA.
*
* Authors: Ettore Perazzoli,
* John Sullivan <[email protected]>,
* Darin Adler <[email protected]>,
* Pavel Cisler <[email protected]>,
* David Emory Watson <[email protected]>
*/
#include <config.h>
#include "nemo-view.h"
#include "nemo-actions.h"
#include "nemo-desktop-icon-view.h"
#include "nemo-error-reporting.h"
#include "nemo-list-view.h"
#include "nemo-mime-actions.h"
#include "nemo-previewer.h"
#include "nemo-properties-window.h"
#include "nemo-bookmark-list.h"
#include "nemo-directory-private.h"
#include <sys/stat.h>
#include <fcntl.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <gio/gio.h>
#include <math.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <libnemo-extension/nemo-menu-provider.h>
#include <libnemo-extension/nemo-selection-provider.h>
#include <libnemo-private/nemo-bookmark.h>
#include <libnemo-private/nemo-clipboard.h>
#include <libnemo-private/nemo-clipboard-monitor.h>
#include <libnemo-private/nemo-desktop-icon-file.h>
#include <libnemo-private/nemo-desktop-directory.h>
#include <libnemo-private/nemo-search-directory.h>
#include <libnemo-private/nemo-directory.h>
#include <libnemo-private/nemo-dnd.h>
#include <libnemo-private/nemo-file-attributes.h>
#include <libnemo-private/nemo-file-changes-queue.h>
#include <libnemo-private/nemo-file-dnd.h>
#include <libnemo-private/nemo-file-operations.h>
#include <libnemo-private/nemo-file-utilities.h>
#include <libnemo-private/nemo-file-private.h>
#include <libnemo-private/nemo-global-preferences.h>
#include <libnemo-private/nemo-link.h>
#include <libnemo-private/nemo-metadata.h>
#include <libnemo-private/nemo-recent.h>
#include <libnemo-private/nemo-module.h>
#include <libnemo-private/nemo-program-choosing.h>
#include <libnemo-private/nemo-trash-monitor.h>
#include <libnemo-private/nemo-ui-utilities.h>
#include <libnemo-private/nemo-signaller.h>
#include <libnemo-private/nemo-icon-names.h>
#include <libnemo-private/nemo-file-undo-manager.h>
#include <libnemo-private/nemo-action.h>
#include <libnemo-private/nemo-widget-action.h>
#include <libnemo-private/nemo-separator-action.h>
#include <libnemo-private/nemo-action-manager.h>
#include <libnemo-private/nemo-mime-application-chooser.h>
#define DEBUG_FLAG NEMO_DEBUG_DIRECTORY_VIEW
#include <libnemo-private/nemo-debug.h>
/* Minimum starting update inverval */
#define UPDATE_INTERVAL_MIN 200
/* Maximum update interval */
#define UPDATE_INTERVAL_MAX 2000
/* Amount of miliseconds the update interval is increased */
#define UPDATE_INTERVAL_INC 250
/* Interval at which the update interval is increased */
#define UPDATE_INTERVAL_TIMEOUT_INTERVAL 500
/* Milliseconds that have to pass without a change to reset the update interval */
#define UPDATE_INTERVAL_RESET 1000
#define SILENT_WINDOW_OPEN_LIMIT 5
#define DUPLICATE_HORIZONTAL_ICON_OFFSET 70
#define DUPLICATE_VERTICAL_ICON_OFFSET 30
#define MAX_QUEUED_UPDATES 250
#define SELECTION_CHANGED_UPDATE_INTERVAL 50
#define NEMO_VIEW_MENU_PATH_OPEN_PLACEHOLDER "/MenuBar/File/Open Placeholder"
#define NEMO_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/MenuBar/File/Open Placeholder/Open With/Applications Placeholder"
#define NEMO_VIEW_MENU_PATH_APPLICATIONS_PLACEHOLDER "/MenuBar/File/Open Placeholder/Applications Placeholder"
#define NEMO_VIEW_MENU_PATH_SCRIPTS_PLACEHOLDER "/MenuBar/File/Open Placeholder/Scripts/Scripts Placeholder"
#define NEMO_VIEW_MENU_PATH_ACTIONS_PLACEHOLDER "/MenuBar/File/Open Placeholder/ActionsPlaceholder"
#define NEMO_VIEW_MENU_PATH_EXTENSION_ACTIONS_PLACEHOLDER "/MenuBar/Edit/Extension Actions"
#define NEMO_VIEW_MENU_PATH_NEW_DOCUMENTS_PLACEHOLDER "/MenuBar/File/New Items Placeholder/New Documents/New Documents Placeholder"
#define NEMO_VIEW_MENU_PATH_OPEN "/MenuBar/File/Open Placeholder/Open"
#define NEMO_VIEW_POPUP_PATH_SELECTION "/selection"
#define NEMO_VIEW_POPUP_PATH_OPEN_PLACEHOLDER "/selection/Open Placeholder"
#define NEMO_VIEW_POPUP_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/selection/Open Placeholder/Open With/Applications Placeholder"
#define NEMO_VIEW_POPUP_PATH_APPLICATIONS_PLACEHOLDER "/selection/Open Placeholder/Applications Placeholder"
#define NEMO_VIEW_POPUP_PATH_SCRIPTS_PLACEHOLDER "/selection/Open Placeholder/Scripts/Scripts Placeholder"
#define NEMO_VIEW_POPUP_PATH_ACTIONS_PLACEHOLDER "/selection/Open Placeholder/ActionsPlaceholder"
#define NEMO_VIEW_POPUP_PATH_EXTENSION_ACTIONS "/selection/Extension Actions"
#define NEMO_VIEW_POPUP_PATH_OPEN "/selection/Open Placeholder/Open"
#define NEMO_VIEW_POPUP_PATH_BACKGROUND "/background"
#define NEMO_VIEW_POPUP_PATH_BACKGROUND_SCRIPTS_PLACEHOLDER "/background/Before Zoom Items/New Object Items/Scripts/Scripts Placeholder"
#define NEMO_VIEW_POPUP_PATH_BACKGROUND_ACTIONS_PLACEHOLDER "/background/Before Zoom Items/New Object Items/ActionsPlaceholder"
#define NEMO_VIEW_POPUP_PATH_BACKGROUND_NEW_DOCUMENTS_PLACEHOLDER "/background/Before Zoom Items/New Object Items/New Documents/New Documents Placeholder"
#define NEMO_VIEW_POPUP_PATH_LOCATION "/location"
#define NEMO_VIEW_POPUP_PATH_BOOKMARK_MOVETO_ENTRIES_PLACEHOLDER "/selection/File Actions/MoveToMenu/BookmarkMoveToPlaceHolder"
#define NEMO_VIEW_POPUP_PATH_BOOKMARK_COPYTO_ENTRIES_PLACEHOLDER "/selection/File Actions/CopyToMenu/BookmarkCopyToPlaceHolder"
#define NEMO_VIEW_MENU_PATH_BOOKMARK_MOVETO_ENTRIES_PLACEHOLDER "/MenuBar/Edit/File Items Placeholder/MoveToMenu/BookmarkMoveToPlaceHolder"
#define NEMO_VIEW_MENU_PATH_BOOKMARK_COPYTO_ENTRIES_PLACEHOLDER "/MenuBar/Edit/File Items Placeholder/CopyToMenu/BookmarkCopyToPlaceHolder"
#define NEMO_VIEW_POPUP_PATH_PLACES_MOVETO_ENTRIES_PLACEHOLDER "/selection/File Actions/MoveToMenu/PlacesMoveToPlaceHolder"
#define NEMO_VIEW_POPUP_PATH_PLACES_COPYTO_ENTRIES_PLACEHOLDER "/selection/File Actions/CopyToMenu/PlacesCopyToPlaceHolder"
#define NEMO_VIEW_MENU_PATH_PLACES_MOVETO_ENTRIES_PLACEHOLDER "/MenuBar/Edit/File Items Placeholder/MoveToMenu/PlacesMoveToPlaceHolder"
#define NEMO_VIEW_MENU_PATH_PLACES_COPYTO_ENTRIES_PLACEHOLDER "/MenuBar/Edit/File Items Placeholder/CopyToMenu/PlacesCopyToPlaceHolder"
#define MAX_MENU_LEVELS 5
#define TEMPLATE_LIMIT 30
enum {
ADD_FILE,
BEGIN_FILE_CHANGES,
BEGIN_LOADING,
CLEAR,
END_FILE_CHANGES,
END_LOADING,
FILE_CHANGED,
LOAD_ERROR,
MOVE_COPY_ITEMS,
REMOVE_FILE,
ZOOM_LEVEL_CHANGED,
SELECTION_CHANGED,
TRASH,
DELETE,
LAST_SIGNAL
};
enum {
PROP_WINDOW_SLOT = 1,
PROP_SUPPORTS_ZOOMING,
NUM_PROPERTIES
};
static guint signals[LAST_SIGNAL] = { 0 };
static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
static GdkAtom copied_files_atom;
static char *scripts_directory_uri = NULL;
static int scripts_directory_uri_length;
struct NemoViewDetails
{
NemoWindow *window;
NemoWindowSlot *slot;
NemoDirectory *model;
NemoFile *directory_as_file;
NemoFile *location_popup_directory_as_file;
NemoBookmarkList *bookmarks;
GdkEventButton *location_popup_event;
GtkActionGroup *dir_action_group;
guint dir_merge_id;
gboolean supports_zooming;
GList *scripts_directory_list;
GtkActionGroup *scripts_action_group;
guint scripts_merge_id;
GtkActionGroup *actions_action_group;
guint actions_merge_id;
guint action_manager_changed_id;
NemoActionManager *action_manager;
GList *templates_directory_list;
GtkActionGroup *templates_action_group;
guint templates_merge_id;
GtkActionGroup *extensions_menu_action_group;
guint extensions_menu_merge_id;
guint display_selection_idle_id;
guint update_menus_timeout_id;
guint update_status_idle_id;
guint reveal_selection_idle_id;
guint display_pending_source_id;
guint changes_timeout_id;
guint update_interval;
guint64 last_queued;
guint files_added_handler_id;
guint files_changed_handler_id;
guint load_error_handler_id;
guint done_loading_handler_id;
guint file_changed_handler_id;
guint delayed_rename_file_id;
GList *new_added_files;
GList *new_changed_files;
GHashTable *non_ready_files;
GList *old_added_files;
GList *old_changed_files;
GList *pending_selection;
/* whether we are in the active slot */
gboolean active;
/* loading indicates whether this view has begun loading a directory.
* This flag should need not be set inside subclasses. NemoView automatically
* sets 'loading' to TRUE before it begins loading a directory's contents and to FALSE
* after it finishes loading the directory and its view.
*/
gboolean loading;
gboolean menu_states_untrustworthy;
gboolean scripts_invalid;
gboolean templates_invalid;
gboolean actions_invalid;
gboolean reported_load_error;
/* flag to indicate that no file updates should be dispatched to subclasses.
* This is a workaround for bug #87701 that prevents the list view from
* losing focus when the underlying GtkTreeView is updated.
*/
gboolean updates_frozen;
guint updates_queued;
gboolean needs_reload;
gboolean is_renaming;
gboolean sort_directories_first;
gboolean sort_favorites_first;
gboolean show_foreign_files;
gboolean show_hidden_files;
gboolean ignore_hidden_file_preferences;
gboolean batching_selection_level;
gboolean selection_changed_while_batched;
gboolean selection_was_removed;
gboolean metadata_for_directory_as_file_pending;
gboolean metadata_for_files_in_directory_pending;
gboolean selection_change_is_due_to_shell;
gboolean send_selection_change_to_shell;
GtkActionGroup *open_with_action_group;
guint open_with_merge_id;
GList *subdirectory_list;
guint copy_move_merge_ids[4];
GtkActionGroup *copy_move_action_groups[4];
guint bookmarks_changed_id;
GdkPoint context_menu_position;
gboolean showing_bookmarks_in_to_menus;
gboolean showing_places_in_to_menus;
GVolumeMonitor *volume_monitor;
GTimer *load_timer;
char *detail_string;
};
typedef struct {
NemoFile *file;
NemoDirectory *directory;
} FileAndDirectory;
/* forward declarations */
static gboolean display_selection_info_idle_callback (gpointer data);
static void nemo_view_duplicate_selection (NemoView *view,
GList *files,
GArray *item_locations);
static void nemo_view_create_links_for_files (NemoView *view,
GList *files,
GArray *item_locations);
static void trash_or_delete_files (GtkWindow *parent_window,
const GList *files,
gboolean delete_if_all_already_in_trash,
NemoView *view);
static void load_directory (NemoView *view,
NemoDirectory *directory);
static void nemo_view_merge_menus (NemoView *view);
static void nemo_view_unmerge_menus (NemoView *view);
static void nemo_view_init_show_hidden_files (NemoView *view);
static void clipboard_changed_callback (NemoClipboardMonitor *monitor,
NemoView *view);
static void open_one_in_new_window (gpointer data,
gpointer callback_data);
static void schedule_update_menus (NemoView *view);
static void schedule_update_menus_callback (gpointer callback_data);
static void remove_update_menus_timeout_callback (NemoView *view);
static void schedule_update_status (NemoView *view);
static void remove_update_status_idle_callback (NemoView *view);
static void reset_update_interval (NemoView *view);
static void schedule_idle_display_of_pending_files (NemoView *view);
static void unschedule_display_of_pending_files (NemoView *view);
static void disconnect_model_handlers (NemoView *view);
static void metadata_for_directory_as_file_ready_callback (NemoFile *file,
gpointer callback_data);
static void metadata_for_files_in_directory_ready_callback (NemoDirectory *directory,
GList *files,
gpointer callback_data);
static void nemo_view_trash_state_changed_callback (NemoTrashMonitor *trash,
gboolean state,
gpointer callback_data);
static void nemo_view_select_file (NemoView *view,
NemoFile *file);
static void update_templates_directory (NemoView *view);
static void user_dirs_changed (NemoView *view);
static gboolean file_list_all_are_folders (GList *file_list);
static void unschedule_pop_up_location_context_menu (NemoView *view);
static void disconnect_bookmark_signals (NemoView *view);
static void run_action_callback (NemoAction *action, gpointer callback_data);
static void update_accelerated_actions (NemoView *view);
G_DEFINE_TYPE (NemoView, nemo_view, GTK_TYPE_SCROLLED_WINDOW);
#define parent_class nemo_view_parent_class
/* virtual methods (public and non-public) */
/**
* nemo_view_merge_menus:
*
* Add this view's menus to the window's menu bar.
* @view: NemoView in question.
*/
static void
nemo_view_merge_menus (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->merge_menus (view);
}
static void
nemo_view_unmerge_menus (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->unmerge_menus (view);}
static char *
real_get_backing_uri (NemoView *view)
{
NemoDirectory *directory;
char *uri;
g_return_val_if_fail (NEMO_IS_VIEW (view), NULL);
if (view->details->model == NULL) {
return NULL;
}
directory = view->details->model;
if (NEMO_IS_DESKTOP_DIRECTORY (directory)) {
directory = nemo_desktop_directory_get_real_directory (NEMO_DESKTOP_DIRECTORY (directory));
} else {
nemo_directory_ref (directory);
}
uri = nemo_directory_get_uri (directory);
nemo_directory_unref (directory);
return uri;
}
/**
*
* nemo_view_get_backing_uri:
*
* Returns the URI for the target location of new directory, new file, new
* link and paste operations.
*/
char *
nemo_view_get_backing_uri (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), NULL);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_backing_uri (view);
}
/**
* nemo_view_select_all:
*
* select all the items in the view
*
**/
static void
nemo_view_select_all (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->select_all (view);
}
static void
nemo_view_call_set_selection (NemoView *view, GList *selection)
{
g_return_if_fail (NEMO_IS_VIEW (view));
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->set_selection (view, selection);
}
static GList *
nemo_view_get_selection_for_file_transfer (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), NULL);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selection_for_file_transfer (view);
}
/**
* nemo_view_get_selected_icon_locations:
*
* return an array of locations of selected icons if available
* Return value: GArray of GdkPoints
*
**/
static GArray *
nemo_view_get_selected_icon_locations (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), NULL);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selected_icon_locations (view);
}
static void
nemo_view_invert_selection (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->invert_selection (view);
}
/**
* nemo_view_reveal_selection:
*
* Scroll as necessary to reveal the selected items.
**/
static void
nemo_view_reveal_selection (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->reveal_selection (view);
}
/**
* nemo_view_reset_to_defaults:
*
* set sorting order, zoom level, etc. to match defaults
*
**/
static void
nemo_view_reset_to_defaults (NemoView *view)
{
NemoFile *file;
NemoWindow *window;
g_return_if_fail (NEMO_IS_VIEW (view));
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->reset_to_defaults (view);
gboolean show_hidden = g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_HIDDEN_FILES);
window = view->details->window;
if (show_hidden) {
nemo_window_set_hidden_files_mode (window, NEMO_WINDOW_SHOW_HIDDEN_FILES_ENABLE);
} else {
nemo_window_set_hidden_files_mode (window, NEMO_WINDOW_SHOW_HIDDEN_FILES_DISABLE);
}
file = view->details->slot->viewed_file;
nemo_file_set_metadata(file, NEMO_METADATA_KEY_SHOW_THUMBNAILS, NULL, NULL);
nemo_file_set_metadata(file, NEMO_METADATA_KEY_DEFAULT_VIEW, NULL, NULL);
gtk_action_activate (gtk_action_group_get_action (nemo_window_get_main_action_group (window), NEMO_ACTION_RELOAD));
}
static gboolean
nemo_view_using_manual_layout (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), FALSE);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->using_manual_layout (view);
}
static guint
nemo_view_get_item_count (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), 0);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_item_count (view);
}
/**
* nemo_view_can_rename_file
*
* Determine whether a file can be renamed.
* @file: A NemoFile
*
* Return value: TRUE if @file can be renamed, FALSE otherwise.
*
**/
static gboolean
nemo_view_can_rename_file (NemoView *view, NemoFile *file)
{
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->can_rename_file (view, file);
}
static gboolean
nemo_view_is_read_only (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), FALSE);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->is_read_only (view);
}
static gboolean
showing_trash_directory (NemoView *view)
{
NemoFile *file;
file = nemo_view_get_directory_as_file (view);
if (file != NULL) {
return nemo_file_is_in_trash (file);
}
return FALSE;
}
static gboolean
showing_recent_directory (NemoView *view)
{
NemoFile *file;
file = nemo_view_get_directory_as_file (view);
if (file != NULL) {
return nemo_file_is_in_recent (file);
}
return FALSE;
}
static gboolean
showing_favorites_directory (NemoView *view)
{
NemoFile *file;
file = nemo_view_get_directory_as_file (view);
if (file != NULL) {
return nemo_file_is_in_favorites (file);
}
return FALSE;
}
static gboolean
showing_admin_enabled_directory (NemoView *view)
{
NemoFile *file;
file = nemo_view_get_directory_as_file (view);
if (file != NULL) {
return nemo_file_has_uri_scheme (file, "admin");
}
return FALSE;
}
static gboolean
nemo_view_supports_creating_files (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), FALSE);
return !nemo_view_is_read_only (view)
&& !showing_trash_directory (view)
&& !showing_recent_directory (view)
&& !showing_favorites_directory (view);
}
static gboolean
nemo_view_is_empty (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), FALSE);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->is_empty (view);
}
/**
* nemo_view_bump_zoom_level:
*
* bump the current zoom level by invoking the relevant subclass through the slot
*
**/
void
nemo_view_bump_zoom_level (NemoView *view,
int zoom_increment)
{
g_return_if_fail (NEMO_IS_VIEW (view));
if (!nemo_view_supports_zooming (view)) {
return;
}
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->bump_zoom_level (view, zoom_increment);
}
/**
* nemo_view_zoom_to_level:
*
* Set the current zoom level by invoking the relevant subclass through the slot
*
**/
void
nemo_view_zoom_to_level (NemoView *view,
NemoZoomLevel zoom_level)
{
g_return_if_fail (NEMO_IS_VIEW (view));
if (!nemo_view_supports_zooming (view)) {
return;
}
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->zoom_to_level (view, zoom_level);
}
NemoZoomLevel
nemo_view_get_zoom_level (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), NEMO_ZOOM_LEVEL_STANDARD);
if (!nemo_view_supports_zooming (view)) {
return NEMO_ZOOM_LEVEL_STANDARD;
}
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_zoom_level (view);
}
/**
* nemo_view_can_zoom_in:
*
* Determine whether the view can be zoomed any closer.
* @view: The zoomable NemoView.
*
* Return value: TRUE if @view can be zoomed any closer, FALSE otherwise.
*
**/
gboolean
nemo_view_can_zoom_in (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), FALSE);
if (!nemo_view_supports_zooming (view)) {
return FALSE;
}
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->can_zoom_in (view);
}
/**
* nemo_view_can_zoom_out:
*
* Determine whether the view can be zoomed any further away.
* @view: The zoomable NemoView.
*
* Return value: TRUE if @view can be zoomed any further away, FALSE otherwise.
*
**/
gboolean
nemo_view_can_zoom_out (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), FALSE);
if (!nemo_view_supports_zooming (view)) {
return FALSE;
}
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->can_zoom_out (view);
}
gboolean
nemo_view_supports_zooming (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), FALSE);
return view->details->supports_zooming;
}
/**
* nemo_view_restore_default_zoom_level:
*
* restore to the default zoom level by invoking the relevant subclass through the slot
*
**/
void
nemo_view_restore_default_zoom_level (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
if (!nemo_view_supports_zooming (view)) {
return;
}
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->restore_default_zoom_level (view);
}
/*
static NemoZoomLevel
nemo_view_get_default_zoom_level (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
if (!nemo_view_supports_zooming (view)) {
return -1;
}
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_default_zoom_level (view);
}
*/
const char *
nemo_view_get_view_id (NemoView *view)
{
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_view_id (view);
}
char *
nemo_view_get_first_visible_file (NemoView *view)
{
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_first_visible_file (view);
}
void
nemo_view_scroll_to_file (NemoView *view,
const char *uri)
{
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->scroll_to_file (view, uri);
}
/**
* nemo_view_get_selection:
*
* Get a list of NemoFile pointers that represents the
* currently-selected items in this view. Subclasses must override
* the signal handler for the 'get_selection' signal. Callers are
* responsible for g_free-ing the list (but not its data).
* @view: NemoView whose selected items are of interest.
*
* Return value: GList of NemoFile pointers representing the selection.
*
**/
GList *
nemo_view_get_selection (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), NULL);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selection (view);
}
/**
* nemo_view_peek_selection:
*
* Get a list of NemoFile pointers that represents the
* currently-selected items in this view. Subclasses must override
* the signal handler for the 'peek_selection' signal. The returned list
* is owned by the view's icon container and should not be freed.
* @view: NemoView whose selected items are of interest.
*
* Return value: GList of NemoFile pointers representing the selection.
*
**/
GList *
nemo_view_peek_selection (NemoView *view)
{
g_return_val_if_fail (NEMO_IS_VIEW (view), NULL);
return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->peek_selection (view);
}
// int
// nemo_view_get_selection_count (NemoView *view)
// {
// g_return_val_if_fail (NEMO_IS_VIEW (view), 0);
// return NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selection_count (view);
// }
/**
* nemo_view_update_menus:
*
* Update the sensitivity and wording of dynamic menu items.
* @view: NemoView in question.
*/
void
nemo_view_update_menus (NemoView *view)
{
g_return_if_fail (NEMO_IS_VIEW (view));
if (!view->details->active) {
return;
}
NEMO_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->update_menus (view);
view->details->menu_states_untrustworthy = FALSE;
}
typedef struct {
GAppInfo *application;
GList *files;
NemoView *directory_view;
} ApplicationLaunchParameters;
typedef struct {
NemoFile *file;
NemoView *directory_view;
} ScriptLaunchParameters;
typedef struct {
NemoFile *file;
NemoView *directory_view;
} CreateTemplateParameters;
typedef struct {
NemoView *view;
char *dest_uri;
} BookmarkCallbackData;
static BookmarkCallbackData *
bookmark_callback_data_new (NemoView *view,
gchar *uri)
{
BookmarkCallbackData *result;
result = g_new0 (BookmarkCallbackData, 1);
result->view = view;
result->dest_uri = g_strdup(uri);
return result;
}
static void
bookmark_callback_data_free (BookmarkCallbackData *data)
{
g_free ((char *)data->dest_uri);
g_free (data);
}
static ApplicationLaunchParameters *
application_launch_parameters_new (GAppInfo *application,
GList *files,
NemoView *directory_view)
{
ApplicationLaunchParameters *result;
result = g_new0 (ApplicationLaunchParameters, 1);
result->application = g_object_ref (application);
result->files = nemo_file_list_copy (files);
if (directory_view != NULL) {
g_object_ref (directory_view);
result->directory_view = directory_view;
}
return result;
}
static void
application_launch_parameters_free (ApplicationLaunchParameters *parameters)
{
g_object_unref (parameters->application);
nemo_file_list_free (parameters->files);
if (parameters->directory_view != NULL) {
g_object_unref (parameters->directory_view);
}
g_free (parameters);
}
static GList *
file_and_directory_list_to_files (GList *fad_list)
{
GList *res, *l;
FileAndDirectory *fad;
res = NULL;
for (l = fad_list; l != NULL; l = l->next) {
fad = l->data;
res = g_list_prepend (res, nemo_file_ref (fad->file));
}
return g_list_reverse (res);
}
static GList *
file_and_directory_list_from_files (NemoDirectory *directory, GList *files)
{
GList *res, *l;
FileAndDirectory *fad;
res = NULL;
for (l = files; l != NULL; l = l->next) {
fad = g_new0 (FileAndDirectory, 1);
fad->directory = nemo_directory_ref (directory);
fad->file = nemo_file_ref (l->data);
res = g_list_prepend (res, fad);
}
return g_list_reverse (res);
}
static void
file_and_directory_free (FileAndDirectory *fad)
{
nemo_directory_unref (fad->directory);
nemo_file_unref (fad->file);
g_free (fad);
}
static void
file_and_directory_list_free (GList *list)
{
GList *l;
for (l = list; l != NULL; l = l->next) {
file_and_directory_free (l->data);
}
g_list_free (list);
}
static gboolean
file_and_directory_equal (gconstpointer v1,
gconstpointer v2)
{
const FileAndDirectory *fad1, *fad2;
fad1 = v1;
fad2 = v2;
return (fad1->file == fad2->file &&
fad1->directory == fad2->directory);
}
static guint
file_and_directory_hash (gconstpointer v)
{