From 128bc9f3eabcb80719dc24a29e5c968d7d5cf1f8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 12 Dec 2005 15:48:43 +0000 Subject: [PATCH] Make the gtk-color-scheme setting work. 2005-12-12 Matthias Clasen Make the gtk-color-scheme setting work. * gtk/gtksettings.h: * gtk/gtksettings.c (_gtk_settings_get_color_hash): Add a getter that takes care of initializing the color hash if it is not already there. * gtk/gtkrc.c (gtk_rc_color_scheme_changed, gtk_rc_context_get): And use it here. --- ChangeLog | 12 ++++++++++++ ChangeLog.pre-2-10 | 12 ++++++++++++ gtk/gtkrc.c | 6 ++---- gtk/gtksettings.c | 29 +++++++++++++++++++++++------ gtk/gtksettings.h | 1 + 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92646c291a..4394222755 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-12-12 Matthias Clasen + + Make the gtk-color-scheme setting work. + + * gtk/gtksettings.h: + * gtk/gtksettings.c (_gtk_settings_get_color_hash): Add a getter + that takes care of initializing the color hash if it is not + already there. + + * gtk/gtkrc.c (gtk_rc_color_scheme_changed, gtk_rc_context_get): + And use it here. + 2005-12-10 Matthias Clasen * gdk/gdk.c (gdk_parse_args): Warn if parsing fails, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 92646c291a..4394222755 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +2005-12-12 Matthias Clasen + + Make the gtk-color-scheme setting work. + + * gtk/gtksettings.h: + * gtk/gtksettings.c (_gtk_settings_get_color_hash): Add a getter + that takes care of initializing the color hash if it is not + already there. + + * gtk/gtkrc.c (gtk_rc_color_scheme_changed, gtk_rc_context_get): + And use it here. + 2005-12-10 Matthias Clasen * gdk/gdk.c (gdk_parse_args): Warn if parsing fails, diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 33396bb6df..6eff19be73 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -596,8 +596,7 @@ gtk_rc_color_scheme_changed (GtkSettings *settings, if (context->color_hash) g_hash_table_unref (context->color_hash); - context->color_hash = g_object_get_data (G_OBJECT (settings), - "gtk-color-scheme"); + context->color_hash = _gtk_settings_get_color_hash (settings); if (context->color_hash) g_hash_table_ref (context->color_hash); @@ -629,8 +628,7 @@ gtk_rc_context_get (GtkSettings *settings) "gtk-color-scheme", &context->colors, NULL); - context->color_hash = g_object_get_data (G_OBJECT (settings), - "gtk-color-scheme"); + context->color_hash = _gtk_settings_get_color_hash (settings); if (context->color_hash) g_hash_table_ref (context->color_hash); diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index dbce1b5fed..8c00026d3c 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1590,12 +1590,17 @@ gtk_color_table_from_string (const gchar *str) while (*p == ' ') p++; - s = strchr (p, '\n'); - if (s) - { - *s = '\0'; - s++; - } + s = p; + while (*s) + { + if (*s == '\n') + { + *s = '\0'; + s++; + break; + } + s++; + } if (!gdk_color_parse (p, &color)) { @@ -1633,5 +1638,17 @@ settings_update_color_scheme (GtkSettings *settings) g_free (colors); } +GHashTable * +_gtk_settings_get_color_hash (GtkSettings *settings) +{ + if (g_object_get_data (G_OBJECT (settings), + "gtk-color-scheme") == NULL) + settings_update_color_scheme (settings); + + return (GHashTable *) g_object_get_data (G_OBJECT (settings), + "gtk-color-scheme"); +} + + #define __GTK_SETTINGS_C__ #include "gtkaliasdef.c" diff --git a/gtk/gtksettings.h b/gtk/gtksettings.h index f058e00a68..a1e0f3d780 100644 --- a/gtk/gtksettings.h +++ b/gtk/gtksettings.h @@ -126,6 +126,7 @@ gboolean _gtk_settings_parse_convert (GtkRcPropertyParser parser, const GValue *src_value, GParamSpec *pspec, GValue *dest_value); +GHashTable* _gtk_settings_get_color_hash (GtkSettings *settings); G_END_DECLS