gtksettings.c 118 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 15 16 17 18
 * 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, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

19

20 21
#define PANGO_ENABLE_BACKEND /* for pango_fc_font_map_cache_clear() */

22
#include "config.h"
23 24 25

#include <string.h>

26
#include "gtkmodules.h"
27
#include "gtksettingsprivate.h"
28
#include "gtkrc.h"
Havoc Pennington's avatar
Havoc Pennington committed
29
#include "gtkintl.h"
30
#include "gtkwidget.h"
31
#include "gtkprivate.h"
32
#include "gtkcssproviderprivate.h"
Matthias Clasen's avatar
Matthias Clasen committed
33
#include "gtksymboliccolor.h"
34
#include "gtktypebuiltins.h"
35
#include "gtkversion.h"
36

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

42 43 44 45 46 47

/**
 * SECTION:gtksettings
 * @Short_description: Sharing settings between applications
 * @Title: Settings
 *
48 49 50
 * GtkSettings provide a mechanism to share global settings between
 * applications.
 *
51 52
 * On the X window system, this sharing is realized by an
 * <ulink url="http://www.freedesktop.org/wiki/Specifications/xsettings-spec">XSettings</ulink>
53 54 55 56 57 58 59 60
 * manager that is usually part of the desktop environment, along with
 * utilities that let the user change these settings. In the absence of
 * an Xsettings manager, GTK+ reads default values for settings from
 * <filename>settings.ini</filename> files in
 * <filename>/etc/gtk-3.0</filename> and <filename>$XDG_CONFIG_HOME/gtk-3.0</filename>. 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 <filename>settings.ini</filename> file
 * next to their <filename>gtk.css</filename> file.
61
 *
62 63 64 65 66 67 68
 * Applications can override system-wide settings with
 * gtk_settings_set_string_property(), gtk_settings_set_long_property(),
 * etc. This should be restricted to special cases though; GtkSettings are
 * not meant as an application configuration facility. When doing so, you
 * need to be aware that settings that are specific to individual widgets
 * may not be available before the widget type has been realized at least
 * once. The following example demonstrates a way to do this:
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
 * <informalexample><programlisting>
 *   gtk_init (&argc, &argv);
 *
 *   /&ast; make sure the type is realized &ast;/
 *   g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM));
 *
 *   g_object_set (gtk_settings_get_default (), "gtk-menu-images", FALSE, NULL);
 * </programlisting></informalexample>
 *
 * There is one GtkSettings instance per screen. It can be obtained with
 * gtk_settings_get_for_screen(), but in many cases, it is more convenient
 * to use gtk_widget_get_settings(). gtk_settings_get_default() returns the
 * GtkSettings instance for the default screen.
 */


Yevgen Muntyan's avatar
Yevgen Muntyan committed
85 86 87 88 89 90
#ifdef GDK_WINDOWING_QUARTZ
#define DEFAULT_KEY_THEME "Mac"
#else
#define DEFAULT_KEY_THEME NULL
#endif

91 92
#define DEFAULT_TIMEOUT_INITIAL 200
#define DEFAULT_TIMEOUT_REPEAT   20
93
#define DEFAULT_TIMEOUT_EXPAND  500
94

95
typedef struct _GtkSettingsPropertyValue GtkSettingsPropertyValue;
96 97
typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;

98 99 100 101 102 103 104
struct _GtkSettingsPrivate
{
  GData *queued_settings;      /* of type GtkSettingsValue* */
  GtkSettingsPropertyValue *property_values;
  GdkScreen *screen;
};

105 106 107
typedef enum
{
  GTK_SETTINGS_SOURCE_DEFAULT,
108
  GTK_SETTINGS_SOURCE_THEME,
109
  GTK_SETTINGS_SOURCE_XSETTING,
110 111 112
  GTK_SETTINGS_SOURCE_APPLICATION
} GtkSettingsSource;

113 114 115
struct _GtkSettingsValuePrivate
{
  GtkSettingsValue public;
116
  GtkSettingsSource source;
117 118 119 120 121
};

struct _GtkSettingsPropertyValue
{
  GValue value;
122
  GtkSettingsSource source;
123 124
};

125 126
enum {
  PROP_0,
127
  PROP_DOUBLE_CLICK_TIME,
128
  PROP_DOUBLE_CLICK_DISTANCE,
129 130
  PROP_CURSOR_BLINK,
  PROP_CURSOR_BLINK_TIME,
131
  PROP_CURSOR_BLINK_TIMEOUT,
132 133
  PROP_SPLIT_CURSOR,
  PROP_THEME_NAME,
134
  PROP_ICON_THEME_NAME,
135
  PROP_FALLBACK_ICON_THEME,
Havoc Pennington's avatar
Havoc Pennington committed
136
  PROP_KEY_THEME_NAME,
Anders Carlsson's avatar
Anders Carlsson committed
137
  PROP_MENU_BAR_ACCEL,
138
  PROP_DND_DRAG_THRESHOLD,
139
  PROP_FONT_NAME,
140
  PROP_ICON_SIZES,
141
  PROP_MODULES,
142
#ifdef GDK_WINDOWING_X11
143 144 145 146
  PROP_XFT_ANTIALIAS,
  PROP_XFT_HINTING,
  PROP_XFT_HINTSTYLE,
  PROP_XFT_RGBA,
147
  PROP_XFT_DPI,
148 149
  PROP_CURSOR_THEME_NAME,
  PROP_CURSOR_THEME_SIZE,
150
#endif
151
  PROP_ALTERNATIVE_BUTTON_ORDER,
152
  PROP_ALTERNATIVE_SORT_ARROWS,
153
  PROP_SHOW_INPUT_METHOD_MENU,
154 155
  PROP_SHOW_UNICODE_MENU,
  PROP_TIMEOUT_INITIAL,
156
  PROP_TIMEOUT_REPEAT,
157
  PROP_TIMEOUT_EXPAND,
158
  PROP_COLOR_SCHEME,
159
  PROP_ENABLE_ANIMATIONS,
160
  PROP_TOUCHSCREEN_MODE,
Kristian Rietveld's avatar
Kristian Rietveld committed
161 162 163
  PROP_TOOLTIP_TIMEOUT,
  PROP_TOOLTIP_BROWSE_TIMEOUT,
  PROP_TOOLTIP_BROWSE_MODE_TIMEOUT,
164 165 166
  PROP_KEYNAV_CURSOR_ONLY,
  PROP_KEYNAV_WRAP_AROUND,
  PROP_ERROR_BELL,
167 168 169
  PROP_COLOR_HASH,
  PROP_FILE_CHOOSER_BACKEND,
  PROP_PRINT_BACKENDS,
170 171
  PROP_PRINT_PREVIEW_COMMAND,
  PROP_ENABLE_MNEMONICS,
172
  PROP_ENABLE_ACCELS,
173
  PROP_RECENT_FILES_LIMIT,
174
  PROP_IM_MODULE,
175
  PROP_RECENT_FILES_MAX_AGE,
176 177 178
  PROP_FONTCONFIG_TIMESTAMP,
  PROP_SOUND_THEME_NAME,
  PROP_ENABLE_INPUT_FEEDBACK_SOUNDS,
179
  PROP_ENABLE_EVENT_SOUNDS,
180 181
  PROP_ENABLE_TOOLTIPS,
  PROP_TOOLBAR_STYLE,
182
  PROP_TOOLBAR_ICON_SIZE,
183
  PROP_AUTO_MNEMONICS,
184 185 186 187 188 189 190 191 192 193 194 195 196 197
  PROP_APPLICATION_PREFER_DARK_THEME,
  PROP_BUTTON_IMAGES,
  PROP_ENTRY_SELECT_ON_FOCUS,
  PROP_ENTRY_PASSWORD_HINT_TIMEOUT,
  PROP_MENU_IMAGES,
  PROP_MENU_BAR_POPUP_DELAY,
  PROP_SCROLLED_WINDOW_PLACEMENT,
  PROP_CAN_CHANGE_ACCELS,
  PROP_MENU_POPUP_DELAY,
  PROP_MENU_POPDOWN_DELAY,
  PROP_LABEL_SELECT_ON_FOCUS,
  PROP_COLOR_PALETTE,
  PROP_IM_PREEDIT_STYLE,
  PROP_IM_STATUS_STYLE
198 199 200
};

/* --- prototypes --- */
201 202
static void     gtk_settings_provider_iface_init (GtkStyleProviderIface *iface);

203 204 205 206 207 208 209 210 211 212 213 214 215 216
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,
                                                  GtkRcPropertyParser    parser);
217
static void    settings_update_double_click      (GtkSettings           *settings);
218 219
static void    settings_update_modules           (GtkSettings           *settings);

220 221
#ifdef GDK_WINDOWING_X11
static void    settings_update_cursor_theme      (GtkSettings           *settings);
222 223
static void    settings_update_resolution        (GtkSettings           *settings);
static void    settings_update_font_options      (GtkSettings           *settings);
224
static gboolean settings_update_fontconfig       (GtkSettings           *settings);
225
#endif
226
static void    settings_update_color_scheme      (GtkSettings *settings);
227
static void    settings_update_theme             (GtkSettings *settings);
228
static void    settings_update_key_theme         (GtkSettings *settings);
229

230 231 232
static void    merge_color_scheme                (GtkSettings           *settings,
                                                  const GValue          *value,
                                                  GtkSettingsSource      source);
233 234
static gchar  *get_color_scheme                  (GtkSettings           *settings);
static GHashTable *get_color_hash                (GtkSettings           *settings);
235 236 237
static void gtk_settings_load_from_key_file      (GtkSettings           *settings,
                                                  const gchar           *path,
                                                  GtkSettingsSource      source);
238

239 240 241 242
/* the default palette for GtkColorSelelection */
static const gchar default_color_palette[] =
  "black:white:gray50:red:purple:blue:light blue:green:yellow:orange:"
  "lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90";
243 244

/* --- variables --- */
245
static GQuark            quark_property_parser = 0;
246
static GSList           *object_list = NULL;
247
static guint             class_n_properties = 0;
248 249


250 251 252
G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0,
                        G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
                                               gtk_settings_provider_iface_init));
253

Matthias Clasen's avatar
Matthias Clasen committed
254
/* --- functions --- */
255 256 257
static void
gtk_settings_init (GtkSettings *settings)
{
258
  GtkSettingsPrivate *priv;
Tim Janik's avatar
Tim Janik committed
259 260
  GParamSpec **pspecs, **p;
  guint i = 0;
261
  gchar *path;
262 263 264 265 266 267 268

  priv = G_TYPE_INSTANCE_GET_PRIVATE (settings,
                                      GTK_TYPE_SETTINGS,
                                      GtkSettingsPrivate);

  settings->priv = priv;
  g_datalist_init (&priv->queued_settings);
269 270 271 272 273 274
  object_list = g_slist_prepend (object_list, settings);

  /* build up property array for all yet existing properties and queue
   * notification for them (at least notification for internal properties
   * will instantly be caught)
   */
Tim Janik's avatar
Tim Janik committed
275 276 277 278
  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++;
279
  priv->property_values = g_new0 (GtkSettingsPropertyValue, i);
Tim Janik's avatar
Tim Janik committed
280
  i = 0;
Hans Breuer's avatar
Hans Breuer committed
281
  g_object_freeze_notify (G_OBJECT (settings));
282

Tim Janik's avatar
Tim Janik committed
283
  for (p = pspecs; *p; p++)
284
    {
Tim Janik's avatar
Tim Janik committed
285
      GParamSpec *pspec = *p;
286
      GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
287

Tim Janik's avatar
Tim Janik committed
288
      if (pspec->owner_type != G_OBJECT_TYPE (settings))
289
        continue;
290
      g_value_init (&priv->property_values[i].value, value_type);
291
      g_param_value_set_default (pspec, &priv->property_values[i].value);
292

293
      g_object_notify (G_OBJECT (settings), pspec->name);
294
      priv->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT;
Tim Janik's avatar
Tim Janik committed
295
      i++;
296
    }
297
  g_free (pspecs);
298

299 300 301 302 303 304 305 306
  path = g_build_filename (GTK_SYSCONFDIR, "gtk-3.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-3.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);
307 308
  g_free (path);

Hans Breuer's avatar
Hans Breuer committed
309
  g_object_thaw_notify (G_OBJECT (settings));
310 311 312 313 314 315
}

static void
gtk_settings_class_init (GtkSettingsClass *class)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
Havoc Pennington's avatar
Havoc Pennington committed
316
  guint result;
317

318 319 320 321 322 323
  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_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
Havoc Pennington's avatar
Havoc Pennington committed
324
  result = settings_install_property_parser (class,
325
                                             g_param_spec_int ("gtk-double-click-time",
326 327
                                                               P_("Double Click Time"),
                                                               P_("Maximum time allowed between two clicks for them to be considered a double click (in milliseconds)"),
328
                                                               0, G_MAXINT, 250,
329
                                                               GTK_PARAM_READWRITE),
Havoc Pennington's avatar
Havoc Pennington committed
330
                                             NULL);
331
  g_assert (result == PROP_DOUBLE_CLICK_TIME);
332 333
  result = settings_install_property_parser (class,
                                             g_param_spec_int ("gtk-double-click-distance",
334 335
                                                               P_("Double Click Distance"),
                                                               P_("Maximum distance allowed between two clicks for them to be considered a double click (in pixels)"),
336
                                                               0, G_MAXINT, 5,
337
                                                               GTK_PARAM_READWRITE),
338 339
                                             NULL);
  g_assert (result == PROP_DOUBLE_CLICK_DISTANCE);
340 341 342 343

  /**
   * GtkSettings:gtk-cursor-blink:
   *
344
   * Whether the cursor should blink.
345
   *
346
   * Also see the #GtkSettings:gtk-cursor-blink-timeout setting,
347
   * which allows more flexible control over cursor blinking.
348
   */
349 350
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-cursor-blink",
351 352 353 354 355
                                                                   P_("Cursor Blink"),
                                                                   P_("Whether the cursor should blink"),
                                                                   TRUE,
                                                                   GTK_PARAM_READWRITE),
                                             NULL);
356 357 358
  g_assert (result == PROP_CURSOR_BLINK);
  result = settings_install_property_parser (class,
                                             g_param_spec_int ("gtk-cursor-blink-time",
359
                                                               P_("Cursor Blink Time"),
360
                                                               P_("Length of the cursor blink cycle, in milliseconds"),
361
                                                               100, G_MAXINT, 1200,
362
                                                               GTK_PARAM_READWRITE),
363 364
                                             NULL);
  g_assert (result == PROP_CURSOR_BLINK_TIME);
365

366 367 368 369 370 371 372
  /**
   * 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
373
   * #GtkSettings:gtk-cursor-blink to %FALSE.
374 375 376 377 378 379 380 381 382 383 384
   *
   * Since: 2.12
   */
  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, G_MAXINT,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
  g_assert (result == PROP_CURSOR_BLINK_TIMEOUT);
385 386
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-split-cursor",
387 388 389 390
                                                                   P_("Split Cursor"),
                                                                   P_("Whether two cursors should be displayed for mixed left-to-right and right-to-left text"),
                                                                   TRUE,
                                                                   GTK_PARAM_READWRITE),
391 392
                                             NULL);
  g_assert (result == PROP_SPLIT_CURSOR);
393 394
  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-theme-name",
395 396 397 398
                                                                   P_("Theme Name"),
                                                                   P_("Name of theme RC file to load"),
                                                                  "Raleigh",
                                                                  GTK_PARAM_READWRITE),
399 400
                                             NULL);
  g_assert (result == PROP_THEME_NAME);
401

402 403
  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-icon-theme-name",
404 405 406 407
                                                                  P_("Icon Theme Name"),
                                                                  P_("Name of icon theme to use"),
                                                                  "hicolor",
                                                                  GTK_PARAM_READWRITE),
408
                                             NULL);
Owen Taylor's avatar
Owen Taylor committed
409
  g_assert (result == PROP_ICON_THEME_NAME);
410 411 412

  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-fallback-icon-theme",
413 414 415 416
                                                                  P_("Fallback Icon Theme Name"),
                                                                  P_("Name of a icon theme to fall back to"),
                                                                  NULL,
                                                                  GTK_PARAM_READWRITE),
417 418
                                             NULL);
  g_assert (result == PROP_FALLBACK_ICON_THEME);
419

420 421
  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-key-theme-name",
422 423 424 425
                                                                  P_("Key Theme Name"),
                                                                  P_("Name of key theme RC file to load"),
                                                                  DEFAULT_KEY_THEME,
                                                                  GTK_PARAM_READWRITE),
426
                                             NULL);
427
  g_assert (result == PROP_KEY_THEME_NAME);
Havoc Pennington's avatar
Havoc Pennington committed
428 429 430

  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-menu-bar-accel",
431 432
                                                                  P_("Menu bar accelerator"),
                                                                  P_("Keybinding to activate the menu bar"),
Havoc Pennington's avatar
Havoc Pennington committed
433
                                                                  "F10",
434
                                                                  GTK_PARAM_READWRITE),
Havoc Pennington's avatar
Havoc Pennington committed
435 436
                                             NULL);
  g_assert (result == PROP_MENU_BAR_ACCEL);
Anders Carlsson's avatar
Anders Carlsson committed
437 438

  result = settings_install_property_parser (class,
439 440 441 442
                                             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,
443
                                                               GTK_PARAM_READWRITE),
444
                                             NULL);
Anders Carlsson's avatar
Anders Carlsson committed
445
  g_assert (result == PROP_DND_DRAG_THRESHOLD);
446 447 448

  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-font-name",
449 450 451 452
                                                                   P_("Font Name"),
                                                                   P_("Name of default font to use"),
                                                                  "Sans 10",
                                                                  GTK_PARAM_READWRITE),
453 454
                                             NULL);
  g_assert (result == PROP_FONT_NAME);
455

456 457 458 459 460 461 462 463
  /**
   * GtkSettings:gtk-icon-sizes:
   *
   * A list of icon sizes. The list is separated by colons, and
   * item has the form:
   *
   * <replaceable>size-name</replaceable> = <replaceable>width</replaceable> , <replaceable>height</replaceable>
   *
464 465 466 467
   * E.g. "gtk-menu=16,16:gtk-button=20,20:gtk-dialog=48,48".
   * GTK+ itself use the following named icon sizes: gtk-menu,
   * gtk-button, gtk-small-toolbar, gtk-large-toolbar, gtk-dnd,
   * gtk-dialog. Applications can register their own named icon
468 469
   * sizes with gtk_icon_size_register().
   */
470 471
  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-icon-sizes",
472 473 474 475
                                                                   P_("Icon Sizes"),
                                                                   P_("List of icon sizes (gtk-menu=16,16:gtk-button=20,20..."),
                                                                  NULL,
                                                                  GTK_PARAM_READWRITE),
476 477
                                             NULL);
  g_assert (result == PROP_ICON_SIZES);
478

479 480
  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-modules",
481 482 483 484
                                                                  P_("GTK Modules"),
                                                                  P_("List of currently active GTK modules"),
                                                                  NULL,
                                                                  GTK_PARAM_READWRITE),
485 486 487
                                             NULL);
  g_assert (result == PROP_MODULES);

488 489
#ifdef GDK_WINDOWING_X11
  result = settings_install_property_parser (class,
490 491 492 493 494 495 496
                                             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),
                                             NULL);

497
  g_assert (result == PROP_XFT_ANTIALIAS);
498 499 500 501 502 503 504 505 506

  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),
                                             NULL);

507
  g_assert (result == PROP_XFT_HINTING);
508

509
  result = settings_install_property_parser (class,
510 511 512 513 514
                                             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),
515
                                              NULL);
516

517
  g_assert (result == PROP_XFT_HINTSTYLE);
518 519 520 521 522 523 524 525 526

  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),
                                             NULL);

527
  g_assert (result == PROP_XFT_RGBA);
528 529 530 531 532 533 534 535 536

  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),
                                             NULL);

537
  g_assert (result == PROP_XFT_DPI);
538 539 540

  result = settings_install_property_parser (class,
                                             g_param_spec_string ("gtk-cursor-theme-name",
541 542 543 544
                                                                  P_("Cursor theme name"),
                                                                  P_("Name of the cursor theme to use, or NULL to use the default theme"),
                                                                  NULL,
                                                                  GTK_PARAM_READWRITE),
545 546 547 548
                                             NULL);
  g_assert (result == PROP_CURSOR_THEME_NAME);

  result = settings_install_property_parser (class,
549 550 551 552 553 554 555
                                             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),
                                             NULL);

556 557
  g_assert (result == PROP_CURSOR_THEME_SIZE);

558
#endif  /* GDK_WINDOWING_X11 */
559 560
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-alternative-button-order",
561 562 563 564
                                                                   P_("Alternative button order"),
                                                                   P_("Whether buttons in dialogs should use the alternative button order"),
                                                                   FALSE,
                                                                   GTK_PARAM_READWRITE),
565 566
                                             NULL);
  g_assert (result == PROP_ALTERNATIVE_BUTTON_ORDER);
567

568 569 570 571
  /**
   * GtkSettings:gtk-alternative-sort-arrows:
   *
   * Controls the direction of the sort indicators in sorted list and tree
572 573
   * views. By default an arrow pointing down means the column is sorted
   * in ascending order. When set to %TRUE, this order will be inverted.
574 575 576 577 578
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-alternative-sort-arrows",
579 580 581 582
                                                                   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),
583 584 585
                                             NULL);
  g_assert (result == PROP_ALTERNATIVE_SORT_ARROWS);

586
  result = settings_install_property_parser (class,
587 588 589 590 591 592
                                             g_param_spec_boolean ("gtk-show-input-method-menu",
                                                                   P_("Show the 'Input Methods' menu"),
                                                                   P_("Whether the context menus of entries and text views should offer to change the input method"),
                                                                   TRUE,
                                                                   GTK_PARAM_READWRITE),
                                             NULL);
593 594 595
  g_assert (result == PROP_SHOW_INPUT_METHOD_MENU);

  result = settings_install_property_parser (class,
596 597 598 599 600 601
                                             g_param_spec_boolean ("gtk-show-unicode-menu",
                                                                   P_("Show the 'Insert Unicode Control Character' menu"),
                                                                   P_("Whether the context menus of entries and text views should offer to insert control characters"),
                                                                   TRUE,
                                                                   GTK_PARAM_READWRITE),
                                             NULL);
602 603
  g_assert (result == PROP_SHOW_UNICODE_MENU);

604
  result = settings_install_property_parser (class,
605 606 607 608 609 610
                                             g_param_spec_int ("gtk-timeout-initial",
                                                               P_("Start timeout"),
                                                               P_("Starting value for timeouts, when button is pressed"),
                                                               0, G_MAXINT, DEFAULT_TIMEOUT_INITIAL,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
611 612 613 614

  g_assert (result == PROP_TIMEOUT_INITIAL);

  result = settings_install_property_parser (class,
615 616 617 618 619 620
                                             g_param_spec_int ("gtk-timeout-repeat",
                                                               P_("Repeat timeout"),
                                                               P_("Repeat value for timeouts, when button is pressed"),
                                                               0, G_MAXINT, DEFAULT_TIMEOUT_REPEAT,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
621 622

  g_assert (result == PROP_TIMEOUT_REPEAT);
623

624
  result = settings_install_property_parser (class,
625 626 627 628 629 630
                                             g_param_spec_int ("gtk-timeout-expand",
                                                               P_("Expand timeout"),
                                                               P_("Expand value for timeouts, when a widget is expanding a new region"),
                                                               0, G_MAXINT, DEFAULT_TIMEOUT_EXPAND,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
631 632 633

  g_assert (result == PROP_TIMEOUT_EXPAND);

634 635 636 637 638 639 640 641 642
  /**
   * GtkSettings:gtk-color-scheme:
   *
   * A palette of named colors for use in themes. The format of the string is
   * <programlisting>
   * name1: color1
   * name2: color2
   * ...
   * </programlisting>
643
   * Color names must be acceptable as identifiers in the
644 645 646
   * <link linkend="gtk-Resource-Files">gtkrc</link> syntax, and
   * color specifications must be in the format accepted by
   * gdk_color_parse().
647
   *
648 649 650 651
   * Note that due to the way the color tables from different sources are
   * merged, color specifications will be converted to hexadecimal form
   * when getting this property.
   *
652 653 654 655 656 657
   * Starting with GTK+ 2.12, the entries can alternatively be separated
   * by ';' instead of newlines:
   * <programlisting>
   * name1: color1; name2: color2; ...
   * </programlisting>
   *
658 659
   * Since: 2.10
   */
660
  result = settings_install_property_parser (class,
661 662 663 664 665 666
                                             g_param_spec_string ("gtk-color-scheme",
                                                                  P_("Color scheme"),
                                                                  P_("A palette of named colors for use in themes"),
                                                                  "",
                                                                  GTK_PARAM_READWRITE),
                                             NULL);
667 668

  g_assert (result == PROP_COLOR_SCHEME);
669 670 671 672 673 674 675 676 677 678

  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),
                                             NULL);

  g_assert (result == PROP_ENABLE_ANIMATIONS);
679

680 681 682
  /**
   * GtkSettings:gtk-touchscreen-mode:
   *
683
   * When %TRUE, there are no motion notify events delivered on this screen,
684 685 686 687 688 689 690 691 692 693 694 695 696 697
   * and widgets can't use the pointer hovering them for any essential
   * functionality.
   *
   * Since: 2.10
   */
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-touchscreen-mode",
                                                                   P_("Enable Touchscreen Mode"),
                                                                   P_("When TRUE, there are no motion notify events delivered on this screen"),
                                                                   FALSE,
                                                                   GTK_PARAM_READWRITE),
                                             NULL);

  g_assert (result == PROP_TOUCHSCREEN_MODE);
698

Kristian Rietveld's avatar
Kristian Rietveld committed
699 700 701 702 703 704 705 706 707
  /**
   * GtkSettings:gtk-tooltip-timeout:
   *
   * Time, in milliseconds, after which a tooltip could appear if the
   * cursor is hovering on top of a widget.
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
708 709 710 711 712 713 714
                                             g_param_spec_int ("gtk-tooltip-timeout",
                                                               P_("Tooltip timeout"),
                                                               P_("Timeout before tooltip is shown"),
                                                               0, G_MAXINT,
                                                               500,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
Kristian Rietveld's avatar
Kristian Rietveld committed
715 716 717 718 719 720 721 722 723 724

  g_assert (result == PROP_TOOLTIP_TIMEOUT);

  /**
   * GtkSettings:gtk-tooltip-browse-timeout:
   *
   * Controls the time after which tooltips will appear when
   * browse mode is enabled, in milliseconds.
   *
   * Browse mode is enabled when the mouse pointer moves off an object
725
   * where a tooltip was currently being displayed. If the mouse pointer
Kristian Rietveld's avatar
Kristian Rietveld committed
726
   * hits another object before the browse mode timeout expires (see
727
   * #GtkSettings:gtk-tooltip-browse-mode-timeout), it will take the
728
   * amount of milliseconds specified by this setting to popup the tooltip
Kristian Rietveld's avatar
Kristian Rietveld committed
729 730 731 732 733
   * for the new object.
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
734 735 736 737 738 739 740
                                             g_param_spec_int ("gtk-tooltip-browse-timeout",
                                                               P_("Tooltip browse timeout"),
                                                               P_("Timeout before tooltip is shown when browse mode is enabled"),
                                                               0, G_MAXINT,
                                                               60,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
Kristian Rietveld's avatar
Kristian Rietveld committed
741 742 743 744 745 746 747 748 749

  g_assert (result == PROP_TOOLTIP_BROWSE_TIMEOUT);

  /**
   * GtkSettings:gtk-tooltip-browse-mode-timeout:
   *
   * Amount of time, in milliseconds, after which the browse mode
   * will be disabled.
   *
750
   * See #GtkSettings:gtk-tooltip-browse-timeout for more information
Kristian Rietveld's avatar
Kristian Rietveld committed
751 752 753 754 755
   * about browse mode.
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
756 757 758 759 760 761 762
                                             g_param_spec_int ("gtk-tooltip-browse-mode-timeout",
                                                               P_("Tooltip browse mode timeout"),
                                                               P_("Timeout after which browse mode is disabled"),
                                                               0, G_MAXINT,
                                                               500,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
Kristian Rietveld's avatar
Kristian Rietveld committed
763 764 765

  g_assert (result == PROP_TOOLTIP_BROWSE_MODE_TIMEOUT);

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
  /**
   * GtkSettings:gtk-keynav-cursor-only:
   *
   * When %TRUE, keyboard navigation should be able to reach all widgets
   * by using the cursor keys only. Tab, Shift etc. keys can't be expected
   * to be present on the used input device.
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-keynav-cursor-only",
                                                                   P_("Keynav Cursor Only"),
                                                                   P_("When TRUE, there are only cursor keys available to navigate widgets"),
                                                                   FALSE,
                                                                   GTK_PARAM_READWRITE),
                                             NULL);

  g_assert (result == PROP_KEYNAV_CURSOR_ONLY);

  /**
   * GtkSettings:gtk-keynav-wrap-around:
   *
   * When %TRUE, some widgets will wrap around when doing keyboard
   * navigation, such as menus, menubars and notebooks.
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-keynav-wrap-around",
                                                                   P_("Keynav Wrap Around"),
                                                                   P_("Whether to wrap around when keyboard-navigating widgets"),
                                                                   TRUE,
                                                                   GTK_PARAM_READWRITE),
                                             NULL);

  g_assert (result == PROP_KEYNAV_WRAP_AROUND);

  /**
   * 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_window_beep(), the windowing system may offer ways to
   * configure the error bell in many ways, such as flashing the
   * window or similar visual effects.
   *
   * Since: 2.12
   */
  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),
                                             NULL);

  g_assert (result == PROP_ERROR_BELL);

824 825 826
  /**
   * GtkSettings:color-hash:
   *
827 828
   * Holds a hash table representation of the #GtkSettings:gtk-color-scheme
   * setting, mapping color names to #GdkColor<!-- -->s.
829 830 831
   *
   * Since: 2.10
   */
832
  result = settings_install_property_parser (class,
833 834 835 836 837 838 839
                                             g_param_spec_boxed ("color-hash",
                                                                 P_("Color Hash"),
                                                                 P_("A hash table representation of the color scheme."),
                                                                 G_TYPE_HASH_TABLE,
                                                                 GTK_PARAM_READABLE),
                                             NULL);
  g_assert (result == PROP_COLOR_HASH);
840

841
  result = settings_install_property_parser (class,
842 843 844 845 846 847 848 849 850 851 852 853 854
                                             g_param_spec_string ("gtk-file-chooser-backend",
                                                                  P_("Default file chooser backend"),
                                                                  P_("Name of the GtkFileChooser backend to use by default"),
                                                                  NULL,
                                                                  GTK_PARAM_READWRITE),
                                             NULL);
  g_assert (result == PROP_FILE_CHOOSER_BACKEND);

  /**
   * 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,
Matthias Clasen's avatar
Matthias Clasen committed
855
   * and may include "file", "cups", "lpr" or "papi".
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872
   *
   * Since: 2.10
   */
  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),
                                             NULL);
  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
873 874
   * the path to the pdf file. The command may also contain a %s
   * placeholder, which will get replaced by the path to a file
875
   * containing the print settings in the format produced by
876
   * gtk_print_settings_to_file().
877 878
   *
   * The preview application is responsible for removing the pdf file
879
   * and the print settings file when it is done.
880 881 882 883 884 885 886 887 888
   *
   * Since: 2.10
   */
  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"),
                                                                  GTK_PRINT_PREVIEW_COMMAND,
                                                                  GTK_PARAM_READWRITE),
889
                                             NULL);
890
  g_assert (result == PROP_PRINT_PREVIEW_COMMAND);
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

  /**
   * GtkSettings:gtk-enable-mnemonics:
   *
   * Whether labels and menu items should have visible mnemonics which
   * can be activated.
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-enable-mnemonics",
                                                                   P_("Enable Mnemonics"),
                                                                   P_("Whether labels should have mnemonics"),
                                                                   TRUE,
                                                                   GTK_PARAM_READWRITE),
                                             NULL);
  g_assert (result == PROP_ENABLE_MNEMONICS);

  /**
   * GtkSettings:gtk-enable-accels:
   *
   * Whether menu items should have visible accelerators which can be
   * activated.
   *
   * Since: 2.12
   */
  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),
                                             NULL);
  g_assert (result == PROP_ENABLE_ACCELS);
925 926 927 928 929 930 931 932 933 934 935

  /**
   * GtkSettings:gtk-recent-files-limit:
   *
   * The number of recently used files that should be displayed by default by
   * #GtkRecentChooser implementations and by the #GtkFileChooser. A value of
   * -1 means every recently used file stored.
   *
   * Since: 2.12
   */
  result = settings_install_property_parser (class,
936 937 938 939 940 941 942
                                             g_param_spec_int ("gtk-recent-files-limit",
                                                               P_("Recent Files Limit"),
                                                               P_("Number of recently used files"),
                                                               -1, G_MAXINT,
                                                               50,
                                                               GTK_PARAM_READWRITE),
                                             NULL);
943
  g_assert (result == PROP_RECENT_FILES_LIMIT);
944 945 946 947

  /**
   * GtkSettings:gtk-im-module:
   *
948 949 950
   * 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.
951 952
   *
   * See #GtkIMContext and see the #GtkSettings:gtk-show-input-method-menu property.
953 954
   */
  result = settings_install_property_parser (class,
955 956 957 958 959 960
                                             g_param_spec_string ("gtk-im-module",
                                                                  P_("Default IM module"),
                                                                  P_("Which IM module should be used by default"),
                                                                  NULL,
                                                                  GTK_PARAM_READWRITE),
                                             NULL);
961
  g_assert (result == PROP_IM_MODULE);
962 963 964 965 966 967 968 969 970 971 972 973

  /**
   * 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.
   *
   * Since: 2.14
   */
  result = settings_install_property_parser (class,
974 975 976 977 978 979 980
                                             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),
                                             NULL);
981
  g_assert (result == PROP_RECENT_FILES_MAX_AGE);
982 983

  result = settings_install_property_parser (class,
984 985 986 987 988 989 990
                                             g_param_spec_uint ("gtk-fontconfig-timestamp",
                                                                P_("Fontconfig configuration timestamp"),
                                                                P_("Timestamp of current fontconfig configuration"),
                                                                0, G_MAXUINT, 0,
                                                                GTK_PARAM_READWRITE),
                                             NULL);

991
  g_assert (result == PROP_FONTCONFIG_TIMESTAMP);
992

993 994 995 996 997
  /**
   * GtkSettings:gtk-sound-theme-name:
   *
   * The XDG sound theme to use for event sounds.
   *
998
   * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
999 1000
   * for more information on event sounds and sound themes.
   *
1001
   * GTK+ itself does not support event sounds, you have to use a loadable
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019
   * module like the one that comes with libcanberra.
   *
   * Since: 2.14
   */
  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),
                                             NULL);
  g_assert (result == PROP_SOUND_THEME_NAME);

  /**
   * GtkSettings:gtk-enable-input-feedback-sounds:
   *
   * Whether to play event sounds as feedback to user input.
   *
1020
   * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
1021 1022
   * for more information on event sounds and sound themes.
   *
1023
   * GTK+ itself does not support event sounds, you have to use a loadable
1024 1025 1026 1027 1028 1029
   * module like the one that comes with libcanberra.
   *
   * Since: 2.14
   */
  result = settings_install_property_parser (class,
                                             g_param_spec_boolean ("gtk-enable-input-feedback-sounds",
Matthias Clasen's avatar
Matthias Clasen committed
1030
                                                                   /* Translators: this means sounds that are played as feedback to user input */
1031 1032 1033 1034
                                                                   P_("Audible Input Feedback"),
                                                                   P_("Whether to play event sounds as feedback to user input"),
                                                                   TRUE,
                                                                   GTK_PARAM_READWRITE),
1035 1036 1037 1038 1039 1040 1041 1042
                                             NULL);
  g_assert (result == PROP_ENABLE_INPUT_FEEDBACK_SOUNDS);

  /**
   * GtkSettings:gtk-enable-event-sounds:
   *
   * Whether to play any event sounds at all.
   *
1043
   * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
1044 1045
   * for more information on event sounds and sound themes.
   *