gtksettings.c 71.8 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
2
3
4
5
6
7
8
9
10
11
12
13
14
 * 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
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
16
17
 */

18

19
#include "config.h"
20

21
#include "gtksettingsprivate.h"
22

23
#include "gtkcssproviderprivate.h"
24
25
#include "gtkprivate.h"
#include "gtkscrolledwindow.h"
26
#include "gtkstylecontextprivate.h"
27
#include "gtkstyleproviderprivate.h"
28
#include "gtktypebuiltins.h"
29
#include "gtkversion.h"
30
#include "gtkwidgetprivate.h"
31

32
#include "gdk/gdkprivate.h"
33

34
35
#include <string.h>

36
37
#ifdef GDK_WINDOWING_X11
#include "x11/gdkx.h"
38
#include <pango/pangofc-fontmap.h>
39
40
#endif

41
42
#ifdef GDK_WINDOWING_WAYLAND
#include "wayland/gdkwayland.h"
43
#include <pango/pangofc-fontmap.h>
44
45
#endif

46
47
48
49
#ifdef GDK_WINDOWING_BROADWAY
#include "broadway/gdkbroadway.h"
#endif

50
51
#ifdef GDK_WINDOWING_MACOS
#include "macos/gdkmacos.h"
52
53
#endif

54
55
56
57
#ifdef GDK_WINDOWING_WIN32
#include "win32/gdkwin32.h"
#endif

58
#ifdef GDK_WINDOWING_MACOS
59
#define PRINT_PREVIEW_COMMAND "open -b com.apple.Preview %f"
60
61
62
63
#else
#define PRINT_PREVIEW_COMMAND "evince --unlink-tempfile --preview --print-settings %s %f"
#endif

64
/**
Matthias Clasen's avatar
Matthias Clasen committed
65
 * GtkSettings:
66
 *
Matthias Clasen's avatar
Matthias Clasen committed
67
 * `GtkSettings` provides a mechanism to share global settings between
68
69
 * applications.
 *
70
 * On the X window system, this sharing is realized by an
71
 * [XSettings](http://www.freedesktop.org/wiki/Specifications/xsettings-spec)
72
 * manager that is usually part of the desktop environment, along with
Matthias Clasen's avatar
Matthias Clasen committed
73
74
75
76
77
78
79
80
 * 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
Matthias Clasen's avatar
Matthias Clasen committed
81
 * `GKeyFile`), and have a section called Settings. Themes can also provide
Matthias Clasen's avatar
Matthias Clasen committed
82
 * default values for settings by installing a `settings.ini` file
83
 * next to their `gtk.css` file.
84
 *
85
 * Applications can override system-wide settings by setting the property
Matthias Clasen's avatar
Matthias Clasen committed
86
87
 * of the `GtkSettings` object with g_object_set(). This should be restricted
 * to special cases though; `GtkSettings` are not meant as an application
Matthias Clasen's avatar
Matthias Clasen committed
88
 * configuration facility.
89
 *
Matthias Clasen's avatar
Matthias Clasen committed
90
 * There is one `GtkSettings` instance per display. It can be obtained with
Matthias Clasen's avatar
Matthias Clasen committed
91
 * [func@Gtk.Settings.get_for_display], but in many cases, it is more
Matthias Clasen's avatar
Matthias Clasen committed
92
 * convenient to use [method@Gtk.Widget.get_settings].
93
94
 */

Emmanuele Bassi's avatar
Emmanuele Bassi committed
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
/* --- typedefs --- */
typedef struct _GtkSettingsValue GtkSettingsValue;

/*< private >
 * GtkSettingsValue:
 * @origin: Origin should be something like “filename:linenumber” for
 *    rc files, or e.g. “XProperty” for other sources.
 * @value: Valid types are LONG, DOUBLE and STRING corresponding to
 *    the token parsed, or a GSTRING holding an unparsed statement
 */
struct _GtkSettingsValue
{
  /* origin should be something like "filename:linenumber" for rc files,
   * or e.g. "XProperty" for other sources
   */
  char *origin;

  /* valid types are LONG, DOUBLE and STRING corresponding to the token parsed,
   * or a GSTRING holding an unparsed statement
   */
  GValue value;

  /* the settings source */
  GtkSettingsSource source;
};

121
typedef struct _GtkSettingsClass GtkSettingsClass;
122
typedef struct _GtkSettingsPropertyValue GtkSettingsPropertyValue;
123

124
struct _GtkSettings
125
{
126
127
  GObject parent_instance;

128
129
  GData *queued_settings;      /* of type GtkSettingsValue* */
  GtkSettingsPropertyValue *property_values;
130
  GdkDisplay *display;
131
  GSList *style_cascades;
132
  GtkCssProvider *theme_provider;
Benjamin Otte's avatar
Benjamin Otte committed
133
  int font_size;
134
  gboolean font_size_absolute;
Benjamin Otte's avatar
Benjamin Otte committed
135
  char *font_family;
136
  cairo_font_options_t *font_options;
137
138
};

139
140
141
142
143
struct _GtkSettingsClass
{
  GObjectClass parent_class;
};

144
145
146
struct _GtkSettingsPropertyValue
{
  GValue value;
147
  GtkSettingsSource source;
148
149
};

150
151
enum {
  PROP_0,
152
  PROP_DOUBLE_CLICK_TIME,
153
  PROP_DOUBLE_CLICK_DISTANCE,
154
155
  PROP_CURSOR_BLINK,
  PROP_CURSOR_BLINK_TIME,
156
  PROP_CURSOR_BLINK_TIMEOUT,
157
  PROP_SPLIT_CURSOR,
158
  PROP_CURSOR_ASPECT_RATIO,
159
  PROP_THEME_NAME,
160
  PROP_ICON_THEME_NAME,
161
  PROP_DND_DRAG_THRESHOLD,
162
  PROP_FONT_NAME,
163
164
165
166
  PROP_XFT_ANTIALIAS,
  PROP_XFT_HINTING,
  PROP_XFT_HINTSTYLE,
  PROP_XFT_RGBA,
167
  PROP_XFT_DPI,
168
  PROP_HINT_FONT_METRICS,
169
170
  PROP_CURSOR_THEME_NAME,
  PROP_CURSOR_THEME_SIZE,
171
  PROP_ALTERNATIVE_BUTTON_ORDER,
172
  PROP_ALTERNATIVE_SORT_ARROWS,
173
  PROP_ENABLE_ANIMATIONS,
174
  PROP_ERROR_BELL,
175
  PROP_PRINT_BACKENDS,
176
  PROP_PRINT_PREVIEW_COMMAND,
177
  PROP_ENABLE_ACCELS,
178
  PROP_IM_MODULE,
179
  PROP_RECENT_FILES_MAX_AGE,
180
181
182
  PROP_FONTCONFIG_TIMESTAMP,
  PROP_SOUND_THEME_NAME,
  PROP_ENABLE_INPUT_FEEDBACK_SOUNDS,
183
  PROP_ENABLE_EVENT_SOUNDS,
184
  PROP_PRIMARY_BUTTON_WARPS_SLIDER,
185
186
187
188
  PROP_APPLICATION_PREFER_DARK_THEME,
  PROP_ENTRY_SELECT_ON_FOCUS,
  PROP_ENTRY_PASSWORD_HINT_TIMEOUT,
  PROP_LABEL_SELECT_ON_FOCUS,
189
  PROP_SHELL_SHOWS_APP_MENU,
190
  PROP_SHELL_SHOWS_MENUBAR,
191
  PROP_SHELL_SHOWS_DESKTOP,
192
  PROP_DECORATION_LAYOUT,
193
194
195
  PROP_TITLEBAR_DOUBLE_CLICK,
  PROP_TITLEBAR_MIDDLE_CLICK,
  PROP_TITLEBAR_RIGHT_CLICK,
196
  PROP_DIALOGS_USE_HEADER,
197
  PROP_ENABLE_PRIMARY_PASTE,
198
  PROP_RECENT_FILES_ENABLED,
199
  PROP_LONG_PRESS_TIME,
200
201
  PROP_KEYNAV_USE_CARET,
  PROP_OVERLAY_SCROLLING
202
203
204
};

/* --- prototypes --- */
205
static void     gtk_settings_provider_iface_init (GtkStyleProviderInterface *iface);
206

207
208
209
210
211
212
213
214
215
216
217
218
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,
219
                                                  GParamSpec            *pspec);
220
static void    settings_update_double_click      (GtkSettings           *settings);
221

222
static void    settings_update_cursor_theme      (GtkSettings           *settings);
223
static void    settings_update_font_options      (GtkSettings           *settings);
Matthias Clasen's avatar
Matthias Clasen committed
224
static void    settings_update_font_values       (GtkSettings           *settings);
225
static gboolean settings_update_fontconfig       (GtkSettings           *settings);
Matthias Clasen's avatar
Matthias Clasen committed
226
227
228
229
static void    settings_update_theme             (GtkSettings           *settings);
static gboolean settings_update_xsetting         (GtkSettings           *settings,
                                                  GParamSpec            *pspec,
                                                  gboolean               force);
230
static void    settings_update_xsettings         (GtkSettings           *settings);
231

232
static void gtk_settings_load_from_key_file      (GtkSettings           *settings,
Benjamin Otte's avatar
Benjamin Otte committed
233
                                                  const char            *path,
234
                                                  GtkSettingsSource      source);
235
static void settings_update_provider             (GdkDisplay            *display,
236
237
                                                  GtkCssProvider       **old,
                                                  GtkCssProvider        *new);
238
239

/* --- variables --- */
240
static GQuark            quark_gtk_settings = 0;
241
static GSList           *object_list = NULL;
242
static guint             class_n_properties = 0;
243

244
static GPtrArray *display_settings;
245

246

247
248
G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0,
                        G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
249
                                               gtk_settings_provider_iface_init));
250

Matthias Clasen's avatar
Matthias Clasen committed
251
/* --- functions --- */
252
253
254
static void
gtk_settings_init (GtkSettings *settings)
{
Tim Janik's avatar
Tim Janik committed
255
  GParamSpec **pspecs, **p;
256
  guint n_pspecs;
Tim Janik's avatar
Tim Janik committed
257
  guint i = 0;
Benjamin Otte's avatar
Benjamin Otte committed
258
259
  char *path;
  const char * const *config_dirs;
260

261
  g_datalist_init (&settings->queued_settings);
262
263
  object_list = g_slist_prepend (object_list, settings);

264
265
  settings->style_cascades = g_slist_prepend (NULL, _gtk_style_cascade_new ());
  settings->theme_provider = gtk_css_provider_new ();
266

267
268
269
270
  /* build up property array for all yet existing properties and queue
   * notification for them (at least notification for internal properties
   * will instantly be caught)
   */
271
272
  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), &n_pspecs);
  settings->property_values = g_new0 (GtkSettingsPropertyValue, n_pspecs);
Hans Breuer's avatar
Hans Breuer committed
273
  g_object_freeze_notify (G_OBJECT (settings));
274

275
  i = 0;
Tim Janik's avatar
Tim Janik committed
276
  for (p = pspecs; *p; p++)
277
    {
Tim Janik's avatar
Tim Janik committed
278
      GParamSpec *pspec = *p;
279
      GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
280

Tim Janik's avatar
Tim Janik committed
281
      if (pspec->owner_type != G_OBJECT_TYPE (settings))
282
        continue;
283
284
      g_value_init (&settings->property_values[i].value, value_type);
      g_param_value_set_default (pspec, &settings->property_values[i].value);
285

286
      g_object_notify_by_pspec (G_OBJECT (settings), pspec);
287
      settings->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT;
Tim Janik's avatar
Tim Janik committed
288
      i++;
289
    }
290
  g_free (pspecs);
291

292
  path = g_build_filename (_gtk_get_data_prefix (), "share", "gtk-4.0", "settings.ini", NULL);
293
  gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
294
295
  g_free (path);

296
  path = g_build_filename (_gtk_get_sysconfdir (), "gtk-4.0", "settings.ini", NULL);
297
  gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
298
299
  g_free (path);

300
  config_dirs = g_get_system_config_dirs ();
301
  for (i = 0; config_dirs[i] != NULL; i++)
302
    {
303
      path = g_build_filename (config_dirs[i], "gtk-4.0", "settings.ini", NULL);
304
      gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
305
306
307
      g_free (path);
    }

308
  path = g_build_filename (g_get_user_config_dir (), "gtk-4.0", "settings.ini", NULL);
309
  gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
310
311
  g_free (path);

Hans Breuer's avatar
Hans Breuer committed
312
  g_object_thaw_notify (G_OBJECT (settings));
313
314

  /* ensure that derived fields are initialized */
315
  if (settings->font_size == 0)
316
    settings_update_font_values (settings);
317
318
319
320
321
322
}

static void
gtk_settings_class_init (GtkSettingsClass *class)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
Matthias Clasen's avatar
Matthias Clasen committed
323
  guint result G_GNUC_UNUSED;
324

325
326
327
328
329
  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;

330
331
  quark_gtk_settings = g_quark_from_static_string ("gtk-settings");

Matthias Clasen's avatar
Matthias Clasen committed
332
333
334
335
336
337
  /**
   * GtkSettings:gtk-double-click-time:
   *
   * The maximum time to allow between two clicks for them to be considered
   * a double click, in milliseconds.
   */
Havoc Pennington's avatar
Havoc Pennington committed
338
  result = settings_install_property_parser (class,
339
                                             g_param_spec_int ("gtk-double-click-time", NULL, NULL,
340
                                                               0, G_MAXINT, 400,
341
                                                               GTK_PARAM_READWRITE));
342
  g_assert (result == PROP_DOUBLE_CLICK_TIME);
Matthias Clasen's avatar
Matthias Clasen committed
343
344
345
346
347
348
349

  /**
   * GtkSettings:gtk-double-click-distance:
   *
   * The maximum distance allowed between two clicks for them to be considered
   * a double click, in pixels.
   */
350
  result = settings_install_property_parser (class,
351
                                             g_param_spec_int ("gtk-double-click-distance", NULL, NULL,
352
                                                               0, G_MAXINT, 5,
353
                                                               GTK_PARAM_READWRITE));
354
  g_assert (result == PROP_DOUBLE_CLICK_DISTANCE);
355
356
357
358

  /**
   * GtkSettings:gtk-cursor-blink:
   *
359
   * Whether the cursor should blink.
360
   *
Matthias Clasen's avatar
Matthias Clasen committed
361
   * Also see the [property@Gtk.Settings:gtk-cursor-blink-timeout] setting,
362
   * which allows more flexible control over cursor blinking.
363
   */
364
  result = settings_install_property_parser (class,
365
                                             g_param_spec_boolean ("gtk-cursor-blink", NULL, NULL,
366
                                                                   TRUE,
367
                                                                   GTK_PARAM_READWRITE));
368
  g_assert (result == PROP_CURSOR_BLINK);
Matthias Clasen's avatar
Matthias Clasen committed
369
370
371
372
373
374

  /**
   * GtkSettings:gtk-cursor-blink-time:
   *
   * Length of the cursor blink cycle, in milliseconds.
   */
375
  result = settings_install_property_parser (class,
376
                                             g_param_spec_int ("gtk-cursor-blink-time", NULL, NULL,
377
                                                               100, G_MAXINT, 1200,
378
                                                               GTK_PARAM_READWRITE));
379
  g_assert (result == PROP_CURSOR_BLINK_TIME);
380

381
382
383
384
  /**
   * GtkSettings:gtk-cursor-blink-timeout:
   *
   * Time after which the cursor stops blinking, in seconds.
Matthias Clasen's avatar
Matthias Clasen committed
385
   *
386
387
388
   * The timer is reset after each user interaction.
   *
   * Setting this to zero has the same effect as setting
Matthias Clasen's avatar
Matthias Clasen committed
389
   * [property@Gtk.Settings:gtk-cursor-blink] to %FALSE.
390
391
   */
  result = settings_install_property_parser (class,
392
                                             g_param_spec_int ("gtk-cursor-blink-timeout", NULL, NULL,
393
                                                               1, G_MAXINT, 10,
394
                                                               GTK_PARAM_READWRITE));
395
  g_assert (result == PROP_CURSOR_BLINK_TIMEOUT);
Matthias Clasen's avatar
Matthias Clasen committed
396
397
398
399
400
401
402

  /**
   * GtkSettings:gtk-split-cursor:
   *
   * Whether two cursors should be displayed for mixed left-to-right and
   * right-to-left text.
   */
403
  result = settings_install_property_parser (class,
404
                                             g_param_spec_boolean ("gtk-split-cursor", NULL, NULL,
405
                                                                   FALSE,
406
                                                                   GTK_PARAM_READWRITE));
407
  g_assert (result == PROP_SPLIT_CURSOR);
408

Matthias Clasen's avatar
Matthias Clasen committed
409
410
411
412
413
  /**
   * GtkSettings:gtk-cursor-aspect-ratio:
   *
   * The aspect ratio of the text caret.
   */
414
  result = settings_install_property_parser (class,
415
                                             g_param_spec_double ("gtk-cursor-aspect-ratio", NULL, NULL,
416
417
                                                                  0.0, 1.0, 0.04,
                                                                  GTK_PARAM_READWRITE));
418
419
  g_assert (result == PROP_CURSOR_ASPECT_RATIO);

Matthias Clasen's avatar
Matthias Clasen committed
420
421
422
423
424
425
426
427
  /**
   * GtkSettings:gtk-theme-name:
   *
   * Name of the theme to load.
   *
   * See [class@Gtk.CssProvider] for details about how
   * GTK finds the CSS stylesheet for a theme.
   */
428
  result = settings_install_property_parser (class,
429
                                             g_param_spec_string ("gtk-theme-name", NULL, NULL,
430
                                                                  DEFAULT_THEME_NAME,
431
                                                                  GTK_PARAM_READWRITE));
432
  g_assert (result == PROP_THEME_NAME);
433

Matthias Clasen's avatar
Matthias Clasen committed
434
435
436
437
438
439
440
441
  /**
   * GtkSettings:gtk-icon-theme-name:
   *
   * Name of the icon theme to use.
   *
   * See [class@Gtk.IconTheme] for details about how
   * GTK handles icon themes.
   */
442
  result = settings_install_property_parser (class,
443
                                             g_param_spec_string ("gtk-icon-theme-name", NULL, NULL,
444
                                                                  DEFAULT_ICON_THEME,
445
                                                                  GTK_PARAM_READWRITE));
Owen Taylor's avatar
Owen Taylor committed
446
  g_assert (result == PROP_ICON_THEME_NAME);
447

Matthias Clasen's avatar
Matthias Clasen committed
448
449
450
451
452
  /**
   * GtkSettings:gtk-dnd-drag-threshold:
   *
   * The number of pixels the cursor can move before dragging.
   */
Anders Carlsson's avatar
Anders Carlsson committed
453
  result = settings_install_property_parser (class,
454
                                             g_param_spec_int ("gtk-dnd-drag-threshold", NULL, NULL,
455
                                                               1, G_MAXINT, 8,
456
                                                               GTK_PARAM_READWRITE));
Anders Carlsson's avatar
Anders Carlsson committed
457
  g_assert (result == PROP_DND_DRAG_THRESHOLD);
458

459
460
461
  /**
   * GtkSettings:gtk-font-name:
   *
Matthias Clasen's avatar
Matthias Clasen committed
462
463
464
   * The default font to use.
   *
   * GTK uses the family name and size from this string.
465
   */
466
  result = settings_install_property_parser (class,
467
                                             g_param_spec_string ("gtk-font-name", NULL, NULL,
468
                                                                  "Sans 10",
469
                                                                  GTK_PARAM_READWRITE));
470
  g_assert (result == PROP_FONT_NAME);
471

Matthias Clasen's avatar
Matthias Clasen committed
472
473
474
475
476
477
478
  /**
   * GtkSettings:gtk-xft-antialias:
   *
   * Whether to antialias fonts.
   *
   * The values are 0 for no, 1 for yes, or -1 for the system default.
   */
479
  result = settings_install_property_parser (class,
480
                                             g_param_spec_int ("gtk-xft-antialias", NULL, NULL,
481
                                                               -1, 1, -1,
482
                                                               GTK_PARAM_READWRITE));
483

484
  g_assert (result == PROP_XFT_ANTIALIAS);
485

Matthias Clasen's avatar
Matthias Clasen committed
486
487
488
489
490
491
492
  /**
   * GtkSettings:gtk-xft-hinting:
   *
   * Whether to enable font hinting.
   *
   * The values are 0 for no, 1 for yes, or -1 for the system default.
   */
493
  result = settings_install_property_parser (class,
494
                                             g_param_spec_int ("gtk-xft-hinting", NULL, NULL,
495
                                                               -1, 1, -1,
496
                                                               GTK_PARAM_READWRITE));
497

498
  g_assert (result == PROP_XFT_HINTING);
499

Matthias Clasen's avatar
Matthias Clasen committed
500
501
502
503
504
505
506
507
  /**
   * GtkSettings:gtk-xft-hintstyle:
   *
   * What degree of font hinting to use.
   *
   * The possible vaues are hintnone, hintslight,
   * hintmedium, hintfull.
   */
508
  result = settings_install_property_parser (class,
509
                                             g_param_spec_string ("gtk-xft-hintstyle", NULL, NULL,
510
                                                                  NULL,
511
                                                                  GTK_PARAM_READWRITE));
512

513
  g_assert (result == PROP_XFT_HINTSTYLE);
514

Matthias Clasen's avatar
Matthias Clasen committed
515
516
517
518
519
520
521
  /**
   * GtkSettings:gtk-xft-rgba:
   *
   * The type of subpixel antialiasing to use.
   *
   * The possible values are none, rgb, bgr, vrgb, vbgr.
   */
522
  result = settings_install_property_parser (class,
523
                                             g_param_spec_string ("gtk-xft-rgba", NULL, NULL,
524
                                                                  NULL,
525
                                                                  GTK_PARAM_READWRITE));
526

527
  g_assert (result == PROP_XFT_RGBA);
528

529
  
Matthias Clasen's avatar
Matthias Clasen committed
530
531
532
533
534
535
536
  /**
   * GtkSettings:gtk-xft-dpi:
   *
   * The font resolution, in 1024 * dots/inch.
   *
   * -1 to use the default value.
   */
537
  result = settings_install_property_parser (class,
538
                                             g_param_spec_int ("gtk-xft-dpi", NULL, NULL,
539
                                                               -1, 1024*1024, -1,
540
                                                               GTK_PARAM_READWRITE));
541

542
  g_assert (result == PROP_XFT_DPI);
543

544
545
546
547
548
549
550
551
552
553
554
  /**
   * GtkSettings:gtk-hint-font-metrics:
   *
   * Whether hinting should be applied to font metrics.
   *
   * Note that this also turns off subpixel positioning of glyphs,
   * since it conflicts with metrics hinting.
   *
   * Since: 4.6
   */
  result = settings_install_property_parser (class,
555
                                             g_param_spec_boolean ("gtk-hint-font-metrics", NULL, NULL,
556
557
558
559
560
                                                                   FALSE,
                                                                   GTK_PARAM_READWRITE));

  g_assert (result == PROP_HINT_FONT_METRICS);

Matthias Clasen's avatar
Matthias Clasen committed
561
562
563
564
565
566
567
  /**
   * GtkSettings:gtk-cursor-theme-name:
   *
   * Name of the cursor theme to use.
   *
   * Use %NULL to use the default theme.
   */
568
  result = settings_install_property_parser (class,
569
                                             g_param_spec_string ("gtk-cursor-theme-name", NULL, NULL,
570
                                                                  NULL,
571
                                                                  GTK_PARAM_READWRITE));
572
573
  g_assert (result == PROP_CURSOR_THEME_NAME);

Matthias Clasen's avatar
Matthias Clasen committed
574
575
576
577
578
579
580
  /**
   * GtkSettings:gtk-cursor-theme-size:
   *
   * The size to use for cursors.
   *
   * 0 means to use the default size.
   */
581
  result = settings_install_property_parser (class,
582
                                             g_param_spec_int ("gtk-cursor-theme-size", NULL, NULL,
583
                                                               0, 128, 0,
584
                                                               GTK_PARAM_READWRITE));
585

586
587
  g_assert (result == PROP_CURSOR_THEME_SIZE);

Matthias Clasen's avatar
Matthias Clasen committed
588
589
590
591
592
  /**
   * GtkSettings:gtk-alternative-button-order:
   *
   * Whether buttons in dialogs should use the alternative button order.
   */
593
  result = settings_install_property_parser (class,
594
                                             g_param_spec_boolean ("gtk-alternative-button-order", NULL, NULL,
595
                                                                   FALSE,
596
                                                                   GTK_PARAM_READWRITE));
597
  g_assert (result == PROP_ALTERNATIVE_BUTTON_ORDER);
598

599
600
601
602
  /**
   * GtkSettings:gtk-alternative-sort-arrows:
   *
   * Controls the direction of the sort indicators in sorted list and tree
Matthias Clasen's avatar
Matthias Clasen committed
603
604
605
   * views.
   *
   * By default an arrow pointing down means the column is sorted
606
   * in ascending order. When set to %TRUE, this order will be inverted.
607
608
   */
  result = settings_install_property_parser (class,
609
                                             g_param_spec_boolean ("gtk-alternative-sort-arrows", NULL, NULL,
610
                                                                   FALSE,
611
                                                                   GTK_PARAM_READWRITE));
612
613
  g_assert (result == PROP_ALTERNATIVE_SORT_ARROWS);

Matthias Clasen's avatar
Matthias Clasen committed
614
615
616
617
618
  /**
   * GtkSettings:gtk-enable-animations:
   *
   * Whether to enable toolkit-wide animations.
   */
619
  result = settings_install_property_parser (class,
620
                                             g_param_spec_boolean ("gtk-enable-animations", NULL, NULL,
621
                                                                   TRUE,
622
                                                                   GTK_PARAM_READWRITE));
623
624

  g_assert (result == PROP_ENABLE_ANIMATIONS);
625

626
627
628
629
  /**
   * GtkSettings:gtk-error-bell:
   *
   * When %TRUE, keyboard navigation and other input-related errors
Matthias Clasen's avatar
Matthias Clasen committed
630
631
632
633
634
   * 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.
635
636
   */
  result = settings_install_property_parser (class,
637
                                             g_param_spec_boolean ("gtk-error-bell", NULL, NULL,
638
                                                                   TRUE,
639
                                                                   GTK_PARAM_READWRITE));
640
641
642

  g_assert (result == PROP_ERROR_BELL);

643
644
645
646
  /**
   * GtkSettings:gtk-print-backends:
   *
   * A comma-separated list of print backends to use in the print
Matthias Clasen's avatar
Matthias Clasen committed
647
648
649
   * dialog.
   *
   * Available print backends depend on the GTK installation,
Matthias Clasen's avatar
Matthias Clasen committed
650
   * and may include "file", "cups", "lpr" or "papi".
651
652
   */
  result = settings_install_property_parser (class,
653
                                             g_param_spec_string ("gtk-print-backends", NULL, NULL,
654
                                                                  GTK_PRINT_BACKENDS,
655
                                                                  GTK_PARAM_READWRITE));
656
657
658
659
660
  g_assert (result == PROP_PRINT_BACKENDS);

  /**
   * GtkSettings:gtk-print-preview-command:
   *
Matthias Clasen's avatar
Matthias Clasen committed
661
662
663
664
665
666
667
   * 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 [method@Gtk.PrintSettings.to_file].
668
   *
Matthias Clasen's avatar
Matthias Clasen committed
669
670
   * The preview application is responsible for removing the pdf
   * file and the print settings file when it is done.
671
672
   */
  result = settings_install_property_parser (class,
673
                                             g_param_spec_string ("gtk-print-preview-command", NULL, NULL,
674
                                                                  PRINT_PREVIEW_COMMAND,
675
                                                                  GTK_PARAM_READWRITE));
676
  g_assert (result == PROP_PRINT_PREVIEW_COMMAND);
677
678
679
680
681
682
683
684

  /**
   * GtkSettings:gtk-enable-accels:
   *
   * Whether menu items should have visible accelerators which can be
   * activated.
   */
  result = settings_install_property_parser (class,
685
                                             g_param_spec_boolean ("gtk-enable-accels", NULL, NULL,
686
                                                                   TRUE,
687
                                                                   GTK_PARAM_READWRITE));
688
  g_assert (result == PROP_ENABLE_ACCELS);
689

690
691
692
  /**
   * GtkSettings:gtk-im-module:
   *
Matthias Clasen's avatar
Matthias Clasen committed
693
694
695
696
   * 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.
Emmanuele Bassi's avatar
Emmanuele Bassi committed
697
   * This also can be a colon-separated list of input methods, which GTK
698
   * will try in turn until it finds one available on the system.
699
   *
Matthias Clasen's avatar
Matthias Clasen committed
700
   * See [class@Gtk.IMContext].
701
702
   */
  result = settings_install_property_parser (class,
703
                                             g_param_spec_string ("gtk-im-module", NULL, NULL,
704
                                                                  NULL,
705
                                                                  GTK_PARAM_READWRITE));
706
  g_assert (result == PROP_IM_MODULE);
707
708
709
710
711

  /**
   * GtkSettings:gtk-recent-files-max-age:
   *
   * The maximum age, in days, of the items inside the recently used
Matthias Clasen's avatar
Matthias Clasen committed
712
713
714
715
716
   * 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.
717
718
   */
  result = settings_install_property_parser (class,
719
                                             g_param_spec_int ("gtk-recent-files-max-age", NULL, NULL,
720
721
                                                               -1, G_MAXINT,
                                                               30,
722
                                                               GTK_PARAM_READWRITE));
723
  g_assert (result == PROP_RECENT_FILES_MAX_AGE);
724

Matthias Clasen's avatar
Matthias Clasen committed
725
726
727
728
729
  /**
   * GtkSettings:gtk-fontconfig-timestamp:
   *
   * Timestamp of the curent fontconfig configuration.
   */
730
  result = settings_install_property_parser (class,
731
                                             g_param_spec_uint ("gtk-fontconfig-timestamp", NULL, NULL,
732
                                                                0, G_MAXUINT, 0,
733
                                                                GTK_PARAM_READWRITE));
734

735
  g_assert (result == PROP_FONTCONFIG_TIMESTAMP);
736

737
738
739
740
741
  /**
   * GtkSettings:gtk-sound-theme-name:
   *
   * The XDG sound theme to use for event sounds.
   *
742
   * See the [Sound Theme Specifications](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec)
743
744
   * for more information on event sounds and sound themes.
   *
Matthias Clasen's avatar
Matthias Clasen committed
745
746
   * GTK itself does not support event sounds, you have to use
   * a loadable module like the one that comes with libcanberra.
747
748
   */
  result = settings_install_property_parser (class,
749
                                             g_param_spec_string ("gtk-sound-theme-name", NULL, NULL,
750
                                                                  "freedesktop",
751
                                                                  GTK_PARAM_READWRITE));
752
753
754
755
756
757
758
  g_assert (result == PROP_SOUND_THEME_NAME);

  /**
   * GtkSettings:gtk-enable-input-feedback-sounds:
   *
   * Whether to play event sounds as feedback to user input.
   *
759
   * See the [Sound Theme Specifications](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec)
760
761
   * for more information on event sounds and sound themes.
   *
Emmanuele Bassi's avatar
Emmanuele Bassi committed
762
   * GTK itself does not support event sounds, you have to use a loadable
763
764
765
   * module like the one that comes with libcanberra.
   */
  result = settings_install_property_parser (class,
766
                                             g_param_spec_boolean ("gtk-enable-input-feedback-sounds", NULL, NULL,
767
                                                                   TRUE,
768
                                                                   GTK_PARAM_READWRITE));
769
770
771
772
773
774
775
  g_assert (result == PROP_ENABLE_INPUT_FEEDBACK_SOUNDS);

  /**
   * GtkSettings:gtk-enable-event-sounds:
   *
   * Whether to play any event sounds at all.
   *
776
   * See the [Sound Theme Specifications](http://www.freedesktop.org/wiki/Specifications/sound-theme-spec)
777
778
   * for more information on event sounds and sound themes.
   *
Emmanuele Bassi's avatar
Emmanuele Bassi committed
779
   * GTK itself does not support event sounds, you have to use a loadable
780
781
782
   * module like the one that comes with libcanberra.
   */
  result = settings_install_property_parser (class,
783
                                             g_param_spec_boolean ("gtk-enable-event-sounds", NULL, NULL,
784
                                                                   TRUE,
785
                                                                   GTK_PARAM_READWRITE));
786
  g_assert (result == PROP_ENABLE_EVENT_SOUNDS);
787

788
  /**
Matthias Clasen's avatar
Matthias Clasen committed
789
   * GtkSettings:gtk-primary-button-warps-slider:
790
   *
791
   * If the value of this setting is %TRUE, clicking the primary button in a
Matthias Clasen's avatar
Matthias Clasen committed
792
   * `GtkRange` trough will move the slider, and hence set the range’s value, to
Matthias Clasen's avatar
Matthias Clasen committed
793
794
795
796
   * 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.
797
798
   *
   * Whichever action you choose for the primary button, the other action will
Matthias Clasen's avatar
Matthias Clasen committed
799
800
   * be available by holding Shift and primary-clicking, or clicking the middle
   * mouse button.
801
802
   */
  result = settings_install_property_parser (class,
803
                                             g_param_spec_boolean ("gtk-primary-button-warps-slider", NULL, NULL,
804
                                                                   TRUE,
805
                                                                   GTK_PARAM_READWRITE));
806
807
  g_assert (result == PROP_PRIMARY_BUTTON_WARPS_SLIDER);

808
809
810
  /**
   * GtkSettings:gtk-application-prefer-dark-theme:
   *
Matthias Clasen's avatar
Matthias Clasen committed
811
812
813
814
   * 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.
815
   *
Matthias Clasen's avatar
Matthias Clasen committed
816
817
818
819
820
   * 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.
821
   *
Matthias Clasen's avatar
Matthias Clasen committed
822
823
824
   * 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...).
825
826
   */
  result = settings_install_property_parser (class,
827
                                             g_param_spec_boolean ("gtk-application-prefer-dark-theme", NULL, NULL,
828
                                                                 FALSE,
829
                                                                 GTK_PARAM_READWRITE));
830
  g_assert (result == PROP_APPLICATION_PREFER_DARK_THEME);
831

Matthias Clasen's avatar
Matthias Clasen committed
832
833
834
835
836
  /**
   * GtkSettings:gkt-entry-select-on-focus:
   *
   * Whether to select the contents of an entry when it is focused.
   */
837
  result = settings_install_property_parser (class,
838
                                             g_param_spec_boolean ("gtk-entry-select-on-focus", NULL, NULL,
839
                                                                   TRUE,
840
                                                                   GTK_PARAM_READWRITE));
841
842
843
844
845
846
  g_assert (result == PROP_ENTRY_SELECT_ON_FOCUS);

  /**
   * GtkSettings:gtk-entry-password-hint-timeout:
   *
   * How long to show the last input character in hidden
Matthias Clasen's avatar
Matthias Clasen committed
847
848
849
   * entries.
   *
   * This value is in milliseconds. 0 disables showing the
850
851
852
   * last char. 600 is a good value for enabling it.
   */
  result = settings_install_property_parser (class,
853
                                             g_param_spec_uint ("gtk-entry-password-hint-timeout", NULL, NULL,
854
                                                                0, G_MAXUINT,
855
                                                                0,
856
                                                                GTK_PARAM_READWRITE));
857
858
  g_assert (result == PROP_ENTRY_PASSWORD_HINT_TIMEOUT);

Matthias Clasen's avatar
Matthias Clasen committed
859
860
861
862
863
864
  /**
   * GtkSettings:gtk-label-select-on-focus:
   *
   * Whether to select the contents of a selectable
   * label when it is focused.
   */
865
  result = settings_install_property_parser (class,
866
                                             g_param_spec_boolean ("gtk-label-select-on-focus", NULL, NULL,
867
                                                                   TRUE,
868
                                                                   GTK_PARAM_READWRITE));
869
870
  g_assert (result == PROP_LABEL_SELECT_ON_FOCUS);

Matthias Clasen's avatar
Matthias Clasen committed
871
872
873
874
875
876
  /**
   * GtkSettings:gtk-shell-shows-app-menu:
   *
   * Set to %TRUE if the desktop environment is displaying
   * the app menu, %FALSE if the app should display it itself.
   */
877
  result = settings_install_property_parser (class,
878
                                             g_param_spec_boolean ("gtk-shell-shows-app-menu", NULL, NULL,
879
                                                                   FALSE, GTK_PARAM_READWRITE));
880
881
  g_assert (result == PROP_SHELL_SHOWS_APP_MENU);

Matthias Clasen's avatar
Matthias Clasen committed
882
883
884