move some utility code here from appearance
2007-07-26 Jens Granseuer <jensgr@gmx.net> * gnome-theme-info.c: (gnome_theme_read_meta_theme), (gnome_theme_color_scheme_parse), (gnome_theme_color_scheme_equal): * gnome-theme-info.h: * gtkrc-utils.c: (str_nequal), (gtkrc_get_color_scheme), (gtkrc_get_color_scheme_for_theme): * gtkrc-utils.h: move some utility code here from appearance * gnome-theme-apply.c: (gnome_meta_theme_set): when applying a metatheme, check whether to set/unset the color scheme gconf key (should fix bug #421866) svn path=/trunk/; revision=7897
This commit is contained in:
parent
7eefc853d1
commit
abd1b52762
11 changed files with 174 additions and 94 deletions
|
@ -144,66 +144,3 @@ theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
theme_parse_color_scheme (const gchar *scheme, GdkColor *colors)
|
||||
{
|
||||
gchar **color_scheme_strings, **color_scheme_pair, *current_string;
|
||||
gint i;
|
||||
|
||||
if (!scheme || !strcmp (scheme, ""))
|
||||
return FALSE;
|
||||
|
||||
/* The color scheme string consists of name:color pairs, seperated by
|
||||
* newlines, so first we split the string up by new line */
|
||||
|
||||
color_scheme_strings = g_strsplit (scheme, "\n", 0);
|
||||
|
||||
/* loop through the name:color pairs, and save the color if we recognise the name */
|
||||
i = 0;
|
||||
while ((current_string = color_scheme_strings[i++])) {
|
||||
color_scheme_pair = g_strsplit (current_string, ":", 0);
|
||||
|
||||
if (color_scheme_pair[0] != NULL && color_scheme_pair[1] != NULL) {
|
||||
g_strstrip (color_scheme_pair[0]);
|
||||
g_strstrip (color_scheme_pair[1]);
|
||||
|
||||
if (!strcmp ("fg_color", color_scheme_pair[0]))
|
||||
gdk_color_parse (color_scheme_pair[1], &colors[0]);
|
||||
else if (!strcmp ("bg_color", color_scheme_pair[0]))
|
||||
gdk_color_parse (color_scheme_pair[1], &colors[1]);
|
||||
else if (!strcmp ("text_color", color_scheme_pair[0]))
|
||||
gdk_color_parse (color_scheme_pair[1], &colors[2]);
|
||||
else if (!strcmp ("base_color", color_scheme_pair[0]))
|
||||
gdk_color_parse (color_scheme_pair[1], &colors[3]);
|
||||
else if (!strcmp ("selected_fg_color", color_scheme_pair[0]))
|
||||
gdk_color_parse (color_scheme_pair[1], &colors[4]);
|
||||
else if (!strcmp ("selected_bg_color", color_scheme_pair[0]))
|
||||
gdk_color_parse (color_scheme_pair[1], &colors[5]);
|
||||
}
|
||||
|
||||
g_strfreev (color_scheme_pair);
|
||||
}
|
||||
|
||||
g_strfreev (color_scheme_strings);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
theme_color_scheme_equal (const gchar *s1, const gchar *s2)
|
||||
{
|
||||
GdkColor c1[6], c2[6];
|
||||
int i;
|
||||
|
||||
if (!theme_parse_color_scheme (s1, c1) ||
|
||||
!theme_parse_color_scheme (s2, c2))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < 6; ++i) {
|
||||
if (!gdk_color_equal (&c1[i], &c2[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue