diff --git a/src/core/widgets/drag_area_widget.py b/src/core/widgets/drag_area_widget.py index 64bedfd..e20c0ae 100644 --- a/src/core/widgets/drag_area_widget.py +++ b/src/core/widgets/drag_area_widget.py @@ -68,6 +68,8 @@ class DragArea(GtkSource.View): # self.put(dynamic_widget, eve.x, eve.y) self.add_child_in_window(dynamic_widget_wrapped, Gtk.TextWindowType.WIDGET, eve.x, eve.y) + dynamic_widget.save() + def _move_callback(self, widget = None, x = None, y = None): # self.move(widget.get_parent(), x, y) self.move_child(widget.get_parent(), x, y) diff --git a/src/core/widgets/pages/pages_widget.py b/src/core/widgets/pages/pages_widget.py index 9271564..34ac1ef 100644 --- a/src/core/widgets/pages/pages_widget.py +++ b/src/core/widgets/pages/pages_widget.py @@ -31,9 +31,10 @@ class Pages(Gtk.Notebook): def _setup_styling(self): self.set_tab_pos(1) # NOTE: LEFT = 0, RIGHT = 1, TOP = 2, BOTTOM = 3 + self.set_scrollable(True) def _setup_signals(self): - self.set_scrollable(True) + self.connect("switch-page", self._switch_page_update) def _load_widgets(self): start_box = Gtk.Box() @@ -81,6 +82,10 @@ class Pages(Gtk.Notebook): page.show_all() self.set_current_page(page_num) + def _switch_page_update(self, notebook, page, page_num): + path = page.get_manifest_pth().replace("MANIFEST", "") + settings.set_active_page(path) + def get_tab_widget(self): return self._tab_widget diff --git a/src/core/widgets/sections/sections_widget.py b/src/core/widgets/sections/sections_widget.py index 692543c..36f2e48 100644 --- a/src/core/widgets/sections/sections_widget.py +++ b/src/core/widgets/sections/sections_widget.py @@ -31,10 +31,10 @@ class Sections(Gtk.Notebook): self.set_scrollable(True) def _setup_signals(self): - event_system.subscribe("create_section_view", self.create_section_view) + self.connect("switch-page", self._switch_page_update) def _subscribe_to_events(self): - ... + event_system.subscribe("create_section_view", self.create_section_view) def _load_widgets(self): start_box = Gtk.Box() @@ -103,5 +103,9 @@ class Sections(Gtk.Notebook): pages_view.show_all() self.set_current_page(page_num) + def _switch_page_update(self, notebook, page, page_num): + path = page.get_section_pth() + settings.set_active_section(path) + def show_widgets_selection(self, widget = None, eve = None): event_system.emit("show_widget_types") diff --git a/src/core/widgets/template/dynamic_widget_template.py b/src/core/widgets/template/dynamic_widget_template.py index dbcec37..a5e3303 100644 --- a/src/core/widgets/template/dynamic_widget_template.py +++ b/src/core/widgets/template/dynamic_widget_template.py @@ -1,4 +1,6 @@ # Python imports +import uuid +import pickle # Lib imports import gi @@ -19,6 +21,7 @@ class DynamicWidget(Gtk.Box): super(DynamicWidget, self).__init__() self._header_widget = DynamicHeaderWidget(move_callback, x, y) + self.uuid = str(uuid.uuid4()) self._setup_styling() self._setup_signals() @@ -50,3 +53,9 @@ class DynamicWidget(Gtk.Box): self.add(widget) except DynamicWidgetException as e: logger.debug(e) + + def save(self): + path = f"{settings.get_active_page()}/{self.uuid}" + logger.debug("Widget save stub...") + # with open(path, "wb") as f: + # pickle.dump(self, f, protocol=pickle.HIGHEST_PROTOCOL, fix_imports=True, buffer_callback=None) diff --git a/src/utils/settings/settings.py b/src/utils/settings/settings.py index d82642f..a92440b 100644 --- a/src/utils/settings/settings.py +++ b/src/utils/settings/settings.py @@ -84,6 +84,8 @@ class Settings(StartCheckMixin): self._debug = False self._dirty_start = False self._active_notebook = None + self._active_section = None + self._active_page = None self.load_settings() @@ -166,8 +168,15 @@ class Settings(StartCheckMixin): def set_main_window(self, window): self._main_window = window def set_builder(self, builder) -> any: self._builder = builder - def set_active_notebook(self, path: str): self._active_notebook = path + def get_active_notebook(self) -> str: return self._active_notebook + def get_active_section(self) -> str: return self._active_section + def get_active_page(self) -> str: return self._active_page + def set_active_notebook(self, path: str): self._active_notebook = path + def set_active_section(self, path: str): self._active_section = path + def set_active_page(self, path: str): self._active_page = path + + def get_monitor_data(self) -> list: screen = self._main_window.get_screen()