generated from itdominator/Python-With-Gtk-Template
Added section title update logic
This commit is contained in:
61
src/core/widgets/dialogs/section_header_updater_widget.py
Normal file
61
src/core/widgets/dialogs/section_header_updater_widget.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
class SectionHeaderUpdater(Gtk.Popover):
|
||||
def __init__(self):
|
||||
super(SectionHeaderUpdater, self).__init__()
|
||||
|
||||
self._label = None
|
||||
self._data = None
|
||||
self._entry = None
|
||||
self._is_setting_up = False
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._subscribe_to_events()
|
||||
self._load_widgets()
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_size_request(128, 56)
|
||||
self.set_position(3)
|
||||
|
||||
def _setup_signals(self):
|
||||
...
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
event_system.subscribe("update_section_title", self._update_section_title)
|
||||
|
||||
def _load_widgets(self):
|
||||
self._entry = Gtk.Entry()
|
||||
self.add(self._entry)
|
||||
self._entry.connect("changed", self.update_section_title)
|
||||
self._entry.show()
|
||||
|
||||
def _update_section_title(self, label, data = []):
|
||||
self._is_setting_up = True
|
||||
self._label = label
|
||||
self._data = data
|
||||
|
||||
self._entry.set_text(label.get_text())
|
||||
self.set_relative_to(label)
|
||||
self.show()
|
||||
|
||||
def update_section_title(self, widget = None, eve = None):
|
||||
if self._is_setting_up:
|
||||
self._is_setting_up = False
|
||||
return
|
||||
|
||||
manifest_pth, name, date = self._data
|
||||
name = widget.get_text()
|
||||
|
||||
self._label.set_label(name)
|
||||
settings.update_manifest(manifest_pth, name, date)
|
Reference in New Issue
Block a user