Externalized items to new glade files and classes #10

Merged
itdominator merged 11 commits from develop into master 2022-12-04 08:49:45 +00:00
10 changed files with 119 additions and 61 deletions
Showing only changes of commit f5eac69c20 - Show all commits

View File

@ -13,6 +13,9 @@ from gi.repository import GLib
from .controller_data import Controller_Data
from .mixins.signals_mixins import SignalsMixins
from widgets.popups.plugins_popup_widget import PluginsPopupWidget
from widgets.popups.io_popup_widget import IOPopupWidget
from widgets.context_menu_widget import ContextMenuWidget
from widgets.new_file_widget import NewFileWidget
from widgets.rename_widget import RenameWidget
@ -53,6 +56,8 @@ class Controller(UI, SignalsMixins, Controller_Data):
# NOTE: Really we will move these to the UI/(New) Window 'base' controller
# after we're done cleaning and refactoring to use fewer mixins.
def _load_widgets(self):
PluginsPopupWidget()
IOPopupWidget()
ContextMenuWidget()
NewFileWidget()
RenameWidget()
@ -159,8 +164,14 @@ class Controller(UI, SignalsMixins, Controller_Data):
self.create_files()
if action in ["save_session", "save_session_as", "load_session"]:
self.save_load_session(action)
if action == "about_page":
event_system.emit("show_about_page")
if action == "io_popup":
event_system.emit("show_io_popup")
if action == "plugins_popup":
event_system.emit("show_plugins_popup")
@endpoint_registry.register(rule="go_home")

View File

@ -11,12 +11,3 @@ from gi.repository import Gtk
class ShowHideMixin:
def show_messages_popup(self, type, text, seconds=None):
self.message_popup_widget.popup()
def show_plugins_popup(self, widget=None, eve=None):
self.builder.get_object("plugin_controls").popup()
def hide_plugins_popup(self, widget=None, eve=None):
self.builder.get_object("plugin_controls").hide()
def show_io_popup(self, widget=None, eve=None):
self.builder.get_object("io_popup").popup()

View File

@ -4,9 +4,7 @@
import inspect
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
# Application imports

View File

@ -4,9 +4,7 @@
import inspect
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
# Application imports

View File

@ -0,0 +1,3 @@
"""
Popups module
"""

View File

@ -0,0 +1,42 @@
# Python imports
# Lib imports
import inspect
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# Application imports
class IOPopupWidget(Gtk.Popover):
"""docstring for IOPopupWidget."""
def __init__(self):
super(IOPopupWidget, self).__init__()
self.builder = settings.get_builder()
self.builder.expose_object(f"io_popup", self)
self._setup_styling()
self._setup_signals()
self._load_widgets()
self.show_all()
def _setup_styling(self):
io_button = self.builder.get_object(f"io_button")
self.set_relative_to(io_button)
self.set_modal(True)
self.set_position(Gtk.PositionType.BOTTOM)
def _setup_signals(self):
event_system.subscribe("show_io_popup", self.show_io_popup)
def _load_widgets(self):
vbox = Gtk.Box()
self.builder.expose_object(f"io_list", vbox)
self.add(vbox)
def show_io_popup(self, widget=None, eve=None):
self.popup()

View File

@ -0,0 +1,47 @@
# Python imports
# Lib imports
import inspect
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
# Application imports
class PluginsPopupWidget(Gtk.Popover):
"""docstring for PluginsPopupWidget."""
def __init__(self):
super(PluginsPopupWidget, self).__init__()
self.builder = settings.get_builder()
self.builder.expose_object(f"plugin_controls", self)
self._setup_styling()
self._setup_signals()
self._load_widgets()
self.show_all()
def _setup_styling(self):
plugins_button = self.builder.get_object(f"plugins_button")
self.set_relative_to(plugins_button)
self.set_modal(True)
self.set_position(Gtk.PositionType.BOTTOM)
def _setup_signals(self):
event_system.subscribe("show_plugins_popup", self.show_plugins_popup)
self.connect("button-release-event", self.hide_plugins_popup)
self.connect("key-release-event", self.hide_plugins_popup)
def _load_widgets(self):
vbox = Gtk.Box()
self.builder.expose_object(f"plugin_control_list", vbox)
self.add(vbox)
def show_plugins_popup(self, widget=None, eve=None):
self.popup()
def hide_plugins_popup(self, widget=None, eve=None):
self.hide()

View File

@ -4,7 +4,6 @@
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gio
# Application imports

View File

@ -367,10 +367,11 @@
<child>
<object class="GtkButton" id="plugins_button">
<property name="label" translatable="yes">Plugins</property>
<property name="name">plugins_popup</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="released" handler="show_plugins_popup" swapped="no"/>
<signal name="released" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
@ -445,12 +446,13 @@
<child>
<object class="GtkButton" id="io_button">
<property name="label" translatable="yes">I/O</property>
<property name="name">io_popup</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">io_img</property>
<property name="always-show-image">True</property>
<signal name="released" handler="show_io_popup" swapped="no"/>
<signal name="released" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
@ -899,23 +901,6 @@
</object>
</child>
</object>
<object class="GtkPopover" id="io_popup">
<property name="can-focus">False</property>
<property name="relative-to">io_button</property>
<property name="position">bottom</property>
<child>
<object class="GtkBox" id="io_list">
<property name="width-request">320</property>
<property name="height-request">320</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkPopover" id="message_popup_widget">
<property name="width-request">320</property>
<property name="can-focus">False</property>
@ -1004,22 +989,6 @@
</object>
</child>
</object>
<object class="GtkPopover" id="plugin_controls">
<property name="can-focus">False</property>
<property name="relative-to">plugins_button</property>
<signal name="button-release-event" handler="hide_plugins_popup" swapped="no"/>
<signal name="key-release-event" handler="hide_plugins_popup" swapped="no"/>
<child>
<object class="GtkBox" id="plugin_control_list">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkMessageDialog" id="warning_alert">
<property name="can-focus">False</property>
<property name="resizable">False</property>