[baobab] Move styling of treeview level cell to CSS
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab] Move styling of treeview level cell to CSS
- Date: Sun, 14 Oct 2012 16:30:01 +0000 (UTC)
commit 0e3062acba33d0dc8282bdf8d16c2ef11eb46a57
Author: Stefano Facchini <stefano facchini gmail com>
Date: Sun Oct 14 16:35:07 2012 +0200
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.
src/baobab-application.vala | 27 +++++++++++++++++++++++++++
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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]