diff options
author | Stefano Facchini <stefano.facchini@gmail.com> | 2012-10-14 16:35:07 +0200 |
---|---|---|
committer | Stefano Facchini <stefano.facchini@gmail.com> | 2012-10-14 18:23:57 +0200 |
commit | 0e3062acba33d0dc8282bdf8d16c2ef11eb46a57 (patch) | |
tree | cb6365e4e4716ca40fa9ff7bf0ca6a05f5772349 | |
parent | 05e9400c1e5924680232d553b8ced27408455155 (diff) | |
download | baobab-0e3062acba33d0dc8282bdf8d16c2ef11eb46a57.tar.gz |
Move styling of treeview level cell to CSS
The CSS should go in the GNOME theme actually, but for now
we use embedded CSS to avoid breaking foreign themes.
-rw-r--r-- | src/baobab-application.vala | 27 | ||||
-rw-r--r-- | src/baobab-cellrenderers.vala | 15 |
2 files changed, 35 insertions, 7 deletions
diff --git a/src/baobab-application.vala b/src/baobab-application.vala index 4c6fc97..69dc919 100644 --- a/src/baobab-application.vala +++ b/src/baobab-application.vala @@ -22,6 +22,29 @@ namespace Baobab { + const string CSS_DATA = ".cell.baobab-level-cell.fill-block, +.cell.baobab-level-cell.fill-block:selected, +.cell.baobab-level-cell.fill-block:selected:hover { + background-color: #edd400; +} + +.cell.baobab-level-cell.fill-block.level-low, +.cell.baobab-level-cell.fill-block.level-low:hover { + background-color: #73d216; +} + +.cell.baobab-level-cell.fill-block.level-high, +.cell.baobab-level-cell.fill-block.level-high:hover { + background-color: #cc0000; +} + +.cell.baobab-level-cell.fill-block:backdrop, +.cell.baobab-level-cell.fill-block:hover:backdrop, +.cell.baobab-level-cell.fill-block.level-low:backdrop, +.cell.baobab-level-cell.fill-block.level-high:backdrop { + background-color: @theme_unfocused_text_color; +}"; + public class Application : Gtk.Application { static Application baobab; @@ -77,6 +100,10 @@ namespace Baobab { baobab = this; + var css_provider = new Gtk.CssProvider (); + css_provider.load_from_data (CSS_DATA, -1); + Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + // Settings ui_settings = new Settings ("org.gnome.baobab.ui"); prefs_settings = new Settings ("org.gnome.baobab.preferences"); diff --git a/src/baobab-cellrenderers.vala b/src/baobab-cellrenderers.vala index 230616a..7704393 100644 --- a/src/baobab-cellrenderers.vala +++ b/src/baobab-cellrenderers.vala @@ -139,15 +139,16 @@ namespace Baobab { if (widget.get_direction () == Gtk.TextDirection.RTL) { x_bar += w - perc_w; } - cr.rectangle (x_bar, y, perc_w, h); + + context.add_class ("fill-block"); + if (percent <= 33) { - cr.set_source_rgb (0x73 / 255.0, 0xd2 / 255.0, 0x16 / 255.0); - } else if (percent <= 66) { - cr.set_source_rgb (0xed / 255.0, 0xd4 / 255.0, 0x00 / 255.0); - } else { - cr.set_source_rgb (0xcc / 255.0, 0x00 / 255.0, 0x00 / 255.0); + context.add_class ("level-low"); + } else if (percent > 66) { + context.add_class ("level-high"); } - cr.fill (); + + context.render_background (cr, x_bar, y, perc_w, h); context.restore (); } |