From 78fc8863758d1f4e69cb643c5485c6ea5dceb5ce Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 18 Jul 2019 18:32:11 +1000 Subject: [PATCH] gui: fix the global orientation changes This broke at some point, let's fix it again by moving to the drawing and calling refresh() from there - no need for the DrawingPerspective to call into the drawing here. --- tuhigui/drawing.py | 5 +++++ tuhigui/drawingperspective.py | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tuhigui/drawing.py b/tuhigui/drawing.py index 827a627..9d03fb4 100644 --- a/tuhigui/drawing.py +++ b/tuhigui/drawing.py @@ -50,6 +50,7 @@ class Drawing(Gtk.Box): def __init__(self, json_data, *args, **kwargs): super().__init__() self.orientation = Config.instance().orientation + Config.instance().connect('notify::orientation', self._on_orientation_changed) self.json_data = json_data self.svg = svg = JsonSvg(json_data, orientation=self.orientation) @@ -60,6 +61,10 @@ class Drawing(Gtk.Box): self.image_svg.set_from_file(svg.filename) self.timestamp = svg.timestamp + def _on_orientation_changed(self, config, pspec): + self.orientation = config.orientation + self.refresh() + def refresh(self): self.svg = svg = JsonSvg(self.json_data, self.orientation) self.image_svg.set_from_file(svg.filename) diff --git a/tuhigui/drawingperspective.py b/tuhigui/drawingperspective.py index f5d3188..dfe7812 100644 --- a/tuhigui/drawingperspective.py +++ b/tuhigui/drawingperspective.py @@ -63,12 +63,6 @@ class DrawingPerspective(Gtk.Stack): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.known_drawings = [] - Config.instance().connect('notify::orientation', self._on_orientation_changed) - - def _on_orientation_changed(self, config, pspec): - # When the orientation changes, we just re-generate all SVGs. This - # isn't something that should happen very often anyway so meh. - self.flowbox_drawings.foreach(lambda child: child.get_child().refresh()) def _cache_drawings(self, device, pspec): # The config backend filters duplicates anyway, so don't care here