1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2000 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
19 #define PANGO_ENABLE_BACKEND /* for pango_fc_font_map_cache_clear() */
25 #include "gtksettings.h"
27 #include "gtkmodules.h"
28 #include "gtkmodulesprivate.h"
29 #include "gtksettingsprivate.h"
31 #include "gtkwidget.h"
32 #include "gtkprivate.h"
33 #include "gtkcssproviderprivate.h"
34 #include "gtkstyleproviderprivate.h"
35 #include "gtksymboliccolor.h"
36 #include "gtktypebuiltins.h"
37 #include "gtkversion.h"
39 #ifdef GDK_WINDOWING_X11
41 #include <pango/pangofc-fontmap.h>
44 #ifdef GDK_WINDOWING_QUARTZ
45 #include "quartz/gdkquartz.h"
49 #include "gtkwin32themeprivate.h"
53 #undef GDK_DEPRECATED_FOR
54 #define GDK_DEPRECATED
55 #define GDK_DEPRECATED_FOR(f)
57 #include "deprecated/gtkrc.h"
62 * @Short_description: Sharing settings between applications
65 * GtkSettings provide a mechanism to share global settings between
68 * On the X window system, this sharing is realized by an
69 * <ulink url="http://www.freedesktop.org/wiki/Specifications/xsettings-spec">XSettings</ulink>
70 * manager that is usually part of the desktop environment, along with
71 * utilities that let the user change these settings. In the absence of
72 * an Xsettings manager, GTK+ reads default values for settings from
73 * <filename>settings.ini</filename> files in
74 * <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
75 * a section called Settings. Themes can also provide default values
76 * for settings by installing a <filename>settings.ini</filename> file
77 * next to their <filename>gtk.css</filename> file.
79 * Applications can override system-wide settings with
80 * gtk_settings_set_string_property(), gtk_settings_set_long_property(),
81 * etc. This should be restricted to special cases though; GtkSettings are
82 * not meant as an application configuration facility. When doing so, you
83 * need to be aware that settings that are specific to individual widgets
84 * may not be available before the widget type has been realized at least
85 * once. The following example demonstrates a way to do this:
86 * <informalexample><programlisting>
87 * gtk_init (&argc, &argv);
89 * /* make sure the type is realized */
90 * g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM));
92 * g_object_set (gtk_settings_get_default (), "gtk-menu-images", FALSE, NULL);
93 * </programlisting></informalexample>
95 * There is one GtkSettings instance per screen. It can be obtained with
96 * gtk_settings_get_for_screen(), but in many cases, it is more convenient
97 * to use gtk_widget_get_settings(). gtk_settings_get_default() returns the
98 * GtkSettings instance for the default screen.
102 #define DEFAULT_TIMEOUT_INITIAL 200
103 #define DEFAULT_TIMEOUT_REPEAT 20
104 #define DEFAULT_TIMEOUT_EXPAND 500
106 typedef struct _GtkSettingsPropertyValue GtkSettingsPropertyValue;
107 typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
109 struct _GtkSettingsPrivate
111 GData *queued_settings; /* of type GtkSettingsValue* */
112 GtkSettingsPropertyValue *property_values;
114 GtkCssProvider *theme_provider;
115 GtkCssProvider *key_theme_provider;
116 GtkStyleProperties *style;
121 GTK_SETTINGS_SOURCE_DEFAULT,
122 GTK_SETTINGS_SOURCE_THEME,
123 GTK_SETTINGS_SOURCE_XSETTING,
124 GTK_SETTINGS_SOURCE_APPLICATION
127 struct _GtkSettingsValuePrivate
129 GtkSettingsValue public;
130 GtkSettingsSource source;
133 struct _GtkSettingsPropertyValue
136 GtkSettingsSource source;
141 PROP_DOUBLE_CLICK_TIME,
142 PROP_DOUBLE_CLICK_DISTANCE,
144 PROP_CURSOR_BLINK_TIME,
145 PROP_CURSOR_BLINK_TIMEOUT,
148 PROP_ICON_THEME_NAME,
149 PROP_FALLBACK_ICON_THEME,
152 PROP_DND_DRAG_THRESHOLD,
161 PROP_CURSOR_THEME_NAME,
162 PROP_CURSOR_THEME_SIZE,
163 PROP_ALTERNATIVE_BUTTON_ORDER,
164 PROP_ALTERNATIVE_SORT_ARROWS,
165 PROP_SHOW_INPUT_METHOD_MENU,
166 PROP_SHOW_UNICODE_MENU,
167 PROP_TIMEOUT_INITIAL,
171 PROP_ENABLE_ANIMATIONS,
172 PROP_TOUCHSCREEN_MODE,
173 PROP_TOOLTIP_TIMEOUT,
174 PROP_TOOLTIP_BROWSE_TIMEOUT,
175 PROP_TOOLTIP_BROWSE_MODE_TIMEOUT,
176 PROP_KEYNAV_CURSOR_ONLY,
177 PROP_KEYNAV_WRAP_AROUND,
180 PROP_FILE_CHOOSER_BACKEND,
182 PROP_PRINT_PREVIEW_COMMAND,
183 PROP_ENABLE_MNEMONICS,
185 PROP_RECENT_FILES_LIMIT,
187 PROP_RECENT_FILES_MAX_AGE,
188 PROP_FONTCONFIG_TIMESTAMP,
189 PROP_SOUND_THEME_NAME,
190 PROP_ENABLE_INPUT_FEEDBACK_SOUNDS,
191 PROP_ENABLE_EVENT_SOUNDS,
192 PROP_ENABLE_TOOLTIPS,
194 PROP_TOOLBAR_ICON_SIZE,
197 PROP_APPLICATION_PREFER_DARK_THEME,
199 PROP_ENTRY_SELECT_ON_FOCUS,
200 PROP_ENTRY_PASSWORD_HINT_TIMEOUT,
202 PROP_MENU_BAR_POPUP_DELAY,
203 PROP_SCROLLED_WINDOW_PLACEMENT,
204 PROP_CAN_CHANGE_ACCELS,
205 PROP_MENU_POPUP_DELAY,
206 PROP_MENU_POPDOWN_DELAY,
207 PROP_LABEL_SELECT_ON_FOCUS,
209 PROP_IM_PREEDIT_STYLE,
210 PROP_IM_STATUS_STYLE,
211 PROP_SHELL_SHOWS_APP_MENU,
212 PROP_SHELL_SHOWS_MENUBAR,
213 PROP_ENABLE_PRIMARY_PASTE
216 /* --- prototypes --- */
217 static void gtk_settings_provider_iface_init (GtkStyleProviderIface *iface);
218 static void gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface);
220 static void gtk_settings_finalize (GObject *object);
221 static void gtk_settings_get_property (GObject *object,
225 static void gtk_settings_set_property (GObject *object,
229 static void gtk_settings_notify (GObject *object,
231 static guint settings_install_property_parser (GtkSettingsClass *class,
233 GtkRcPropertyParser parser);
234 static void settings_update_double_click (GtkSettings *settings);
235 static void settings_update_modules (GtkSettings *settings);
237 static void settings_update_cursor_theme (GtkSettings *settings);
238 static void settings_update_resolution (GtkSettings *settings);
239 static void settings_update_font_options (GtkSettings *settings);
240 static gboolean settings_update_fontconfig (GtkSettings *settings);
241 static void settings_update_color_scheme (GtkSettings *settings);
242 static void settings_update_theme (GtkSettings *settings);
243 static void settings_update_key_theme (GtkSettings *settings);
245 static void merge_color_scheme (GtkSettings *settings,
247 GtkSettingsSource source);
248 static gchar *get_color_scheme (GtkSettings *settings);
249 static GHashTable *get_color_hash (GtkSettings *settings);
250 static void gtk_settings_load_from_key_file (GtkSettings *settings,
252 GtkSettingsSource source);
254 /* the default palette for GtkColorSelelection */
255 static const gchar default_color_palette[] =
256 "black:white:gray50:red:purple:blue:light blue:green:yellow:orange:"
257 "lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90";
259 /* --- variables --- */
260 static GQuark quark_property_parser = 0;
261 static GSList *object_list = NULL;
262 static guint class_n_properties = 0;
265 G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0,
266 G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
267 gtk_settings_provider_iface_init)
268 G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE,
269 gtk_settings_provider_private_init));
271 /* --- functions --- */
273 gtk_settings_init (GtkSettings *settings)
275 GtkSettingsPrivate *priv;
276 GParamSpec **pspecs, **p;
280 priv = G_TYPE_INSTANCE_GET_PRIVATE (settings,
284 settings->priv = priv;
285 g_datalist_init (&priv->queued_settings);
286 object_list = g_slist_prepend (object_list, settings);
288 /* build up property array for all yet existing properties and queue
289 * notification for them (at least notification for internal properties
290 * will instantly be caught)
292 pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), NULL);
293 for (p = pspecs; *p; p++)
294 if ((*p)->owner_type == G_OBJECT_TYPE (settings))
296 priv->property_values = g_new0 (GtkSettingsPropertyValue, i);
298 g_object_freeze_notify (G_OBJECT (settings));
300 for (p = pspecs; *p; p++)
302 GParamSpec *pspec = *p;
303 GType value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
305 if (pspec->owner_type != G_OBJECT_TYPE (settings))
307 g_value_init (&priv->property_values[i].value, value_type);
308 g_param_value_set_default (pspec, &priv->property_values[i].value);
310 g_object_notify (G_OBJECT (settings), pspec->name);
311 priv->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT;
316 path = g_build_filename (_gtk_get_sysconfdir (), "gtk-3.0", "settings.ini", NULL);
317 if (g_file_test (path, G_FILE_TEST_EXISTS))
318 gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
321 path = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "settings.ini", NULL);
322 if (g_file_test (path, G_FILE_TEST_EXISTS))
323 gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_DEFAULT);
326 g_object_thaw_notify (G_OBJECT (settings));
330 gtk_settings_class_init (GtkSettingsClass *class)
332 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
335 gobject_class->finalize = gtk_settings_finalize;
336 gobject_class->get_property = gtk_settings_get_property;
337 gobject_class->set_property = gtk_settings_set_property;
338 gobject_class->notify = gtk_settings_notify;
340 quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
341 result = settings_install_property_parser (class,
342 g_param_spec_int ("gtk-double-click-time",
343 P_("Double Click Time"),
344 P_("Maximum time allowed between two clicks for them to be considered a double click (in milliseconds)"),
346 GTK_PARAM_READWRITE),
348 g_assert (result == PROP_DOUBLE_CLICK_TIME);
349 result = settings_install_property_parser (class,
350 g_param_spec_int ("gtk-double-click-distance",
351 P_("Double Click Distance"),
352 P_("Maximum distance allowed between two clicks for them to be considered a double click (in pixels)"),
354 GTK_PARAM_READWRITE),
356 g_assert (result == PROP_DOUBLE_CLICK_DISTANCE);
359 * GtkSettings:gtk-cursor-blink:
361 * Whether the cursor should blink.
363 * Also see the #GtkSettings:gtk-cursor-blink-timeout setting,
364 * which allows more flexible control over cursor blinking.
366 result = settings_install_property_parser (class,
367 g_param_spec_boolean ("gtk-cursor-blink",
369 P_("Whether the cursor should blink"),
371 GTK_PARAM_READWRITE),
373 g_assert (result == PROP_CURSOR_BLINK);
374 result = settings_install_property_parser (class,
375 g_param_spec_int ("gtk-cursor-blink-time",
376 P_("Cursor Blink Time"),
377 P_("Length of the cursor blink cycle, in milliseconds"),
379 GTK_PARAM_READWRITE),
381 g_assert (result == PROP_CURSOR_BLINK_TIME);
384 * GtkSettings:gtk-cursor-blink-timeout:
386 * Time after which the cursor stops blinking, in seconds.
387 * The timer is reset after each user interaction.
389 * Setting this to zero has the same effect as setting
390 * #GtkSettings:gtk-cursor-blink to %FALSE.
394 result = settings_install_property_parser (class,
395 g_param_spec_int ("gtk-cursor-blink-timeout",
396 P_("Cursor Blink Timeout"),
397 P_("Time after which the cursor stops blinking, in seconds"),
398 1, G_MAXINT, G_MAXINT,
399 GTK_PARAM_READWRITE),
401 g_assert (result == PROP_CURSOR_BLINK_TIMEOUT);
402 result = settings_install_property_parser (class,
403 g_param_spec_boolean ("gtk-split-cursor",
405 P_("Whether two cursors should be displayed for mixed left-to-right and right-to-left text"),
407 GTK_PARAM_READWRITE),
409 g_assert (result == PROP_SPLIT_CURSOR);
410 result = settings_install_property_parser (class,
411 g_param_spec_string ("gtk-theme-name",
413 P_("Name of theme to load"),
415 _gtk_win32_theme_get_default (),
419 GTK_PARAM_READWRITE),
421 g_assert (result == PROP_THEME_NAME);
423 result = settings_install_property_parser (class,
424 g_param_spec_string ("gtk-icon-theme-name",
425 P_("Icon Theme Name"),
426 P_("Name of icon theme to use"),
428 GTK_PARAM_READWRITE),
430 g_assert (result == PROP_ICON_THEME_NAME);
432 result = settings_install_property_parser (class,
433 g_param_spec_string ("gtk-fallback-icon-theme",
434 P_("Fallback Icon Theme Name"),
435 P_("Name of a icon theme to fall back to"),
437 GTK_PARAM_READWRITE),
439 g_assert (result == PROP_FALLBACK_ICON_THEME);
441 result = settings_install_property_parser (class,
442 g_param_spec_string ("gtk-key-theme-name",
443 P_("Key Theme Name"),
444 P_("Name of key theme to load"),
446 GTK_PARAM_READWRITE),
448 g_assert (result == PROP_KEY_THEME_NAME);
450 result = settings_install_property_parser (class,
451 g_param_spec_string ("gtk-menu-bar-accel",
452 P_("Menu bar accelerator"),
453 P_("Keybinding to activate the menu bar"),
455 GTK_PARAM_READWRITE),
457 g_assert (result == PROP_MENU_BAR_ACCEL);
459 result = settings_install_property_parser (class,
460 g_param_spec_int ("gtk-dnd-drag-threshold",
461 P_("Drag threshold"),
462 P_("Number of pixels the cursor can move before dragging"),
464 GTK_PARAM_READWRITE),
466 g_assert (result == PROP_DND_DRAG_THRESHOLD);
468 result = settings_install_property_parser (class,
469 g_param_spec_string ("gtk-font-name",
471 P_("Name of default font to use"),
473 GTK_PARAM_READWRITE),
475 g_assert (result == PROP_FONT_NAME);
478 * GtkSettings:gtk-icon-sizes:
480 * A list of icon sizes. The list is separated by colons, and
483 * <replaceable>size-name</replaceable> = <replaceable>width</replaceable> , <replaceable>height</replaceable>
485 * E.g. "gtk-menu=16,16:gtk-button=20,20:gtk-dialog=48,48".
486 * GTK+ itself use the following named icon sizes: gtk-menu,
487 * gtk-button, gtk-small-toolbar, gtk-large-toolbar, gtk-dnd,
488 * gtk-dialog. Applications can register their own named icon
489 * sizes with gtk_icon_size_register().
491 result = settings_install_property_parser (class,
492 g_param_spec_string ("gtk-icon-sizes",
494 P_("List of icon sizes (gtk-menu=16,16:gtk-button=20,20..."),
496 GTK_PARAM_READWRITE),
498 g_assert (result == PROP_ICON_SIZES);
500 result = settings_install_property_parser (class,
501 g_param_spec_string ("gtk-modules",
503 P_("List of currently active GTK modules"),
505 GTK_PARAM_READWRITE),
507 g_assert (result == PROP_MODULES);
509 result = settings_install_property_parser (class,
510 g_param_spec_int ("gtk-xft-antialias",
512 P_("Whether to antialias Xft fonts; 0=no, 1=yes, -1=default"),
514 GTK_PARAM_READWRITE),
517 g_assert (result == PROP_XFT_ANTIALIAS);
519 result = settings_install_property_parser (class,
520 g_param_spec_int ("gtk-xft-hinting",
522 P_("Whether to hint Xft fonts; 0=no, 1=yes, -1=default"),
524 GTK_PARAM_READWRITE),
527 g_assert (result == PROP_XFT_HINTING);
529 result = settings_install_property_parser (class,
530 g_param_spec_string ("gtk-xft-hintstyle",
531 P_("Xft Hint Style"),
532 P_("What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull"),
534 GTK_PARAM_READWRITE),
537 g_assert (result == PROP_XFT_HINTSTYLE);
539 result = settings_install_property_parser (class,
540 g_param_spec_string ("gtk-xft-rgba",
542 P_("Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr"),
544 GTK_PARAM_READWRITE),
547 g_assert (result == PROP_XFT_RGBA);
549 result = settings_install_property_parser (class,
550 g_param_spec_int ("gtk-xft-dpi",
552 P_("Resolution for Xft, in 1024 * dots/inch. -1 to use default value"),
554 GTK_PARAM_READWRITE),
557 g_assert (result == PROP_XFT_DPI);
559 result = settings_install_property_parser (class,
560 g_param_spec_string ("gtk-cursor-theme-name",
561 P_("Cursor theme name"),
562 P_("Name of the cursor theme to use, or NULL to use the default theme"),
564 GTK_PARAM_READWRITE),
566 g_assert (result == PROP_CURSOR_THEME_NAME);
568 result = settings_install_property_parser (class,
569 g_param_spec_int ("gtk-cursor-theme-size",
570 P_("Cursor theme size"),
571 P_("Size to use for cursors, or 0 to use the default size"),
573 GTK_PARAM_READWRITE),
576 g_assert (result == PROP_CURSOR_THEME_SIZE);
578 result = settings_install_property_parser (class,
579 g_param_spec_boolean ("gtk-alternative-button-order",
580 P_("Alternative button order"),
581 P_("Whether buttons in dialogs should use the alternative button order"),
583 GTK_PARAM_READWRITE),
585 g_assert (result == PROP_ALTERNATIVE_BUTTON_ORDER);
588 * GtkSettings:gtk-alternative-sort-arrows:
590 * Controls the direction of the sort indicators in sorted list and tree
591 * views. By default an arrow pointing down means the column is sorted
592 * in ascending order. When set to %TRUE, this order will be inverted.
596 result = settings_install_property_parser (class,
597 g_param_spec_boolean ("gtk-alternative-sort-arrows",
598 P_("Alternative sort indicator direction"),
599 P_("Whether the direction of the sort indicators in list and tree views is inverted compared to the default (where down means ascending)"),
601 GTK_PARAM_READWRITE),
603 g_assert (result == PROP_ALTERNATIVE_SORT_ARROWS);
605 result = settings_install_property_parser (class,
606 g_param_spec_boolean ("gtk-show-input-method-menu",
607 P_("Show the 'Input Methods' menu"),
608 P_("Whether the context menus of entries and text views should offer to change the input method"),
610 GTK_PARAM_READWRITE),
612 g_assert (result == PROP_SHOW_INPUT_METHOD_MENU);
614 result = settings_install_property_parser (class,
615 g_param_spec_boolean ("gtk-show-unicode-menu",
616 P_("Show the 'Insert Unicode Control Character' menu"),
617 P_("Whether the context menus of entries and text views should offer to insert control characters"),
619 GTK_PARAM_READWRITE),
621 g_assert (result == PROP_SHOW_UNICODE_MENU);
623 result = settings_install_property_parser (class,
624 g_param_spec_int ("gtk-timeout-initial",
626 P_("Starting value for timeouts, when button is pressed"),
627 0, G_MAXINT, DEFAULT_TIMEOUT_INITIAL,
628 GTK_PARAM_READWRITE),
631 g_assert (result == PROP_TIMEOUT_INITIAL);
633 result = settings_install_property_parser (class,
634 g_param_spec_int ("gtk-timeout-repeat",
635 P_("Repeat timeout"),
636 P_("Repeat value for timeouts, when button is pressed"),
637 0, G_MAXINT, DEFAULT_TIMEOUT_REPEAT,
638 GTK_PARAM_READWRITE),
641 g_assert (result == PROP_TIMEOUT_REPEAT);
643 result = settings_install_property_parser (class,
644 g_param_spec_int ("gtk-timeout-expand",
645 P_("Expand timeout"),
646 P_("Expand value for timeouts, when a widget is expanding a new region"),
647 0, G_MAXINT, DEFAULT_TIMEOUT_EXPAND,
648 GTK_PARAM_READWRITE),
651 g_assert (result == PROP_TIMEOUT_EXPAND);
654 * GtkSettings:gtk-color-scheme:
656 * A palette of named colors for use in themes. The format of the string is
662 * Color names must be acceptable as identifiers in the
663 * <link linkend="gtk-Resource-Files">gtkrc</link> syntax, and
664 * color specifications must be in the format accepted by
667 * Note that due to the way the color tables from different sources are
668 * merged, color specifications will be converted to hexadecimal form
669 * when getting this property.
671 * Starting with GTK+ 2.12, the entries can alternatively be separated
672 * by ';' instead of newlines:
674 * name1: color1; name2: color2; ...
679 result = settings_install_property_parser (class,
680 g_param_spec_string ("gtk-color-scheme",
682 P_("A palette of named colors for use in themes"),
684 GTK_PARAM_READWRITE),
687 g_assert (result == PROP_COLOR_SCHEME);
689 result = settings_install_property_parser (class,
690 g_param_spec_boolean ("gtk-enable-animations",
691 P_("Enable Animations"),
692 P_("Whether to enable toolkit-wide animations."),
694 GTK_PARAM_READWRITE),
697 g_assert (result == PROP_ENABLE_ANIMATIONS);
700 * GtkSettings:gtk-touchscreen-mode:
702 * When %TRUE, there are no motion notify events delivered on this screen,
703 * and widgets can't use the pointer hovering them for any essential
708 * Deprecated: 3.4. Generally the behavior touchscreen input should be
709 * performed dynamically based on gdk_event_get_source_device().
711 result = settings_install_property_parser (class,
712 g_param_spec_boolean ("gtk-touchscreen-mode",
713 P_("Enable Touchscreen Mode"),
714 P_("When TRUE, there are no motion notify events delivered on this screen"),
716 GTK_PARAM_READWRITE | G_PARAM_DEPRECATED),
719 g_assert (result == PROP_TOUCHSCREEN_MODE);
722 * GtkSettings:gtk-tooltip-timeout:
724 * Time, in milliseconds, after which a tooltip could appear if the
725 * cursor is hovering on top of a widget.
729 result = settings_install_property_parser (class,
730 g_param_spec_int ("gtk-tooltip-timeout",
731 P_("Tooltip timeout"),
732 P_("Timeout before tooltip is shown"),
735 GTK_PARAM_READWRITE),
738 g_assert (result == PROP_TOOLTIP_TIMEOUT);
741 * GtkSettings:gtk-tooltip-browse-timeout:
743 * Controls the time after which tooltips will appear when
744 * browse mode is enabled, in milliseconds.
746 * Browse mode is enabled when the mouse pointer moves off an object
747 * where a tooltip was currently being displayed. If the mouse pointer
748 * hits another object before the browse mode timeout expires (see
749 * #GtkSettings:gtk-tooltip-browse-mode-timeout), it will take the
750 * amount of milliseconds specified by this setting to popup the tooltip
751 * for the new object.
755 result = settings_install_property_parser (class,
756 g_param_spec_int ("gtk-tooltip-browse-timeout",
757 P_("Tooltip browse timeout"),
758 P_("Timeout before tooltip is shown when browse mode is enabled"),
761 GTK_PARAM_READWRITE),
764 g_assert (result == PROP_TOOLTIP_BROWSE_TIMEOUT);
767 * GtkSettings:gtk-tooltip-browse-mode-timeout:
769 * Amount of time, in milliseconds, after which the browse mode
772 * See #GtkSettings:gtk-tooltip-browse-timeout for more information
777 result = settings_install_property_parser (class,
778 g_param_spec_int ("gtk-tooltip-browse-mode-timeout",
779 P_("Tooltip browse mode timeout"),
780 P_("Timeout after which browse mode is disabled"),
783 GTK_PARAM_READWRITE),
786 g_assert (result == PROP_TOOLTIP_BROWSE_MODE_TIMEOUT);
789 * GtkSettings:gtk-keynav-cursor-only:
791 * When %TRUE, keyboard navigation should be able to reach all widgets
792 * by using the cursor keys only. Tab, Shift etc. keys can't be expected
793 * to be present on the used input device.
797 result = settings_install_property_parser (class,
798 g_param_spec_boolean ("gtk-keynav-cursor-only",
799 P_("Keynav Cursor Only"),
800 P_("When TRUE, there are only cursor keys available to navigate widgets"),
802 GTK_PARAM_READWRITE),
805 g_assert (result == PROP_KEYNAV_CURSOR_ONLY);
808 * GtkSettings:gtk-keynav-wrap-around:
810 * When %TRUE, some widgets will wrap around when doing keyboard
811 * navigation, such as menus, menubars and notebooks.
815 result = settings_install_property_parser (class,
816 g_param_spec_boolean ("gtk-keynav-wrap-around",
817 P_("Keynav Wrap Around"),
818 P_("Whether to wrap around when keyboard-navigating widgets"),
820 GTK_PARAM_READWRITE),
823 g_assert (result == PROP_KEYNAV_WRAP_AROUND);
826 * GtkSettings:gtk-error-bell:
828 * When %TRUE, keyboard navigation and other input-related errors
829 * will cause a beep. Since the error bell is implemented using
830 * gdk_window_beep(), the windowing system may offer ways to
831 * configure the error bell in many ways, such as flashing the
832 * window or similar visual effects.
836 result = settings_install_property_parser (class,
837 g_param_spec_boolean ("gtk-error-bell",
839 P_("When TRUE, keyboard navigation and other errors will cause a beep"),
841 GTK_PARAM_READWRITE),
844 g_assert (result == PROP_ERROR_BELL);
847 * GtkSettings:color-hash:
849 * Holds a hash table representation of the #GtkSettings:gtk-color-scheme
850 * setting, mapping color names to #GdkColor<!-- -->s.
854 result = settings_install_property_parser (class,
855 g_param_spec_boxed ("color-hash",
857 P_("A hash table representation of the color scheme."),
861 g_assert (result == PROP_COLOR_HASH);
863 result = settings_install_property_parser (class,
864 g_param_spec_string ("gtk-file-chooser-backend",
865 P_("Default file chooser backend"),
866 P_("Name of the GtkFileChooser backend to use by default"),
868 GTK_PARAM_READWRITE),
870 g_assert (result == PROP_FILE_CHOOSER_BACKEND);
873 * GtkSettings:gtk-print-backends:
875 * A comma-separated list of print backends to use in the print
876 * dialog. Available print backends depend on the GTK+ installation,
877 * and may include "file", "cups", "lpr" or "papi".
881 result = settings_install_property_parser (class,
882 g_param_spec_string ("gtk-print-backends",
883 P_("Default print backend"),
884 P_("List of the GtkPrintBackend backends to use by default"),
886 GTK_PARAM_READWRITE),
888 g_assert (result == PROP_PRINT_BACKENDS);
891 * GtkSettings:gtk-print-preview-command:
893 * A command to run for displaying the print preview. The command
894 * should contain a %f placeholder, which will get replaced by
895 * the path to the pdf file. The command may also contain a %s
896 * placeholder, which will get replaced by the path to a file
897 * containing the print settings in the format produced by
898 * gtk_print_settings_to_file().
900 * The preview application is responsible for removing the pdf file
901 * and the print settings file when it is done.
905 result = settings_install_property_parser (class,
906 g_param_spec_string ("gtk-print-preview-command",
907 P_("Default command to run when displaying a print preview"),
908 P_("Command to run when displaying a print preview"),
909 GTK_PRINT_PREVIEW_COMMAND,
910 GTK_PARAM_READWRITE),
912 g_assert (result == PROP_PRINT_PREVIEW_COMMAND);
915 * GtkSettings:gtk-enable-mnemonics:
917 * Whether labels and menu items should have visible mnemonics which
922 result = settings_install_property_parser (class,
923 g_param_spec_boolean ("gtk-enable-mnemonics",
924 P_("Enable Mnemonics"),
925 P_("Whether labels should have mnemonics"),
927 GTK_PARAM_READWRITE),
929 g_assert (result == PROP_ENABLE_MNEMONICS);
932 * GtkSettings:gtk-enable-accels:
934 * Whether menu items should have visible accelerators which can be
939 result = settings_install_property_parser (class,
940 g_param_spec_boolean ("gtk-enable-accels",
941 P_("Enable Accelerators"),
942 P_("Whether menu items should have accelerators"),
944 GTK_PARAM_READWRITE),
946 g_assert (result == PROP_ENABLE_ACCELS);
949 * GtkSettings:gtk-recent-files-limit:
951 * The number of recently used files that should be displayed by default by
952 * #GtkRecentChooser implementations and by the #GtkFileChooser. A value of
953 * -1 means every recently used file stored.
957 result = settings_install_property_parser (class,
958 g_param_spec_int ("gtk-recent-files-limit",
959 P_("Recent Files Limit"),
960 P_("Number of recently used files"),
963 GTK_PARAM_READWRITE),
965 g_assert (result == PROP_RECENT_FILES_LIMIT);
968 * GtkSettings:gtk-im-module:
970 * Which IM (input method) module should be used by default. This is the
971 * input method that will be used if the user has not explicitly chosen
972 * another input method from the IM context menu.
973 * This also can be a colon-separated list of input methods, which GTK+
974 * will try in turn until it finds one available on the system.
976 * See #GtkIMContext and see the #GtkSettings:gtk-show-input-method-menu property.
978 result = settings_install_property_parser (class,
979 g_param_spec_string ("gtk-im-module",
980 P_("Default IM module"),
981 P_("Which IM module should be used by default"),
983 GTK_PARAM_READWRITE),
985 g_assert (result == PROP_IM_MODULE);
988 * GtkSettings:gtk-recent-files-max-age:
990 * The maximum age, in days, of the items inside the recently used
991 * resources list. Items older than this setting will be excised
992 * from the list. If set to 0, the list will always be empty; if
993 * set to -1, no item will be removed.
997 result = settings_install_property_parser (class,
998 g_param_spec_int ("gtk-recent-files-max-age",
999 P_("Recent Files Max Age"),
1000 P_("Maximum age of recently used files, in days"),
1003 GTK_PARAM_READWRITE),
1005 g_assert (result == PROP_RECENT_FILES_MAX_AGE);
1007 result = settings_install_property_parser (class,
1008 g_param_spec_uint ("gtk-fontconfig-timestamp",
1009 P_("Fontconfig configuration timestamp"),
1010 P_("Timestamp of current fontconfig configuration"),
1012 GTK_PARAM_READWRITE),
1015 g_assert (result == PROP_FONTCONFIG_TIMESTAMP);
1018 * GtkSettings:gtk-sound-theme-name:
1020 * The XDG sound theme to use for event sounds.
1022 * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
1023 * for more information on event sounds and sound themes.
1025 * GTK+ itself does not support event sounds, you have to use a loadable
1026 * module like the one that comes with libcanberra.
1030 result = settings_install_property_parser (class,
1031 g_param_spec_string ("gtk-sound-theme-name",
1032 P_("Sound Theme Name"),
1033 P_("XDG sound theme name"),
1035 GTK_PARAM_READWRITE),
1037 g_assert (result == PROP_SOUND_THEME_NAME);
1040 * GtkSettings:gtk-enable-input-feedback-sounds:
1042 * Whether to play event sounds as feedback to user input.
1044 * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
1045 * for more information on event sounds and sound themes.
1047 * GTK+ itself does not support event sounds, you have to use a loadable
1048 * module like the one that comes with libcanberra.
1052 result = settings_install_property_parser (class,
1053 g_param_spec_boolean ("gtk-enable-input-feedback-sounds",
1054 /* Translators: this means sounds that are played as feedback to user input */
1055 P_("Audible Input Feedback"),
1056 P_("Whether to play event sounds as feedback to user input"),
1058 GTK_PARAM_READWRITE),
1060 g_assert (result == PROP_ENABLE_INPUT_FEEDBACK_SOUNDS);
1063 * GtkSettings:gtk-enable-event-sounds:
1065 * Whether to play any event sounds at all.
1067 * See the <ulink url="http://www.freedesktop.org/wiki/Specifications/sound-theme-spec">Sound Theme spec</ulink>
1068 * for more information on event sounds and sound themes.
1070 * GTK+ itself does not support event sounds, you have to use a loadable
1071 * module like the one that comes with libcanberra.
1075 result = settings_install_property_parser (class,
1076 g_param_spec_boolean ("gtk-enable-event-sounds",
1077 P_("Enable Event Sounds"),
1078 P_("Whether to play any event sounds at all"),
1080 GTK_PARAM_READWRITE),
1082 g_assert (result == PROP_ENABLE_EVENT_SOUNDS);
1085 * GtkSettings:gtk-enable-tooltips:
1087 * Whether tooltips should be shown on widgets.
1091 result = settings_install_property_parser (class,
1092 g_param_spec_boolean ("gtk-enable-tooltips",
1093 P_("Enable Tooltips"),
1094 P_("Whether tooltips should be shown on widgets"),
1096 GTK_PARAM_READWRITE),
1098 g_assert (result == PROP_ENABLE_TOOLTIPS);
1101 * GtkSettings:gtk-toolbar-style:
1103 * The size of icons in default toolbars.
1105 result = settings_install_property_parser (class,
1106 g_param_spec_enum ("gtk-toolbar-style",
1107 P_("Toolbar style"),
1108 P_("Whether default toolbars have text only, text and icons, icons only, etc."),
1109 GTK_TYPE_TOOLBAR_STYLE,
1111 GTK_PARAM_READWRITE),
1112 gtk_rc_property_parse_enum);
1113 g_assert (result == PROP_TOOLBAR_STYLE);
1116 * GtkSettings:gtk-toolbar-icon-size:
1118 * The size of icons in default toolbars.
1120 result = settings_install_property_parser (class,
1121 g_param_spec_enum ("gtk-toolbar-icon-size",
1122 P_("Toolbar Icon Size"),
1123 P_("The size of icons in default toolbars."),
1125 GTK_ICON_SIZE_LARGE_TOOLBAR,
1126 GTK_PARAM_READWRITE),
1127 gtk_rc_property_parse_enum);
1128 g_assert (result == PROP_TOOLBAR_ICON_SIZE);
1131 * GtkSettings:gtk-auto-mnemonics:
1133 * Whether mnemonics should be automatically shown and hidden when the user
1134 * presses the mnemonic activator.
1138 result = settings_install_property_parser (class,
1139 g_param_spec_boolean ("gtk-auto-mnemonics",
1140 P_("Auto Mnemonics"),
1141 P_("Whether mnemonics should be automatically shown and hidden when the user presses the mnemonic activator."),
1143 GTK_PARAM_READWRITE),
1145 g_assert (result == PROP_AUTO_MNEMONICS);
1148 * GtkSettings:gtk-visible-focus:
1150 * Whether 'focus rectangles' should be always visible, never visible,
1151 * or hidden until the user starts to use the keyboard.
1155 result = settings_install_property_parser (class,
1156 g_param_spec_enum ("gtk-visible-focus",
1157 P_("Visible Focus"),
1158 P_("Whether 'focus rectangles' should be hidden until the user starts to use the keyboard."),
1159 GTK_TYPE_POLICY_TYPE,
1161 GTK_PARAM_READWRITE),
1162 gtk_rc_property_parse_enum);
1163 g_assert (result == PROP_VISIBLE_FOCUS);
1166 * GtkSettings:gtk-application-prefer-dark-theme:
1168 * Whether the application prefers to use a dark theme. If a GTK+ theme
1169 * includes a dark variant, it will be used instead of the configured
1172 * Some applications benefit from minimizing the amount of light pollution that
1173 * interferes with the content. Good candidates for dark themes are photo and
1174 * video editors that make the actual content get all the attention and minimize
1175 * the distraction of the chrome.
1177 * Dark themes should not be used for documents, where large spaces are white/light
1178 * and the dark chrome creates too much contrast (web browser, text editor...).
1182 result = settings_install_property_parser (class,
1183 g_param_spec_boolean ("gtk-application-prefer-dark-theme",
1184 P_("Application prefers a dark theme"),
1185 P_("Whether the application prefers to have a dark theme."),
1187 GTK_PARAM_READWRITE),
1189 g_assert (result == PROP_APPLICATION_PREFER_DARK_THEME);
1192 * GtkSettings::gtk-button-images:
1194 * Whether images should be shown on buttons
1198 result = settings_install_property_parser (class,
1199 g_param_spec_boolean ("gtk-button-images",
1200 P_("Show button images"),
1201 P_("Whether images should be shown on buttons"),
1203 GTK_PARAM_READWRITE),
1205 g_assert (result == PROP_BUTTON_IMAGES);
1207 result = settings_install_property_parser (class,
1208 g_param_spec_boolean ("gtk-entry-select-on-focus",
1209 P_("Select on focus"),
1210 P_("Whether to select the contents of an entry when it is focused"),
1212 GTK_PARAM_READWRITE),
1214 g_assert (result == PROP_ENTRY_SELECT_ON_FOCUS);
1217 * GtkSettings:gtk-entry-password-hint-timeout:
1219 * How long to show the last input character in hidden
1220 * entries. This value is in milliseconds. 0 disables showing the
1221 * last char. 600 is a good value for enabling it.
1225 result = settings_install_property_parser (class,
1226 g_param_spec_uint ("gtk-entry-password-hint-timeout",
1227 P_("Password Hint Timeout"),
1228 P_("How long to show the last input character in hidden entries"),
1231 GTK_PARAM_READWRITE),
1233 g_assert (result == PROP_ENTRY_PASSWORD_HINT_TIMEOUT);
1235 result = settings_install_property_parser (class,
1236 g_param_spec_boolean ("gtk-menu-images",
1237 P_("Show menu images"),
1238 P_("Whether images should be shown in menus"),
1240 GTK_PARAM_READWRITE),
1242 g_assert (result == PROP_MENU_IMAGES);
1244 result = settings_install_property_parser (class,
1245 g_param_spec_int ("gtk-menu-bar-popup-delay",
1246 P_("Delay before drop down menus appear"),
1247 P_("Delay before the submenus of a menu bar appear"),
1250 GTK_PARAM_READWRITE),
1252 g_assert (result == PROP_MENU_BAR_POPUP_DELAY);
1255 * GtkSettings:gtk-scrolled-window-placement:
1257 * Where the contents of scrolled windows are located with respect to the
1258 * scrollbars, if not overridden by the scrolled window's own placement.
1262 result = settings_install_property_parser (class,
1263 g_param_spec_enum ("gtk-scrolled-window-placement",
1264 P_("Scrolled Window Placement"),
1265 P_("Where the contents of scrolled windows are located with respect to the scrollbars, if not overridden by the scrolled window's own placement."),
1266 GTK_TYPE_CORNER_TYPE,
1267 GTK_CORNER_TOP_LEFT,
1268 GTK_PARAM_READWRITE),
1269 gtk_rc_property_parse_enum);
1270 g_assert (result == PROP_SCROLLED_WINDOW_PLACEMENT);
1272 result = settings_install_property_parser (class,
1273 g_param_spec_boolean ("gtk-can-change-accels",
1274 P_("Can change accelerators"),
1275 P_("Whether menu accelerators can be changed by pressing a key over the menu item"),
1277 GTK_PARAM_READWRITE),
1279 g_assert (result == PROP_CAN_CHANGE_ACCELS);
1281 result = settings_install_property_parser (class,
1282 g_param_spec_int ("gtk-menu-popup-delay",
1283 P_("Delay before submenus appear"),
1284 P_("Minimum time the pointer must stay over a menu item before the submenu appear"),
1287 GTK_PARAM_READWRITE),
1289 g_assert (result == PROP_MENU_POPUP_DELAY);
1291 result = settings_install_property_parser (class,
1292 g_param_spec_int ("gtk-menu-popdown-delay",
1293 P_("Delay before hiding a submenu"),
1294 P_("The time before hiding a submenu when the pointer is moving towards the submenu"),
1297 GTK_PARAM_READWRITE),
1299 g_assert (result == PROP_MENU_POPDOWN_DELAY);
1301 result = settings_install_property_parser (class,
1302 g_param_spec_boolean ("gtk-label-select-on-focus",
1303 P_("Select on focus"),
1304 P_("Whether to select the contents of a selectable label when it is focused"),
1306 GTK_PARAM_READWRITE),
1308 g_assert (result == PROP_LABEL_SELECT_ON_FOCUS);
1310 result = settings_install_property_parser (class,
1311 g_param_spec_string ("gtk-color-palette",
1312 P_("Custom palette"),
1313 P_("Palette to use in the color selector"),
1314 default_color_palette,
1315 GTK_PARAM_READWRITE),
1317 g_assert (result == PROP_COLOR_PALETTE);
1319 result = settings_install_property_parser (class,
1320 g_param_spec_enum ("gtk-im-preedit-style",
1321 P_("IM Preedit style"),
1322 P_("How to draw the input method preedit string"),
1323 GTK_TYPE_IM_PREEDIT_STYLE,
1324 GTK_IM_PREEDIT_CALLBACK,
1325 GTK_PARAM_READWRITE),
1326 gtk_rc_property_parse_enum);
1327 g_assert (result == PROP_IM_PREEDIT_STYLE);
1329 result = settings_install_property_parser (class,
1330 g_param_spec_enum ("gtk-im-status-style",
1331 P_("IM Status style"),
1332 P_("How to draw the input method statusbar"),
1333 GTK_TYPE_IM_STATUS_STYLE,
1334 GTK_IM_STATUS_CALLBACK,
1335 GTK_PARAM_READWRITE),
1336 gtk_rc_property_parse_enum);
1337 g_assert (result == PROP_IM_STATUS_STYLE);
1339 result = settings_install_property_parser (class,
1340 g_param_spec_boolean ("gtk-shell-shows-app-menu",
1341 P_("Desktop shell shows app menu"),
1342 P_("Set to TRUE if the desktop environment "
1343 "is displaying the app menu, FALSE if "
1344 "the app should display it itself."),
1345 FALSE, GTK_PARAM_READWRITE),
1347 g_assert (result == PROP_SHELL_SHOWS_APP_MENU);
1349 result = settings_install_property_parser (class,
1350 g_param_spec_boolean ("gtk-shell-shows-menubar",
1351 P_("Desktop shell shows the menubar"),
1352 P_("Set to TRUE if the desktop environment "
1353 "is displaying the menubar, FALSE if "
1354 "the app should display it itself."),
1355 FALSE, GTK_PARAM_READWRITE),
1357 g_assert (result == PROP_SHELL_SHOWS_MENUBAR);
1360 * GtkSettings:gtk-enable-primary-paste:
1362 * Whether a middle click on a mouse should paste the
1363 * 'PRIMARY' clipboard content at the cursor location.
1367 result = settings_install_property_parser (class,
1368 g_param_spec_boolean ("gtk-enable-primary-paste",
1369 P_("Enable primary paste"),
1370 P_("Whether a middle click on a mouse should paste the 'PRIMARY' clipboard content at the cursor location."),
1372 GTK_PARAM_READWRITE),
1374 g_assert (result == PROP_ENABLE_PRIMARY_PASTE);
1376 g_type_class_add_private (class, sizeof (GtkSettingsPrivate));
1380 settings_ensure_style (GtkSettings *settings)
1382 GtkSettingsPrivate *priv = settings->priv;
1383 PangoFontDescription *font_desc;
1384 gchar *font_name, *color_scheme;
1391 priv->style = gtk_style_properties_new ();
1393 g_object_get (settings,
1394 "gtk-font-name", &font_name,
1395 "gtk-color-scheme", &color_scheme,
1398 colors = g_strsplit_set (color_scheme, "\n;", -1);
1400 for (i = 0; colors[i]; i++)
1402 GtkSymbolicColor *color;
1410 pos = strchr (colors[i], ':');
1415 /* Set NUL after color name */
1419 /* Find start of color string */
1423 if (!*pos || !gdk_rgba_parse (&col, pos))
1426 color = gtk_symbolic_color_new_literal (&col);
1427 gtk_style_properties_map_color (priv->style, name, color);
1428 gtk_symbolic_color_unref (color);
1431 font_desc = pango_font_description_from_string (font_name);
1433 /* Unset normal attributes from this description,
1434 * so they do not override theme values */
1435 if (pango_font_description_get_weight (font_desc) == PANGO_WEIGHT_NORMAL)
1436 pango_font_description_unset_fields (font_desc,
1437 PANGO_FONT_MASK_WEIGHT);
1439 if (pango_font_description_get_stretch (font_desc) == PANGO_STRETCH_NORMAL)
1440 pango_font_description_unset_fields (font_desc,
1441 PANGO_FONT_MASK_STRETCH);
1443 if (pango_font_description_get_variant (font_desc) == PANGO_VARIANT_NORMAL)
1444 pango_font_description_unset_fields (font_desc,
1445 PANGO_FONT_MASK_VARIANT);
1447 if (pango_font_description_get_style (font_desc) == PANGO_STYLE_NORMAL)
1448 pango_font_description_unset_fields (font_desc,
1449 PANGO_FONT_MASK_STYLE);
1451 gtk_style_properties_set (priv->style, 0,
1455 pango_font_description_free (font_desc);
1456 g_strfreev (colors);
1457 g_free (color_scheme);
1461 static GtkStyleProperties *
1462 gtk_settings_get_style (GtkStyleProvider *provider,
1463 GtkWidgetPath *path)
1465 GtkSettings *settings;
1467 settings = GTK_SETTINGS (provider);
1469 settings_ensure_style (settings);
1471 return g_object_ref (settings->priv->style);
1475 gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
1477 iface->get_style = gtk_settings_get_style;
1480 static GtkSymbolicColor *
1481 gtk_settings_style_provider_get_color (GtkStyleProviderPrivate *provider,
1484 GtkSettings *settings = GTK_SETTINGS (provider);
1486 settings_ensure_style (settings);
1488 return _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style), name);
1492 gtk_settings_style_provider_lookup (GtkStyleProviderPrivate *provider,
1493 const GtkCssMatcher *matcher,
1494 GtkCssLookup *lookup)
1496 GtkSettings *settings = GTK_SETTINGS (provider);
1498 settings_ensure_style (settings);
1500 _gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style),
1506 gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider,
1507 const GtkCssMatcher *matcher)
1509 GtkSettings *settings = GTK_SETTINGS (provider);
1511 settings_ensure_style (settings);
1513 return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style),
1518 gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface)
1520 iface->get_color = gtk_settings_style_provider_get_color;
1521 iface->lookup = gtk_settings_style_provider_lookup;
1522 iface->get_change = gtk_settings_style_provider_get_change;
1526 gtk_settings_finalize (GObject *object)
1528 GtkSettings *settings = GTK_SETTINGS (object);
1529 GtkSettingsPrivate *priv = settings->priv;
1532 object_list = g_slist_remove (object_list, settings);
1534 for (i = 0; i < class_n_properties; i++)
1535 g_value_unset (&priv->property_values[i].value);
1536 g_free (priv->property_values);
1538 g_datalist_clear (&priv->queued_settings);
1540 if (priv->theme_provider)
1541 g_object_unref (priv->theme_provider);
1543 if (priv->key_theme_provider)
1544 g_object_unref (priv->key_theme_provider);
1547 g_object_unref (priv->style);
1549 G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object);
1553 settings_init_style (GtkSettings *settings)
1555 static GtkCssProvider *css_provider = NULL;
1557 GdkScreen *screen = settings->priv->screen;
1559 /* Add provider for user file */
1560 if (G_UNLIKELY (!css_provider))
1564 css_provider = gtk_css_provider_new ();
1565 css_path = g_build_filename (g_get_user_config_dir (),
1570 if (g_file_test (css_path,
1571 G_FILE_TEST_IS_REGULAR))
1572 gtk_css_provider_load_from_path (css_provider, css_path, NULL);
1577 gtk_style_context_add_provider_for_screen (screen,
1578 GTK_STYLE_PROVIDER (css_provider),
1579 GTK_STYLE_PROVIDER_PRIORITY_USER);
1581 gtk_style_context_add_provider_for_screen (screen,
1582 GTK_STYLE_PROVIDER (settings),
1583 GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
1585 settings_update_theme (settings);
1586 settings_update_key_theme (settings);
1590 * gtk_settings_get_for_screen:
1591 * @screen: a #GdkScreen.
1593 * Gets the #GtkSettings object for @screen, creating it if necessary.
1595 * Return value: (transfer none): a #GtkSettings object.
1600 gtk_settings_get_for_screen (GdkScreen *screen)
1602 GtkSettings *settings;
1604 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
1606 settings = g_object_get_data (G_OBJECT (screen), "gtk-settings");
1609 #ifdef GDK_WINDOWING_QUARTZ
1610 if (GDK_IS_QUARTZ_SCREEN (screen))
1611 settings = g_object_new (GTK_TYPE_SETTINGS,
1612 "gtk-key-theme-name", "Mac",
1613 "gtk-shell-shows-app-menu", TRUE,
1614 "gtk-shell-shows-menubar", TRUE,
1618 settings = g_object_new (GTK_TYPE_SETTINGS, NULL);
1619 settings->priv->screen = screen;
1620 g_object_set_data_full (G_OBJECT (screen), I_("gtk-settings"),
1621 settings, g_object_unref);
1623 settings_init_style (settings);
1624 settings_update_double_click (settings);
1625 settings_update_cursor_theme (settings);
1626 settings_update_resolution (settings);
1627 settings_update_font_options (settings);
1628 settings_update_color_scheme (settings);
1635 * gtk_settings_get_default:
1637 * Gets the #GtkSettings object for the default GDK screen, creating
1638 * it if necessary. See gtk_settings_get_for_screen().
1640 * Return value: (transfer none): a #GtkSettings object. If there is no default
1641 * screen, then returns %NULL.
1644 gtk_settings_get_default (void)
1646 GdkScreen *screen = gdk_screen_get_default ();
1649 return gtk_settings_get_for_screen (screen);
1655 gtk_settings_set_property (GObject *object,
1657 const GValue *value,
1660 GtkSettings *settings = GTK_SETTINGS (object);
1661 GtkSettingsPrivate *priv = settings->priv;
1663 g_value_copy (value, &priv->property_values[property_id - 1].value);
1664 priv->property_values[property_id - 1].source = GTK_SETTINGS_SOURCE_APPLICATION;
1666 if (pspec->param_id == PROP_COLOR_SCHEME)
1667 merge_color_scheme (settings, value, GTK_SETTINGS_SOURCE_APPLICATION);
1671 gtk_settings_get_property (GObject *object,
1676 GtkSettings *settings = GTK_SETTINGS (object);
1677 GtkSettingsPrivate *priv = settings->priv;
1678 GType value_type = G_VALUE_TYPE (value);
1679 GType fundamental_type = G_TYPE_FUNDAMENTAL (value_type);
1681 /* handle internal properties */
1682 switch (property_id)
1684 case PROP_COLOR_HASH:
1685 g_value_set_boxed (value, get_color_hash (settings));
1687 case PROP_COLOR_SCHEME:
1688 g_value_take_string (value, get_color_scheme (settings));
1693 /* For enums and strings, we need to get the value as a string,
1694 * not as an int, since we support using names/nicks as the setting
1697 if ((g_value_type_transformable (G_TYPE_INT, value_type) &&
1698 !(fundamental_type == G_TYPE_ENUM || fundamental_type == G_TYPE_FLAGS)) ||
1699 g_value_type_transformable (G_TYPE_STRING, G_VALUE_TYPE (value)) ||
1700 g_value_type_transformable (GDK_TYPE_COLOR, G_VALUE_TYPE (value)))
1702 if (priv->property_values[property_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION ||
1703 !gdk_screen_get_setting (priv->screen, pspec->name, value))
1704 g_value_copy (&priv->property_values[property_id - 1].value, value);
1706 g_param_value_validate (pspec, value);
1710 GValue val = G_VALUE_INIT;
1712 /* Try to get xsetting as a string and parse it. */
1714 g_value_init (&val, G_TYPE_STRING);
1716 if (priv->property_values[property_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION ||
1717 !gdk_screen_get_setting (priv->screen, pspec->name, &val))
1719 g_value_copy (&priv->property_values[property_id - 1].value, value);
1723 GValue tmp_value = G_VALUE_INIT;
1724 GValue gstring_value = G_VALUE_INIT;
1725 GtkRcPropertyParser parser = (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser);
1727 g_value_init (&gstring_value, G_TYPE_GSTRING);
1728 g_value_take_boxed (&gstring_value,
1729 g_string_new (g_value_get_string (&val)));
1731 g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1733 if (parser && _gtk_settings_parse_convert (parser, &gstring_value,
1736 g_value_copy (&tmp_value, value);
1737 g_param_value_validate (pspec, value);
1741 g_value_copy (&priv->property_values[property_id - 1].value, value);
1744 g_value_unset (&gstring_value);
1745 g_value_unset (&tmp_value);
1748 g_value_unset (&val);
1753 settings_invalidate_style (GtkSettings *settings)
1755 GtkSettingsPrivate *priv = settings->priv;
1759 g_object_unref (priv->style);
1763 _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (settings));
1767 gtk_settings_notify (GObject *object,
1770 GtkSettings *settings = GTK_SETTINGS (object);
1771 GtkSettingsPrivate *priv = settings->priv;
1772 guint property_id = pspec->param_id;
1774 if (priv->screen == NULL) /* initialization */
1777 switch (property_id)
1780 settings_update_modules (settings);
1782 case PROP_DOUBLE_CLICK_TIME:
1783 case PROP_DOUBLE_CLICK_DISTANCE:
1784 settings_update_double_click (settings);
1786 case PROP_COLOR_SCHEME:
1787 settings_update_color_scheme (settings);
1788 settings_invalidate_style (settings);
1789 gtk_style_context_reset_widgets (priv->screen);
1791 case PROP_FONT_NAME:
1792 settings_invalidate_style (settings);
1793 gtk_style_context_reset_widgets (priv->screen);
1795 case PROP_KEY_THEME_NAME:
1796 settings_update_key_theme (settings);
1798 case PROP_THEME_NAME:
1799 case PROP_APPLICATION_PREFER_DARK_THEME:
1800 settings_update_theme (settings);
1803 settings_update_resolution (settings);
1804 /* This is a hack because with gtk_rc_reset_styles() doesn't get
1805 * widgets with gtk_widget_style_set(), and also causes more
1806 * recomputation than necessary.
1808 gtk_style_context_reset_widgets (priv->screen);
1810 case PROP_XFT_ANTIALIAS:
1811 case PROP_XFT_HINTING:
1812 case PROP_XFT_HINTSTYLE:
1814 settings_update_font_options (settings);
1815 gtk_style_context_reset_widgets (priv->screen);
1817 case PROP_FONTCONFIG_TIMESTAMP:
1818 if (settings_update_fontconfig (settings))
1819 gtk_style_context_reset_widgets (priv->screen);
1821 case PROP_CURSOR_THEME_NAME:
1822 case PROP_CURSOR_THEME_SIZE:
1823 settings_update_cursor_theme (settings);
1829 _gtk_settings_parse_convert (GtkRcPropertyParser parser,
1830 const GValue *src_value,
1834 gboolean success = FALSE;
1836 g_return_val_if_fail (G_VALUE_HOLDS (dest_value, G_PARAM_SPEC_VALUE_TYPE (pspec)), FALSE);
1841 gboolean free_gstring = TRUE;
1843 if (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING))
1845 gstring = g_value_get_boxed (src_value);
1846 free_gstring = FALSE;
1848 else if (G_VALUE_HOLDS_LONG (src_value))
1850 gstring = g_string_new (NULL);
1851 g_string_append_printf (gstring, "%ld", g_value_get_long (src_value));
1853 else if (G_VALUE_HOLDS_DOUBLE (src_value))
1855 gstring = g_string_new (NULL);
1856 g_string_append_printf (gstring, "%f", g_value_get_double (src_value));
1858 else if (G_VALUE_HOLDS_STRING (src_value))
1860 gchar *tstr = g_strescape (g_value_get_string (src_value), NULL);
1862 gstring = g_string_new (NULL);
1863 g_string_append_c (gstring, '\"');
1864 g_string_append (gstring, tstr);
1865 g_string_append_c (gstring, '\"');
1870 g_return_val_if_fail (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING), FALSE);
1871 gstring = NULL; /* silence compiler */
1874 success = (parser (pspec, gstring, dest_value) &&
1875 !g_param_value_validate (pspec, dest_value));
1878 g_string_free (gstring, TRUE);
1880 else if (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING))
1882 if (G_VALUE_HOLDS (dest_value, G_TYPE_STRING))
1884 GString *gstring = g_value_get_boxed (src_value);
1886 g_value_set_string (dest_value, gstring ? gstring->str : NULL);
1887 success = !g_param_value_validate (pspec, dest_value);
1890 else if (g_value_type_transformable (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value)))
1891 success = g_param_value_convert (pspec, src_value, dest_value, TRUE);
1897 apply_queued_setting (GtkSettings *settings,
1899 GtkSettingsValuePrivate *qvalue)
1901 GtkSettingsPrivate *priv = settings->priv;
1902 GValue tmp_value = G_VALUE_INIT;
1903 GtkRcPropertyParser parser = (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser);
1905 g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1906 if (_gtk_settings_parse_convert (parser, &qvalue->public.value,
1909 if (pspec->param_id == PROP_COLOR_SCHEME)
1910 merge_color_scheme (settings, &tmp_value, qvalue->source);
1912 if (priv->property_values[pspec->param_id - 1].source <= qvalue->source)
1914 g_value_copy (&tmp_value, &priv->property_values[pspec->param_id - 1].value);
1915 priv->property_values[pspec->param_id - 1].source = qvalue->source;
1916 g_object_notify (G_OBJECT (settings), g_param_spec_get_name (pspec));
1922 gchar *debug = g_strdup_value_contents (&qvalue->public.value);
1924 g_message ("%s: failed to retrieve property `%s' of type `%s' from rc file value \"%s\" of type `%s'",
1925 qvalue->public.origin ? qvalue->public.origin : "(for origin information, set GTK_DEBUG)",
1927 g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
1929 G_VALUE_TYPE_NAME (&tmp_value));
1932 g_value_unset (&tmp_value);
1936 settings_install_property_parser (GtkSettingsClass *class,
1938 GtkRcPropertyParser parser)
1940 GSList *node, *next;
1942 switch (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec)))
1944 case G_TYPE_BOOLEAN:
1957 if (strcmp (g_param_spec_get_name (pspec), "color-hash") == 0)
1965 g_warning (G_STRLOC ": parser needs to be specified for property \"%s\" of type `%s'",
1966 pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
1970 if (g_object_class_find_property (G_OBJECT_CLASS (class), pspec->name))
1972 g_warning (G_STRLOC ": an rc-data property \"%s\" already exists",
1977 for (node = object_list; node; node = node->next)
1978 g_object_freeze_notify (node->data);
1980 g_object_class_install_property (G_OBJECT_CLASS (class), ++class_n_properties, pspec);
1981 g_param_spec_set_qdata (pspec, quark_property_parser, (gpointer) parser);
1983 for (node = object_list; node; node = node->next)
1985 GtkSettings *settings = node->data;
1986 GtkSettingsPrivate *priv = settings->priv;
1987 GtkSettingsValuePrivate *qvalue;
1989 priv->property_values = g_renew (GtkSettingsPropertyValue, priv->property_values, class_n_properties);
1990 priv->property_values[class_n_properties - 1].value.g_type = 0;
1991 g_value_init (&priv->property_values[class_n_properties - 1].value, G_PARAM_SPEC_VALUE_TYPE (pspec));
1992 g_param_value_set_default (pspec, &priv->property_values[class_n_properties - 1].value);
1993 priv->property_values[class_n_properties - 1].source = GTK_SETTINGS_SOURCE_DEFAULT;
1994 g_object_notify (G_OBJECT (settings), pspec->name);
1996 qvalue = g_datalist_get_data (&priv->queued_settings, pspec->name);
1998 apply_queued_setting (settings, pspec, qvalue);
2001 for (node = object_list; node; node = next)
2004 g_object_thaw_notify (node->data);
2007 return class_n_properties;
2011 _gtk_rc_property_parser_from_type (GType type)
2013 if (type == GDK_TYPE_COLOR)
2014 return gtk_rc_property_parse_color;
2015 else if (type == GTK_TYPE_REQUISITION)
2016 return gtk_rc_property_parse_requisition;
2017 else if (type == GTK_TYPE_BORDER)
2018 return gtk_rc_property_parse_border;
2019 else if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM && G_TYPE_IS_DERIVED (type))
2020 return gtk_rc_property_parse_enum;
2021 else if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS && G_TYPE_IS_DERIVED (type))
2022 return gtk_rc_property_parse_flags;
2028 gtk_settings_install_property (GParamSpec *pspec)
2030 static GtkSettingsClass *klass = NULL;
2032 GtkRcPropertyParser parser;
2034 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
2037 klass = g_type_class_ref (GTK_TYPE_SETTINGS);
2039 parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
2041 settings_install_property_parser (klass, pspec, parser);
2045 * gtk_settings_install_property_parser:
2047 * @parser: (scope call):
2050 gtk_settings_install_property_parser (GParamSpec *pspec,
2051 GtkRcPropertyParser parser)
2053 static GtkSettingsClass *klass = NULL;
2055 g_return_if_fail (G_IS_PARAM_SPEC (pspec));
2056 g_return_if_fail (parser != NULL);
2059 klass = g_type_class_ref (GTK_TYPE_SETTINGS);
2061 settings_install_property_parser (klass, pspec, parser);
2065 free_value (gpointer data)
2067 GtkSettingsValuePrivate *qvalue = data;
2069 g_value_unset (&qvalue->public.value);
2070 g_free (qvalue->public.origin);
2071 g_slice_free (GtkSettingsValuePrivate, qvalue);
2075 gtk_settings_set_property_value_internal (GtkSettings *settings,
2076 const gchar *prop_name,
2077 const GtkSettingsValue *new_value,
2078 GtkSettingsSource source)
2080 GtkSettingsPrivate *priv = settings->priv;
2081 GtkSettingsValuePrivate *qvalue;
2086 if (!G_VALUE_HOLDS_LONG (&new_value->value) &&
2087 !G_VALUE_HOLDS_DOUBLE (&new_value->value) &&
2088 !G_VALUE_HOLDS_STRING (&new_value->value) &&
2089 !G_VALUE_HOLDS (&new_value->value, G_TYPE_GSTRING))
2091 g_warning (G_STRLOC ": value type invalid (%s)", g_type_name (G_VALUE_TYPE (&new_value->value)));
2095 name = g_strdup (prop_name);
2096 g_strcanon (name, G_CSET_DIGITS "-" G_CSET_a_2_z G_CSET_A_2_Z, '-');
2097 name_quark = g_quark_from_string (name);
2100 qvalue = g_datalist_id_get_data (&priv->queued_settings, name_quark);
2103 qvalue = g_slice_new0 (GtkSettingsValuePrivate);
2104 g_datalist_id_set_data_full (&priv->queued_settings, name_quark, qvalue, free_value);
2108 g_free (qvalue->public.origin);
2109 g_value_unset (&qvalue->public.value);
2111 qvalue->public.origin = g_strdup (new_value->origin);
2112 g_value_init (&qvalue->public.value, G_VALUE_TYPE (&new_value->value));
2113 g_value_copy (&new_value->value, &qvalue->public.value);
2114 qvalue->source = source;
2115 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), g_quark_to_string (name_quark));
2117 apply_queued_setting (settings, pspec, qvalue);
2121 gtk_settings_set_property_value (GtkSettings *settings,
2122 const gchar *prop_name,
2123 const GtkSettingsValue *new_value)
2125 g_return_if_fail (GTK_SETTINGS (settings));
2126 g_return_if_fail (prop_name != NULL);
2127 g_return_if_fail (new_value != NULL);
2129 gtk_settings_set_property_value_internal (settings, prop_name, new_value,
2130 GTK_SETTINGS_SOURCE_APPLICATION);
2134 _gtk_settings_set_property_value_from_rc (GtkSettings *settings,
2135 const gchar *prop_name,
2136 const GtkSettingsValue *new_value)
2138 g_return_if_fail (GTK_SETTINGS (settings));
2139 g_return_if_fail (prop_name != NULL);
2140 g_return_if_fail (new_value != NULL);
2142 gtk_settings_set_property_value_internal (settings, prop_name, new_value,
2143 GTK_SETTINGS_SOURCE_THEME);
2147 gtk_settings_set_string_property (GtkSettings *settings,
2149 const gchar *v_string,
2150 const gchar *origin)
2152 GtkSettingsValue svalue = { NULL, { 0, }, };
2154 g_return_if_fail (GTK_SETTINGS (settings));
2155 g_return_if_fail (name != NULL);
2156 g_return_if_fail (v_string != NULL);
2158 svalue.origin = (gchar*) origin;
2159 g_value_init (&svalue.value, G_TYPE_STRING);
2160 g_value_set_static_string (&svalue.value, v_string);
2161 gtk_settings_set_property_value (settings, name, &svalue);
2162 g_value_unset (&svalue.value);
2166 gtk_settings_set_long_property (GtkSettings *settings,
2169 const gchar *origin)
2171 GtkSettingsValue svalue = { NULL, { 0, }, };
2173 g_return_if_fail (GTK_SETTINGS (settings));
2174 g_return_if_fail (name != NULL);
2176 svalue.origin = (gchar*) origin;
2177 g_value_init (&svalue.value, G_TYPE_LONG);
2178 g_value_set_long (&svalue.value, v_long);
2179 gtk_settings_set_property_value (settings, name, &svalue);
2180 g_value_unset (&svalue.value);
2184 gtk_settings_set_double_property (GtkSettings *settings,
2187 const gchar *origin)
2189 GtkSettingsValue svalue = { NULL, { 0, }, };
2191 g_return_if_fail (GTK_SETTINGS (settings));
2192 g_return_if_fail (name != NULL);
2194 svalue.origin = (gchar*) origin;
2195 g_value_init (&svalue.value, G_TYPE_DOUBLE);
2196 g_value_set_double (&svalue.value, v_double);
2197 gtk_settings_set_property_value (settings, name, &svalue);
2198 g_value_unset (&svalue.value);
2202 * gtk_rc_property_parse_color:
2203 * @pspec: a #GParamSpec
2204 * @gstring: the #GString to be parsed
2205 * @property_value: a #GValue which must hold #GdkColor values.
2207 * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
2208 * or gtk_widget_class_install_style_property_parser() which parses a
2209 * color given either by its name or in the form
2210 * <literal>{ red, green, blue }</literal> where %red, %green and
2211 * %blue are integers between 0 and 65535 or floating-point numbers
2214 * Return value: %TRUE if @gstring could be parsed and @property_value
2215 * has been set to the resulting #GdkColor.
2218 gtk_rc_property_parse_color (const GParamSpec *pspec,
2219 const GString *gstring,
2220 GValue *property_value)
2222 GdkColor color = { 0, 0, 0, 0, };
2226 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
2227 g_return_val_if_fail (G_VALUE_HOLDS (property_value, GDK_TYPE_COLOR), FALSE);
2229 scanner = gtk_rc_scanner_new ();
2230 g_scanner_input_text (scanner, gstring->str, gstring->len);
2231 if (gtk_rc_parse_color (scanner, &color) == G_TOKEN_NONE &&
2232 g_scanner_get_next_token (scanner) == G_TOKEN_EOF)
2234 g_value_set_boxed (property_value, &color);
2239 g_scanner_destroy (scanner);
2245 * gtk_rc_property_parse_enum:
2246 * @pspec: a #GParamSpec
2247 * @gstring: the #GString to be parsed
2248 * @property_value: a #GValue which must hold enum values.
2250 * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
2251 * or gtk_widget_class_install_style_property_parser() which parses a single
2252 * enumeration value.
2254 * The enumeration value can be specified by its name, its nickname or
2255 * its numeric value. For consistency with flags parsing, the value
2256 * may be surrounded by parentheses.
2258 * Return value: %TRUE if @gstring could be parsed and @property_value
2259 * has been set to the resulting #GEnumValue.
2262 gtk_rc_property_parse_enum (const GParamSpec *pspec,
2263 const GString *gstring,
2264 GValue *property_value)
2266 gboolean need_closing_brace = FALSE, success = FALSE;
2268 GEnumValue *enum_value = NULL;
2270 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
2271 g_return_val_if_fail (G_VALUE_HOLDS_ENUM (property_value), FALSE);
2273 scanner = gtk_rc_scanner_new ();
2274 g_scanner_input_text (scanner, gstring->str, gstring->len);
2276 /* we just want to parse _one_ value, but for consistency with flags parsing
2277 * we support optional parenthesis
2279 g_scanner_get_next_token (scanner);
2280 if (scanner->token == '(')
2282 need_closing_brace = TRUE;
2283 g_scanner_get_next_token (scanner);
2285 if (scanner->token == G_TOKEN_IDENTIFIER)
2287 GEnumClass *class = G_PARAM_SPEC_ENUM (pspec)->enum_class;
2289 enum_value = g_enum_get_value_by_name (class, scanner->value.v_identifier);
2291 enum_value = g_enum_get_value_by_nick (class, scanner->value.v_identifier);
2294 g_value_set_enum (property_value, enum_value->value);
2298 else if (scanner->token == G_TOKEN_INT)
2300 g_value_set_enum (property_value, scanner->value.v_int);
2303 if (need_closing_brace && g_scanner_get_next_token (scanner) != ')')
2305 if (g_scanner_get_next_token (scanner) != G_TOKEN_EOF)
2308 g_scanner_destroy (scanner);
2314 parse_flags_value (GScanner *scanner,
2318 g_scanner_get_next_token (scanner);
2319 if (scanner->token == G_TOKEN_IDENTIFIER)
2321 GFlagsValue *flags_value;
2323 flags_value = g_flags_get_value_by_name (class, scanner->value.v_identifier);
2325 flags_value = g_flags_get_value_by_nick (class, scanner->value.v_identifier);
2328 *number |= flags_value->value;
2329 return G_TOKEN_NONE;
2332 else if (scanner->token == G_TOKEN_INT)
2334 *number |= scanner->value.v_int;
2335 return G_TOKEN_NONE;
2337 return G_TOKEN_IDENTIFIER;
2341 * gtk_rc_property_parse_flags:
2342 * @pspec: a #GParamSpec
2343 * @gstring: the #GString to be parsed
2344 * @property_value: a #GValue which must hold flags values.
2346 * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
2347 * or gtk_widget_class_install_style_property_parser() which parses flags.
2349 * Flags can be specified by their name, their nickname or
2350 * numerically. Multiple flags can be specified in the form
2351 * <literal>"( flag1 | flag2 | ... )"</literal>.
2353 * Return value: %TRUE if @gstring could be parsed and @property_value
2354 * has been set to the resulting flags value.
2357 gtk_rc_property_parse_flags (const GParamSpec *pspec,
2358 const GString *gstring,
2359 GValue *property_value)
2362 gboolean success = FALSE;
2365 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
2366 g_return_val_if_fail (G_VALUE_HOLDS_FLAGS (property_value), FALSE);
2368 class = G_PARAM_SPEC_FLAGS (pspec)->flags_class;
2369 scanner = gtk_rc_scanner_new ();
2370 g_scanner_input_text (scanner, gstring->str, gstring->len);
2372 /* parse either a single flags value or a "\( ... [ \| ... ] \)" compound */
2373 if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER ||
2374 scanner->next_token == G_TOKEN_INT)
2376 guint token, flags_value = 0;
2378 token = parse_flags_value (scanner, class, &flags_value);
2380 if (token == G_TOKEN_NONE && g_scanner_peek_next_token (scanner) == G_TOKEN_EOF)
2383 g_value_set_flags (property_value, flags_value);
2387 else if (g_scanner_get_next_token (scanner) == '(')
2389 guint token, flags_value = 0;
2391 /* parse first value */
2392 token = parse_flags_value (scanner, class, &flags_value);
2394 /* parse nth values, preceeded by '|' */
2395 while (token == G_TOKEN_NONE && g_scanner_get_next_token (scanner) == '|')
2396 token = parse_flags_value (scanner, class, &flags_value);
2398 /* done, last token must have closed expression */
2399 if (token == G_TOKEN_NONE && scanner->token == ')' &&
2400 g_scanner_peek_next_token (scanner) == G_TOKEN_EOF)
2402 g_value_set_flags (property_value, flags_value);
2406 g_scanner_destroy (scanner);
2412 get_braced_int (GScanner *scanner,
2419 g_scanner_get_next_token (scanner);
2420 if (scanner->token != '{')
2424 g_scanner_get_next_token (scanner);
2425 if (scanner->token != G_TOKEN_INT)
2428 *value = scanner->value.v_int;
2432 g_scanner_get_next_token (scanner);
2433 if (scanner->token != '}')
2438 g_scanner_get_next_token (scanner);
2439 if (scanner->token != ',')
2447 * gtk_rc_property_parse_requisition:
2448 * @pspec: a #GParamSpec
2449 * @gstring: the #GString to be parsed
2450 * @property_value: a #GValue which must hold boxed values.
2452 * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
2453 * or gtk_widget_class_install_style_property_parser() which parses a
2454 * requisition in the form
2455 * <literal>"{ width, height }"</literal> for integers %width and %height.
2457 * Return value: %TRUE if @gstring could be parsed and @property_value
2458 * has been set to the resulting #GtkRequisition.
2461 gtk_rc_property_parse_requisition (const GParamSpec *pspec,
2462 const GString *gstring,
2463 GValue *property_value)
2465 GtkRequisition requisition;
2467 gboolean success = FALSE;
2469 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
2470 g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
2472 scanner = gtk_rc_scanner_new ();
2473 g_scanner_input_text (scanner, gstring->str, gstring->len);
2475 if (get_braced_int (scanner, TRUE, FALSE, &requisition.width) &&
2476 get_braced_int (scanner, FALSE, TRUE, &requisition.height))
2478 g_value_set_boxed (property_value, &requisition);
2482 g_scanner_destroy (scanner);
2488 * gtk_rc_property_parse_border:
2489 * @pspec: a #GParamSpec
2490 * @gstring: the #GString to be parsed
2491 * @property_value: a #GValue which must hold boxed values.
2493 * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
2494 * or gtk_widget_class_install_style_property_parser() which parses
2495 * borders in the form
2496 * <literal>"{ left, right, top, bottom }"</literal> for integers
2497 * %left, %right, %top and %bottom.
2499 * Return value: %TRUE if @gstring could be parsed and @property_value
2500 * has been set to the resulting #GtkBorder.
2503 gtk_rc_property_parse_border (const GParamSpec *pspec,
2504 const GString *gstring,
2505 GValue *property_value)
2509 gboolean success = FALSE;
2510 int left, right, top, bottom;
2512 g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
2513 g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
2515 scanner = gtk_rc_scanner_new ();
2516 g_scanner_input_text (scanner, gstring->str, gstring->len);
2518 if (get_braced_int (scanner, TRUE, FALSE, &left) &&
2519 get_braced_int (scanner, FALSE, FALSE, &right) &&
2520 get_braced_int (scanner, FALSE, FALSE, &top) &&
2521 get_braced_int (scanner, FALSE, TRUE, &bottom))
2524 border.right = right;
2526 border.bottom = bottom;
2527 g_value_set_boxed (property_value, &border);
2531 g_scanner_destroy (scanner);
2537 _gtk_settings_handle_event (GdkEventSetting *event)
2540 GtkSettings *settings;
2544 screen = gdk_window_get_screen (event->window);
2545 settings = gtk_settings_get_for_screen (screen);
2546 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name);
2550 property_id = pspec->param_id;
2552 if (property_id == PROP_COLOR_SCHEME)
2554 GValue value = G_VALUE_INIT;
2556 g_value_init (&value, G_TYPE_STRING);
2557 if (!gdk_screen_get_setting (screen, pspec->name, &value))
2558 g_value_set_static_string (&value, "");
2559 merge_color_scheme (settings, &value, GTK_SETTINGS_SOURCE_XSETTING);
2560 g_value_unset (&value);
2562 g_object_notify (G_OBJECT (settings), pspec->name);
2567 reset_rc_values_foreach (GQuark key_id,
2571 GtkSettingsValuePrivate *qvalue = data;
2572 GSList **to_reset = user_data;
2574 if (qvalue->source == GTK_SETTINGS_SOURCE_THEME)
2575 *to_reset = g_slist_prepend (*to_reset, GUINT_TO_POINTER (key_id));
2579 _gtk_settings_reset_rc_values (GtkSettings *settings)
2581 GtkSettingsPrivate *priv = settings->priv;
2582 GSList *to_reset = NULL;
2584 GParamSpec **pspecs, **p;
2587 /* Remove any queued settings */
2588 g_datalist_foreach (&priv->queued_settings,
2589 reset_rc_values_foreach,
2592 for (tmp_list = to_reset; tmp_list; tmp_list = tmp_list->next)
2594 GQuark key_id = GPOINTER_TO_UINT (tmp_list->data);
2595 g_datalist_id_remove_data (&priv->queued_settings, key_id);
2598 g_slist_free (to_reset);
2600 /* Now reset the active settings
2602 pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), NULL);
2605 g_object_freeze_notify (G_OBJECT (settings));
2606 for (p = pspecs; *p; p++)
2608 if (priv->property_values[i].source == GTK_SETTINGS_SOURCE_THEME)
2610 GParamSpec *pspec = *p;
2612 g_param_value_set_default (pspec, &priv->property_values[i].value);
2613 g_object_notify (G_OBJECT (settings), pspec->name);
2617 g_object_thaw_notify (G_OBJECT (settings));
2622 settings_update_double_click (GtkSettings *settings)
2624 GtkSettingsPrivate *priv = settings->priv;
2626 if (gdk_screen_get_number (priv->screen) == 0)
2628 GdkDisplay *display = gdk_screen_get_display (priv->screen);
2629 gint double_click_time;
2630 gint double_click_distance;
2632 g_object_get (settings,
2633 "gtk-double-click-time", &double_click_time,
2634 "gtk-double-click-distance", &double_click_distance,
2637 gdk_display_set_double_click_time (display, double_click_time);
2638 gdk_display_set_double_click_distance (display, double_click_distance);
2643 settings_update_modules (GtkSettings *settings)
2647 g_object_get (settings,
2648 "gtk-modules", &modules,
2651 _gtk_modules_settings_changed (settings, modules);
2657 settings_update_cursor_theme (GtkSettings *settings)
2659 #ifdef GDK_WINDOWING_X11
2660 GdkDisplay *display = gdk_screen_get_display (settings->priv->screen);
2661 gchar *theme = NULL;
2664 if (GDK_IS_X11_DISPLAY (display))
2666 g_object_get (settings,
2667 "gtk-cursor-theme-name", &theme,
2668 "gtk-cursor-theme-size", &size,
2671 gdk_x11_display_set_cursor_theme (display, theme, size);
2679 settings_update_font_options (GtkSettings *settings)
2681 GtkSettingsPrivate *priv = settings->priv;
2683 gchar *hint_style_str;
2684 cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_NONE;
2686 cairo_antialias_t antialias_mode = CAIRO_ANTIALIAS_GRAY;
2688 cairo_subpixel_order_t subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
2689 cairo_font_options_t *options;
2691 g_object_get (settings,
2692 "gtk-xft-antialias", &antialias,
2693 "gtk-xft-hinting", &hinting,
2694 "gtk-xft-hintstyle", &hint_style_str,
2695 "gtk-xft-rgba", &rgba_str,
2698 options = cairo_font_options_create ();
2700 cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
2702 if (hinting >= 0 && !hinting)
2704 hint_style = CAIRO_HINT_STYLE_NONE;
2706 else if (hint_style_str)
2708 if (strcmp (hint_style_str, "hintnone") == 0)
2709 hint_style = CAIRO_HINT_STYLE_NONE;
2710 else if (strcmp (hint_style_str, "hintslight") == 0)
2711 hint_style = CAIRO_HINT_STYLE_SLIGHT;
2712 else if (strcmp (hint_style_str, "hintmedium") == 0)
2713 hint_style = CAIRO_HINT_STYLE_MEDIUM;
2714 else if (strcmp (hint_style_str, "hintfull") == 0)
2715 hint_style = CAIRO_HINT_STYLE_FULL;
2718 g_free (hint_style_str);
2720 cairo_font_options_set_hint_style (options, hint_style);
2724 if (strcmp (rgba_str, "rgb") == 0)
2725 subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB;
2726 else if (strcmp (rgba_str, "bgr") == 0)
2727 subpixel_order = CAIRO_SUBPIXEL_ORDER_BGR;
2728 else if (strcmp (rgba_str, "vrgb") == 0)
2729 subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB;
2730 else if (strcmp (rgba_str, "vbgr") == 0)
2731 subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR;
2736 cairo_font_options_set_subpixel_order (options, subpixel_order);
2738 if (antialias >= 0 && !antialias)
2739 antialias_mode = CAIRO_ANTIALIAS_NONE;
2740 else if (subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT)
2741 antialias_mode = CAIRO_ANTIALIAS_SUBPIXEL;
2742 else if (antialias >= 0)
2743 antialias_mode = CAIRO_ANTIALIAS_GRAY;
2745 cairo_font_options_set_antialias (options, antialias_mode);
2747 gdk_screen_set_font_options (priv->screen, options);
2749 cairo_font_options_destroy (options);
2753 settings_update_fontconfig (GtkSettings *settings)
2755 #ifdef GDK_WINDOWING_X11
2756 static guint last_update_timestamp;
2757 static gboolean last_update_needed;
2761 g_object_get (settings,
2762 "gtk-fontconfig-timestamp", ×tamp,
2765 /* if timestamp is the same as last_update_timestamp, we already have
2766 * updated fontconig on this timestamp (another screen requested it perhaps?),
2767 * just return the cached result.*/
2769 if (timestamp != last_update_timestamp)
2771 PangoFontMap *fontmap = pango_cairo_font_map_get_default ();
2772 gboolean update_needed = FALSE;
2775 if (PANGO_IS_FC_FONT_MAP (fontmap) && !FcConfigUptoDate (NULL))
2777 pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (fontmap));
2778 if (FcInitReinitialize ())
2779 update_needed = TRUE;
2782 last_update_timestamp = timestamp;
2783 last_update_needed = update_needed;
2786 return last_update_needed;
2789 #endif /* GDK_WINDOWING_X11 */
2793 settings_update_resolution (GtkSettings *settings)
2795 GtkSettingsPrivate *priv = settings->priv;
2799 g_object_get (settings,
2800 "gtk-xft-dpi", &dpi_int,
2804 dpi = dpi_int / 1024.;
2808 gdk_screen_set_resolution (priv->screen, dpi);
2813 GHashTable *color_hash;
2814 GHashTable *tables[GTK_SETTINGS_SOURCE_APPLICATION + 1];
2815 gchar *lastentry[GTK_SETTINGS_SOURCE_APPLICATION + 1];
2819 color_scheme_data_free (ColorSchemeData *data)
2823 g_hash_table_unref (data->color_hash);
2825 for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++)
2827 if (data->tables[i])
2828 g_hash_table_unref (data->tables[i]);
2829 g_free (data->lastentry[i]);
2832 g_slice_free (ColorSchemeData, data);
2836 settings_update_color_scheme (GtkSettings *settings)
2838 if (!g_object_get_data (G_OBJECT (settings), "gtk-color-scheme"))
2840 GtkSettingsPrivate *priv = settings->priv;
2841 ColorSchemeData *data;
2842 GValue value = G_VALUE_INIT;
2844 data = g_slice_new0 (ColorSchemeData);
2845 data->color_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
2846 (GDestroyNotify) gdk_color_free);
2847 g_object_set_data_full (G_OBJECT (settings), "gtk-color-scheme",
2848 data, (GDestroyNotify) color_scheme_data_free);
2850 g_value_init (&value, G_TYPE_STRING);
2851 if (priv->screen && gdk_screen_get_setting (priv->screen, "gtk-color-scheme", &value))
2853 merge_color_scheme (settings, &value, GTK_SETTINGS_SOURCE_XSETTING);
2854 g_value_unset (&value);
2860 settings_update_provider (GdkScreen *screen,
2861 GtkCssProvider **old,
2862 GtkCssProvider *new)
2868 gtk_style_context_remove_provider_for_screen (screen,
2869 GTK_STYLE_PROVIDER (*old));
2870 g_object_unref (*old);
2876 gtk_style_context_add_provider_for_screen (screen,
2877 GTK_STYLE_PROVIDER (new),
2878 GTK_STYLE_PROVIDER_PRIORITY_THEME);
2879 *old = g_object_ref (new);
2885 settings_update_theme (GtkSettings *settings)
2887 GtkSettingsPrivate *priv = settings->priv;
2888 GtkCssProvider *provider = NULL;
2889 gboolean prefer_dark_theme;
2892 g_object_get (settings,
2893 "gtk-theme-name", &theme_name,
2894 "gtk-application-prefer-dark-theme", &prefer_dark_theme,
2897 if (theme_name && *theme_name)
2899 if (prefer_dark_theme)
2900 provider = gtk_css_provider_get_named (theme_name, "dark");
2903 provider = gtk_css_provider_get_named (theme_name, NULL);
2906 /* If we didn't find the named theme, fall back */
2908 provider = gtk_css_provider_get_named ("Raleigh", NULL);
2910 settings_update_provider (priv->screen, &priv->theme_provider, provider);
2912 if (theme_name && *theme_name)
2917 /* reload per-theme settings */
2918 theme_dir = _gtk_css_provider_get_theme_dir ();
2919 path = g_build_filename (theme_dir, theme_name, "gtk-3.0", "settings.ini", NULL);
2921 if (g_file_test (path, G_FILE_TEST_EXISTS))
2922 gtk_settings_load_from_key_file (settings, path, GTK_SETTINGS_SOURCE_THEME);
2928 g_free (theme_name);
2932 settings_update_key_theme (GtkSettings *settings)
2934 GtkSettingsPrivate *priv = settings->priv;
2935 GtkCssProvider *provider = NULL;
2936 gchar *key_theme_name;
2938 g_object_get (settings,
2939 "gtk-key-theme-name", &key_theme_name,
2942 if (key_theme_name && *key_theme_name)
2943 provider = gtk_css_provider_get_named (key_theme_name, "keys");
2945 settings_update_provider (priv->screen, &priv->key_theme_provider, provider);
2946 g_free (key_theme_name);
2950 add_color_to_hash (gchar *name,
2956 old = g_hash_table_lookup (target, name);
2957 if (!old || !gdk_color_equal (old, color))
2959 g_hash_table_insert (target, g_strdup (name), gdk_color_copy (color));
2968 add_colors_to_hash_from_string (GHashTable *hash,
2969 const gchar *colors)
2971 gchar *s, *p, *name;
2973 gboolean changed = FALSE;
2976 copy = g_strdup (colors);
2981 p = strchr (s, ':');
2996 if (*s == '\n' || *s == ';')
3005 if (gdk_color_parse (p, &color))
3006 changed |= add_color_to_hash (name, &color, hash);
3015 update_color_hash (ColorSchemeData *data,
3017 GtkSettingsSource source)
3019 gboolean changed = FALSE;
3021 GHashTable *old_hash;
3022 GHashTableIter iter;
3026 if ((str == NULL || *str == '\0') &&
3027 (data->lastentry[source] == NULL || data->lastentry[source][0] == '\0'))
3030 if (str && data->lastentry[source] && strcmp (str, data->lastentry[source]) == 0)
3033 /* For the THEME source we merge the values rather than over-writing
3034 * them, since multiple rc files might define independent sets of colors
3036 if ((source != GTK_SETTINGS_SOURCE_THEME) &&
3037 data->tables[source] && g_hash_table_size (data->tables[source]) > 0)
3039 g_hash_table_unref (data->tables[source]);
3040 data->tables[source] = NULL;
3041 changed = TRUE; /* We can't rely on the code below since str might be "" */
3044 if (data->tables[source] == NULL)
3045 data->tables[source] = g_hash_table_new_full (g_str_hash, g_str_equal,
3047 (GDestroyNotify) gdk_color_free);
3049 g_free (data->lastentry[source]);
3050 data->lastentry[source] = g_strdup (str);
3052 changed |= add_colors_to_hash_from_string (data->tables[source], str);
3057 /* Rebuild the merged hash table. */
3058 if (data->color_hash)
3060 old_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
3061 (GDestroyNotify) gdk_color_free);
3063 g_hash_table_iter_init (&iter, data->color_hash);
3064 while (g_hash_table_iter_next (&iter, &name, &color))
3066 g_hash_table_insert (old_hash, name, color);
3067 g_hash_table_iter_steal (&iter);
3075 for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++)
3077 if (data->tables[i])
3078 g_hash_table_foreach (data->tables[i], (GHFunc) add_color_to_hash,
3084 /* now check if the merged hash has changed */
3086 if (g_hash_table_size (old_hash) != g_hash_table_size (data->color_hash))
3090 GHashTableIter iter;
3091 gpointer key, value, new_value;
3093 g_hash_table_iter_init (&iter, old_hash);
3094 while (g_hash_table_iter_next (&iter, &key, &value))
3096 new_value = g_hash_table_lookup (data->color_hash, key);
3097 if (!new_value || !gdk_color_equal (value, new_value))
3105 g_hash_table_unref (old_hash);
3114 merge_color_scheme (GtkSettings *settings,
3115 const GValue *value,
3116 GtkSettingsSource source)
3118 ColorSchemeData *data;
3119 const gchar *colors;
3121 g_object_freeze_notify (G_OBJECT (settings));
3123 colors = g_value_get_string (value);
3125 settings_update_color_scheme (settings);
3127 data = (ColorSchemeData *) g_object_get_data (G_OBJECT (settings),
3128 "gtk-color-scheme");
3130 if (update_color_hash (data, colors, source))
3131 g_object_notify (G_OBJECT (settings), "color-hash");
3133 g_object_thaw_notify (G_OBJECT (settings));
3137 get_color_hash (GtkSettings *settings)
3139 ColorSchemeData *data;
3141 settings_update_color_scheme (settings);
3143 data = (ColorSchemeData *)g_object_get_data (G_OBJECT (settings),
3144 "gtk-color-scheme");
3146 return data->color_hash;
3150 append_color_scheme (gpointer key,
3154 gchar *name = (gchar *)key;
3155 GdkColor *color = (GdkColor *)value;
3156 GString *string = (GString *)data;
3158 g_string_append_printf (string, "%s: #%04x%04x%04x\n",
3159 name, color->red, color->green, color->blue);
3163 get_color_scheme (GtkSettings *settings)
3165 ColorSchemeData *data;
3168 settings_update_color_scheme (settings);
3170 data = (ColorSchemeData *) g_object_get_data (G_OBJECT (settings),
3171 "gtk-color-scheme");
3173 string = g_string_new ("");
3175 g_hash_table_foreach (data->color_hash, append_color_scheme, string);
3177 return g_string_free (string, FALSE);
3181 _gtk_settings_get_screen (GtkSettings *settings)
3183 return settings->priv->screen;
3188 gtk_settings_load_from_key_file (GtkSettings *settings,
3190 GtkSettingsSource source)
3201 keyfile = g_key_file_new ();
3203 if (!g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, &error))
3205 g_warning ("Failed to parse %s: %s", path, error->message);
3207 g_error_free (error);
3212 keys = g_key_file_get_keys (keyfile, "Settings", &n_keys, &error);
3215 g_warning ("Failed to parse %s: %s", path, error->message);
3216 g_error_free (error);
3220 for (i = 0; i < n_keys; i++)
3225 GtkSettingsValue svalue = { NULL, { 0, }, };
3228 pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), key);
3231 g_warning ("Unknown key %s in %s", key, path);
3235 if (pspec->owner_type != G_OBJECT_TYPE (settings))
3238 value_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
3241 case G_TYPE_BOOLEAN:
3245 g_value_init (&svalue.value, G_TYPE_LONG);
3246 b_val = g_key_file_get_boolean (keyfile, "Settings", key, &error);
3248 g_value_set_long (&svalue.value, b_val);
3256 g_value_init (&svalue.value, G_TYPE_LONG);
3257 i_val = g_key_file_get_integer (keyfile, "Settings", key, &error);
3259 g_value_set_long (&svalue.value, i_val);
3267 g_value_init (&svalue.value, G_TYPE_DOUBLE);
3268 d_val = g_key_file_get_double (keyfile, "Settings", key, &error);
3270 g_value_set_double (&svalue.value, d_val);
3278 g_value_init (&svalue.value, G_TYPE_GSTRING);
3279 s_val = g_key_file_get_string (keyfile, "Settings", key, &error);
3281 g_value_take_boxed (&svalue.value, g_string_new (s_val));
3288 g_warning ("Error setting %s in %s: %s", key, path, error->message);
3289 g_error_free (error);
3294 if (g_getenv ("GTK_DEBUG"))
3295 svalue.origin = (gchar *)path;
3296 gtk_settings_set_property_value_internal (settings, key, &svalue, source);
3297 g_value_unset (&svalue.value);
3303 g_key_file_free (keyfile);