diff options
author | Eben Eliason <eben@localhost.localdomain> | 2008-03-25 05:43:22 (GMT) |
---|---|---|
committer | Eben Eliason <eben@localhost.localdomain> | 2008-03-25 05:43:22 (GMT) |
commit | c4fabca6d9923af6412615740840ff3b6af4ebcf (patch) | |
tree | 69d57631fa34f8f91c6584cb33ca2e55ef419d5b | |
parent | c67f9f26483b334b65ed4e109e48fb5a9dfd4f20 (diff) | |
parent | a4b7d70d1ee5d380b44092cb6fef08edb0678fab (diff) |
Merge branch 'master' of git+ssh://dev.laptop.org/git/artwork
-rw-r--r-- | gtk/engine/sugar-rc-style.c | 89 | ||||
-rw-r--r-- | gtk/engine/sugar-rc-style.h | 22 | ||||
-rw-r--r-- | gtk/engine/sugar-style.c | 46 | ||||
-rw-r--r-- | gtk/theme/gtkrc.em | 67 |
4 files changed, 161 insertions, 63 deletions
diff --git a/gtk/engine/sugar-rc-style.c b/gtk/engine/sugar-rc-style.c index 1a89322..0e25172 100644 --- a/gtk/engine/sugar-rc-style.c +++ b/gtk/engine/sugar-rc-style.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2007, Red Hat, Inc. + * Copyright (C) 2008, Benjamin Berg * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,7 +36,8 @@ static gchar symbols[] = "scrollbar_border\0" "fake_padding\0" "subcell_size\0" - "label_fg_color\0" + "parent_fg_color\0" + "parent_bg_color\0" "bg\0" "fg\0" "base\0" @@ -50,7 +52,8 @@ typedef enum { TOKEN_SCROLLBAR_BORDER, TOKEN_FAKE_PADDING, TOKEN_SUBCELL_SIZE, - TOKEN_LABEL_FG_COLOR, + TOKEN_PARENT_FG_COLOR, + TOKEN_PARENT_BG_COLOR, TOKEN_BG, TOKEN_FG, TOKEN_BASE, @@ -84,6 +87,8 @@ sugar_rc_style_register_type (GTypeModule *module) static void sugar_rc_style_init (SugarRcStyle *rc_style) { + gint i; + /* Initilize the RC style. */ rc_style->line_width = 3; rc_style->thick_line_width = 4; @@ -92,10 +97,15 @@ sugar_rc_style_init (SugarRcStyle *rc_style) rc_style->fake_padding = 0; rc_style->subcell_size = 15; rc_style->hint = NULL; - rc_style->apply_label_color.bg = 0; - rc_style->apply_label_color.fg = 0; - rc_style->apply_label_color.base = 0; - rc_style->apply_label_color.text = 0; + + rc_style->color_flags = 0; + + for (i = 0; i < 5; i++) { + rc_style->color_mapping.fg[i] = SUGAR_COLOR_ORIGINAL; + rc_style->color_mapping.bg[i] = SUGAR_COLOR_ORIGINAL; + rc_style->color_mapping.base[i] = SUGAR_COLOR_ORIGINAL; + rc_style->color_mapping.text[i] = SUGAR_COLOR_ORIGINAL; + } } @@ -156,7 +166,7 @@ sugar_rc_parse_color_assignment (GScanner *scanner, SugarRcStyle *rc_style) GTokenType type; GTokenType token; GtkStateType state; - guint8 *bitfield; + SugarRCColor color; type = g_scanner_cur_token(scanner); @@ -172,26 +182,29 @@ sugar_rc_parse_color_assignment (GScanner *scanner, SugarRcStyle *rc_style) return G_TOKEN_EQUAL_SIGN; token = g_scanner_get_next_token(scanner); - if (token != TOKEN_LABEL_FG_COLOR) - return TOKEN_LABEL_FG_COLOR; + if (token == TOKEN_PARENT_FG_COLOR) + color = SUGAR_COLOR_FG; + else if (token == TOKEN_PARENT_BG_COLOR) + color = SUGAR_COLOR_BG; + else + return TOKEN_PARENT_FG_COLOR; switch (type) { case TOKEN_BG: - bitfield = &rc_style->apply_label_color.bg; + rc_style->color_mapping.bg[state] = color; break; case TOKEN_FG: - bitfield = &rc_style->apply_label_color.fg; + rc_style->color_mapping.fg[state] = color; break; case TOKEN_BASE: - bitfield = &rc_style->apply_label_color.base; + rc_style->color_mapping.base[state] = color; break; case TOKEN_TEXT: - bitfield = &rc_style->apply_label_color.text; + rc_style->color_mapping.text[state] = color; break; default: return G_TOKEN_IDENTIFIER; } - *bitfield |= 1 << state; return G_TOKEN_NONE; } @@ -259,9 +272,13 @@ sugar_rc_style_parse (GtkRcStyle *rc_style, token = sugar_rc_parse_string(scanner, &sugar_rc_style->hint); sugar_rc_style->flags |= OPTION_HINT; break; - case TOKEN_LABEL_FG_COLOR: - token = sugar_rc_parse_color(scanner, &sugar_rc_style->label_fg_color); - sugar_rc_style->flags |= OPTION_LABEL_FG_COLOR; + case TOKEN_PARENT_FG_COLOR: + token = sugar_rc_parse_color(scanner, &sugar_rc_style->colors[SUGAR_COLOR_FG]); + sugar_rc_style->color_flags |= 1 << SUGAR_COLOR_FG; + break; + case TOKEN_PARENT_BG_COLOR: + token = sugar_rc_parse_color(scanner, &sugar_rc_style->colors[SUGAR_COLOR_BG]); + sugar_rc_style->color_flags |= 1 << SUGAR_COLOR_BG; break; case TOKEN_FG: @@ -295,6 +312,7 @@ sugar_rc_style_merge (GtkRcStyle *dest, SugarRcStyle *sugar_src; SugarRcStyleOptions flags; GtkStateType state; + gint i; parent_class->merge (dest, src); @@ -319,18 +337,43 @@ sugar_rc_style_merge (GtkRcStyle *dest, sugar_dest->fake_padding = sugar_src->fake_padding; if (flags & OPTION_SUBCELL_SIZE) sugar_dest->subcell_size = sugar_src->subcell_size; - if (flags & OPTION_LABEL_FG_COLOR) - sugar_dest->label_fg_color = sugar_src->label_fg_color; if (flags & OPTION_HINT) { g_free (sugar_dest->hint); sugar_dest->hint = g_strdup (sugar_src->hint); } sugar_dest->flags |= flags; - sugar_dest->apply_label_color.bg |= sugar_src->apply_label_color.bg; - sugar_dest->apply_label_color.fg |= sugar_src->apply_label_color.fg; - sugar_dest->apply_label_color.base |= sugar_src->apply_label_color.base; - sugar_dest->apply_label_color.text |= sugar_src->apply_label_color.text; + + + flags = (~sugar_dest->color_flags) & sugar_src->color_flags; + for (i = 0; i < SUGAR_COLOR_COUNT; i++) { + if (flags & (1 << i)) + sugar_dest->colors[i] = sugar_src->colors[i]; + + } + sugar_dest->color_flags |= flags; + + for (i = 0; i < 5; i++) { + if ((sugar_dest->color_mapping.bg[i] == SUGAR_COLOR_ORIGINAL) && + !(dest->color_flags[i] & GTK_RC_BG)) { + sugar_dest->color_mapping.bg[i] = sugar_src->color_mapping.bg[i]; + } + + if ((sugar_dest->color_mapping.fg[i] == SUGAR_COLOR_ORIGINAL) && + !(dest->color_flags[i] & GTK_RC_FG)) { + sugar_dest->color_mapping.fg[i] = sugar_src->color_mapping.fg[i]; + } + + if ((sugar_dest->color_mapping.base[i] == SUGAR_COLOR_ORIGINAL) && + !(dest->color_flags[i] & GTK_RC_BASE)) { + sugar_dest->color_mapping.base[i] = sugar_src->color_mapping.base[i]; + } + + if ((sugar_dest->color_mapping.text[i] == SUGAR_COLOR_ORIGINAL) && + !(dest->color_flags[i] & GTK_RC_TEXT)) { + sugar_dest->color_mapping.text[i] = sugar_src->color_mapping.text[i]; + } + } } diff --git a/gtk/engine/sugar-rc-style.h b/gtk/engine/sugar-rc-style.h index f650c79..be6c8ee 100644 --- a/gtk/engine/sugar-rc-style.h +++ b/gtk/engine/sugar-rc-style.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2007, Red Hat, Inc. + * Copyright (C) 2008, Benjamin Berg * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,12 +42,18 @@ typedef enum { } SugarRcStyleOptions; typedef struct { - guint8 fg; - guint8 bg; - guint8 base; - guint8 text; -} SugarColorBitfield; + guint8 fg[5]; + guint8 bg[5]; + guint8 base[5]; + guint8 text[5]; +} SugarColorMapping; +typedef enum { + SUGAR_COLOR_ORIGINAL = 0xff, + SUGAR_COLOR_FG = 0, + SUGAR_COLOR_BG = 1, +} SugarRCColor; +#define SUGAR_COLOR_COUNT 2 #define SUGAR_TYPE_RC_STYLE sugar_type_rc_style #define SUGAR_RC_STYLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), SUGAR_TYPE_RC_STYLE, SugarRcStyle)) @@ -71,8 +78,9 @@ struct _SugarRcStyle { /* The purpose of this color is to be able to apply a color from * a different style at merge time. This cannot be done with symbolic * colors. */ - GdkColor label_fg_color; - SugarColorBitfield apply_label_color; + guint color_flags; + GdkColor colors[SUGAR_COLOR_COUNT]; + SugarColorMapping color_mapping; }; struct _SugarRcStyleClass { diff --git a/gtk/engine/sugar-style.c b/gtk/engine/sugar-style.c index 24cbc9b..0ffaf06 100644 --- a/gtk/engine/sugar-style.c +++ b/gtk/engine/sugar-style.c @@ -83,18 +83,40 @@ sugar_style_init_from_rc (GtkStyle *style, GtkRcStyle *rc_style) parent_class->init_from_rc(GTK_STYLE (style), GTK_RC_STYLE (rc_style)); - /* Copy the label fg color. */ - if (sugar_rc_style->flags & OPTION_LABEL_FG_COLOR) { - /* Now copy colors around if wanted. If any color has been set. */ - for (state = 0; state < 5; state++) { - if (sugar_rc_style->apply_label_color.bg & (1 << state)) - style->bg[state] = sugar_rc_style->label_fg_color; - if (sugar_rc_style->apply_label_color.fg & (1 << state)) - style->fg[state] = sugar_rc_style->label_fg_color; - if (sugar_rc_style->apply_label_color.base & (1 << state)) - style->base[state] = sugar_rc_style->label_fg_color; - if (sugar_rc_style->apply_label_color.text & (1 << state)) - style->text[state] = sugar_rc_style->label_fg_color; + /* Copy the sugar engines colors. */ + for (state = 0; state < 5; state++) { + SugarRCColor color; + + if (sugar_rc_style->color_mapping.fg[state] != SUGAR_COLOR_ORIGINAL) { + color = sugar_rc_style->color_mapping.fg[state]; + if (sugar_rc_style->color_flags & (1 << color)) + style->fg[state] = sugar_rc_style->colors[color]; + else + g_warning("Trying to use an uninitilized color.\n"); + } + + if (sugar_rc_style->color_mapping.bg[state] != SUGAR_COLOR_ORIGINAL) { + color = sugar_rc_style->color_mapping.bg[state]; + if (sugar_rc_style->color_flags & (1 << color)) + style->bg[state] = sugar_rc_style->colors[color]; + else + g_warning("Trying to use an uninitilized color.\n"); + } + + if (sugar_rc_style->color_mapping.text[state] != SUGAR_COLOR_ORIGINAL) { + color = sugar_rc_style->color_mapping.text[state]; + if (sugar_rc_style->color_flags & (1 << color)) + style->text[state] = sugar_rc_style->colors[color]; + else + g_warning("Trying to use an uninitilized color.\n"); + } + + if (sugar_rc_style->color_mapping.base[state] != SUGAR_COLOR_ORIGINAL) { + color = sugar_rc_style->color_mapping.base[state]; + if (sugar_rc_style->color_flags & (1 << color)) + style->base[state] = sugar_rc_style->colors[color]; + else + g_warning("Trying to use an uninitilized color.\n"); } } } diff --git a/gtk/theme/gtkrc.em b/gtk/theme/gtkrc.em index 535b095..c73f513 100644 --- a/gtk/theme/gtkrc.em +++ b/gtk/theme/gtkrc.em @@ -147,7 +147,6 @@ style "default" thick_line_width = $thick_line_width subcell_size = $subcell_size - # Not sure about this one, but it is not that important max_radius = $( 2*subcell_size ) } } @@ -176,7 +175,8 @@ style "window-child" fg[NORMAL] = $black engine "sugar" { - label_fg_color = $black + parent_fg_color = $black + parent_bg_color = $panel_grey } } @@ -193,7 +193,8 @@ style "black-bg-child" fg[NORMAL] = $white engine "sugar" { - label_fg_color = $white + parent_fg_color = $white + parent_bg_color = $black } } @@ -211,7 +212,8 @@ style "groupbox-panel-child" fg[NORMAL] = $black engine "sugar" { - label_fg_color = $black + parent_fg_color = $black + parent_bg_color = $selection_grey } } @@ -228,7 +230,8 @@ style "groupbox-palette-child" fg[NORMAL] = $white engine "sugar" { - label_fg_color = $white + parent_fg_color = $white + parent_bg_color = $toolbar_grey } } @@ -275,7 +278,8 @@ style "menu-child" base[INSENSITIVE] = $black engine "sugar" { - label_fg_color = $white + parent_fg_color = $white + parent_bg_color = $black } } @@ -358,7 +362,7 @@ style "scale" { GtkWidget::focus-line-width = 0 - bg[NORMAL] = "#808080" + bg[NORMAL] = $button_grey # "square" slider (really round of course) # Same as indicator-size? @@ -413,6 +417,11 @@ style "spinbutton" style "frame" { bg[NORMAL] = $toolbar_grey + + engine "sugar" { + parent_bg_color = $toolbar_grey + parent_fg_color = $white + } } style "notebook-tab" @@ -474,6 +483,15 @@ style "toolbar" { xthickness = 0 ythickness = 0 + + bg[NORMAL] = $toolbar_grey + bg[INSENSITIVE] = $toolbar_grey + base[INSENSITIVE] = $toolbar_grey + + engine "sugar" { + parent_fg_color = $white + parent_bg_color = $toolbar_grey + } } style "toolbox" @@ -486,7 +504,8 @@ style "toolbox" base[INSENSITIVE] = $toolbar_grey engine "sugar" { - label_fg_color = $white + parent_fg_color = $white + parent_bg_color = $toolbar_grey } } @@ -581,9 +600,9 @@ style "checkbutton" engine "sugar" { # Reset the colors to the normal color again # as they were overriden by the button style - fg[NORMAL] = label_fg_color - fg[PRELIGHT] = label_fg_color - fg[ACTIVE] = label_fg_color + fg[NORMAL] = parent_fg_color + fg[PRELIGHT] = parent_fg_color + fg[ACTIVE] = parent_fg_color } } @@ -648,6 +667,14 @@ style "trayicon" bg[ACTIVE] = $button_grey } +style "parent-bg" +{ + engine "sugar" { + bg[NORMAL] = parent_bg_color + bg[INSENSITIVE] = parent_bg_color + } +} + #################################################################### # Default style, setting some generic options and style properties #################################################################### @@ -660,13 +687,9 @@ class "GtkWidget" style "default" # This one should probably be the default (ie. no window-child style) widget_class "<GtkWindow>" style "window" -widget_class "<GtkWindow>*<GtkEventBox>" style "window" -widget_class "<GtkWindow>*<GtkLayout>" style "window" widget_class "<GtkWindow>*" style "window-child" widget_class "*<SugarAlert>" style "black-bg" -widget_class "*<SugarAlert>*<GtkEventBox>" style "black-bg" -widget_class "*<SugarAlert>*<GtkLayout>" style "black-bg" widget_class "*<SugarAlert>*" style "black-bg-child" @@ -692,18 +715,12 @@ widget_class "*<SugarPanel>*" style "panel" # GroupBoxes (don't set bg[NORMAL] on the widget itself) widget_class "<GtkWindow>*<SugarGroupBox>*" style "groupbox-panel-child" -widget_class "<GtkWindow>*<SugarGroupBox>*<GtkEventBox>" style "groupbox-panel" -widget_class "<GtkWindow>*<SugarGroupBox>*<GtkLayout>" style "groupbox-panel" widget_class "<GtkWindow>*<GtkNotebook>*" style "groupbox-panel-child" widget_class "<GtkWindow>*<GtkNotebook>" style "notebook-panel" -widget_class "<GtkWindow>*<GtkNotebook>*<GtkEventBox>" style "groupbox-panel" -widget_class "<GtkWindow>*<GtkNotebook>*<GtkLayout>" style "groupbox-panel" widget_class "<SugarPalette>*<SugarGroupBox>*" style "groupbox-palette-child" -widget_class "<SugarPalette>*<SugarGroupBox>*<GtkEventBox>" style "groupbox-palette" -widget_class "<SugarPalette>*<SugarGroupBox>*<GtkLayout>" style "groupbox-palette" # SugarToolbox @@ -759,3 +776,11 @@ widget_class "*<GtkToolbar>" style "toolbar" # Tray widget_class "*<SugarTrayIcon>*" style "trayicon" + +# Widgets that should get the background color from the parent +widget_class "*<GtkEventBox>" style "parent-bg" +widget_class "*<GtkLayout>" style "parent-bg" +widget_class "*<GtkViewport>" style "parent-bg" +widget_class "*<GtkDrawingArea>" style "parent-bg" +widget_class "*<GtkScrolledWindow>" style "parent-bg" + |