[pitivi] ruler: Update colors when theme is changed
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] ruler: Update colors when theme is changed
- Date: Wed, 13 Apr 2022 19:47:55 +0000 (UTC)
commit 0c745994129ee4d0969070b9d118c26fd888c8e0
Author: Thejas Kiran P S <thejaskiranps gmail com>
Date: Wed Apr 13 19:47:54 2022 +0000
ruler: Update colors when theme is changed
Fixes #2462
pitivi/timeline/ruler.py | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 6a429c7f5..d6fd4efca 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -116,7 +116,9 @@ class ScaleRuler(Gtk.DrawingArea, Loggable):
self.position = 0 # In nanoseconds
-# Timeline position changed method
+ # Update colors when theme or color preferences change.
+ Gtk.Settings.get_default().connect("notify::gtk-theme-name", self._update_colors_cb)
+ Gtk.Settings.get_default().connect("notify::gtk-application-prefer-dark-theme",
self._update_colors_cb)
def set_pipeline(self, pipeline):
self._pipeline = pipeline
@@ -127,21 +129,7 @@ class ScaleRuler(Gtk.DrawingArea, Loggable):
self.position = position
self.queue_draw()
-# Gtk.Widget overrides
-
- def do_configure_event(self, unused_event):
- width = self.get_allocated_width()
- height = self.get_allocated_height()
- self.debug("Configuring, height %d, width %d", width, height)
-
- # Destroy previous buffer
- if self.pixbuf is not None:
- self.pixbuf.finish()
- self.pixbuf = None
-
- # Create a new buffer
- self.pixbuf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
-
+ def _set_colors(self):
# pylint: disable=attribute-defined-outside-init
context = self.get_style_context()
color_normal = gtk_style_context_get_color(context, Gtk.StateFlags.NORMAL)
@@ -162,6 +150,25 @@ class ScaleRuler(Gtk.DrawingArea, Loggable):
# Two colors with high contrast.
self._color_frame = gtk_style_context_get_color(context, Gtk.StateFlags.LINK)
+ def _update_colors_cb(self, settings, gparams):
+ self._set_colors()
+
+# Gtk.Widget overrides
+
+ def do_configure_event(self, unused_event):
+ width = self.get_allocated_width()
+ height = self.get_allocated_height()
+ self.debug("Configuring, height %d, width %d", width, height)
+
+ # Destroy previous buffer
+ if self.pixbuf is not None:
+ self.pixbuf.finish()
+ self.pixbuf = None
+
+ # Create a new buffer
+ self.pixbuf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
+
+ self._set_colors()
return False
def do_draw(self, context):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]