diff --git a/tuhigui/config.py b/tuhigui/config.py index 828fb78..1a86c7f 100644 --- a/tuhigui/config.py +++ b/tuhigui/config.py @@ -122,7 +122,7 @@ class Config(GObject.Object): self.notify('drawings') @classmethod - def load(cls): + def instance(cls): if cls._config_obj is None: cls._config_obj = Config() return cls._config_obj diff --git a/tuhigui/drawing.py b/tuhigui/drawing.py index 3d2c8a6..1d262b2 100644 --- a/tuhigui/drawing.py +++ b/tuhigui/drawing.py @@ -98,4 +98,4 @@ class Drawing(Gtk.Box): @Gtk.Template.Callback('_on_delete_button_clicked') def _on_delete_button_clicked(self, button): - Config.load().delete_drawing(self.timestamp) + Config.instance().delete_drawing(self.timestamp) diff --git a/tuhigui/drawingperspective.py b/tuhigui/drawingperspective.py index 7210513..8ffd3f8 100644 --- a/tuhigui/drawingperspective.py +++ b/tuhigui/drawingperspective.py @@ -65,20 +65,18 @@ class DrawingPerspective(Gtk.Stack): self.last_sync_time = 0 self._sync_label_timer = GObject.timeout_add_seconds(60, self._update_sync_label) self._update_sync_label() - Config.load().connect('notify::orientation', self._on_orientation_changed) + 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.known_drawings = [] - 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 for ts in self.device.drawings_available: json_string = self.device.json(ts) - Config.load().add_drawing(ts, json_string) + Config.instance().add_drawing(ts, json_string) def _update_drawings(self, config, pspec): for js in config.drawings: @@ -134,11 +132,11 @@ class DrawingPerspective(Gtk.Stack): # json itself (once cached) that we then actually use for SVG # generation. device.connect('notify::drawings-available', self._cache_drawings) - Config.load().connect('notify::drawings', self._update_drawings) + Config.instance().connect('notify::drawings', self._update_drawings) self._on_battery_changed(device, None) - self._update_drawings(Config.load(), None) + self._update_drawings(Config.instance(), None) # We always want to sync on startup logger.debug(f'{device.name} - starting to listen') @@ -200,5 +198,5 @@ class DrawingPerspective(Gtk.Stack): @Gtk.Template.Callback('_on_undo_clicked') def _on_undo_clicked(self, button): - Config.load().undelete_drawing(button.deleted_drawing) + Config.instance().undelete_drawing(button.deleted_drawing) self.overlay_undo.set_reveal_child(False) diff --git a/tuhigui/svg.py b/tuhigui/svg.py index 7b785fc..a45bc99 100644 --- a/tuhigui/svg.py +++ b/tuhigui/svg.py @@ -32,7 +32,7 @@ class JsonSvg(GObject.Object): self.timestamp = json['timestamp'] self.filename = os.path.join(DATA_PATH, f'{self.timestamp}.svg') - self.orientation = Config.load().orientation + self.orientation = Config.instance().orientation self._convert() def _convert(self): diff --git a/tuhigui/window.py b/tuhigui/window.py index 2fb2cb0..d2b87fb 100644 --- a/tuhigui/window.py +++ b/tuhigui/window.py @@ -73,7 +73,7 @@ class MainWindow(Gtk.ApplicationWindow): action = Gio.SimpleAction.new_stateful('orientation', GLib.VariantType('s'), GLib.Variant('s', 'landscape')) action.connect('activate', self._on_orientation_changed) - action.set_state(GLib.Variant.new_string(Config.load().orientation)) + action.set_state(GLib.Variant.new_string(Config.instance().orientation)) self.add_action(action) builder = Gtk.Builder.new_from_string(MENU_XML, -1) @@ -135,4 +135,4 @@ class MainWindow(Gtk.ApplicationWindow): def _on_orientation_changed(self, action, label): action.set_state(label) - Config.load().orientation = label.get_string() # this is a GVariant + Config.instance().orientation = label.get_string() # this is a GVariant