-
Notifications
You must be signed in to change notification settings - Fork 366
/
gtksettings.c
2048 lines (1754 loc) · 78 KB
/
gtksettings.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
/* GTK - The GIMP Toolkit
* Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
*/
#include "config.h"
#include "gtksettingsprivate.h"
#include "gtkcssproviderprivate.h"
#include "gtkhslaprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkscrolledwindow.h"
#include "gtkstylecontextprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtktypebuiltins.h"
#include "gtkversion.h"
#include "gtkwidgetprivate.h"
#include "gdk/gdk-private.h"
#include <string.h>
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
#include <pango/pangofc-fontmap.h>
#endif
#ifdef GDK_WINDOWING_WAYLAND
#include "wayland/gdkwayland.h"
#include <pango/pangofc-fontmap.h>
#endif
#ifdef GDK_WINDOWING_BROADWAY
#include "broadway/gdkbroadway.h"
#endif
#ifdef GDK_WINDOWING_QUARTZ
#include "quartz/gdkquartz.h"
#endif
#ifdef GDK_WINDOWING_WIN32
#include "win32/gdkwin32.h"
#endif
#ifdef GDK_WINDOWING_QUARTZ
#define PRINT_PREVIEW_COMMAND "open -b com.apple.Preview %f"
#else
#define PRINT_PREVIEW_COMMAND "evince --unlink-tempfile --preview --print-settings %s %f"
#endif
/**
* SECTION:gtksettings
* @Short_description: Sharing settings between applications
* @Title: Settings
*
* GtkSettings provide a mechanism to share global settings between
* applications.
*
* On the X window system, this sharing is realized by an
* [XSettings](http://www.freedesktop.org/wiki/Specifications/xsettings-spec)
* manager that is usually part of the desktop environment, along with
* utilities that let the user change these settings.
*
* On Wayland, the settings are obtained either via a settings portal,
* or by reading desktop settings from DConf.
*
* In the absence of these sharing mechanisms, GTK reads default values for
* settings from `settings.ini` files in `/etc/gtk-4.0`, `$XDG_CONFIG_DIRS/gtk-4.0`
* and `$XDG_CONFIG_HOME/gtk-4.0`. These files must be valid key files (see
* #GKeyFile), and have a section called Settings. Themes can also provide
* default values for settings by installing a `settings.ini` file
* next to their `gtk.css` file.
*
* Applications can override system-wide settings by setting the property
* of the GtkSettings object with g_object_set(). This should be restricted
* to special cases though; GtkSettings are not meant as an application
* configuration facility.
*
* There is one GtkSettings instance per display. It can be obtained with
* gtk_settings_get_for_display(), but in many cases, it is more convenient
* to use gtk_widget_get_settings().
*/
#define DEFAULT_TIMEOUT_INITIAL 500
#define DEFAULT_TIMEOUT_REPEAT 50
#define DEFAULT_TIMEOUT_EXPAND 500
typedef struct _GtkSettingsClass GtkSettingsClass;
typedef struct _GtkSettingsPropertyValue GtkSettingsPropertyValue;
typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
struct _GtkSettings
{
GObject parent_instance;
GData *queued_settings; /* of type GtkSettingsValue* */
GtkSettingsPropertyValue *property_values;
GdkDisplay *display;
GSList *style_cascades;
GtkCssProvider *theme_provider;
gint font_size;
gboolean font_size_absolute;
gchar *font_family;
cairo_font_options_t *font_options;
};
struct _GtkSettingsClass
{
GObjectClass parent_class;
};
struct _GtkSettingsValuePrivate
{
GtkSettingsValue public;
GtkSettingsSource source;
};
struct _GtkSettingsPropertyValue
{
GValue value;
GtkSettingsSource source;
};
enum {
PROP_0,
PROP_DOUBLE_CLICK_TIME,
PROP_DOUBLE_CLICK_DISTANCE,
PROP_CURSOR_BLINK,
PROP_CURSOR_BLINK_TIME,
PROP_CURSOR_BLINK_TIMEOUT,
PROP_SPLIT_CURSOR,
PROP_CURSOR_ASPECT_RATIO,
PROP_THEME_NAME,
PROP_ICON_THEME_NAME,
PROP_DND_DRAG_THRESHOLD,
PROP_FONT_NAME,
PROP_XFT_ANTIALIAS,
PROP_XFT_HINTING,
PROP_XFT_HINTSTYLE,
PROP_XFT_RGBA,
PROP_XFT_DPI,
PROP_CURSOR_THEME_NAME,
PROP_CURSOR_THEME_SIZE,
PROP_ALTERNATIVE_BUTTON_ORDER,
PROP_ALTERNATIVE_SORT_ARROWS,
PROP_ENABLE_ANIMATIONS,
PROP_ERROR_BELL,
PROP_PRINT_BACKENDS,
PROP_PRINT_PREVIEW_COMMAND,
PROP_ENABLE_ACCELS,
PROP_IM_MODULE,
PROP_RECENT_FILES_MAX_AGE,
PROP_FONTCONFIG_TIMESTAMP,
PROP_SOUND_THEME_NAME,
PROP_ENABLE_INPUT_FEEDBACK_SOUNDS,
PROP_ENABLE_EVENT_SOUNDS,
PROP_PRIMARY_BUTTON_WARPS_SLIDER,
PROP_APPLICATION_PREFER_DARK_THEME,
PROP_ENTRY_SELECT_ON_FOCUS,
PROP_ENTRY_PASSWORD_HINT_TIMEOUT,
PROP_LABEL_SELECT_ON_FOCUS,
PROP_SHELL_SHOWS_APP_MENU,
PROP_SHELL_SHOWS_MENUBAR,
PROP_SHELL_SHOWS_DESKTOP,
PROP_DECORATION_LAYOUT,
PROP_TITLEBAR_DOUBLE_CLICK,
PROP_TITLEBAR_MIDDLE_CLICK,
PROP_TITLEBAR_RIGHT_CLICK,
PROP_DIALOGS_USE_HEADER,
PROP_ENABLE_PRIMARY_PASTE,
PROP_RECENT_FILES_ENABLED,
PROP_LONG_PRESS_TIME,
PROP_KEYNAV_USE_CARET,
PROP_OVERLAY_SCROLLING
};
/* --- prototypes --- */
static void gtk_settings_provider_iface_init (GtkStyleProviderInterface *iface);
static void gtk_settings_finalize (GObject *object);
static void gtk_settings_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gtk_settings_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_settings_notify (GObject *object,
GParamSpec *pspec);
static guint settings_install_property_parser (GtkSettingsClass *class,
GParamSpec *pspec);
static void settings_update_double_click (GtkSettings *settings);
static void settings_update_cursor_theme (GtkSettings *settings);
static void settings_update_font_options (GtkSettings *settings);
static void settings_update_font_values (GtkSettings *settings);
static gboolean settings_update_fontconfig (GtkSettings *settings);
static void settings_update_theme (GtkSettings *settings);
static gboolean settings_update_xsetting (GtkSettings *settings,
GParamSpec *pspec,
gboolean force);
static void settings_update_xsettings (GtkSettings *settings);
static void gtk_settings_load_from_key_file (GtkSettings *settings,
const gchar *path,
GtkSettingsSource source);
static void settings_update_provider (GdkDisplay *display,
GtkCssProvider **old,
GtkCssProvider *new);
/* --- variables --- */
static GQuark quark_gtk_settings = 0;
static GSList *object_list = NULL;
static guint class_n_properties = 0;
static GPtrArray *display_settings;
G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
gtk_settings_provider_iface_init));
/* --- functions --- */
static void
gtk_settings_init (GtkSettings *settings)
{
GParamSpec **pspecs, **p;
guint i = 0;
gchar *path;
const gchar * const *config_dirs;
g_datalist_init (&settings->queued_settings);
object_list = g_slist_prepend (object_list, settings);
settings->style_cascades = g_slist_prepend (NULL, _gtk_style_cascade_new ());
settings->theme_provider = gtk_css_provider_new ();
/* build up property array for all yet existing properties and queue
* notification for them (at least notification for internal properties
* will instantly be caught)
*/
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), NULL);
for (p = pspecs; *p; p++)
if ((*p)->owner_type == G_OBJECT_TYPE (settings))
i++;
settings->property_values = g_new0 (GtkSettingsPropertyValue, i);
i = 0;
g_object_freeze_notify (G_OBJECT (settings));
for (p = pspecs; *p; p++)
{
GParamSpec *pspec = *p;
GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
if (pspec->owner_type != G_OBJECT_TYPE (settings))
continue;
g_value_init (&settings->property_values[i].value, value_type);
g_param_value_set_default (pspec, &settings->property_values[i].value);
g_object_notify_by_pspec (G_OBJECT (settings), pspec);
settings->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT;
i++;
}
g_free (pspecs);
path = g_build_filename (_gtk_get_data_prefix (), "share", "gtk-4.0", "settings.ini", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
g_free (path);
path = g_build_filename (_gtk_get_sysconfdir (), "gtk-4.0", "settings.ini", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
g_free (path);
config_dirs = g_get_system_config_dirs ();
for (i = 0; config_dirs[i] != NULL; i++)
{
path = g_build_filename (config_dirs[i], "gtk-4.0", "settings.ini", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
g_free (path);
}
path = g_build_filename (g_get_user_config_dir (), "gtk-4.0", "settings.ini", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
g_free (path);
g_object_thaw_notify (G_OBJECT (settings));
/* ensure that derived fields are initialized */
if (settings->font_size == 0)
settings_update_font_values (settings);
}
static void
gtk_settings_class_init (GtkSettingsClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
guint result;
gobject_class->finalize = gtk_settings_finalize;
gobject_class->get_property = gtk_settings_get_property;
gobject_class->set_property = gtk_settings_set_property;
gobject_class->notify = gtk_settings_notify;
quark_gtk_settings = g_quark_from_static_string ("gtk-settings");
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-double-click-time",
P_("Double Click Time"),
P_("Maximum time allowed between two clicks for them to be considered a double click (in milliseconds)"),
0, G_MAXINT, 400,
GTK_PARAM_READWRITE));
g_assert (result == PROP_DOUBLE_CLICK_TIME);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-double-click-distance",
P_("Double Click Distance"),
P_("Maximum distance allowed between two clicks for them to be considered a double click (in pixels)"),
0, G_MAXINT, 5,
GTK_PARAM_READWRITE));
g_assert (result == PROP_DOUBLE_CLICK_DISTANCE);
/**
* GtkSettings:gtk-cursor-blink:
*
* Whether the cursor should blink.
*
* Also see the #GtkSettings:gtk-cursor-blink-timeout setting,
* which allows more flexible control over cursor blinking.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-cursor-blink",
P_("Cursor Blink"),
P_("Whether the cursor should blink"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_CURSOR_BLINK);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-cursor-blink-time",
P_("Cursor Blink Time"),
P_("Length of the cursor blink cycle, in milliseconds"),
100, G_MAXINT, 1200,
GTK_PARAM_READWRITE));
g_assert (result == PROP_CURSOR_BLINK_TIME);
/**
* GtkSettings:gtk-cursor-blink-timeout:
*
* Time after which the cursor stops blinking, in seconds.
* The timer is reset after each user interaction.
*
* Setting this to zero has the same effect as setting
* #GtkSettings:gtk-cursor-blink to %FALSE.
*/
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-cursor-blink-timeout",
P_("Cursor Blink Timeout"),
P_("Time after which the cursor stops blinking, in seconds"),
1, G_MAXINT, 10,
GTK_PARAM_READWRITE));
g_assert (result == PROP_CURSOR_BLINK_TIMEOUT);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-split-cursor",
P_("Split Cursor"),
P_("Whether two cursors should be displayed for mixed left-to-right and right-to-left text"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_SPLIT_CURSOR);
result = settings_install_property_parser (class,
g_param_spec_float ("gtk-cursor-aspect-ratio",
P_("Cursor Aspect Ratio"),
P_("The aspect ratio of the text caret"),
0.0, 1.0, 0.04,
GTK_PARAM_READWRITE));
g_assert (result == PROP_CURSOR_ASPECT_RATIO);
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-theme-name",
P_("Theme Name"),
P_("Name of theme to load"),
DEFAULT_THEME_NAME,
GTK_PARAM_READWRITE));
g_assert (result == PROP_THEME_NAME);
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-icon-theme-name",
P_("Icon Theme Name"),
P_("Name of icon theme to use"),
DEFAULT_ICON_THEME,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ICON_THEME_NAME);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-dnd-drag-threshold",
P_("Drag threshold"),
P_("Number of pixels the cursor can move before dragging"),
1, G_MAXINT, 8,
GTK_PARAM_READWRITE));
g_assert (result == PROP_DND_DRAG_THRESHOLD);
/**
* GtkSettings:gtk-font-name:
*
* The default font to use. GTK uses the family name and size from this string.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-font-name",
P_("Font Name"),
P_("The default font family and size to use"),
"Sans 10",
GTK_PARAM_READWRITE));
g_assert (result == PROP_FONT_NAME);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-xft-antialias",
P_("Xft Antialias"),
P_("Whether to antialias Xft fonts; 0=no, 1=yes, -1=default"),
-1, 1, -1,
GTK_PARAM_READWRITE));
g_assert (result == PROP_XFT_ANTIALIAS);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-xft-hinting",
P_("Xft Hinting"),
P_("Whether to hint Xft fonts; 0=no, 1=yes, -1=default"),
-1, 1, -1,
GTK_PARAM_READWRITE));
g_assert (result == PROP_XFT_HINTING);
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-xft-hintstyle",
P_("Xft Hint Style"),
P_("What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull"),
NULL,
GTK_PARAM_READWRITE));
g_assert (result == PROP_XFT_HINTSTYLE);
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-xft-rgba",
P_("Xft RGBA"),
P_("Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr"),
NULL,
GTK_PARAM_READWRITE));
g_assert (result == PROP_XFT_RGBA);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-xft-dpi",
P_("Xft DPI"),
P_("Resolution for Xft, in 1024 * dots/inch. -1 to use default value"),
-1, 1024*1024, -1,
GTK_PARAM_READWRITE));
g_assert (result == PROP_XFT_DPI);
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-cursor-theme-name",
P_("Cursor theme name"),
P_("Name of the cursor theme to use, or NULL to use the default theme"),
NULL,
GTK_PARAM_READWRITE));
g_assert (result == PROP_CURSOR_THEME_NAME);
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-cursor-theme-size",
P_("Cursor theme size"),
P_("Size to use for cursors, or 0 to use the default size"),
0, 128, 0,
GTK_PARAM_READWRITE));
g_assert (result == PROP_CURSOR_THEME_SIZE);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-alternative-button-order",
P_("Alternative button order"),
P_("Whether buttons in dialogs should use the alternative button order"),
FALSE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ALTERNATIVE_BUTTON_ORDER);
/**
* GtkSettings:gtk-alternative-sort-arrows:
*
* Controls the direction of the sort indicators in sorted list and tree
* views. By default an arrow pointing down means the column is sorted
* in ascending order. When set to %TRUE, this order will be inverted.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-alternative-sort-arrows",
P_("Alternative sort indicator direction"),
P_("Whether the direction of the sort indicators in list and tree views is inverted compared to the default (where down means ascending)"),
FALSE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ALTERNATIVE_SORT_ARROWS);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-enable-animations",
P_("Enable Animations"),
P_("Whether to enable toolkit-wide animations."),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ENABLE_ANIMATIONS);
/**
* GtkSettings:gtk-error-bell:
*
* When %TRUE, keyboard navigation and other input-related errors
* will cause a beep. Since the error bell is implemented using
* gdk_surface_beep(), the windowing system may offer ways to
* configure the error bell in many ways, such as flashing the
* window or similar visual effects.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-error-bell",
P_("Error Bell"),
P_("When TRUE, keyboard navigation and other errors will cause a beep"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ERROR_BELL);
/**
* GtkSettings:gtk-print-backends:
*
* A comma-separated list of print backends to use in the print
* dialog. Available print backends depend on the GTK installation,
* and may include "file", "cups", "lpr" or "papi".
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-print-backends",
P_("Default print backend"),
P_("List of the GtkPrintBackend backends to use by default"),
GTK_PRINT_BACKENDS,
GTK_PARAM_READWRITE));
g_assert (result == PROP_PRINT_BACKENDS);
/**
* GtkSettings:gtk-print-preview-command:
*
* A command to run for displaying the print preview. The command
* should contain a `%f` placeholder, which will get replaced by
* the path to the pdf file. The command may also contain a `%s`
* placeholder, which will get replaced by the path to a file
* containing the print settings in the format produced by
* gtk_print_settings_to_file().
*
* The preview application is responsible for removing the pdf file
* and the print settings file when it is done.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-print-preview-command",
P_("Default command to run when displaying a print preview"),
P_("Command to run when displaying a print preview"),
PRINT_PREVIEW_COMMAND,
GTK_PARAM_READWRITE));
g_assert (result == PROP_PRINT_PREVIEW_COMMAND);
/**
* GtkSettings:gtk-enable-accels:
*
* Whether menu items should have visible accelerators which can be
* activated.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-enable-accels",
P_("Enable Accelerators"),
P_("Whether menu items should have accelerators"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ENABLE_ACCELS);
/**
* GtkSettings:gtk-im-module:
*
* Which IM (input method) module should be used by default. This is the
* input method that will be used if the user has not explicitly chosen
* another input method from the IM context menu.
* This also can be a colon-separated list of input methods, which GTK
* will try in turn until it finds one available on the system.
*
* See #GtkIMContext.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-im-module",
P_("Default IM module"),
P_("Which IM module should be used by default"),
NULL,
GTK_PARAM_READWRITE));
g_assert (result == PROP_IM_MODULE);
/**
* GtkSettings:gtk-recent-files-max-age:
*
* The maximum age, in days, of the items inside the recently used
* resources list. Items older than this setting will be excised
* from the list. If set to 0, the list will always be empty; if
* set to -1, no item will be removed.
*/
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-recent-files-max-age",
P_("Recent Files Max Age"),
P_("Maximum age of recently used files, in days"),
-1, G_MAXINT,
30,
GTK_PARAM_READWRITE));
g_assert (result == PROP_RECENT_FILES_MAX_AGE);
result = settings_install_property_parser (class,
g_param_spec_uint ("gtk-fontconfig-timestamp",
P_("Fontconfig configuration timestamp"),
P_("Timestamp of current fontconfig configuration"),
0, G_MAXUINT, 0,
GTK_PARAM_READWRITE));
g_assert (result == PROP_FONTCONFIG_TIMESTAMP);
/**
* GtkSettings:gtk-sound-theme-name:
*
* The XDG sound theme to use for event sounds.
*
* See the [Sound Theme Specifications](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec)
* for more information on event sounds and sound themes.
*
* GTK itself does not support event sounds, you have to use a loadable
* module like the one that comes with libcanberra.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-sound-theme-name",
P_("Sound Theme Name"),
P_("XDG sound theme name"),
"freedesktop",
GTK_PARAM_READWRITE));
g_assert (result == PROP_SOUND_THEME_NAME);
/**
* GtkSettings:gtk-enable-input-feedback-sounds:
*
* Whether to play event sounds as feedback to user input.
*
* See the [Sound Theme Specifications](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec)
* for more information on event sounds and sound themes.
*
* GTK itself does not support event sounds, you have to use a loadable
* module like the one that comes with libcanberra.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-enable-input-feedback-sounds",
/* Translators: this means sounds that are played as feedback to user input */
P_("Audible Input Feedback"),
P_("Whether to play event sounds as feedback to user input"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ENABLE_INPUT_FEEDBACK_SOUNDS);
/**
* GtkSettings:gtk-enable-event-sounds:
*
* Whether to play any event sounds at all.
*
* See the [Sound Theme Specifications](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec)
* for more information on event sounds and sound themes.
*
* GTK itself does not support event sounds, you have to use a loadable
* module like the one that comes with libcanberra.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-enable-event-sounds",
P_("Enable Event Sounds"),
P_("Whether to play any event sounds at all"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ENABLE_EVENT_SOUNDS);
/**
* GtkSettings:gtk-primary-button-warps-slider:
*
* If the value of this setting is %TRUE, clicking the primary button in a
* #GtkRange trough will move the slider, and hence set the range’s value, to
* the point that you clicked. If it is %FALSE, a primary click will cause the
* slider/value to move by the range’s page-size towards the point clicked.
*
* Whichever action you choose for the primary button, the other action will
* be available by holding Shift and primary-clicking, or (since GTK 3.22.25)
* clicking the middle mouse button.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-primary-button-warps-slider",
P_("Primary button warps slider"),
P_("Whether a primary click on the trough should warp the slider into position"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_PRIMARY_BUTTON_WARPS_SLIDER);
/**
* GtkSettings:gtk-application-prefer-dark-theme:
*
* Whether the application prefers to use a dark theme. If a GTK theme
* includes a dark variant, it will be used instead of the configured
* theme.
*
* Some applications benefit from minimizing the amount of light pollution that
* interferes with the content. Good candidates for dark themes are photo and
* video editors that make the actual content get all the attention and minimize
* the distraction of the chrome.
*
* Dark themes should not be used for documents, where large spaces are white/light
* and the dark chrome creates too much contrast (web browser, text editor...).
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-application-prefer-dark-theme",
P_("Application prefers a dark theme"),
P_("Whether the application prefers to have a dark theme."),
FALSE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_APPLICATION_PREFER_DARK_THEME);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-entry-select-on-focus",
P_("Select on focus"),
P_("Whether to select the contents of an entry when it is focused"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ENTRY_SELECT_ON_FOCUS);
/**
* GtkSettings:gtk-entry-password-hint-timeout:
*
* How long to show the last input character in hidden
* entries. This value is in milliseconds. 0 disables showing the
* last char. 600 is a good value for enabling it.
*/
result = settings_install_property_parser (class,
g_param_spec_uint ("gtk-entry-password-hint-timeout",
P_("Password Hint Timeout"),
P_("How long to show the last input character in hidden entries"),
0, G_MAXUINT,
0,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ENTRY_PASSWORD_HINT_TIMEOUT);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-label-select-on-focus",
P_("Select on focus"),
P_("Whether to select the contents of a selectable label when it is focused"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_LABEL_SELECT_ON_FOCUS);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-shell-shows-app-menu",
P_("Desktop shell shows app menu"),
P_("Set to TRUE if the desktop environment "
"is displaying the app menu, FALSE if "
"the app should display it itself."),
FALSE, GTK_PARAM_READWRITE));
g_assert (result == PROP_SHELL_SHOWS_APP_MENU);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-shell-shows-menubar",
P_("Desktop shell shows the menubar"),
P_("Set to TRUE if the desktop environment "
"is displaying the menubar, FALSE if "
"the app should display it itself."),
FALSE, GTK_PARAM_READWRITE));
g_assert (result == PROP_SHELL_SHOWS_MENUBAR);
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-shell-shows-desktop",
P_("Desktop environment shows the desktop folder"),
P_("Set to TRUE if the desktop environment "
"is displaying the desktop folder, FALSE "
"if not."),
TRUE, GTK_PARAM_READWRITE));
g_assert (result == PROP_SHELL_SHOWS_DESKTOP);
/**
* GtkSettings:gtk-decoration-layout:
*
* This setting determines which buttons should be put in the
* titlebar of client-side decorated windows, and whether they
* should be placed at the left of right.
*
* The format of the string is button names, separated by commas.
* A colon separates the buttons that should appear on the left
* from those on the right. Recognized button names are minimize,
* maximize, close, icon (the window icon) and menu (a menu button
* for the fallback app menu).
*
* For example, "menu:minimize,maximize,close" specifies a menu
* on the left, and minimize, maximize and close buttons on the right.
*
* Note that buttons will only be shown when they are meaningful.
* E.g. a menu button only appears when the desktop shell does not
* show the app menu, and a close button only appears on a window
* that can be closed.
*
* Also note that the setting can be overridden with the
* #GtkHeaderBar:decoration-layout property.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-decoration-layout",
P_("Decoration Layout"),
P_("The layout for window decorations"),
"menu:minimize,maximize,close", GTK_PARAM_READWRITE));
g_assert (result == PROP_DECORATION_LAYOUT);
/**
* GtkSettings:gtk-titlebar-double-click:
*
* This setting determines the action to take when a double-click
* occurs on the titlebar of client-side decorated windows.
*
* Recognized actions are minimize, toggle-maximize, menu, lower
* or none.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-titlebar-double-click",
P_("Titlebar double-click action"),
P_("The action to take on titlebar double-click"),
"toggle-maximize", GTK_PARAM_READWRITE));
g_assert (result == PROP_TITLEBAR_DOUBLE_CLICK);
/**
* GtkSettings:gtk-titlebar-middle-click:
*
* This setting determines the action to take when a middle-click
* occurs on the titlebar of client-side decorated windows.
*
* Recognized actions are minimize, toggle-maximize, menu, lower
* or none.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-titlebar-middle-click",
P_("Titlebar middle-click action"),
P_("The action to take on titlebar middle-click"),
"none", GTK_PARAM_READWRITE));
g_assert (result == PROP_TITLEBAR_MIDDLE_CLICK);
/**
* GtkSettings:gtk-titlebar-right-click:
*
* This setting determines the action to take when a right-click
* occurs on the titlebar of client-side decorated windows.
*
* Recognized actions are minimize, toggle-maximize, menu, lower
* or none.
*/
result = settings_install_property_parser (class,
g_param_spec_string ("gtk-titlebar-right-click",
P_("Titlebar right-click action"),
P_("The action to take on titlebar right-click"),
"menu", GTK_PARAM_READWRITE));
g_assert (result == PROP_TITLEBAR_RIGHT_CLICK);
/**
* GtkSettings:gtk-dialogs-use-header:
*
* Whether builtin GTK dialogs such as the file chooser, the
* color chooser or the font chooser will use a header bar at
* the top to show action widgets, or an action area at the bottom.
*
* This setting does not affect custom dialogs using GtkDialog
* directly, or message dialogs.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-dialogs-use-header",
P_("Dialogs use header bar"),
P_("Whether builtin GTK dialogs should use a header bar instead of an action area."),
FALSE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_DIALOGS_USE_HEADER);
/**
* GtkSettings:gtk-enable-primary-paste:
*
* Whether a middle click on a mouse should paste the
* 'PRIMARY' clipboard content at the cursor location.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-enable-primary-paste",
P_("Enable primary paste"),
P_("Whether a middle click on a mouse should paste the “PRIMARY” clipboard content at the cursor location."),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_ENABLE_PRIMARY_PASTE);
/**
* GtkSettings:gtk-recent-files-enabled:
*
* Whether GTK should keep track of items inside the recently used
* resources list. If set to %FALSE, the list will always be empty.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-recent-files-enabled",
P_("Recent Files Enabled"),
P_("Whether GTK remembers recent files"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_RECENT_FILES_ENABLED);
/**
* GtkSettings:gtk-long-press-time:
*
* The time for a button or touch press to be considered a "long press".
*/
result = settings_install_property_parser (class,
g_param_spec_uint ("gtk-long-press-time",
P_("Long press time"),
P_("Time for a button/touch press to be considered a long press (in milliseconds)"),
0, G_MAXINT, 500,
GTK_PARAM_READWRITE));
g_assert (result == PROP_LONG_PRESS_TIME);
/**
* GtkSettings:gtk-keynav-use-caret:
*
* Whether GTK should make sure that text can be navigated with
* a caret, even if it is not editable. This is useful when using
* a screen reader.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-keynav-use-caret",
P_("Whether to show cursor in text"),
P_("Whether to show cursor in text"),
FALSE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_KEYNAV_USE_CARET);
/**
* GtkSettings:gtk-overlay-scrolling:
*
* Whether scrolled windows may use overlayed scrolling indicators.
* If this is set to %FALSE, scrolled windows will have permanent
* scrollbars.
*/
result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-overlay-scrolling",
P_("Whether to use overlay scrollbars"),
P_("Whether to use overlay scrollbars"),
TRUE,
GTK_PARAM_READWRITE));
g_assert (result == PROP_OVERLAY_SCROLLING);
}
static GtkSettings *
gtk_settings_style_provider_get_settings (GtkStyleProvider *provider)
{
return GTK_SETTINGS (provider);
}
static void
gtk_settings_provider_iface_init (GtkStyleProviderInterface *iface)
{
iface->get_settings = gtk_settings_style_provider_get_settings;
}
static void
gtk_settings_finalize (GObject *object)
{
GtkSettings *settings = GTK_SETTINGS (object);
guint i;
object_list = g_slist_remove (object_list, settings);
for (i = 0; i < class_n_properties; i++)
g_value_unset (&settings->property_values[i].value);
g_free (settings->property_values);
g_datalist_clear (&settings->queued_settings);
settings_update_provider (settings->display, &settings->theme_provider, NULL);
g_slist_free_full (settings->style_cascades, g_object_unref);
if (settings->font_options)
cairo_font_options_destroy (settings->font_options);