Updat Event Page manifest files

This commit is contained in:
itdominator 2023-04-02 13:01:23 -05:00
parent 8c26fe544e
commit 60de4955f7
5 changed files with 76 additions and 11 deletions

View File

@ -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...")

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -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