From 8c9454a2988dab9e59fd09fbdbcd397fbc9efb4b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 22 Aug 2019 13:51:21 +1000 Subject: [PATCH] gui: don't regenerate the SVG when the rotate button is clicked Do this when we're saving the file instead and rotate the pixbuf itself only. For the tablet-wide orientation we regenerate the SVGs because this is supposed to be a once-off setting so being smart here doesn't gain us anything. Signed-off-by: Peter Hutterer --- tuhi/gui/drawing.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tuhi/gui/drawing.py b/tuhi/gui/drawing.py index e70097a..b357f8b 100644 --- a/tuhi/gui/drawing.py +++ b/tuhi/gui/drawing.py @@ -119,6 +119,12 @@ class Drawing(Gtk.EventBox): response = dialog.run() if response == Gtk.ResponseType.OK: import shutil + + # regenerate the SVG based on the current rotation. + # where we used the orientation buttons, we haven't updated the + # file itself. + self.refresh() + file = dialog.get_filename() shutil.copyfile(self.svg.filename, file) # FIXME: error handling @@ -132,14 +138,16 @@ class Drawing(Gtk.EventBox): @Gtk.Template.Callback('_on_rotate_button_clicked') def _on_rotate_button_clicked(self, button): if button == self.btn_rotate_left: + self.pixbuf = self.pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.COUNTERCLOCKWISE) advance = 1 else: + self.pixbuf = self.pixbuf.rotate_simple(GdkPixbuf.PixbufRotation.CLOCKWISE) advance = 3 orientations = ['portrait', 'landscape', 'reverse-portrait', 'reverse-landscape'] * 3 o = orientations[orientations.index(self.orientation) + advance] self.orientation = o - self.refresh() + self.redraw() @Gtk.Template.Callback('_on_enter') def _on_enter(self, *args):