def test_component_symbol_set_presenter(): csymbol = ComponentSymbol() @csymbol.presenter(options=['x', 'y']) class MyPresenter: pass assert csymbol._presenter_cls == MyPresenter assert set(csymbol._presenter_options) == {'x', 'y'}
def test_component_symbol_set_view(): csymbol = ComponentSymbol() @csymbol.view(options=['a', 'b']) class MyView: pass assert csymbol._view_cls == MyView assert set(csymbol._view_options) == {'a', 'b'}
def test_component_symbol_set_presenter_with_no_options(): csymbol = ComponentSymbol() @csymbol.presenter() class MyPresenter: pass
def test_component_symbol_set_view_with_no_options(): csymbol = ComponentSymbol() @csymbol.view() class MyView: pass
from typing import Any, Mapping, Optional from gi.repository import Gtk from opendrop.mvp.component import ComponentSymbol, ComponentFactory from opendrop.mvp.presenter import Presenter from opendrop.mvp.view import View from opendrop.utility.bindable import Bindable stack_cs = ComponentSymbol() # type: ComponentSymbol[Gtk.Widget] @stack_cs.view(options=['children', 'gtk_properties']) class StackView(View['StackPresenter', Gtk.Widget]): def _do_init( self, children: Mapping[Any, ComponentFactory[Gtk.Widget]], gtk_properties: Optional[Mapping[str, Any]] = None) -> Gtk.Widget: self._children = children # Active child component id self._active_child_cid = None # Active child stack id self._active_child_sid = None self.widget = Gtk.Grid(**(gtk_properties or {})) self.widget.show() self.presenter.view_ready()