From 60de4955f794b840e8b018bc4871a73ae8095acf Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 2 Apr 2023 13:01:23 -0500 Subject: [PATCH] Updat Event Page manifest files --- src/core/widgets/drag_area_widget.py | 35 +++++++++++++++++++ src/core/widgets/page_widget.py | 35 +++++++++++++++---- src/core/widgets/pages/pages_widget.py | 3 +- .../widgets/template/tab_header_template.py | 4 ++- src/utils/settings/settings.py | 10 +++++- 5 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 src/core/widgets/drag_area_widget.py diff --git a/src/core/widgets/drag_area_widget.py b/src/core/widgets/drag_area_widget.py new file mode 100644 index 0000000..0e23beb --- /dev/null +++ b/src/core/widgets/drag_area_widget.py @@ -0,0 +1,35 @@ +# Python imports + +# Lib imports +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk + +# Application imports + + + +class DragArea(Gtk.Fixed): + def __init__(self): + super(DragArea, self).__init__() + + self._setup_styling() + self._setup_signals() + self._subscribe_to_events() + self._load_widgets() + + + def _setup_styling(self): + ... + + def _setup_signals(self): + self.connect("button-release-event", self.add_or_select_widget) + + def _subscribe_to_events(self): + ... + + def _load_widgets(self): + ... + + def add_or_select_widget(self, widget = None, eve = None): + logger.debug(f"Add or selecting widget...") diff --git a/src/core/widgets/page_widget.py b/src/core/widgets/page_widget.py index 515b5d5..376a01d 100644 --- a/src/core/widgets/page_widget.py +++ b/src/core/widgets/page_widget.py @@ -6,6 +6,7 @@ gi.require_version('Gtk', '3.0') from gi.repository import Gtk # Application imports +from .drag_area_widget import DragArea from .pages_tab_widget import PagesTabWidget @@ -14,11 +15,9 @@ class Page(Gtk.ScrolledWindow): def __init__(self, close_tab, section_pth, manifest_pth): super(Page, self).__init__() - self._close_tab = close_tab - self._tab_widget = PagesTabWidget(self, self._close_tab) - - self._manifest_pth = settings.generate_page_manifest(section_pth) if not manifest_pth else manifest_pth + self._close_tab = close_tab + self._drag_area = None self._name = None self._date = None @@ -27,6 +26,9 @@ class Page(Gtk.ScrolledWindow): self._subscribe_to_events() self._load_widgets() + self._load_page_manifest() + self._tab_widget = PagesTabWidget(self, self._close_tab, self._name) + def _setup_styling(self): ... @@ -38,12 +40,14 @@ class Page(Gtk.ScrolledWindow): ... def _load_widgets(self): - viewport = Gtk.Viewport() + viewport = Gtk.Viewport() + self._drag_area = DragArea() + viewport.set_vexpand(True) viewport.set_hexpand(True) - fixed = Gtk.Fixed() - viewport.add(fixed) + viewport.add(self._drag_area) + viewport.show_all() self.add(viewport) @@ -65,3 +69,20 @@ class Page(Gtk.ScrolledWindow): self._name = parts[1].strip() if parts[0] == "date": self._date = parts[1].strip() + + + def add_fixed_base_widgets(self): + entry = Gtk.Entry(text = self._name) + date_label = Gtk.Label(label = self._date) + + entry.connect("changed", self._update_header) + entry.set_width_chars(25) + entry.set_max_length(25) + + self._drag_area.put(entry, 30, 30) + self._drag_area.put(date_label, 30, 65) + + def _update_header(self, widget = None, eve = None): + self._name = widget.get_text() + self._tab_widget.set_tab_label(self._name) + settings.update_manifest(self._manifest_pth, self._name, self._date) diff --git a/src/core/widgets/pages/pages_widget.py b/src/core/widgets/pages/pages_widget.py index 05e8076..409b174 100644 --- a/src/core/widgets/pages/pages_widget.py +++ b/src/core/widgets/pages/pages_widget.py @@ -28,8 +28,6 @@ class Pages(Gtk.Notebook): self._load_widgets() self._load_pages_data() - self.show_all() - def _setup_styling(self): self.set_tab_pos(1) # NOTE: LEFT = 0, RIGHT = 1, TOP = 2, BOTTOM = 3 @@ -81,6 +79,7 @@ class Pages(Gtk.Notebook): self.set_tab_detachable(page, False) self.set_tab_reorderable(page, True) + page.add_fixed_base_widgets() page.show_all() self.set_current_page(page_num) diff --git a/src/core/widgets/template/tab_header_template.py b/src/core/widgets/template/tab_header_template.py index 2e2021b..15e1c0a 100644 --- a/src/core/widgets/template/tab_header_template.py +++ b/src/core/widgets/template/tab_header_template.py @@ -23,7 +23,6 @@ class TabHeaderTemplate(Gtk.Box): super(TabHeaderTemplate, self).__init__() self.INDEX = self.ccount - logger.info(label) self.NAME = f"tab_{self.INDEX}" self.LABEL = self.NAME if not label else label self._container = container @@ -69,3 +68,6 @@ class TabHeaderTemplate(Gtk.Box): def set_tab_label(self, label = "untitled"): self.get_children()[0].set_label(label) + + def get_tab_label(self): + return self.get_children()[0].get_text() diff --git a/src/utils/settings/settings.py b/src/utils/settings/settings.py index 1d7b6c3..d180b83 100644 --- a/src/utils/settings/settings.py +++ b/src/utils/settings/settings.py @@ -143,7 +143,15 @@ class Settings(StartCheckMixin): os.mkdir(section) with open(manifest, "w") as f: - f.write(f"name={name}\ndate={datetime.datetime.now()}") + date = datetime.datetime.now() + f.write(f"name={name}\ndate={date.strftime('%B %d, %Y %H:%M %p')}") + f.close() + + return manifest + + def update_manifest(self, manifest, name, date): + with open(manifest, "w") as f: + f.write(f"name={name}\ndate={date}") f.close() return manifest