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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-prefs-dialog.c - Implementation for preferences dialog.
Copyright (C) 1999, 2000 Eazel, Inc.
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Authors: Ramiro Estrugo <ramiro@eazel.com>
*/
#include <config.h>
#include "nautilus-global-preferences.h"
#include "nautilus-file-utilities.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-gtk-extensions.h"
#include "nautilus-preferences-dialog.h"
#include "nautilus-preferences-group.h"
#include "nautilus-preferences-item.h"
#include "nautilus-string.h"
#include "nautilus-user-level-manager.h"
#include "nautilus-view-identifier.h"
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <gtk/gtkbox.h>
#include <libgnome/gnome-i18n.h>
#include <liboaf/liboaf.h>
/* Constants */
#define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences")
/* default web search uri */
#define DEFAULT_SEARCH_WEB_URI "http://www.eazel.com/websearch"
static const char PROXY_KEY[] = "/system/gnome-vfs/http-proxy";
static const char USE_PROXY_KEY[] = "/system/gnome-vfs/use-http-proxy";
/* Forward declarations */
static char * global_preferences_get_sidebar_panel_key (const char *panel_iid);
static gboolean global_preferences_is_sidebar_panel_enabled_cover (gpointer data,
gpointer callback_data);
static GList * global_preferences_get_sidebar_panel_view_identifiers (void);
static gboolean global_preferences_close_dialog_callback (GtkWidget *dialog,
gpointer user_data);
static void global_preferences_register_boolean_with_defaults (const char *name,
const char *description,
gboolean novice_default,
gboolean intermediate_default,
gboolean hacker_default);
static GtkWidget *global_prefs_dialog = NULL;
static int
compare_view_identifiers (gconstpointer a, gconstpointer b)
{
NautilusViewIdentifier *idenfifier_a;
NautilusViewIdentifier *idenfifier_b;
g_assert (a != NULL);
g_assert (b != NULL);
idenfifier_a = (NautilusViewIdentifier*) a;
idenfifier_b = (NautilusViewIdentifier*) b;
return nautilus_strcmp (idenfifier_a->name, idenfifier_b->name);
}
/*
* Private stuff
*/
static GtkWidget *
global_preferences_create_dialog (void)
{
GtkWidget *prefs_dialog;
NautilusPreferencesBox *preference_box;
GtkWidget *directory_views_pane;
GtkWidget *sidebar_panels_pane;
GtkWidget *appearance_pane;
GtkWidget *file_indexing_pane;
GtkWidget *tradeoffs_pane;
GtkWidget *navigation_pane;
/*
* In the soon to come star trek future, the following widgetry
* might be either fetched from a glade file or generated from
* an xml file.
*/
prefs_dialog = nautilus_preferences_dialog_new (GLOBAL_PREFERENCES_DIALOG_TITLE);
gtk_signal_connect (GTK_OBJECT (prefs_dialog),
"close",
GTK_SIGNAL_FUNC (global_preferences_close_dialog_callback),
NULL);
/* Create a preference box */
preference_box = NAUTILUS_PREFERENCES_BOX (nautilus_preferences_dialog_get_prefs_box
(NAUTILUS_PREFERENCES_DIALOG (prefs_dialog)));
/*
* Directory Views pane
*/
directory_views_pane = nautilus_preferences_box_add_pane (preference_box,
_("Folder Views"),
_("Folder Views Settings"));
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Window Behavior"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
0,
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Click Behavior"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
1,
NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_PREFERENCE_ITEM_ENUM);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Trash Behavior"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
2,
NAUTILUS_PREFERENCES_CONFIRM_TRASH,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Display"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
3,
NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
3,
NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
3,
NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
3,
NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
/*
* Sidebar panels pane
*/
sidebar_panels_pane = nautilus_preferences_box_add_pane (preference_box,
_("Sidebar Panels"),
_("Sidebar Panels Description"));
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (sidebar_panels_pane),
_("Choose which panels should appear in the sidebar"));
{
char *preference_key;
GList *view_identifiers;
GList *p;
NautilusViewIdentifier *identifier;
view_identifiers = global_preferences_get_sidebar_panel_view_identifiers ();
view_identifiers = g_list_sort (view_identifiers, compare_view_identifiers);
for (p = view_identifiers; p != NULL; p = p->next) {
identifier = (NautilusViewIdentifier *) (p->data);
preference_key = global_preferences_get_sidebar_panel_key (identifier->iid);
g_assert (preference_key != NULL);
nautilus_preferences_pane_add_item_to_nth_group
(NAUTILUS_PREFERENCES_PANE (sidebar_panels_pane),
0,
preference_key,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
g_free (preference_key);
}
nautilus_view_identifier_list_free (view_identifiers);
}
/*
* Appearance
*/
appearance_pane = nautilus_preferences_box_add_pane (preference_box,
_("Appearance"),
_("Appearance Settings"));
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Smoother Graphics"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
0,
NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Fonts"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
1,
NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Views"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
2,
NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
2,
NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
2,
NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
2,
NAUTILUS_PREFERENCES_START_WITH_SIDEBAR,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Desktop"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
3,
NAUTILUS_PREFERENCES_SHOW_DESKTOP,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
/*
* Tradeoffs
*/
tradeoffs_pane = nautilus_preferences_box_add_pane (preference_box,
_("Speed Tradeoffs"),
_("Speed Tradeoffs Settings"));
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Text in Icons"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
0,
NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Show Thumbnails for Image Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
1,
NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Previewing Sound Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
2,
NAUTILUS_PREFERENCES_PREVIEW_SOUND,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
/* FIXME bugzilla.eazel.com 2560: This title phrase needs improvement. */
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), _("Make Folder Appearance Details Public"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane),
3,
NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA,
NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM);
/*
* Search Settings
*/
file_indexing_pane = nautilus_preferences_box_add_pane (preference_box,
_("Search"),
_("Search Settings"));
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane),
_("Search Complexity Options"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane),
0,
NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
NAUTILUS_PREFERENCE_ITEM_ENUM);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane),
_("Search Tradeoffs"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane),
1,
NAUTILUS_PREFERENCES_SEARCH_METHOD,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane),
_("Search Locations"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (file_indexing_pane),
2,
NAUTILUS_PREFERENCES_SEARCH_WEB_URI,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
/*
* Navigation
*/
navigation_pane = nautilus_preferences_box_add_pane (preference_box,
_("Navigation"),
_("Navigation Settings"));
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), _("Home Location"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
0,
NAUTILUS_PREFERENCES_HOME_URI,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), _("Proxy Settings"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
1,
NAUTILUS_PREFERENCES_HTTP_USE_PROXY,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
1,
NAUTILUS_PREFERENCES_HTTP_PROXY,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
1,
NAUTILUS_PREFERENCES_HTTP_PROXY_PORT,
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING);
/* built-in bookmarks */
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
_("Built-in Bookmarks"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane),
2,
NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
/* all done */
return prefs_dialog;
}
/*
* Presummably, the following would be registered
* only if the component was present. Once we
* have smarter activation, that will be case.
*
* For now turn on all the ones we know about.
*/
static GList *
global_preferences_get_sidebar_panel_view_identifiers (void)
{
CORBA_Environment ev;
const char *query;
OAF_ServerInfoList *oaf_result;
guint i;
NautilusViewIdentifier *id;
GList *view_identifiers;
CORBA_exception_init (&ev);
query = "nautilus:sidebar_panel_name.defined() AND repo_ids.has ('IDL:Bonobo/Control:1.0')";
oaf_result = oaf_query (query, NULL, &ev);
view_identifiers = NULL;
if (ev._major == CORBA_NO_EXCEPTION && oaf_result != NULL) {
for (i = 0; i < oaf_result->_length; i++) {
id = nautilus_view_identifier_new_from_sidebar_panel
(&oaf_result->_buffer[i]);
view_identifiers = g_list_prepend (view_identifiers, id);
}
view_identifiers = g_list_reverse (view_identifiers);
}
if (oaf_result != NULL) {
CORBA_free (oaf_result);
}
CORBA_exception_free (&ev);
return view_identifiers;
}
GList *
nautilus_global_preferences_get_enabled_sidebar_panel_view_identifiers (void)
{
GList *enabled_view_identifiers;
GList *disabled_view_identifiers;
enabled_view_identifiers = global_preferences_get_sidebar_panel_view_identifiers ();
enabled_view_identifiers = nautilus_g_list_partition
(enabled_view_identifiers,
global_preferences_is_sidebar_panel_enabled_cover,
NULL,
&disabled_view_identifiers);
nautilus_view_identifier_list_free (disabled_view_identifiers);
return enabled_view_identifiers;
}
static void
destroy_global_prefs_dialog (void)
{
/* Free the dialog first, cause it has refs to preferences */
if (global_prefs_dialog != NULL) {
/* Since it's a top-level window, it's OK to destroy rather than unref'ing. */
gtk_widget_destroy (global_prefs_dialog);
}
}
static GtkWidget *
global_preferences_get_dialog (void)
{
static gboolean set_up_exit = FALSE;
nautilus_global_preferences_initialize ();
if (global_prefs_dialog == NULL) {
global_prefs_dialog = global_preferences_create_dialog ();
}
if (!set_up_exit) {
g_atexit (destroy_global_prefs_dialog);
set_up_exit = TRUE;
}
return global_prefs_dialog;
}
/* FIXME bugzilla.eazel.com 1275:
* The actual defaults need to be user level specific.
*/
static const char *novice_default_sidebar_panel_iids[] =
{
"OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185",
"OAFIID:hyperbola_navigation_tree:57542ce0-71ff-442d-a764-462c92514234",
"OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb",
NULL
};
static const char *intermediate_default_sidebar_panel_iids[] =
{
"OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb",
"OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185",
"OAFIID:nautilus_tree_view:2d826a6e-1669-4a45-94b8-23d65d22802d",
"OAFIID:hyperbola_navigation_tree:57542ce0-71ff-442d-a764-462c92514234",
NULL
};
static const char *hacker_default_sidebar_panel_iids[] =
{
"OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185",
"OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb",
"OAFIID:nautilus_tree_view:2d826a6e-1669-4a45-94b8-23d65d22802d",
"OAFIID:hyperbola_navigation_tree:57542ce0-71ff-442d-a764-462c92514234",
NULL
};
static const char **
get_default_sidebar_iids_for_user_level (guint user_level)
{
switch (user_level) {
case NAUTILUS_USER_LEVEL_NOVICE:
return novice_default_sidebar_panel_iids;
break;
case NAUTILUS_USER_LEVEL_INTERMEDIATE:
return intermediate_default_sidebar_panel_iids;
break;
case NAUTILUS_USER_LEVEL_HACKER:
return hacker_default_sidebar_panel_iids;
break;
default:
g_assert_not_reached ();
break;
}
g_assert_not_reached ();
return NULL;
}
static gboolean
sidebar_panel_iid_is_in_default_list (const char *iid,
guint user_level)
{
guint i;
const char **default_sidebar_panel_iids;
g_return_val_if_fail (iid != NULL, FALSE);
default_sidebar_panel_iids = get_default_sidebar_iids_for_user_level (user_level);
for (i = 0; default_sidebar_panel_iids[i] != NULL; i++) {
if (strcmp (iid, default_sidebar_panel_iids[i]) == 0) {
return TRUE;
}
}
return FALSE;
}
static void
global_preferences_register_sidebar_panels (void)
{
GList *view_identifiers;
GList *p;
view_identifiers = global_preferences_get_sidebar_panel_view_identifiers ();
for (p = view_identifiers; p != NULL; p = p->next) {
NautilusViewIdentifier *identifier;
char *preference_key;
gboolean novice_default_value;
gboolean intermediate_default_value;
gboolean hacker_default_value;
identifier = (NautilusViewIdentifier *) (p->data);
g_assert (identifier != NULL);
preference_key = global_preferences_get_sidebar_panel_key (identifier->iid);
g_assert (preference_key != NULL);
novice_default_value = sidebar_panel_iid_is_in_default_list (identifier->iid,
NAUTILUS_USER_LEVEL_NOVICE);
intermediate_default_value = sidebar_panel_iid_is_in_default_list (identifier->iid,
NAUTILUS_USER_LEVEL_INTERMEDIATE);
hacker_default_value = sidebar_panel_iid_is_in_default_list (identifier->iid,
NAUTILUS_USER_LEVEL_HACKER);
global_preferences_register_boolean_with_defaults (preference_key,
identifier->name,
novice_default_value,
intermediate_default_value,
hacker_default_value);
g_free (preference_key);
}
nautilus_view_identifier_list_free (view_identifiers);
}
static char *
global_preferences_get_sidebar_panel_key (const char *panel_iid)
{
g_return_val_if_fail (panel_iid != NULL, NULL);
return g_strdup_printf ("%s/%s", NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE, panel_iid);
}
static gboolean
global_preferences_is_sidebar_panel_enabled (NautilusViewIdentifier *panel_identifier)
{
gboolean enabled;
gchar *key;
g_return_val_if_fail (panel_identifier != NULL, FALSE);
g_return_val_if_fail (panel_identifier->iid != NULL, FALSE);
key = global_preferences_get_sidebar_panel_key (panel_identifier->iid);
g_assert (key != NULL);
enabled = nautilus_preferences_get_boolean (key, FALSE);
g_free (key);
return enabled;
}
static gboolean
global_preferences_is_sidebar_panel_enabled_cover (gpointer data, gpointer callback_data)
{
return global_preferences_is_sidebar_panel_enabled (data);
}
static void
global_preferences_register_with_defaults (const char *name,
const char *description,
NautilusPreferenceType type,
gconstpointer novice_default,
gconstpointer intermediate_default,
gconstpointer hacker_default)
{
gconstpointer defaults[3];
defaults[0] = novice_default;
defaults[1] = intermediate_default;
defaults[2] = hacker_default;
nautilus_preference_set_info_by_name (name,
description,
type,
defaults,
3);
}
static void
global_preferences_register_boolean_with_defaults (const char *name,
const char *description,
gboolean novice_default,
gboolean intermediate_default,
gboolean hacker_default)
{
global_preferences_register_with_defaults (name,
description,
NAUTILUS_PREFERENCE_BOOLEAN,
(gconstpointer) GINT_TO_POINTER (novice_default),
(gconstpointer) GINT_TO_POINTER (intermediate_default),
(gconstpointer) GINT_TO_POINTER (hacker_default));
}
static void
global_preferences_register_string_with_defaults (const char *name,
const char *description,
const char *novice_default,
const char *intermediate_default,
const char *hacker_default)
{
global_preferences_register_with_defaults (name,
description,
NAUTILUS_PREFERENCE_STRING,
(gconstpointer) novice_default,
(gconstpointer) intermediate_default,
(gconstpointer) hacker_default);
}
static void
global_preferences_register_enum_with_defaults (const char *name,
const char *description,
int novice_default,
int intermediate_default,
int hacker_default)
{
global_preferences_register_with_defaults (name,
description,
NAUTILUS_PREFERENCE_ENUM,
(gconstpointer) GINT_TO_POINTER (novice_default),
(gconstpointer) GINT_TO_POINTER (intermediate_default),
(gconstpointer) GINT_TO_POINTER (hacker_default));
}
static void
global_preferences_register_speed_tradeoff_with_defaults (const char *name,
const char *description,
NautilusSpeedTradeoffValue novice_default,
NautilusSpeedTradeoffValue intermediate_default,
NautilusSpeedTradeoffValue hacker_default)
{
global_preferences_register_with_defaults (name,
description,
NAUTILUS_PREFERENCE_ENUM,
(gconstpointer) GINT_TO_POINTER (novice_default),
(gconstpointer) GINT_TO_POINTER (intermediate_default),
(gconstpointer) GINT_TO_POINTER (hacker_default));
nautilus_preference_enum_add_entry_by_name (name,
_("always"),
_("Always"),
NAUTILUS_SPEED_TRADEOFF_ALWAYS);
nautilus_preference_enum_add_entry_by_name (name,
_("local only"),
_("Local Files Only"),
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
nautilus_preference_enum_add_entry_by_name (name,
_("never"),
_("Never"),
NAUTILUS_SPEED_TRADEOFF_NEVER);
}
/* These three callbacks should go away in the future when we can handle system wide prefs */
static void
proxy_changed (gpointer user_data)
{
char *proxy, *port, *new_proxy;
gboolean use_proxy;
/* Don't write to the system preference if use_proxy is FALSE */
use_proxy = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, FALSE);
if (!use_proxy) {
return;
}
proxy = nautilus_preferences_get (NAUTILUS_PREFERENCES_HTTP_PROXY, "");
port = nautilus_preferences_get (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, "");
new_proxy = g_strdup_printf ("%s:%s", proxy, port);
nautilus_preferences_set (PROXY_KEY, new_proxy);
g_free (proxy);
g_free (port);
g_free (new_proxy);
}
static void
use_proxy_changed (gpointer user_data)
{
gboolean use_proxy;
GConfClient *gconf_client;
use_proxy = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, FALSE);
gconf_client = gconf_client_get_default ();
if (gconf_client != NULL) {
gconf_client_set_bool (gconf_client, USE_PROXY_KEY, use_proxy, NULL);
}
if (use_proxy) {
proxy_changed (NULL);
} else {
/* Unset the system key */
if (gconf_client != NULL) {
gconf_client_unset (gconf_client, PROXY_KEY, NULL);
}
}
}
static void
register_proxy_preferences (void)
{
gboolean use_proxy;
char *proxy_string, *port, *proxy;
GConfClient *gconf_client;
use_proxy = FALSE;
proxy = NULL;
port = NULL;
proxy_string = NULL;
gconf_client = gconf_client_get_default ();
if (gconf_client != NULL) {
/* Get system level proxy values from gconf */
use_proxy = gconf_client_get_bool (gconf_client, USE_PROXY_KEY, NULL);
proxy_string = gconf_client_get_string (gconf_client, PROXY_KEY, NULL);
if (proxy_string != NULL) {
port = strchr (proxy_string, ':');
if (port != NULL) {
proxy = g_strdup (proxy_string);
proxy [port - proxy_string] = '\0';
port++;
}
}
gtk_object_unref (GTK_OBJECT (gconf_client));
}
if (proxy == NULL) {
proxy = g_strdup ("");
}
if (port == NULL) {
port = "8080";
}
nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, use_proxy);
nautilus_preferences_set (NAUTILUS_PREFERENCES_HTTP_PROXY, proxy);
nautilus_preferences_set (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, port);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_HTTP_USE_PROXY,
_("Use HTTP Proxy"),
use_proxy,
use_proxy,
use_proxy);
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_HTTP_PROXY,
_("HTTP Proxy"),
proxy,
proxy,
proxy);
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT,
_("HTTP Proxy Port"),
port,
port,
port);
g_free (proxy);
g_free (proxy_string);
/* Add a callbacks to update the system setting with the new local setting. This should go away when the
* prefs mechanism can handle system wide prefs.
*/
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, use_proxy_changed, NULL);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_PROXY, proxy_changed, NULL);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, proxy_changed, NULL);
}
/**
* global_preferences_register
*
* Register preferences that meet one of the following criteria:
*
* 1) Need a 'nice' default
* 2) Need a description (because the appear in the preferences dialog)
*/
static void
global_preferences_register (void)
{
static gboolean preferences_registered = FALSE;
if (preferences_registered) {
return;
}
preferences_registered = TRUE;
/*
* In the soon to come star trek future, the following information
* will be fetched using the latest xml techniques.
*/
/*
* Non user level specific preferences:
*/
/* FIXME bugzilla.eazel.com 2654:
* Cannot set default values for non user level preferecens. Yes, this
* is bad. The right way to fix this problem (and many other default
* value problems) is to use gconf schemas. See the bug for info.
*/
#if 0
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_THEME,
_("current theme"),
"default",
"default",
"default");
#endif
/*
* User user level specific preferences:
*/
/* Window create new */
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
_("Open each item in a new window"),
FALSE,
FALSE,
FALSE);
/* Trash confirm */
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
_("Ask before deleting items from the trash"),
TRUE,
TRUE,
TRUE);
/* Click activation type */
global_preferences_register_enum_with_defaults (NAUTILUS_PREFERENCES_CLICK_POLICY,
_("Click policy"),
NAUTILUS_CLICK_POLICY_DOUBLE,
NAUTILUS_CLICK_POLICY_DOUBLE,
NAUTILUS_CLICK_POLICY_DOUBLE);
nautilus_preference_enum_add_entry_by_name (NAUTILUS_PREFERENCES_CLICK_POLICY,
_("single"),
_("Activate items with a single click"),
NAUTILUS_CLICK_POLICY_SINGLE);
nautilus_preference_enum_add_entry_by_name (NAUTILUS_PREFERENCES_CLICK_POLICY,
_("double"),
_("Activate items with a double click"),
NAUTILUS_CLICK_POLICY_DOUBLE);
/* Speed tradeoffs */
global_preferences_register_speed_tradeoff_with_defaults (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
_("Display text in icons"),
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY,
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY,
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
global_preferences_register_speed_tradeoff_with_defaults (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
_("Show thumbnails for image files"),
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
NAUTILUS_SPEED_TRADEOFF_ALWAYS);
global_preferences_register_speed_tradeoff_with_defaults (NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA,
_("Read and write metadata in each folder"),
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
NAUTILUS_SPEED_TRADEOFF_ALWAYS);
global_preferences_register_speed_tradeoff_with_defaults (NAUTILUS_PREFERENCES_PREVIEW_SOUND,
_("Play a sound file when the mouse is over it"),
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
NAUTILUS_SPEED_TRADEOFF_ALWAYS);
/* Sidebar panels */
global_preferences_register_sidebar_panels ();
/* Appearance options */
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
_("Use smoother (but slower) graphics"),
FALSE,
FALSE,
FALSE);
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY,
_("Font family used to display file names"),
"helvetica",
"helvetica",
"helvetica");
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR,
_("Display tool bar in new windows"),
TRUE,
TRUE,
TRUE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR,
_("Display location bar in new windows"),
TRUE,
TRUE,
TRUE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR,
_("Display status bar in new windows"),
TRUE,
TRUE,
TRUE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR,
_("Display sidebar in new windows"),
TRUE,
TRUE,
TRUE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_SHOW_DESKTOP,
_("Use Nautilus to draw the desktop"),
FALSE,
FALSE,
FALSE);
/* search tradeoffs */
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_SEARCH_METHOD,
_("Always do slow, complete search"),
FALSE,
FALSE,
FALSE);
/* search bar type */
global_preferences_register_enum_with_defaults (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
_("search type to do by default"),
NAUTILUS_SIMPLE_SEARCH_BAR,
NAUTILUS_COMPLEX_SEARCH_BAR,
NAUTILUS_COMPLEX_SEARCH_BAR);
nautilus_preference_enum_add_entry_by_name (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
_("search by text"),
_("Search for files by text only"),
NAUTILUS_SIMPLE_SEARCH_BAR);
nautilus_preference_enum_add_entry_by_name (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
_("search by text and properties"),
_("Search for files by text and by their properties"),
NAUTILUS_COMPLEX_SEARCH_BAR);
/* web search uri */
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_SEARCH_WEB_URI,
_("Search Web Location"),
DEFAULT_SEARCH_WEB_URI,
DEFAULT_SEARCH_WEB_URI,
DEFAULT_SEARCH_WEB_URI);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
_("Show hidden files (starting with \".\")"),
FALSE,
FALSE,
TRUE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES,
_("Show backup files (ending with \"~\")"),
FALSE,
FALSE,
TRUE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS,
_("Show special flags in Properties window"),
FALSE,
FALSE,
TRUE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
_("Show only folders in tree sidebar panel"),
FALSE,
FALSE,
FALSE);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_CAN_ADD_CONTENT,
_("Can add Content"),
FALSE,
TRUE,
TRUE);
/* built-in bookmarks */
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
_("Don't include the built-in bookmarks"),
FALSE,
FALSE,
FALSE);
{
char *user_main_directory;
char *novice_home_location;
char *intermediate_home_location;
char *hacker_home_location;
user_main_directory = nautilus_get_user_main_directory ();
novice_home_location = g_strdup_printf ("file://%s", user_main_directory);
intermediate_home_location = g_strdup_printf ("file://%s", g_get_home_dir());
hacker_home_location = g_strdup_printf ("file://%s", g_get_home_dir());
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_HOME_URI,
"Home Location",
novice_home_location,
intermediate_home_location,
hacker_home_location);
g_free (user_main_directory);
g_free (novice_home_location);
g_free (intermediate_home_location);
g_free (hacker_home_location);
}
register_proxy_preferences ();
}
static gboolean
global_preferences_close_dialog_callback (GtkWidget *dialog,
gpointer user_data)
{
nautilus_global_preferences_hide_dialog ();
return TRUE;
}
/*
* Public functions
*/
void
nautilus_global_preferences_show_dialog (void)
{
GtkWidget *dialog = global_preferences_get_dialog ();
nautilus_gtk_window_present (GTK_WINDOW (dialog));
}
void
nautilus_global_preferences_hide_dialog (void)
{
GtkWidget *dialog = global_preferences_get_dialog ();
gtk_widget_hide (dialog);
}
void
nautilus_global_preferences_set_dialog_title (const char *title)
{
GtkWidget *dialog;
g_return_if_fail (title != NULL);
dialog = global_preferences_get_dialog ();
gtk_window_set_title (GTK_WINDOW (dialog), title);
}
void
nautilus_global_preferences_dialog_update (void)
{
gboolean was_showing = FALSE;
/* Free the dialog first, cause it has refs to preferences */
if (global_prefs_dialog != NULL) {
was_showing = GTK_WIDGET_VISIBLE (global_prefs_dialog);
gtk_widget_destroy (global_prefs_dialog);
global_prefs_dialog = NULL;
}
global_preferences_get_dialog ();
if (was_showing) {
nautilus_global_preferences_show_dialog ();
}
}
void
nautilus_global_preferences_initialize (void)
{
static gboolean initialized = FALSE;
if (initialized) {
return;
}
global_preferences_register ();
initialized = TRUE;
}
|