svg: pass the orientation into the constructor

Don't let the SVG generation parse the config file, not necessary here.
pull/145/head
Peter Hutterer 2019-07-16 21:15:11 +10:00
parent 1743a93873
commit 3e23e8bc31
2 changed files with 7 additions and 7 deletions

View File

@ -47,8 +47,10 @@ class Drawing(Gtk.Box):
def __init__(self, json_data, *args, **kwargs):
super().__init__()
self.orientation = Config.instance().orientation
self.json_data = json_data
self.svg = svg = JsonSvg(json_data)
self.svg = svg = JsonSvg(json_data, orientation=self.orientation)
day = relative_date(svg.timestamp)
hour = time.strftime('%H:%M', time.localtime(svg.timestamp))

View File

@ -13,8 +13,6 @@
from gi.repository import GObject
from .config import Config
import xdg.BaseDirectory
import svgwrite
import os
@ -23,7 +21,7 @@ DATA_PATH = os.path.join(xdg.BaseDirectory.xdg_data_home, 'tuhigui')
class JsonSvg(GObject.Object):
def __init__(self, json, *args, **kwargs):
def __init__(self, json, orientation, *args, **kwargs):
self.json = json
try:
os.mkdir(DATA_PATH)
@ -32,7 +30,7 @@ class JsonSvg(GObject.Object):
self.timestamp = json['timestamp']
self.filename = os.path.join(DATA_PATH, f'{self.timestamp}.svg')
self.orientation = Config.instance().orientation
self.orientation = orientation
self._convert()
def _convert(self):
@ -61,11 +59,11 @@ class JsonSvg(GObject.Object):
# Normalize coordinates too
x, y = x / 100, y / 100
if self.orientation == 'reverse-Portrait':
if self.orientation == 'reverse-portrait':
x, y = y, width - x
elif self.orientation == 'portrait':
x, y = height - y, x
elif self.orientation == 'reverse-Landscape':
elif self.orientation == 'reverse-landscape':
x, y = width - x, height - y
delta = (p['pressure'] - 1000.0) / 1000.0