# Python imports # Lib imports import gi 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 # class Page(Gtk.Box): class Page(Gtk.ScrolledWindow): def __init__(self, close_tab, section_pth, manifest_pth): super(Page, self).__init__() 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 self._setup_styling() self._setup_signals() self._subscribe_to_events() self._load_widgets() self._load_page_manifest() self._add_fixed_base_widgets() self._tab_widget = PagesTabWidget(self, self._close_tab, self._name) def _setup_styling(self): # ctx = self.get_style_context() # ctx.add_class("page-bg") ... def _setup_signals(self): ... def _subscribe_to_events(self): ... def _load_widgets(self): self._drag_area = DragArea() viewport = Gtk.Viewport() viewport.add(self._drag_area) self.add(viewport) def get_tab_widget(self): return self._tab_widget def get_manifest_pth(self): return self._manifest_pth def _load_page_manifest(self, manifest_pth = None): if manifest_pth: self._manifest_pth = manifest_pth with open(self._manifest_pth, "r") as f: lines = f.readlines() for line in lines: parts = line.split("=") if parts[0] == "name": self._name = parts[1].strip() if parts[0] == "date": self._date = parts[1].strip() def _add_fixed_base_widgets(self): self._drag_area.add_fixed_base_widgets(self._name, self._date, self._update_header) 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)