[baobab] Ringchart: always use the correct state when getting colors
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab] Ringchart: always use the correct state when getting colors
- Date: Thu, 10 Sep 2015 11:34:50 +0000 (UTC)
commit 5380d41b1ce90973558fc6edcd8dbd85c06318a7
Author: Sebastian Keller <sebastian-keller gmx de>
Date: Mon Sep 7 22:51:09 2015 +0200
Ringchart: always use the correct state when getting colors
The ringchart was calling get_background_color on the toplevel context
with a fixed state of NORMAL without saving the context first. If the
toplevel however had additional state flags set, such as BACKDROP, this
could trigger an invalidation and cause a redraw, resulting in a redraw
loop.
Instead of saving/restoring the context, this patch uses the current
state of the context, which is the right thing to do in general anyway
and does not require saving/restoring the context unless the context is
actually modified.
https://bugzilla.gnome.org/show_bug.cgi?id=754703
src/baobab-ringschart.vala | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/baobab-ringschart.vala b/src/baobab-ringschart.vala
index c87de29..d489eda 100644
--- a/src/baobab-ringschart.vala
+++ b/src/baobab-ringschart.vala
@@ -94,6 +94,7 @@ namespace Baobab {
}
var context = get_style_context ();
+ var context_state = context.get_state ();
context.save ();
context.add_class ("subfolder-tip");
context.add_class ("tooltip");
@@ -107,7 +108,7 @@ namespace Baobab {
Gdk.Rectangle last_rect = Gdk.Rectangle ();
- var padding = context.get_padding (Gtk.StateFlags.NORMAL);
+ var padding = context.get_padding (context_state);
var vpadding = padding.top + padding.bottom;
var hpadding = padding.left + padding.right;
@@ -194,7 +195,7 @@ namespace Baobab {
cr.rectangle (tooltip_rect.x + tooltip_rect.width, tooltip_rect.y, -tooltip_rect.width,
tooltip_rect.height);
cr.clip ();
- var bg_color = context.get_background_color (Gtk.StateFlags.NORMAL);
+ var bg_color = context.get_background_color (context_state);
cr.set_line_width (1);
cr.move_to (sector_center_x, sector_center_y);
Gdk.cairo_set_source_rgba (cr, bg_color);
@@ -235,10 +236,14 @@ namespace Baobab {
get_allocation (out allocation);
var context = get_style_context ();
+ var context_state = context.get_state ();
context.save ();
- var border_color = context.get_border_color (Gtk.StateFlags.NORMAL);
- var bg_color = get_toplevel ().get_style_context ().get_background_color (Gtk.StateFlags.NORMAL);
+ var toplevel_context = get_toplevel ().get_style_context ();
+ var toplevel_context_state = toplevel_context.get_state ();
+
+ var border_color = context.get_border_color (context_state);
+ var bg_color = toplevel_context.get_background_color (toplevel_context_state);
var center_x = allocation.width / 2;
var center_y = allocation.height / 2;
@@ -298,7 +303,10 @@ namespace Baobab {
Gtk.Allocation allocation;
get_allocation (out allocation);
- var padding = get_style_context ().get_padding (Gtk.StateFlags.NORMAL);
+ var context = get_style_context ();
+ var context_state = context.get_state ();
+
+ var padding = context.get_padding (context_state);
var max_radius = int.min (allocation.width / 2, allocation.height / 2) - padding.left; //
Assuming that padding is the same for all sides
var thickness = max_radius / (max_depth + 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]