-
Notifications
You must be signed in to change notification settings - Fork 309
/
Copy pathnemo-file-management-properties.c
1169 lines (968 loc) · 40.4 KB
/
nemo-file-management-properties.c
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-file-management-properties.c - Functions to create and show the nemo preference dialog.
Copyright (C) 2002 Jan Arne Petersen
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 51 Franklin Street - Suite 500,
Boston, MA 02110-1335, USA.
Authors: Jan Arne Petersen <[email protected]>
*/
#include <config.h>
#include "nemo-file-management-properties.h"
#include <string.h>
#include <time.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
#include <eel/eel-glib-extensions.h>
#include <libnemo-private/nemo-column-chooser.h>
#include <libnemo-private/nemo-column-utilities.h>
#include <libnemo-private/nemo-global-preferences.h>
#include <libnemo-private/nemo-module.h>
#include "nemo-plugin-manager.h"
#include "nemo-actions.h"
/* string enum preferences */
#define NEMO_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET "default_view_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET "icon_view_zoom_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_COMPACT_VIEW_ZOOM_WIDGET "compact_view_zoom_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET "list_view_zoom_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET "sort_order_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET "date_format_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FONT_CHOICE_WIDGET "date_font_choice_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET "preview_image_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET "preview_folder_combobox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SIZE_PREFIXES_WIDGET "size_prefixes_combobox"
/* bool preferences */
#define NEMO_FILE_MANAGEMENT_PROPERTIES_INHERIT_VIEW_WIDGET "inherit_view_checkbox"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_REVERSE_SORT_WIDGET "reverse_sort_checkbox"
#define NEMO_FILE_MANAGEMENT_QUICK_RENAMES_WITH_PAUSE_IN_BETWEEN "quick_renames_with_pause_in_between"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_FAVORITES_FIRST_WIDGET "sort_favorites_first_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET "sort_folders_first_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_COMPACT_LAYOUT_WIDGET "compact_layout_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET "labels_beside_icons_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_ALL_COLUMNS_SAME_WIDTH "all_columns_same_width_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET "always_use_browser_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_MOVE_WIDGET "trash_confirm_move_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET "trash_confirm_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET "trash_delete_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SWAP_TRASH_DELETE "swap_trash_binding_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_OPEN_NEW_WINDOW_WIDGET "new_window_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET "treeview_folders_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_PREVIOUS_ICON_TOOLBAR_WIDGET "show_previous_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_NEXT_ICON_TOOLBAR_WIDGET "show_next_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_UP_ICON_TOOLBAR_WIDGET "show_up_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_RELOAD_ICON_TOOLBAR_WIDGET "show_reload_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_EDIT_ICON_TOOLBAR_WIDGET "show_edit_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_HOME_ICON_TOOLBAR_WIDGET "show_home_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_COMPUTER_ICON_TOOLBAR_WIDGET "show_computer_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_SEARCH_ICON_TOOLBAR_WIDGET "show_search_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_NEW_FOLDER_ICON_TOOLBAR_WIDGET "show_new_folder_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_OPEN_IN_TERMINAL_ICON_TOOLBAR_WIDGET "show_open_in_terminal_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_ICON_VIEW_ICON_TOOLBAR_WIDGET "show_icon_view_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_LIST_VIEW_ICON_TOOLBAR_WIDGET "show_list_view_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_COMPACT_VIEW_ICON_TOOLBAR_WIDGET "show_compact_view_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_SHOW_THUMBNAILS_ICON_TOOLBAR_WIDGET "show_show_thumbnails_icon_toolbar_togglebutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_FULL_PATH_IN_TITLE_BARS_WIDGET "show_full_path_in_title_bars_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_CLOSE_DEVICE_VIEW_ON_EJECT_WIDGET "close_device_view_on_eject_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_AUTOMOUNT_MEDIA_WIDGET "media_automount_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_AUTOOPEN_MEDIA_WIDGET "media_autoopen_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_AUTORUN_MEDIA_WIDGET "media_autorun_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_DETECT_CONTENT_MEDIA_WIDGET "media_detect_content_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_ADVANCED_PERMISSIONS_WIDGET "show_advanced_permissions_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_START_WITH_DUAL_PANE_WIDGET "start_with_dual_pane_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_IGNORE_VIEW_METADATA_WIDGET "ignore_view_metadata_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_BOOKMARKS_IN_TO_MENUS_WIDGET "bookmarks_in_to_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_PLACES_IN_TO_MENUS_WIDGET "places_in_to_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_INHERIT_SHOW_THUMBNAILS_WIDGET "inherit_show_thumbnails_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_BULK_RENAME_WIDGET "bulk_rename_entry"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_ICON_VIEW_WIDGET "tooltips_on_icon_view_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_LIST_VIEW_WIDGET "tooltips_on_list_view_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_DESKTOP_WIDGET "tooltips_on_desktop_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_FILE_TYPE_WIDGET "tt_show_file_type_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_MOD_DATE_WIDGET "tt_show_modified_date_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_ACCESS_DATE_WIDGET "tt_show_accessed_date_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_CREATED_DATE_WIDGET "tt_show_created_date_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_FULL_PATH_WIDGET "tt_show_full_path_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_NEMO_PREFERENCES_SKIP_FILE_OP_QUEUE_WIDGET "skip_file_op_queue_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_NEMO_PREFERENCES_CLICK_DBL_PARENT_FOLDER_WIDGET "click_double_parent_folder_checkbutton"
/* int enums */
#define NEMO_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET "preview_image_size_combobox"
#define W(s) (gtk_builder_get_object (builder, s))
#define TOOLBAR_PADDING 20
static const char * const default_view_values[] = {
"icon-view",
"list-view",
"compact-view",
NULL
};
static const char * const zoom_values[] = {
"smallest",
"smaller",
"small",
"standard",
"large",
"larger",
"largest",
NULL
};
static const char * const sort_order_values[] = {
"name",
"size",
"type",
"detailed_type",
"mtime",
"atime",
"trash-time",
NULL
};
static const char * const date_format_values[] = {
"locale",
"iso",
"informal",
NULL
};
static const char * const date_font_choice_values[] = {
"auto-mono",
"system-mono",
"no-mono",
NULL
};
static const char * const preview_image_values[] = {
"always",
"local-only",
"never",
NULL
};
static const char * const preview_folder_values[] = {
"always",
"local-only",
"never",
NULL
};
static const char * const click_behavior_components[] = {
"single_click_radiobutton",
"double_click_radiobutton",
NULL
};
static const char * const click_behavior_values[] = {
"single",
"double",
NULL
};
static const char * const executable_text_components[] = {
"scripts_execute_radiobutton",
"scripts_view_radiobutton",
"scripts_confirm_radiobutton",
"scripts_execute_terminal_radiobutton",
NULL
};
static const char * const executable_text_values[] = {
"launch",
"display",
"ask",
NULL
};
static const char * const size_prefixes_values[] = {
"base-10",
"base-10-full",
"base-2",
"base-2-full",
NULL
};
static const guint64 thumbnail_limit_values[] = {
102400,
512000,
1048576,
3145728,
5242880,
10485760,
104857600,
1073741824,
2147483648U,
4294967295U,
8589934592U,
17179869184U,
34359738368U,
68719476736U
};
static const char * const icon_captions_components[] = {
"captions_0_combobox",
"captions_1_combobox",
"captions_2_combobox",
NULL
};
static GtkWidget *preferences_dialog = NULL;
static void
nemo_file_management_properties_size_group_create (GtkBuilder *builder,
char *prefix,
int items)
{
GtkSizeGroup *size_group;
int i;
char *item_name;
GtkWidget *widget;
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
for (i = 0; i < items; i++) {
item_name = g_strdup_printf ("%s_%d", prefix, i);
widget = GTK_WIDGET (gtk_builder_get_object (builder, item_name));
gtk_size_group_add_widget (size_group, widget);
g_free (item_name);
}
g_object_unref (G_OBJECT (size_group));
}
static void
columns_changed_callback (NemoColumnChooser *chooser,
gpointer callback_data)
{
char **visible_columns;
char **column_order;
nemo_column_chooser_get_settings (NEMO_COLUMN_CHOOSER (chooser),
&visible_columns,
&column_order);
g_settings_set_strv (nemo_list_view_preferences,
NEMO_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
(const char * const *)visible_columns);
g_settings_set_strv (nemo_list_view_preferences,
NEMO_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
(const char * const *)column_order);
g_strfreev (visible_columns);
g_strfreev (column_order);
}
static void
free_column_names_array (GPtrArray *column_names)
{
g_ptr_array_foreach (column_names, (GFunc) g_free, NULL);
g_ptr_array_free (column_names, TRUE);
}
static void
create_icon_caption_combo_box_items (GtkComboBoxText *combo_box,
GList *columns)
{
GList *l;
GPtrArray *column_names;
column_names = g_ptr_array_new ();
/* Translators: this is referred to captions under icons. */
gtk_combo_box_text_append_text (combo_box, _("None"));
g_ptr_array_add (column_names, g_strdup ("none"));
for (l = columns; l != NULL; l = l->next) {
NemoColumn *column;
char *name;
char *label;
column = NEMO_COLUMN (l->data);
g_object_get (G_OBJECT (column),
"name", &name, "label", &label,
NULL);
/* Don't show name here, it doesn't make sense */
if (!strcmp (name, "name")) {
g_free (name);
g_free (label);
continue;
}
gtk_combo_box_text_append_text (combo_box, label);
g_ptr_array_add (column_names, name);
g_free (label);
}
g_object_set_data_full (G_OBJECT (combo_box), "column_names",
column_names,
(GDestroyNotify) free_column_names_array);
}
static void
icon_captions_changed_callback (GtkComboBox *combo_box,
gpointer user_data)
{
GPtrArray *captions;
GtkBuilder *builder;
guint i;
builder = GTK_BUILDER (user_data);
captions = g_ptr_array_new ();
for (i = 0; icon_captions_components[i] != NULL; i++) {
int active;
GPtrArray *column_names;
char *name;
GtkWidget *c_box;
c_box = GTK_WIDGET (gtk_builder_get_object
(builder, icon_captions_components[i]));
active = gtk_combo_box_get_active (GTK_COMBO_BOX (c_box));
column_names = g_object_get_data (G_OBJECT (c_box),
"column_names");
name = g_ptr_array_index (column_names, active);
g_ptr_array_add (captions, name);
}
g_ptr_array_add (captions, NULL);
g_settings_set_strv (nemo_icon_view_preferences,
NEMO_PREFERENCES_ICON_VIEW_CAPTIONS,
(const char **)captions->pdata);
g_ptr_array_free (captions, TRUE);
}
static void
update_caption_combo_box (GtkBuilder *builder,
const char *combo_box_name,
const char *name)
{
GtkWidget *combo_box;
guint i;
GPtrArray *column_names;
combo_box = GTK_WIDGET (gtk_builder_get_object (builder, combo_box_name));
g_signal_handlers_block_by_func
(combo_box,
G_CALLBACK (icon_captions_changed_callback),
builder);
column_names = g_object_get_data (G_OBJECT (combo_box),
"column_names");
for (i = 0; i < column_names->len; ++i) {
if (!strcmp (name, g_ptr_array_index (column_names, i))) {
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), i);
break;
}
}
g_signal_handlers_unblock_by_func
(combo_box,
G_CALLBACK (icon_captions_changed_callback),
builder);
}
static void
update_icon_captions_from_settings (GtkBuilder *builder)
{
char **captions;
int i, j;
captions = g_settings_get_strv (nemo_icon_view_preferences, NEMO_PREFERENCES_ICON_VIEW_CAPTIONS);
if (captions == NULL)
return;
for (i = 0, j = 0;
icon_captions_components[i] != NULL;
i++) {
char *data;
if (captions[j]) {
data = captions[j];
++j;
} else {
data = (char *)"none";
}
update_caption_combo_box (builder,
icon_captions_components[i],
data);
}
g_strfreev (captions);
}
static void
nemo_file_management_properties_dialog_setup_icon_caption_page (GtkBuilder *builder)
{
GList *columns;
int i;
gboolean writable;
writable = g_settings_is_writable (nemo_icon_view_preferences,
NEMO_PREFERENCES_ICON_VIEW_CAPTIONS);
columns = nemo_get_common_columns ();
for (i = 0; icon_captions_components[i] != NULL; i++) {
GtkWidget *combo_box;
combo_box = GTK_WIDGET (gtk_builder_get_object (builder,
icon_captions_components[i]));
create_icon_caption_combo_box_items (GTK_COMBO_BOX_TEXT (combo_box), columns);
gtk_widget_set_sensitive (combo_box, writable);
g_signal_connect (combo_box, "changed",
G_CALLBACK (icon_captions_changed_callback),
builder);
}
nemo_column_list_free (columns);
update_icon_captions_from_settings (builder);
}
static void
nemo_file_management_properties_dialog_setup_plugin_page (GtkBuilder *builder)
{
GtkWidget *box;
box = GTK_WIDGET (gtk_builder_get_object (builder, "plugin_box"));
gtk_box_pack_start (GTK_BOX (box),
GTK_WIDGET (nemo_plugin_manager_new ()),
TRUE, TRUE, 0);
}
static void
create_date_format_menu (GtkBuilder *builder)
{
GtkComboBoxText *combo_box;
gchar *date_string;
GDateTime *now;
combo_box = GTK_COMBO_BOX_TEXT
(gtk_builder_get_object (builder,
NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET));
now = g_date_time_new_now_local ();
date_string = g_date_time_format (now, "%c");
gtk_combo_box_text_append_text (combo_box, date_string);
g_free (date_string);
date_string = g_date_time_format (now, "%Y-%m-%d %H:%M:%S");
gtk_combo_box_text_append_text (combo_box, date_string);
g_free (date_string);
gtk_combo_box_text_append_text (combo_box, _("Yesterday"));
g_date_time_unref (now);
}
static void
set_columns_from_settings (NemoColumnChooser *chooser)
{
char **visible_columns;
char **column_order;
visible_columns = g_settings_get_strv (nemo_list_view_preferences,
NEMO_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
column_order = g_settings_get_strv (nemo_list_view_preferences,
NEMO_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
nemo_column_chooser_set_settings (NEMO_COLUMN_CHOOSER (chooser),
visible_columns,
column_order);
g_strfreev (visible_columns);
g_strfreev (column_order);
}
static void
use_default_callback (NemoColumnChooser *chooser,
gpointer user_data)
{
g_settings_reset (nemo_list_view_preferences,
NEMO_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
g_settings_reset (nemo_list_view_preferences,
NEMO_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
set_columns_from_settings (chooser);
}
static void
nemo_file_management_properties_dialog_setup_list_column_page (GtkBuilder *builder)
{
GtkWidget *chooser;
GtkWidget *box;
chooser = nemo_column_chooser_new (NULL);
set_columns_from_settings (NEMO_COLUMN_CHOOSER (chooser));
g_signal_connect (chooser, "changed",
G_CALLBACK (columns_changed_callback), chooser);
g_signal_connect (chooser, "use_default",
G_CALLBACK (use_default_callback), chooser);
gtk_widget_show (chooser);
box = GTK_WIDGET (gtk_builder_get_object (builder, "list_columns_vbox"));
gtk_box_pack_start (GTK_BOX (box), chooser, TRUE, TRUE, 0);
}
static void
bind_builder_bool (GtkBuilder *builder,
GSettings *settings,
const char *widget_name,
const char *prefs)
{
g_settings_bind (settings, prefs,
gtk_builder_get_object (builder, widget_name),
"active", G_SETTINGS_BIND_DEFAULT);
}
static void
bind_builder_bool_inverted (GtkBuilder *builder,
GSettings *settings,
const char *widget_name,
const char *prefs)
{
g_settings_bind (settings, prefs,
gtk_builder_get_object (builder, widget_name),
"active", G_SETTINGS_BIND_INVERT_BOOLEAN);
}
static void
bind_builder_string_entry (GtkBuilder *builder,
GSettings *settings,
const char *widget_name,
const char *prefs)
{
g_settings_bind (settings, prefs,
gtk_builder_get_object (builder, widget_name),
"text", G_SETTINGS_BIND_DEFAULT);
}
static gboolean
enum_get_mapping (GValue *value,
GVariant *variant,
gpointer user_data)
{
const char **enum_values = user_data;
const char *str;
int i;
str = g_variant_get_string (variant, NULL);
for (i = 0; enum_values[i] != NULL; i++) {
if (strcmp (enum_values[i], str) == 0) {
g_value_set_int (value, i);
return TRUE;
}
}
return FALSE;
}
static GVariant *
enum_set_mapping (const GValue *value,
const GVariantType *expected_type,
gpointer user_data)
{
const char **enum_values = user_data;
return g_variant_new_string (enum_values[g_value_get_int (value)]);
}
static void
bind_builder_enum (GtkBuilder *builder,
GSettings *settings,
const char *widget_name,
const char *prefs,
const char **enum_values)
{
g_settings_bind_with_mapping (settings, prefs,
gtk_builder_get_object (builder, widget_name),
"active", G_SETTINGS_BIND_DEFAULT,
enum_get_mapping,
enum_set_mapping,
enum_values, NULL);
}
typedef struct {
const guint64 *values;
int n_values;
} UIntEnumBinding;
static gboolean
uint_enum_get_mapping (GValue *value,
GVariant *variant,
gpointer user_data)
{
UIntEnumBinding *binding = user_data;
guint64 v;
int i;
v = g_variant_get_uint64 (variant);
for (i = 0; i < binding->n_values; i++) {
if (binding->values[i] >= v) {
g_value_set_int (value, i);
return TRUE;
}
}
return FALSE;
}
static GVariant *
uint_enum_set_mapping (const GValue *value,
const GVariantType *expected_type,
gpointer user_data)
{
UIntEnumBinding *binding = user_data;
return g_variant_new_uint64 (binding->values[g_value_get_int (value)]);
}
static void
bind_builder_uint_enum (GtkBuilder *builder,
GSettings *settings,
const char *widget_name,
const char *prefs,
const guint64 *values,
int n_values)
{
UIntEnumBinding *binding;
binding = g_new (UIntEnumBinding, 1);
binding->values = values;
binding->n_values = n_values;
g_settings_bind_with_mapping (settings, prefs,
gtk_builder_get_object (builder, widget_name),
"active", G_SETTINGS_BIND_DEFAULT,
uint_enum_get_mapping,
uint_enum_set_mapping,
binding, g_free);
}
static GVariant *
radio_mapping_set (const GValue *gvalue,
const GVariantType *expected_type,
gpointer user_data)
{
const gchar *widget_value = user_data;
GVariant *retval = NULL;
if (g_value_get_boolean (gvalue)) {
retval = g_variant_new_string (widget_value);
}
return retval;
}
static gboolean
radio_mapping_get (GValue *gvalue,
GVariant *variant,
gpointer user_data)
{
const gchar *widget_value = user_data;
const gchar *value;
value = g_variant_get_string (variant, NULL);
if (g_strcmp0 (value, widget_value) == 0) {
g_value_set_boolean (gvalue, TRUE);
} else {
g_value_set_boolean (gvalue, FALSE);
}
return TRUE;
}
static void
bind_builder_radio (GtkBuilder *builder,
GSettings *settings,
const char **widget_names,
const char *prefs,
const char **values)
{
GtkWidget *button;
int i;
for (i = 0; widget_names[i] != NULL; i++) {
button = GTK_WIDGET (gtk_builder_get_object (builder, widget_names[i]));
g_settings_bind_with_mapping (settings, prefs,
button, "active",
G_SETTINGS_BIND_DEFAULT,
radio_mapping_get, radio_mapping_set,
(gpointer) values[i], NULL);
}
}
static void
setup_configurable_menu_items (GtkBuilder *builder)
{
gint i;
for (i = 0; i < CONFIGURABLE_MENU_ITEM_COUNT; i++) {
if (CONFIGURABLE_MENU_ITEM_INFO[i].config_widget_name == NULL) {
continue;
}
bind_builder_bool (builder,
nemo_menu_config_preferences,
CONFIGURABLE_MENU_ITEM_INFO[i].config_widget_name,
CONFIGURABLE_MENU_ITEM_INFO[i].settings_key);
}
}
static void
setup_tooltip_items (GtkBuilder *builder)
{
gboolean enabled = FALSE;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_ICON_VIEW_WIDGET))) ||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_DESKTOP_WIDGET))) ||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_LIST_VIEW_WIDGET)));
gtk_widget_set_sensitive (GTK_WIDGET (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_FILE_TYPE_WIDGET)), enabled);
gtk_widget_set_sensitive (GTK_WIDGET (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_MOD_DATE_WIDGET)), enabled);
gtk_widget_set_sensitive (GTK_WIDGET (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_CREATED_DATE_WIDGET)), enabled);
gtk_widget_set_sensitive (GTK_WIDGET (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_ACCESS_DATE_WIDGET)), enabled);
gtk_widget_set_sensitive (GTK_WIDGET (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIP_FULL_PATH_WIDGET)), enabled);
}
static void
connect_tooltip_items (GtkBuilder *builder)
{
GtkToggleButton *w;
w = GTK_TOGGLE_BUTTON (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_ICON_VIEW_WIDGET));
g_signal_connect_swapped (w, "toggled", G_CALLBACK (setup_tooltip_items), builder);
w = GTK_TOGGLE_BUTTON (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_LIST_VIEW_WIDGET));
g_signal_connect_swapped (w, "toggled", G_CALLBACK (setup_tooltip_items), builder);
w = GTK_TOGGLE_BUTTON (W (NEMO_FILE_MANAGEMENT_PROPERTIES_TOOLTIPS_ON_DESKTOP_WIDGET));
g_signal_connect_swapped (w, "toggled", G_CALLBACK (setup_tooltip_items), builder);
}
/* When single click radio button is selected, checkbox for quick renames should get unselected and disable to avoid annoying features */
static void
setup_quick_renames (GtkBuilder *builder)
{
gboolean enabled = FALSE;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (W (click_behavior_components[1])));
if(enabled==FALSE){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(W (NEMO_FILE_MANAGEMENT_QUICK_RENAMES_WITH_PAUSE_IN_BETWEEN)), FALSE);
}
gtk_widget_set_sensitive (GTK_WIDGET (W (NEMO_FILE_MANAGEMENT_QUICK_RENAMES_WITH_PAUSE_IN_BETWEEN)), enabled);
}
static void
connect_quick_renames (GtkBuilder *builder)
{
GtkRadioButton *w;
w=GTK_RADIO_BUTTON(W(click_behavior_components[0]));
g_signal_connect_swapped (w, "toggled", G_CALLBACK (setup_quick_renames), builder);
w=GTK_RADIO_BUTTON(W(click_behavior_components[1]));
g_signal_connect_swapped (w, "toggled", G_CALLBACK (setup_quick_renames), builder);
}
static void
on_dialog_destroy (GtkWidget *widget,
gpointer user_data)
{
GtkBuilder *builder = GTK_BUILDER (user_data);
g_object_unref (builder);
}
static void
on_date_format_combo_changed (GtkComboBox *widget,
gpointer user_data)
{
GtkBuilder *builder = GTK_BUILDER (user_data);
gint active = gtk_combo_box_get_active (widget);
switch (active) {
case NEMO_DATE_FORMAT_LOCALE:
case NEMO_DATE_FORMAT_ISO:
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FONT_CHOICE_WIDGET)), TRUE);
break;
case NEMO_DATE_FORMAT_INFORMAL:
default:
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FONT_CHOICE_WIDGET)), FALSE);
break;
}
}
static void
set_gtk_filechooser_sort_first (GObject *object,
GParamSpec *pspec)
{
g_settings_set_boolean (gtk_filechooser_preferences,
NEMO_PREFERENCES_SORT_DIRECTORIES_FIRST,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object)));
}
static void
nemo_file_management_properties_dialog_setup (GtkBuilder *builder,
GtkWindow *window,
const gchar *initial_page)
{
GtkWidget *dialog;
/* setup UI */
nemo_file_management_properties_size_group_create (builder,
(char *)"views_label",
5);
nemo_file_management_properties_size_group_create (builder,
(char *)"captions_label",
3);
nemo_file_management_properties_size_group_create (builder,
(char *)"preview_label",
3);
create_date_format_menu (builder);
/* nemo patch */
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_PREVIOUS_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_PREVIOUS_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_NEXT_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_NEXT_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_UP_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_UP_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_RELOAD_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_RELOAD_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_EDIT_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_EDIT_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_HOME_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_HOME_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_COMPUTER_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_COMPUTER_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_SEARCH_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_SEARCH_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_NEW_FOLDER_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_NEW_FOLDER_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_OPEN_IN_TERMINAL_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_OPEN_IN_TERMINAL_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_ICON_VIEW_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_ICON_VIEW_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_LIST_VIEW_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_LIST_VIEW_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_COMPACT_VIEW_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_COMPACT_VIEW_ICON_TOOLBAR);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_SHOW_THUMBNAILS_ICON_TOOLBAR_WIDGET,
NEMO_PREFERENCES_SHOW_SHOW_THUMBNAILS_TOOLBAR);
/* setup preferences */
bind_builder_bool (builder, nemo_icon_view_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET,
NEMO_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS);
bind_builder_bool (builder, nemo_compact_view_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_ALL_COLUMNS_SAME_WIDTH,
NEMO_PREFERENCES_COMPACT_VIEW_ALL_COLUMNS_SAME_WIDTH);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET,
NEMO_PREFERENCES_SORT_DIRECTORIES_FIRST);
g_signal_connect (gtk_builder_get_object (builder, NEMO_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET),
"notify::active",
G_CALLBACK (set_gtk_filechooser_sort_first), NULL);
bind_builder_bool(builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_QUICK_RENAMES_WITH_PAUSE_IN_BETWEEN,
NEMO_PREFERENCES_CLICK_TO_RENAME);
bind_builder_bool_inverted (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET,
NEMO_PREFERENCES_ALWAYS_USE_BROWSER);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_MOVE_WIDGET,
NEMO_PREFERENCES_CONFIRM_MOVE_TO_TRASH);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET,
NEMO_PREFERENCES_CONFIRM_TRASH);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET,
NEMO_PREFERENCES_ENABLE_DELETE);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SWAP_TRASH_DELETE,
NEMO_PREFERENCES_SWAP_TRASH_DELETE);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_FULL_PATH_IN_TITLE_BARS_WIDGET,
NEMO_PREFERENCES_SHOW_FULL_PATH_TITLES);
bind_builder_bool (builder, nemo_tree_sidebar_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_TREE_VIEW_FOLDERS_WIDGET,
NEMO_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_INHERIT_VIEW_WIDGET,
NEMO_PREFERENCES_INHERIT_FOLDER_VIEWER);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_REVERSE_SORT_WIDGET,
NEMO_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_FAVORITES_FIRST_WIDGET,
NEMO_PREFERENCES_SORT_FAVORITES_FIRST);
bind_builder_enum (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET,
NEMO_PREFERENCES_DEFAULT_FOLDER_VIEWER,
(const char **) default_view_values);
bind_builder_enum (builder, nemo_icon_view_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET,
NEMO_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
(const char **) zoom_values);
bind_builder_enum (builder, nemo_compact_view_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_COMPACT_VIEW_ZOOM_WIDGET,
NEMO_PREFERENCES_COMPACT_VIEW_DEFAULT_ZOOM_LEVEL,
(const char **) zoom_values);
bind_builder_enum (builder, nemo_list_view_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET,
NEMO_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
(const char **) zoom_values);
bind_builder_enum (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET,
NEMO_PREFERENCES_DEFAULT_SORT_ORDER,
(const char **) sort_order_values);
bind_builder_enum (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET,
NEMO_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
(const char **) preview_image_values);
bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_INHERIT_SHOW_THUMBNAILS_WIDGET,
NEMO_PREFERENCES_INHERIT_SHOW_THUMBNAILS);
bind_builder_enum (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET,
NEMO_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
(const char **) preview_folder_values);
bind_builder_enum (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_SIZE_PREFIXES_WIDGET,
NEMO_PREFERENCES_SIZE_PREFIXES,
(const char **) size_prefixes_values);
bind_builder_enum (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET,
NEMO_PREFERENCES_DATE_FORMAT,
(const char **) date_format_values);