From 1bcf8a0027bff3fcefbc63d6cf7cc3915a5455d7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 23 Dec 2010 21:55:47 -0500 Subject: Remove sealed members from GtkSettings --- gtk/gtksettings.c | 1137 +++++++++++++++++++++++++++-------------------------- 1 file changed, 586 insertions(+), 551 deletions(-) (limited to 'gtk/gtksettings.c') diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 2e0f7d69af..e9e4978bbb 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -24,7 +24,7 @@ #include #include "gtkmodules.h" -#include "gtksettings.h" +#include "gtksettingsprivate.h" #include "gtkrc.h" #include "gtkintl.h" #include "gtkwidget.h" @@ -84,8 +84,16 @@ #define DEFAULT_TIMEOUT_REPEAT 20 #define DEFAULT_TIMEOUT_EXPAND 500 +typedef struct _GtkSettingsPropertyValue GtkSettingsPropertyValue; typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate; +struct _GtkSettingsPrivate +{ + GData *queued_settings; /* of type GtkSettingsValue* */ + GtkSettingsPropertyValue *property_values; + GdkScreen *screen; +}; + typedef enum { GTK_SETTINGS_SOURCE_DEFAULT, @@ -184,20 +192,20 @@ enum { /* --- prototypes --- */ static void gtk_settings_provider_iface_init (GtkStyleProviderIface *iface); -static void gtk_settings_finalize (GObject *object); -static void gtk_settings_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -static void gtk_settings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gtk_settings_notify (GObject *object, - GParamSpec *pspec); -static guint settings_install_property_parser (GtkSettingsClass *class, - GParamSpec *pspec, - GtkRcPropertyParser parser); +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); static void settings_update_double_click (GtkSettings *settings); static void settings_update_modules (GtkSettings *settings); @@ -210,9 +218,9 @@ static gboolean settings_update_fontconfig (GtkSettings *setting static void settings_update_color_scheme (GtkSettings *settings); static void settings_update_theme (GtkSettings *settings); -static void merge_color_scheme (GtkSettings *settings, - const GValue *value, - GtkSettingsSource source); +static void merge_color_scheme (GtkSettings *settings, + const GValue *value, + GtkSettingsSource source); static gchar *get_color_scheme (GtkSettings *settings); static GHashTable *get_color_hash (GtkSettings *settings); @@ -222,9 +230,9 @@ static const gchar default_color_palette[] = "lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90"; /* --- variables --- */ -static GQuark quark_property_parser = 0; +static GQuark quark_property_parser = 0; static GSList *object_list = NULL; -static guint class_n_properties = 0; +static guint class_n_properties = 0; G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0, @@ -235,10 +243,16 @@ G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0, static void gtk_settings_init (GtkSettings *settings) { + GtkSettingsPrivate *priv; GParamSpec **pspecs, **p; guint i = 0; - - g_datalist_init (&settings->queued_settings); + + priv = G_TYPE_INSTANCE_GET_PRIVATE (settings, + GTK_TYPE_SETTINGS, + GtkSettingsPrivate); + + settings->priv = priv; + g_datalist_init (&priv->queued_settings); object_list = g_slist_prepend (object_list, settings); /* build up property array for all yet existing properties and queue @@ -249,7 +263,7 @@ gtk_settings_init (GtkSettings *settings) for (p = pspecs; *p; p++) if ((*p)->owner_type == G_OBJECT_TYPE (settings)) i++; - settings->property_values = g_new0 (GtkSettingsPropertyValue, i); + priv->property_values = g_new0 (GtkSettingsPropertyValue, i); i = 0; g_object_freeze_notify (G_OBJECT (settings)); for (p = pspecs; *p; p++) @@ -257,11 +271,11 @@ gtk_settings_init (GtkSettings *settings) GParamSpec *pspec = *p; if (pspec->owner_type != G_OBJECT_TYPE (settings)) - continue; - g_value_init (&settings->property_values[i].value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - g_param_value_set_default (pspec, &settings->property_values[i].value); + continue; + g_value_init (&priv->property_values[i].value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_param_value_set_default (pspec, &priv->property_values[i].value); g_object_notify (G_OBJECT (settings), pspec->name); - settings->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT; + priv->property_values[i].source = GTK_SETTINGS_SOURCE_DEFAULT; i++; } g_object_thaw_notify (G_OBJECT (settings)); @@ -273,7 +287,7 @@ gtk_settings_class_init (GtkSettingsClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); guint result; - + gobject_class->finalize = gtk_settings_finalize; gobject_class->get_property = gtk_settings_get_property; gobject_class->set_property = gtk_settings_set_property; @@ -300,18 +314,18 @@ gtk_settings_class_init (GtkSettingsClass *class) /** * GtkSettings:gtk-cursor-blink: * - * Whether the cursor should blink. + * Whether the cursor should blink. * - * Also see the #GtkSettings:gtk-cursor-blink-timeout setting, + * Also see the #GtkSettings:gtk-cursor-blink-timeout setting, * which allows more flexible control over cursor blinking. */ result = settings_install_property_parser (class, g_param_spec_boolean ("gtk-cursor-blink", - P_("Cursor Blink"), - P_("Whether the cursor should blink"), - TRUE, - GTK_PARAM_READWRITE), - NULL); + P_("Cursor Blink"), + P_("Whether the cursor should blink"), + TRUE, + GTK_PARAM_READWRITE), + NULL); g_assert (result == PROP_CURSOR_BLINK); result = settings_install_property_parser (class, g_param_spec_int ("gtk-cursor-blink-time", @@ -321,7 +335,7 @@ gtk_settings_class_init (GtkSettingsClass *class) GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_CURSOR_BLINK_TIME); - + /** * GtkSettings:gtk-cursor-blink-timeout: * @@ -329,7 +343,7 @@ gtk_settings_class_init (GtkSettingsClass *class) * The timer is reset after each user interaction. * * Setting this to zero has the same effect as setting - * #GtkSettings:gtk-cursor-blink to %FALSE. + * #GtkSettings:gtk-cursor-blink to %FALSE. * * Since: 2.12 */ @@ -343,47 +357,47 @@ gtk_settings_class_init (GtkSettingsClass *class) g_assert (result == PROP_CURSOR_BLINK_TIMEOUT); result = settings_install_property_parser (class, g_param_spec_boolean ("gtk-split-cursor", - P_("Split Cursor"), - P_("Whether two cursors should be displayed for mixed left-to-right and right-to-left text"), - TRUE, - GTK_PARAM_READWRITE), + P_("Split Cursor"), + P_("Whether two cursors should be displayed for mixed left-to-right and right-to-left text"), + TRUE, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_SPLIT_CURSOR); result = settings_install_property_parser (class, g_param_spec_string ("gtk-theme-name", - P_("Theme Name"), - P_("Name of theme RC file to load"), - "Raleigh", - GTK_PARAM_READWRITE), + P_("Theme Name"), + P_("Name of theme RC file to load"), + "Raleigh", + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_THEME_NAME); result = settings_install_property_parser (class, g_param_spec_string ("gtk-icon-theme-name", - P_("Icon Theme Name"), - P_("Name of icon theme to use"), - "hicolor", - GTK_PARAM_READWRITE), + P_("Icon Theme Name"), + P_("Name of icon theme to use"), + "hicolor", + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_ICON_THEME_NAME); result = settings_install_property_parser (class, g_param_spec_string ("gtk-fallback-icon-theme", - P_("Fallback Icon Theme Name"), - P_("Name of a icon theme to fall back to"), - NULL, - GTK_PARAM_READWRITE), + P_("Fallback Icon Theme Name"), + P_("Name of a icon theme to fall back to"), + NULL, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_FALLBACK_ICON_THEME); - + result = settings_install_property_parser (class, g_param_spec_string ("gtk-key-theme-name", - P_("Key Theme Name"), - P_("Name of key theme RC file to load"), - DEFAULT_KEY_THEME, - GTK_PARAM_READWRITE), + P_("Key Theme Name"), + P_("Name of key theme RC file to load"), + DEFAULT_KEY_THEME, + GTK_PARAM_READWRITE), NULL); - g_assert (result == PROP_KEY_THEME_NAME); + g_assert (result == PROP_KEY_THEME_NAME); result = settings_install_property_parser (class, g_param_spec_string ("gtk-menu-bar-accel", @@ -395,20 +409,20 @@ gtk_settings_class_init (GtkSettingsClass *class) g_assert (result == PROP_MENU_BAR_ACCEL); result = settings_install_property_parser (class, - g_param_spec_int ("gtk-dnd-drag-threshold", - P_("Drag threshold"), - P_("Number of pixels the cursor can move before dragging"), - 1, G_MAXINT, 8, + g_param_spec_int ("gtk-dnd-drag-threshold", + P_("Drag threshold"), + P_("Number of pixels the cursor can move before dragging"), + 1, G_MAXINT, 8, GTK_PARAM_READWRITE), - NULL); + NULL); g_assert (result == PROP_DND_DRAG_THRESHOLD); result = settings_install_property_parser (class, g_param_spec_string ("gtk-font-name", - P_("Font Name"), - P_("Name of default font to use"), - "Sans 10", - GTK_PARAM_READWRITE), + P_("Font Name"), + P_("Name of default font to use"), + "Sans 10", + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_FONT_NAME); @@ -420,107 +434,107 @@ gtk_settings_class_init (GtkSettingsClass *class) * * size-name = width , height * - * 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 + * 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 * sizes with gtk_icon_size_register(). */ result = settings_install_property_parser (class, g_param_spec_string ("gtk-icon-sizes", - P_("Icon Sizes"), - P_("List of icon sizes (gtk-menu=16,16:gtk-button=20,20..."), - NULL, - GTK_PARAM_READWRITE), + P_("Icon Sizes"), + P_("List of icon sizes (gtk-menu=16,16:gtk-button=20,20..."), + NULL, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_ICON_SIZES); result = settings_install_property_parser (class, g_param_spec_string ("gtk-modules", - P_("GTK Modules"), - P_("List of currently active GTK modules"), - NULL, - GTK_PARAM_READWRITE), + P_("GTK Modules"), + P_("List of currently active GTK modules"), + NULL, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_MODULES); #ifdef GDK_WINDOWING_X11 result = settings_install_property_parser (class, - g_param_spec_int ("gtk-xft-antialias", - P_("Xft Antialias"), - P_("Whether to antialias Xft fonts; 0=no, 1=yes, -1=default"), - -1, 1, -1, - GTK_PARAM_READWRITE), - NULL); - + 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); + g_assert (result == PROP_XFT_ANTIALIAS); - - result = settings_install_property_parser (class, - g_param_spec_int ("gtk-xft-hinting", - P_("Xft Hinting"), - P_("Whether to hint Xft fonts; 0=no, 1=yes, -1=default"), - -1, 1, -1, - GTK_PARAM_READWRITE), - NULL); - + + 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); + g_assert (result == PROP_XFT_HINTING); - + result = settings_install_property_parser (class, - g_param_spec_string ("gtk-xft-hintstyle", - P_("Xft Hint Style"), - P_("What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull"), - NULL, - GTK_PARAM_READWRITE), + g_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), NULL); - + g_assert (result == PROP_XFT_HINTSTYLE); - - result = settings_install_property_parser (class, - g_param_spec_string ("gtk-xft-rgba", - P_("Xft RGBA"), - P_("Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr"), - NULL, - GTK_PARAM_READWRITE), - NULL); - + + 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); + g_assert (result == PROP_XFT_RGBA); - - result = settings_install_property_parser (class, - g_param_spec_int ("gtk-xft-dpi", - P_("Xft DPI"), - P_("Resolution for Xft, in 1024 * dots/inch. -1 to use default value"), - -1, 1024*1024, -1, - GTK_PARAM_READWRITE), - NULL); - + + 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); + g_assert (result == PROP_XFT_DPI); result = settings_install_property_parser (class, g_param_spec_string ("gtk-cursor-theme-name", - P_("Cursor theme name"), - P_("Name of the cursor theme to use, or NULL to use the default theme"), - NULL, - GTK_PARAM_READWRITE), + P_("Cursor theme name"), + P_("Name of the cursor theme to use, or NULL to use the default theme"), + NULL, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_CURSOR_THEME_NAME); result = settings_install_property_parser (class, - g_param_spec_int ("gtk-cursor-theme-size", - P_("Cursor theme size"), - P_("Size to use for cursors, or 0 to use the default size"), - 0, 128, 0, - GTK_PARAM_READWRITE), - NULL); - + 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); + g_assert (result == PROP_CURSOR_THEME_SIZE); #endif /* GDK_WINDOWING_X11 */ result = settings_install_property_parser (class, g_param_spec_boolean ("gtk-alternative-button-order", - P_("Alternative button order"), - P_("Whether buttons in dialogs should use the alternative button order"), - FALSE, - GTK_PARAM_READWRITE), + P_("Alternative button order"), + P_("Whether buttons in dialogs should use the alternative button order"), + FALSE, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_ALTERNATIVE_BUTTON_ORDER); @@ -535,58 +549,58 @@ gtk_settings_class_init (GtkSettingsClass *class) */ result = settings_install_property_parser (class, g_param_spec_boolean ("gtk-alternative-sort-arrows", - P_("Alternative sort indicator direction"), - P_("Whether the direction of the sort indicators in list and tree views is inverted compared to the default (where down means ascending)"), - FALSE, - GTK_PARAM_READWRITE), + 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), NULL); g_assert (result == PROP_ALTERNATIVE_SORT_ARROWS); result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_SHOW_INPUT_METHOD_MENU); result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_SHOW_UNICODE_MENU); result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_TIMEOUT_INITIAL); result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_TIMEOUT_REPEAT); result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_TIMEOUT_EXPAND); @@ -599,11 +613,11 @@ gtk_settings_class_init (GtkSettingsClass *class) * name2: color2 * ... * - * Color names must be acceptable as identifiers in the + * Color names must be acceptable as identifiers in the * gtkrc syntax, and * color specifications must be in the format accepted by * gdk_color_parse(). - * + * * 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. @@ -617,12 +631,12 @@ gtk_settings_class_init (GtkSettingsClass *class) * Since: 2.10 */ result = settings_install_property_parser (class, - g_param_spec_string ("gtk-color-scheme", - P_("Color scheme"), - P_("A palette of named colors for use in themes"), - "", - GTK_PARAM_READWRITE), - NULL); + g_param_spec_string ("gtk-color-scheme", + P_("Color scheme"), + P_("A palette of named colors for use in themes"), + "", + GTK_PARAM_READWRITE), + NULL); g_assert (result == PROP_COLOR_SCHEME); @@ -664,13 +678,13 @@ gtk_settings_class_init (GtkSettingsClass *class) * Since: 2.12 */ result = settings_install_property_parser (class, - g_param_spec_int ("gtk-tooltip-timeout", - P_("Tooltip timeout"), - P_("Timeout before tooltip is shown"), - 0, G_MAXINT, - 500, - GTK_PARAM_READWRITE), - NULL); + g_param_spec_int ("gtk-tooltip-timeout", + P_("Tooltip timeout"), + P_("Timeout before tooltip is shown"), + 0, G_MAXINT, + 500, + GTK_PARAM_READWRITE), + NULL); g_assert (result == PROP_TOOLTIP_TIMEOUT); @@ -683,20 +697,20 @@ gtk_settings_class_init (GtkSettingsClass *class) * Browse mode is enabled when the mouse pointer moves off an object * where a tooltip was currently being displayed. If the mouse pointer * hits another object before the browse mode timeout expires (see - * #GtkSettings:gtk-tooltip-browse-mode-timeout), it will take the + * #GtkSettings:gtk-tooltip-browse-mode-timeout), it will take the * amount of milliseconds specified by this setting to popup the tooltip * for the new object. * * Since: 2.12 */ result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_TOOLTIP_BROWSE_TIMEOUT); @@ -712,13 +726,13 @@ gtk_settings_class_init (GtkSettingsClass *class) * Since: 2.12 */ result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_TOOLTIP_BROWSE_MODE_TIMEOUT); @@ -783,12 +797,12 @@ gtk_settings_class_init (GtkSettingsClass *class) /** * GtkSettings:color-hash: * - * Holds a hash table representation of the #GtkSettings:gtk-color-scheme - * setting, mapping color names to #GdkColors. + * Holds a hash table representation of the #GtkSettings:gtk-color-scheme + * setting, mapping color names to #GdkColors. * * Since: 2.10 */ - result = settings_install_property_parser (class, + result = settings_install_property_parser (class, g_param_spec_boxed ("color-hash", P_("Color Hash"), P_("A hash table representation of the color scheme."), @@ -797,7 +811,7 @@ gtk_settings_class_init (GtkSettingsClass *class) NULL); g_assert (result == PROP_COLOR_HASH); - result = settings_install_property_parser (class, + result = settings_install_property_parser (class, g_param_spec_string ("gtk-file-chooser-backend", P_("Default file chooser backend"), P_("Name of the GtkFileChooser backend to use by default"), @@ -831,7 +845,7 @@ gtk_settings_class_init (GtkSettingsClass *class) * should contain a %f placeholder, which will get replaced by * the path to the pdf file. The command may also contain a %s * placeholder, which will get replaced by the path to a file - * containing the print settings in the format produced by + * containing the print settings in the format produced by * gtk_print_settings_to_file(). * * The preview application is responsible for removing the pdf file @@ -845,7 +859,7 @@ gtk_settings_class_init (GtkSettingsClass *class) P_("Command to run when displaying a print preview"), GTK_PRINT_PREVIEW_COMMAND, GTK_PARAM_READWRITE), - NULL); + NULL); g_assert (result == PROP_PRINT_PREVIEW_COMMAND); /** @@ -892,31 +906,31 @@ gtk_settings_class_init (GtkSettingsClass *class) * Since: 2.12 */ result = settings_install_property_parser (class, - 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); + 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); g_assert (result == PROP_RECENT_FILES_LIMIT); /** * GtkSettings:gtk-im-module: * - * Which IM (input method) module should be used by default. This is the - * input method that will be used if the user has not explicitly chosen - * another input method from the IM context menu. + * 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. * * See #GtkIMContext and see the #GtkSettings:gtk-show-input-method-menu property. */ result = settings_install_property_parser (class, - g_param_spec_string ("gtk-im-module", - P_("Default IM module"), - P_("Which IM module should be used by default"), - NULL, - GTK_PARAM_READWRITE), - NULL); + 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); g_assert (result == PROP_IM_MODULE); /** @@ -930,23 +944,23 @@ gtk_settings_class_init (GtkSettingsClass *class) * Since: 2.14 */ result = settings_install_property_parser (class, - g_param_spec_int ("gtk-recent-files-max-age", - P_("Recent Files Max Age"), - P_("Maximum age of recently used files, in days"), - -1, G_MAXINT, - 30, - GTK_PARAM_READWRITE), - NULL); + 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); g_assert (result == PROP_RECENT_FILES_MAX_AGE); result = settings_install_property_parser (class, - g_param_spec_uint ("gtk-fontconfig-timestamp", - P_("Fontconfig configuration timestamp"), - P_("Timestamp of current fontconfig configuration"), - 0, G_MAXUINT, 0, - GTK_PARAM_READWRITE), - NULL); - + 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); + g_assert (result == PROP_FONTCONFIG_TIMESTAMP); /** @@ -954,10 +968,10 @@ gtk_settings_class_init (GtkSettingsClass *class) * * The XDG sound theme to use for event sounds. * - * See the Sound Theme spec + * See the Sound Theme spec * for more information on event sounds and sound themes. * - * GTK+ itself does not support event sounds, you have to use a loadable + * GTK+ itself does not support event sounds, you have to use a loadable * module like the one that comes with libcanberra. * * Since: 2.14 @@ -976,10 +990,10 @@ gtk_settings_class_init (GtkSettingsClass *class) * * Whether to play event sounds as feedback to user input. * - * See the Sound Theme spec + * See the Sound Theme spec * for more information on event sounds and sound themes. * - * GTK+ itself does not support event sounds, you have to use a loadable + * GTK+ itself does not support event sounds, you have to use a loadable * module like the one that comes with libcanberra. * * Since: 2.14 @@ -987,10 +1001,10 @@ gtk_settings_class_init (GtkSettingsClass *class) result = settings_install_property_parser (class, g_param_spec_boolean ("gtk-enable-input-feedback-sounds", /* Translators: this means sounds that are played as feedback to user input */ - P_("Audible Input Feedback"), - P_("Whether to play event sounds as feedback to user input"), - TRUE, - GTK_PARAM_READWRITE), + P_("Audible Input Feedback"), + P_("Whether to play event sounds as feedback to user input"), + TRUE, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_ENABLE_INPUT_FEEDBACK_SOUNDS); @@ -999,20 +1013,20 @@ gtk_settings_class_init (GtkSettingsClass *class) * * Whether to play any event sounds at all. * - * See the Sound Theme spec + * See the Sound Theme spec * for more information on event sounds and sound themes. * - * GTK+ itself does not support event sounds, you have to use a loadable + * GTK+ itself does not support event sounds, you have to use a loadable * module like the one that comes with libcanberra. * * Since: 2.14 */ result = settings_install_property_parser (class, g_param_spec_boolean ("gtk-enable-event-sounds", - P_("Enable Event Sounds"), - P_("Whether to play any event sounds at all"), - TRUE, - GTK_PARAM_READWRITE), + P_("Enable Event Sounds"), + P_("Whether to play any event sounds at all"), + TRUE, + GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_ENABLE_EVENT_SOUNDS); @@ -1171,7 +1185,7 @@ gtk_settings_class_init (GtkSettingsClass *class) /** * GtkSettings:gtk-scrolled-window-placement: * - * Where the contents of scrolled windows are located with respect to the + * Where the contents of scrolled windows are located with respect to the * scrollbars, if not overridden by the scrolled window's own placement. * * Since: 2.10 @@ -1252,6 +1266,8 @@ gtk_settings_class_init (GtkSettingsClass *class) GTK_PARAM_READWRITE), gtk_rc_property_parse_enum); g_assert (result == PROP_IM_STATUS_STYLE); + + g_type_class_add_private (class, sizeof (GtkSettingsPrivate)); } static GtkStyleProperties * @@ -1330,15 +1346,16 @@ static void gtk_settings_finalize (GObject *object) { GtkSettings *settings = GTK_SETTINGS (object); + GtkSettingsPrivate *priv = settings->priv; guint i; object_list = g_slist_remove (object_list, settings); for (i = 0; i < class_n_properties; i++) - g_value_unset (&settings->property_values[i].value); - g_free (settings->property_values); - - g_datalist_clear (&settings->queued_settings); + g_value_unset (&priv->property_values[i].value); + g_free (priv->property_values); + + g_datalist_clear (&priv->queued_settings); G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object); } @@ -1347,6 +1364,8 @@ static void settings_init_style (GtkSettings *settings) { static GtkCssProvider *css_provider = NULL; + + GdkScreen *screen = settings->priv->screen; GtkCssProvider *default_provider; /* Add provider for user file */ @@ -1367,16 +1386,16 @@ settings_init_style (GtkSettings *settings) g_free (css_path); } - gtk_style_context_add_provider_for_screen (settings->screen, + gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); default_provider = gtk_css_provider_get_default (); - gtk_style_context_add_provider_for_screen (settings->screen, + gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (default_provider), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK); - gtk_style_context_add_provider_for_screen (settings->screen, + gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (settings), GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); @@ -1404,9 +1423,9 @@ gtk_settings_get_for_screen (GdkScreen *screen) if (!settings) { settings = g_object_new (GTK_TYPE_SETTINGS, NULL); - settings->screen = screen; - g_object_set_data_full (G_OBJECT (screen), I_("gtk-settings"), - settings, g_object_unref); + settings->priv->screen = screen; + g_object_set_data_full (G_OBJECT (screen), I_("gtk-settings"), + settings, g_object_unref); settings_init_style (settings); settings_update_double_click (settings); @@ -1417,13 +1436,13 @@ gtk_settings_get_for_screen (GdkScreen *screen) #endif settings_update_color_scheme (settings); } - + return settings; } /** * gtk_settings_get_default: - * + * * Gets the #GtkSettings object for the default GDK screen, creating * it if necessary. See gtk_settings_get_for_screen(). * @@ -1443,26 +1462,28 @@ gtk_settings_get_default (void) static void gtk_settings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { GtkSettings *settings = GTK_SETTINGS (object); + GtkSettingsPrivate *priv = settings->priv; + + g_value_copy (value, &priv->property_values[property_id - 1].value); + priv->property_values[property_id - 1].source = GTK_SETTINGS_SOURCE_APPLICATION; - g_value_copy (value, &settings->property_values[property_id - 1].value); - settings->property_values[property_id - 1].source = GTK_SETTINGS_SOURCE_APPLICATION; - if (pspec->param_id == PROP_COLOR_SCHEME) merge_color_scheme (settings, value, GTK_SETTINGS_SOURCE_APPLICATION); } static void gtk_settings_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { GtkSettings *settings = GTK_SETTINGS (object); + GtkSettingsPrivate *priv = settings->priv; GType value_type = G_VALUE_TYPE (value); GType fundamental_type = G_TYPE_FUNDAMENTAL (value_type); @@ -1487,10 +1508,10 @@ gtk_settings_get_property (GObject *object, g_value_type_transformable (G_TYPE_STRING, G_VALUE_TYPE (value)) || g_value_type_transformable (GDK_TYPE_COLOR, G_VALUE_TYPE (value))) { - if (settings->property_values[property_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION || - !gdk_screen_get_setting (settings->screen, pspec->name, value)) - g_value_copy (&settings->property_values[property_id - 1].value, value); - else + if (priv->property_values[property_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION || + !gdk_screen_get_setting (priv->screen, pspec->name, value)) + g_value_copy (&priv->property_values[property_id - 1].value, value); + else g_param_value_validate (pspec, value); } else @@ -1498,20 +1519,20 @@ gtk_settings_get_property (GObject *object, GValue val = { 0, }; /* Try to get xsetting as a string and parse it. */ - + g_value_init (&val, G_TYPE_STRING); - if (settings->property_values[property_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION || - !gdk_screen_get_setting (settings->screen, pspec->name, &val)) + if (priv->property_values[property_id - 1].source == GTK_SETTINGS_SOURCE_APPLICATION || + !gdk_screen_get_setting (priv->screen, pspec->name, &val)) { - g_value_copy (&settings->property_values[property_id - 1].value, value); + g_value_copy (&priv->property_values[property_id - 1].value, value); } else { GValue tmp_value = { 0, }; GValue gstring_value = { 0, }; GtkRcPropertyParser parser = (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser); - + g_value_init (&gstring_value, G_TYPE_GSTRING); g_value_take_boxed (&gstring_value, g_string_new (g_value_get_string (&val))); @@ -1526,7 +1547,7 @@ gtk_settings_get_property (GObject *object, } else { - g_value_copy (&settings->property_values[property_id - 1].value, value); + g_value_copy (&priv->property_values[property_id - 1].value, value); } g_value_unset (&gstring_value); @@ -1539,12 +1560,13 @@ gtk_settings_get_property (GObject *object, static void gtk_settings_notify (GObject *object, - GParamSpec *pspec) + GParamSpec *pspec) { GtkSettings *settings = GTK_SETTINGS (object); + GtkSettingsPrivate *priv = settings->priv; guint property_id = pspec->param_id; - if (settings->screen == NULL) /* initialization */ + if (priv->screen == NULL) /* initialization */ return; switch (property_id) @@ -1558,7 +1580,7 @@ gtk_settings_notify (GObject *object, break; case PROP_COLOR_SCHEME: settings_update_color_scheme (settings); - gtk_style_context_reset_widgets (settings->screen); + gtk_style_context_reset_widgets (priv->screen); break; case PROP_THEME_NAME: settings_update_theme (settings); @@ -1570,18 +1592,18 @@ gtk_settings_notify (GObject *object, * widgets with gtk_widget_style_set(), and also causes more * recomputation than necessary. */ - gtk_style_context_reset_widgets (settings->screen); + gtk_style_context_reset_widgets (priv->screen); break; case PROP_XFT_ANTIALIAS: case PROP_XFT_HINTING: case PROP_XFT_HINTSTYLE: case PROP_XFT_RGBA: settings_update_font_options (settings); - gtk_style_context_reset_widgets (settings->screen); + gtk_style_context_reset_widgets (priv->screen); break; case PROP_FONTCONFIG_TIMESTAMP: if (settings_update_fontconfig (settings)) - gtk_style_context_reset_widgets (settings->screen); + gtk_style_context_reset_widgets (priv->screen); break; case PROP_CURSOR_THEME_NAME: case PROP_CURSOR_THEME_SIZE: @@ -1593,9 +1615,9 @@ gtk_settings_notify (GObject *object, gboolean _gtk_settings_parse_convert (GtkRcPropertyParser parser, - const GValue *src_value, - GParamSpec *pspec, - GValue *dest_value) + const GValue *src_value, + GParamSpec *pspec, + GValue *dest_value) { gboolean success = FALSE; @@ -1605,52 +1627,52 @@ _gtk_settings_parse_convert (GtkRcPropertyParser parser, { GString *gstring; gboolean free_gstring = TRUE; - + if (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING)) - { - gstring = g_value_get_boxed (src_value); - free_gstring = FALSE; - } + { + gstring = g_value_get_boxed (src_value); + free_gstring = FALSE; + } else if (G_VALUE_HOLDS_LONG (src_value)) - { - gstring = g_string_new (NULL); - g_string_append_printf (gstring, "%ld", g_value_get_long (src_value)); - } + { + gstring = g_string_new (NULL); + g_string_append_printf (gstring, "%ld", g_value_get_long (src_value)); + } else if (G_VALUE_HOLDS_DOUBLE (src_value)) - { - gstring = g_string_new (NULL); - g_string_append_printf (gstring, "%f", g_value_get_double (src_value)); - } + { + gstring = g_string_new (NULL); + g_string_append_printf (gstring, "%f", g_value_get_double (src_value)); + } else if (G_VALUE_HOLDS_STRING (src_value)) - { - gchar *tstr = g_strescape (g_value_get_string (src_value), NULL); - - gstring = g_string_new ("\""); - g_string_append (gstring, tstr); - g_string_append_c (gstring, '\"'); - g_free (tstr); - } + { + gchar *tstr = g_strescape (g_value_get_string (src_value), NULL); + + gstring = g_string_new ("\""); + g_string_append (gstring, tstr); + g_string_append_c (gstring, '\"'); + g_free (tstr); + } else - { - g_return_val_if_fail (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING), FALSE); - gstring = NULL; /* silence compiler */ - } + { + g_return_val_if_fail (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING), FALSE); + gstring = NULL; /* silence compiler */ + } success = (parser (pspec, gstring, dest_value) && - !g_param_value_validate (pspec, dest_value)); + !g_param_value_validate (pspec, dest_value)); if (free_gstring) - g_string_free (gstring, TRUE); + g_string_free (gstring, TRUE); } else if (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING)) { if (G_VALUE_HOLDS (dest_value, G_TYPE_STRING)) - { - GString *gstring = g_value_get_boxed (src_value); + { + GString *gstring = g_value_get_boxed (src_value); - g_value_set_string (dest_value, gstring ? gstring->str : NULL); - success = !g_param_value_validate (pspec, dest_value); - } + g_value_set_string (dest_value, gstring ? gstring->str : NULL); + success = !g_param_value_validate (pspec, dest_value); + } } else if (g_value_type_transformable (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value))) success = g_param_value_convert (pspec, src_value, dest_value, TRUE); @@ -1659,38 +1681,39 @@ _gtk_settings_parse_convert (GtkRcPropertyParser parser, } static void -apply_queued_setting (GtkSettings *data, - GParamSpec *pspec, - GtkSettingsValuePrivate *qvalue) +apply_queued_setting (GtkSettings *settings, + GParamSpec *pspec, + GtkSettingsValuePrivate *qvalue) { + GtkSettingsPrivate *priv = settings->priv; GValue tmp_value = { 0, }; GtkRcPropertyParser parser = (GtkRcPropertyParser) g_param_spec_get_qdata (pspec, quark_property_parser); g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); if (_gtk_settings_parse_convert (parser, &qvalue->public.value, - pspec, &tmp_value)) + pspec, &tmp_value)) { - if (pspec->param_id == PROP_COLOR_SCHEME) - merge_color_scheme (data, &tmp_value, qvalue->source); + if (pspec->param_id == PROP_COLOR_SCHEME) + merge_color_scheme (settings, &tmp_value, qvalue->source); - if (data->property_values[pspec->param_id - 1].source <= qvalue->source) - { - g_value_copy (&tmp_value, &data->property_values[pspec->param_id - 1].value); - data->property_values[pspec->param_id - 1].source = qvalue->source; - g_object_notify (G_OBJECT (data), g_param_spec_get_name (pspec)); - } + if (priv->property_values[pspec->param_id - 1].source <= qvalue->source) + { + g_value_copy (&tmp_value, &priv->property_values[pspec->param_id - 1].value); + priv->property_values[pspec->param_id - 1].source = qvalue->source; + g_object_notify (G_OBJECT (settings), g_param_spec_get_name (pspec)); + } } else { gchar *debug = g_strdup_value_contents (&qvalue->public.value); - + g_message ("%s: failed to retrieve property `%s' of type `%s' from rc file value \"%s\" of type `%s'", - qvalue->public.origin ? qvalue->public.origin : "(for origin information, set GTK_DEBUG)", - pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), - debug, - G_VALUE_TYPE_NAME (&tmp_value)); + qvalue->public.origin ? qvalue->public.origin : "(for origin information, set GTK_DEBUG)", + pspec->name, + g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), + debug, + G_VALUE_TYPE_NAME (&tmp_value)); g_free (debug); } g_value_unset (&tmp_value); @@ -1698,8 +1721,8 @@ apply_queued_setting (GtkSettings *data, static guint settings_install_property_parser (GtkSettingsClass *class, - GParamSpec *pspec, - GtkRcPropertyParser parser) + GParamSpec *pspec, + GtkRcPropertyParser parser) { GSList *node, *next; @@ -1734,10 +1757,10 @@ settings_install_property_parser (GtkSettingsClass *class, if (g_object_class_find_property (G_OBJECT_CLASS (class), pspec->name)) { g_warning (G_STRLOC ": an rc-data property \"%s\" already exists", - pspec->name); + pspec->name); return 0; } - + for (node = object_list; node; node = node->next) g_object_freeze_notify (node->data); @@ -1747,18 +1770,19 @@ settings_install_property_parser (GtkSettingsClass *class, for (node = object_list; node; node = node->next) { GtkSettings *settings = node->data; + GtkSettingsPrivate *priv = settings->priv; GtkSettingsValuePrivate *qvalue; - - settings->property_values = g_renew (GtkSettingsPropertyValue, settings->property_values, class_n_properties); - settings->property_values[class_n_properties - 1].value.g_type = 0; - g_value_init (&settings->property_values[class_n_properties - 1].value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - g_param_value_set_default (pspec, &settings->property_values[class_n_properties - 1].value); - settings->property_values[class_n_properties - 1].source = GTK_SETTINGS_SOURCE_DEFAULT; + + priv->property_values = g_renew (GtkSettingsPropertyValue, priv->property_values, class_n_properties); + priv->property_values[class_n_properties - 1].value.g_type = 0; + g_value_init (&priv->property_values[class_n_properties - 1].value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_param_value_set_default (pspec, &priv->property_values[class_n_properties - 1].value); + priv->property_values[class_n_properties - 1].source = GTK_SETTINGS_SOURCE_DEFAULT; g_object_notify (G_OBJECT (settings), pspec->name); - - qvalue = g_datalist_get_data (&settings->queued_settings, pspec->name); + + qvalue = g_datalist_get_data (&priv->queued_settings, pspec->name); if (qvalue) - apply_queued_setting (settings, pspec, qvalue); + apply_queued_setting (settings, pspec, qvalue); } for (node = object_list; node; node = next) @@ -1806,7 +1830,7 @@ gtk_settings_install_property (GParamSpec *pspec) void gtk_settings_install_property_parser (GParamSpec *pspec, - GtkRcPropertyParser parser) + GtkRcPropertyParser parser) { static GtkSettingsClass *klass = NULL; @@ -1823,7 +1847,7 @@ static void free_value (gpointer data) { GtkSettingsValuePrivate *qvalue = data; - + g_value_unset (&qvalue->public.value); g_free (qvalue->public.origin); g_slice_free (GtkSettingsValuePrivate, qvalue); @@ -1831,10 +1855,11 @@ free_value (gpointer data) static void gtk_settings_set_property_value_internal (GtkSettings *settings, - const gchar *prop_name, - const GtkSettingsValue *new_value, - GtkSettingsSource source) + const gchar *prop_name, + const GtkSettingsValue *new_value, + GtkSettingsSource source) { + GtkSettingsPrivate *priv = settings->priv; GtkSettingsValuePrivate *qvalue; GParamSpec *pspec; gchar *name; @@ -1848,17 +1873,17 @@ gtk_settings_set_property_value_internal (GtkSettings *settings, g_warning (G_STRLOC ": value type invalid"); return; } - + name = g_strdup (prop_name); g_strcanon (name, G_CSET_DIGITS "-" G_CSET_a_2_z G_CSET_A_2_Z, '-'); name_quark = g_quark_from_string (name); g_free (name); - qvalue = g_datalist_id_get_data (&settings->queued_settings, name_quark); + qvalue = g_datalist_id_get_data (&priv->queued_settings, name_quark); if (!qvalue) { qvalue = g_slice_new0 (GtkSettingsValuePrivate); - g_datalist_id_set_data_full (&settings->queued_settings, name_quark, qvalue, free_value); + g_datalist_id_set_data_full (&priv->queued_settings, name_quark, qvalue, free_value); } else { @@ -1876,35 +1901,35 @@ gtk_settings_set_property_value_internal (GtkSettings *settings, void gtk_settings_set_property_value (GtkSettings *settings, - const gchar *prop_name, - const GtkSettingsValue *new_value) + const gchar *prop_name, + const GtkSettingsValue *new_value) { g_return_if_fail (GTK_SETTINGS (settings)); g_return_if_fail (prop_name != NULL); g_return_if_fail (new_value != NULL); gtk_settings_set_property_value_internal (settings, prop_name, new_value, - GTK_SETTINGS_SOURCE_APPLICATION); + GTK_SETTINGS_SOURCE_APPLICATION); } void _gtk_settings_set_property_value_from_rc (GtkSettings *settings, - const gchar *prop_name, - const GtkSettingsValue *new_value) + const gchar *prop_name, + const GtkSettingsValue *new_value) { g_return_if_fail (GTK_SETTINGS (settings)); g_return_if_fail (prop_name != NULL); g_return_if_fail (new_value != NULL); gtk_settings_set_property_value_internal (settings, prop_name, new_value, - GTK_SETTINGS_SOURCE_RC_FILE); + GTK_SETTINGS_SOURCE_RC_FILE); } void gtk_settings_set_string_property (GtkSettings *settings, - const gchar *name, - const gchar *v_string, - const gchar *origin) + const gchar *name, + const gchar *v_string, + const gchar *origin) { GtkSettingsValue svalue = { NULL, { 0, }, }; @@ -1921,12 +1946,12 @@ gtk_settings_set_string_property (GtkSettings *settings, void gtk_settings_set_long_property (GtkSettings *settings, - const gchar *name, - glong v_long, - const gchar *origin) + const gchar *name, + glong v_long, + const gchar *origin) { GtkSettingsValue svalue = { NULL, { 0, }, }; - + g_return_if_fail (GTK_SETTINGS (settings)); g_return_if_fail (name != NULL); @@ -1939,9 +1964,9 @@ gtk_settings_set_long_property (GtkSettings *settings, void gtk_settings_set_double_property (GtkSettings *settings, - const gchar *name, - gdouble v_double, - const gchar *origin) + const gchar *name, + gdouble v_double, + const gchar *origin) { GtkSettingsValue svalue = { NULL, { 0, }, }; @@ -1960,21 +1985,21 @@ gtk_settings_set_double_property (GtkSettings *settings, * @pspec: a #GParamSpec * @gstring: the #GString to be parsed * @property_value: a #GValue which must hold #GdkColor values. - * + * * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser() * or gtk_widget_class_install_style_property_parser() which parses a - * color given either by its name or in the form + * color given either by its name or in the form * { red, green, blue } where %red, %green and * %blue are integers between 0 and 65535 or floating-point numbers * between 0 and 1. - * + * * Return value: %TRUE if @gstring could be parsed and @property_value * has been set to the resulting #GdkColor. **/ gboolean gtk_rc_property_parse_color (const GParamSpec *pspec, - const GString *gstring, - GValue *property_value) + const GString *gstring, + GValue *property_value) { GdkColor color = { 0, 0, 0, 0, }; GScanner *scanner; @@ -2003,7 +2028,7 @@ gtk_rc_property_parse_color (const GParamSpec *pspec, * @pspec: a #GParamSpec * @gstring: the #GString to be parsed * @property_value: a #GValue which must hold enum values. - * + * * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser() * or gtk_widget_class_install_style_property_parser() which parses a single * enumeration value. @@ -2011,14 +2036,14 @@ gtk_rc_property_parse_color (const GParamSpec *pspec, * The enumeration value can be specified by its name, its nickname or * its numeric value. For consistency with flags parsing, the value * may be surrounded by parentheses. - * + * * Return value: %TRUE if @gstring could be parsed and @property_value * has been set to the resulting #GEnumValue. **/ gboolean gtk_rc_property_parse_enum (const GParamSpec *pspec, - const GString *gstring, - GValue *property_value) + const GString *gstring, + GValue *property_value) { gboolean need_closing_brace = FALSE, success = FALSE; GScanner *scanner; @@ -2042,15 +2067,15 @@ gtk_rc_property_parse_enum (const GParamSpec *pspec, if (scanner->token == G_TOKEN_IDENTIFIER) { GEnumClass *class = G_PARAM_SPEC_ENUM (pspec)->enum_class; - + enum_value = g_enum_get_value_by_name (class, scanner->value.v_identifier); if (!enum_value) - enum_value = g_enum_get_value_by_nick (class, scanner->value.v_identifier); + enum_value = g_enum_get_value_by_nick (class, scanner->value.v_identifier); if (enum_value) - { - g_value_set_enum (property_value, enum_value->value); - success = TRUE; - } + { + g_value_set_enum (property_value, enum_value->value); + success = TRUE; + } } else if (scanner->token == G_TOKEN_INT) { @@ -2069,8 +2094,8 @@ gtk_rc_property_parse_enum (const GParamSpec *pspec, static guint parse_flags_value (GScanner *scanner, - GFlagsClass *class, - guint *number) + GFlagsClass *class, + guint *number) { g_scanner_get_next_token (scanner); if (scanner->token == G_TOKEN_IDENTIFIER) @@ -2079,12 +2104,12 @@ parse_flags_value (GScanner *scanner, flags_value = g_flags_get_value_by_name (class, scanner->value.v_identifier); if (!flags_value) - flags_value = g_flags_get_value_by_nick (class, scanner->value.v_identifier); + flags_value = g_flags_get_value_by_nick (class, scanner->value.v_identifier); if (flags_value) - { - *number |= flags_value->value; - return G_TOKEN_NONE; - } + { + *number |= flags_value->value; + return G_TOKEN_NONE; + } } else if (scanner->token == G_TOKEN_INT) { @@ -2099,21 +2124,21 @@ parse_flags_value (GScanner *scanner, * @pspec: a #GParamSpec * @gstring: the #GString to be parsed * @property_value: a #GValue which must hold flags values. - * + * * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser() - * or gtk_widget_class_install_style_property_parser() which parses flags. - * + * or gtk_widget_class_install_style_property_parser() which parses flags. + * * Flags can be specified by their name, their nickname or - * numerically. Multiple flags can be specified in the form + * numerically. Multiple flags can be specified in the form * "( flag1 | flag2 | ... )". - * + * * Return value: %TRUE if @gstring could be parsed and @property_value * has been set to the resulting flags value. **/ gboolean gtk_rc_property_parse_flags (const GParamSpec *pspec, - const GString *gstring, - GValue *property_value) + const GString *gstring, + GValue *property_value) { GFlagsClass *class; gboolean success = FALSE; @@ -2131,15 +2156,15 @@ gtk_rc_property_parse_flags (const GParamSpec *pspec, scanner->next_token == G_TOKEN_INT) { guint token, flags_value = 0; - + token = parse_flags_value (scanner, class, &flags_value); if (token == G_TOKEN_NONE && g_scanner_peek_next_token (scanner) == G_TOKEN_EOF) - { - success = TRUE; - g_value_set_flags (property_value, flags_value); - } - + { + success = TRUE; + g_value_set_flags (property_value, flags_value); + } + } else if (g_scanner_get_next_token (scanner) == '(') { @@ -2150,15 +2175,15 @@ gtk_rc_property_parse_flags (const GParamSpec *pspec, /* parse nth values, preceeded by '|' */ while (token == G_TOKEN_NONE && g_scanner_get_next_token (scanner) == '|') - token = parse_flags_value (scanner, class, &flags_value); + token = parse_flags_value (scanner, class, &flags_value); /* done, last token must have closed expression */ if (token == G_TOKEN_NONE && scanner->token == ')' && - g_scanner_peek_next_token (scanner) == G_TOKEN_EOF) - { - g_value_set_flags (property_value, flags_value); - success = TRUE; - } + g_scanner_peek_next_token (scanner) == G_TOKEN_EOF) + { + g_value_set_flags (property_value, flags_value); + success = TRUE; + } } g_scanner_destroy (scanner); @@ -2167,15 +2192,15 @@ gtk_rc_property_parse_flags (const GParamSpec *pspec, static gboolean get_braced_int (GScanner *scanner, - gboolean first, - gboolean last, - gint *value) + gboolean first, + gboolean last, + gint *value) { if (first) { g_scanner_get_next_token (scanner); if (scanner->token != '{') - return FALSE; + return FALSE; } g_scanner_get_next_token (scanner); @@ -2188,13 +2213,13 @@ get_braced_int (GScanner *scanner, { g_scanner_get_next_token (scanner); if (scanner->token != '}') - return FALSE; + return FALSE; } else { g_scanner_get_next_token (scanner); if (scanner->token != ',') - return FALSE; + return FALSE; } return TRUE; @@ -2205,19 +2230,19 @@ get_braced_int (GScanner *scanner, * @pspec: a #GParamSpec * @gstring: the #GString to be parsed * @property_value: a #GValue which must hold boxed values. - * + * * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser() * or gtk_widget_class_install_style_property_parser() which parses a - * requisition in the form + * requisition in the form * "{ width, height }" for integers %width and %height. - * + * * Return value: %TRUE if @gstring could be parsed and @property_value * has been set to the resulting #GtkRequisition. **/ gboolean gtk_rc_property_parse_requisition (const GParamSpec *pspec, - const GString *gstring, - GValue *property_value) + const GString *gstring, + GValue *property_value) { GtkRequisition requisition; GScanner *scanner; @@ -2246,20 +2271,20 @@ gtk_rc_property_parse_requisition (const GParamSpec *pspec, * @pspec: a #GParamSpec * @gstring: the #GString to be parsed * @property_value: a #GValue which must hold boxed values. - * + * * A #GtkRcPropertyParser for use with gtk_settings_install_property_parser() * or gtk_widget_class_install_style_property_parser() which parses - * borders in the form - * "{ left, right, top, bottom }" for integers + * borders in the form + * "{ left, right, top, bottom }" for integers * %left, %right, %top and %bottom. - * + * * Return value: %TRUE if @gstring could be parsed and @property_value * has been set to the resulting #GtkBorder. **/ gboolean gtk_rc_property_parse_border (const GParamSpec *pspec, - const GString *gstring, - GValue *property_value) + const GString *gstring, + GValue *property_value) { GtkBorder border; GScanner *scanner; @@ -2293,23 +2318,25 @@ gtk_rc_property_parse_border (const GParamSpec *pspec, void _gtk_settings_handle_event (GdkEventSetting *event) { + GdkScreen *screen; GtkSettings *settings; GParamSpec *pspec; guint property_id; - settings = gtk_settings_get_for_screen (gdk_window_get_screen (event->window)); + screen = gdk_window_get_screen (event->window); + settings = gtk_settings_get_for_screen (screen); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name); - - if (pspec) + + if (pspec) { property_id = pspec->param_id; if (property_id == PROP_COLOR_SCHEME) { GValue value = { 0, }; - + g_value_init (&value, G_TYPE_STRING); - if (!gdk_screen_get_setting (settings->screen, pspec->name, &value)) + if (!gdk_screen_get_setting (screen, pspec->name, &value)) g_value_set_static_string (&value, ""); merge_color_scheme (settings, &value, GTK_SETTINGS_SOURCE_XSETTING); g_value_unset (&value); @@ -2319,9 +2346,9 @@ _gtk_settings_handle_event (GdkEventSetting *event) } static void -reset_rc_values_foreach (GQuark key_id, - gpointer data, - gpointer user_data) +reset_rc_values_foreach (GQuark key_id, + gpointer data, + gpointer user_data) { GtkSettingsValuePrivate *qvalue = data; GSList **to_reset = user_data; @@ -2333,21 +2360,21 @@ reset_rc_values_foreach (GQuark key_id, void _gtk_settings_reset_rc_values (GtkSettings *settings) { + GtkSettingsPrivate *priv = settings->priv; GSList *to_reset = NULL; GSList *tmp_list; GParamSpec **pspecs, **p; gint i; - /* Remove any queued settings - */ - g_datalist_foreach (&settings->queued_settings, - reset_rc_values_foreach, - &to_reset); + /* Remove any queued settings */ + g_datalist_foreach (&priv->queued_settings, + reset_rc_values_foreach, + &to_reset); for (tmp_list = to_reset; tmp_list; tmp_list = tmp_list->next) { GQuark key_id = GPOINTER_TO_UINT (tmp_list->data); - g_datalist_id_remove_data (&settings->queued_settings, key_id); + g_datalist_id_remove_data (&priv->queued_settings, key_id); } g_slist_free (to_reset); @@ -2360,13 +2387,13 @@ _gtk_settings_reset_rc_values (GtkSettings *settings) g_object_freeze_notify (G_OBJECT (settings)); for (p = pspecs; *p; p++) { - if (settings->property_values[i].source == GTK_SETTINGS_SOURCE_RC_FILE) - { - GParamSpec *pspec = *p; + if (priv->property_values[i].source == GTK_SETTINGS_SOURCE_RC_FILE) + { + GParamSpec *pspec = *p; - g_param_value_set_default (pspec, &settings->property_values[i].value); - g_object_notify (G_OBJECT (settings), pspec->name); - } + g_param_value_set_default (pspec, &priv->property_values[i].value); + g_object_notify (G_OBJECT (settings), pspec->name); + } i++; } g_object_thaw_notify (G_OBJECT (settings)); @@ -2376,17 +2403,19 @@ _gtk_settings_reset_rc_values (GtkSettings *settings) static void settings_update_double_click (GtkSettings *settings) { - if (gdk_screen_get_number (settings->screen) == 0) + GtkSettingsPrivate *priv = settings->priv; + + if (gdk_screen_get_number (priv->screen) == 0) { - GdkDisplay *display = gdk_screen_get_display (settings->screen); + GdkDisplay *display = gdk_screen_get_display (priv->screen); gint double_click_time; gint double_click_distance; - - g_object_get (settings, - "gtk-double-click-time", &double_click_time, - "gtk-double-click-distance", &double_click_distance, - NULL); - + + g_object_get (settings, + "gtk-double-click-time", &double_click_time, + "gtk-double-click-distance", &double_click_distance, + NULL); + gdk_display_set_double_click_time (display, double_click_time); gdk_display_set_double_click_distance (display, double_click_distance); } @@ -2396,13 +2425,13 @@ static void settings_update_modules (GtkSettings *settings) { gchar *modules; - - g_object_get (settings, - "gtk-modules", &modules, - NULL); - + + g_object_get (settings, + "gtk-modules", &modules, + NULL); + _gtk_modules_settings_changed (settings, modules); - + g_free (modules); } @@ -2410,15 +2439,15 @@ settings_update_modules (GtkSettings *settings) static void settings_update_cursor_theme (GtkSettings *settings) { - GdkDisplay *display = gdk_screen_get_display (settings->screen); + GdkDisplay *display = gdk_screen_get_display (settings->priv->screen); gchar *theme = NULL; gint size = 0; - - g_object_get (settings, - "gtk-cursor-theme-name", &theme, - "gtk-cursor-theme-size", &size, - NULL); - + + g_object_get (settings, + "gtk-cursor-theme-name", &theme, + "gtk-cursor-theme-size", &size, + NULL); + gdk_x11_display_set_cursor_theme (display, theme, size); g_free (theme); @@ -2427,6 +2456,7 @@ settings_update_cursor_theme (GtkSettings *settings) static void settings_update_font_options (GtkSettings *settings) { + GtkSettingsPrivate *priv = settings->priv; gint hinting; gchar *hint_style_str; cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_NONE; @@ -2435,18 +2465,18 @@ settings_update_font_options (GtkSettings *settings) gchar *rgba_str; cairo_subpixel_order_t subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT; cairo_font_options_t *options; - + g_object_get (settings, - "gtk-xft-antialias", &antialias, - "gtk-xft-hinting", &hinting, - "gtk-xft-hintstyle", &hint_style_str, - "gtk-xft-rgba", &rgba_str, - NULL); + "gtk-xft-antialias", &antialias, + "gtk-xft-hinting", &hinting, + "gtk-xft-hintstyle", &hint_style_str, + "gtk-xft-rgba", &rgba_str, + NULL); options = cairo_font_options_create (); cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON); - + if (hinting >= 0 && !hinting) { hint_style = CAIRO_HINT_STYLE_NONE; @@ -2454,13 +2484,13 @@ settings_update_font_options (GtkSettings *settings) else if (hint_style_str) { if (strcmp (hint_style_str, "hintnone") == 0) - hint_style = CAIRO_HINT_STYLE_NONE; + hint_style = CAIRO_HINT_STYLE_NONE; else if (strcmp (hint_style_str, "hintslight") == 0) - hint_style = CAIRO_HINT_STYLE_SLIGHT; + hint_style = CAIRO_HINT_STYLE_SLIGHT; else if (strcmp (hint_style_str, "hintmedium") == 0) - hint_style = CAIRO_HINT_STYLE_MEDIUM; + hint_style = CAIRO_HINT_STYLE_MEDIUM; else if (strcmp (hint_style_str, "hintfull") == 0) - hint_style = CAIRO_HINT_STYLE_FULL; + hint_style = CAIRO_HINT_STYLE_FULL; } g_free (hint_style_str); @@ -2470,30 +2500,30 @@ settings_update_font_options (GtkSettings *settings) if (rgba_str) { if (strcmp (rgba_str, "rgb") == 0) - subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB; + subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB; else if (strcmp (rgba_str, "bgr") == 0) - subpixel_order = CAIRO_SUBPIXEL_ORDER_BGR; + subpixel_order = CAIRO_SUBPIXEL_ORDER_BGR; else if (strcmp (rgba_str, "vrgb") == 0) - subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB; + subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB; else if (strcmp (rgba_str, "vbgr") == 0) - subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR; + subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR; g_free (rgba_str); } cairo_font_options_set_subpixel_order (options, subpixel_order); - + if (antialias >= 0 && !antialias) antialias_mode = CAIRO_ANTIALIAS_NONE; else if (subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT) antialias_mode = CAIRO_ANTIALIAS_SUBPIXEL; else if (antialias >= 0) antialias_mode = CAIRO_ANTIALIAS_GRAY; - + cairo_font_options_set_antialias (options, antialias_mode); - gdk_screen_set_font_options (settings->screen, options); - + gdk_screen_set_font_options (priv->screen, options); + cairo_font_options_destroy (options); } @@ -2507,8 +2537,8 @@ settings_update_fontconfig (GtkSettings *settings) guint timestamp; g_object_get (settings, - "gtk-fontconfig-timestamp", ×tamp, - NULL); + "gtk-fontconfig-timestamp", ×tamp, + NULL); /* if timestamp is the same as last_update_timestamp, we already have * updated fontconig on this timestamp (another screen requested it perhaps?), @@ -2521,11 +2551,11 @@ settings_update_fontconfig (GtkSettings *settings) /* bug 547680 */ if (PANGO_IS_FC_FONT_MAP (fontmap) && !FcConfigUptoDate (NULL)) - { - pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (fontmap)); - if (FcInitReinitialize ()) - update_needed = TRUE; - } + { + pango_fc_font_map_cache_clear (PANGO_FC_FONT_MAP (fontmap)); + if (FcInitReinitialize ()) + update_needed = TRUE; + } last_update_timestamp = timestamp; last_update_needed = update_needed; @@ -2538,23 +2568,25 @@ settings_update_fontconfig (GtkSettings *settings) static void settings_update_resolution (GtkSettings *settings) { + GtkSettingsPrivate *priv = settings->priv; gint dpi_int; - double dpi; - + gdouble dpi; + g_object_get (settings, - "gtk-xft-dpi", &dpi_int, - NULL); + "gtk-xft-dpi", &dpi_int, + NULL); if (dpi_int > 0) dpi = dpi_int / 1024.; else dpi = -1.; - gdk_screen_set_resolution (settings->screen, dpi); + gdk_screen_set_resolution (priv->screen, dpi); } #endif -typedef struct { +typedef struct +{ GHashTable *color_hash; GHashTable *tables[GTK_SETTINGS_SOURCE_APPLICATION + 1]; gchar *lastentry[GTK_SETTINGS_SOURCE_APPLICATION + 1]; @@ -2570,7 +2602,7 @@ color_scheme_data_free (ColorSchemeData *data) for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++) { if (data->tables[i]) - g_hash_table_unref (data->tables[i]); + g_hash_table_unref (data->tables[i]); g_free (data->lastentry[i]); } @@ -2582,17 +2614,18 @@ settings_update_color_scheme (GtkSettings *settings) { if (!g_object_get_data (G_OBJECT (settings), "gtk-color-scheme")) { + GtkSettingsPrivate *priv = settings->priv; ColorSchemeData *data; GValue value = { 0, }; data = g_slice_new0 (ColorSchemeData); data->color_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - (GDestroyNotify) gdk_color_free); + (GDestroyNotify) gdk_color_free); g_object_set_data_full (G_OBJECT (settings), "gtk-color-scheme", - data, (GDestroyNotify) color_scheme_data_free); + data, (GDestroyNotify) color_scheme_data_free); g_value_init (&value, G_TYPE_STRING); - if (gdk_screen_get_setting (settings->screen, "gtk-color-scheme", &value)) + if (gdk_screen_get_setting (priv->screen, "gtk-color-scheme", &value)) { merge_color_scheme (settings, &value, GTK_SETTINGS_SOURCE_XSETTING); g_value_unset (&value); @@ -2604,6 +2637,8 @@ static void settings_update_theme (GtkSettings *settings) { static GQuark quark_theme_name = 0; + + GtkSettingsPrivate *priv = settings->priv; GtkCssProvider *provider, *new_provider = NULL; gboolean prefer_dark_theme; gchar *theme_name; @@ -2632,12 +2667,12 @@ settings_update_theme (GtkSettings *settings) if (new_provider != provider) { if (provider) - gtk_style_context_remove_provider_for_screen (settings->screen, + gtk_style_context_remove_provider_for_screen (priv->screen, GTK_STYLE_PROVIDER (provider)); if (new_provider) { - gtk_style_context_add_provider_for_screen (settings->screen, + gtk_style_context_add_provider_for_screen (priv->screen, GTK_STYLE_PROVIDER (new_provider), GTK_STYLE_PROVIDER_PRIORITY_THEME); g_object_ref (new_provider); @@ -2650,8 +2685,8 @@ settings_update_theme (GtkSettings *settings) static gboolean add_color_to_hash (gchar *name, - GdkColor *color, - GHashTable *target) + GdkColor *color, + GHashTable *target) { GdkColor *old; @@ -2668,7 +2703,7 @@ add_color_to_hash (gchar *name, static gboolean add_colors_to_hash_from_string (GHashTable *hash, - const gchar *colors) + const gchar *colors) { gchar *s, *p, *name; GdkColor color; @@ -2687,25 +2722,25 @@ add_colors_to_hash_from_string (GHashTable *hash, p++; } else - break; + break; while (*p == ' ') p++; s = p; - while (*s) - { - if (*s == '\n' || *s == ';') - { - *s = '\0'; - s++; - break; - } - s++; - } + while (*s) + { + if (*s == '\n' || *s == ';') + { + *s = '\0'; + s++; + break; + } + s++; + } if (gdk_color_parse (p, &color)) - changed |= add_color_to_hash (name, &color, hash); + changed |= add_color_to_hash (name, &color, hash); } g_free (copy); @@ -2715,8 +2750,8 @@ add_colors_to_hash_from_string (GHashTable *hash, static gboolean update_color_hash (ColorSchemeData *data, - const gchar *str, - GtkSettingsSource source) + const gchar *str, + GtkSettingsSource source) { gboolean changed = FALSE; gint i; @@ -2745,8 +2780,8 @@ update_color_hash (ColorSchemeData *data, if (data->tables[source] == NULL) data->tables[source] = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, - (GDestroyNotify) gdk_color_free); + g_free, + (GDestroyNotify) gdk_color_free); g_free (data->lastentry[source]); data->lastentry[source] = g_strdup (str); @@ -2777,8 +2812,8 @@ update_color_hash (ColorSchemeData *data, for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++) { if (data->tables[i]) - g_hash_table_foreach (data->tables[i], (GHFunc) add_color_to_hash, - data->color_hash); + g_hash_table_foreach (data->tables[i], (GHFunc) add_color_to_hash, + data->color_hash); } if (old_hash) @@ -2813,9 +2848,9 @@ update_color_hash (ColorSchemeData *data, } static void -merge_color_scheme (GtkSettings *settings, - const GValue *value, - GtkSettingsSource source) +merge_color_scheme (GtkSettings *settings, + const GValue *value, + GtkSettingsSource source) { ColorSchemeData *data; const gchar *colors; @@ -2827,8 +2862,8 @@ merge_color_scheme (GtkSettings *settings, settings_update_color_scheme (settings); data = (ColorSchemeData *) g_object_get_data (G_OBJECT (settings), - "gtk-color-scheme"); - + "gtk-color-scheme"); + if (update_color_hash (data, colors, source)) g_object_notify (G_OBJECT (settings), "color-hash"); @@ -2841,24 +2876,24 @@ get_color_hash (GtkSettings *settings) ColorSchemeData *data; settings_update_color_scheme (settings); - - data = (ColorSchemeData *)g_object_get_data (G_OBJECT (settings), - "gtk-color-scheme"); + + data = (ColorSchemeData *)g_object_get_data (G_OBJECT (settings), + "gtk-color-scheme"); return data->color_hash; } -static void +static void append_color_scheme (gpointer key, - gpointer value, - gpointer data) + gpointer value, + gpointer data) { gchar *name = (gchar *)key; GdkColor *color = (GdkColor *)value; GString *string = (GString *)data; g_string_append_printf (string, "%s: #%04x%04x%04x\n", - name, color->red, color->green, color->blue); + name, color->red, color->green, color->blue); } static gchar * @@ -2866,11 +2901,11 @@ get_color_scheme (GtkSettings *settings) { ColorSchemeData *data; GString *string; - + settings_update_color_scheme (settings); data = (ColorSchemeData *) g_object_get_data (G_OBJECT (settings), - "gtk-color-scheme"); + "gtk-color-scheme"); string = g_string_new (""); @@ -2882,5 +2917,5 @@ get_color_scheme (GtkSettings *settings) GdkScreen * _gtk_settings_get_screen (GtkSettings *settings) { - return settings->screen; + return settings->priv->screen; } -- cgit v1.2.1