mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
feat: dedicated emitter
This commit is contained in:
1 parent
ea841395fc
commit
ac7700ec23
24 files changed
+207
-112
No files matched your search
@@ -2,6 +2,7 @@ from dzgui.const.enum import CursorPosition
|
||||
from dzgui.const.constants import SEPARATOR
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib, Gdk, GObject, Pango # noqa E402
|
||||
|
||||
@@ -20,7 +21,7 @@ class CursorMixin:
|
||||
case Gdk.KEY_l | Gdk.KEY_Right:
|
||||
if event.state is Gdk.ModifierType.CONTROL_MASK:
|
||||
return
|
||||
self.controller.mediator.right_panel.focus_button_box()
|
||||
self.emitter.emit("request_button_box_focus")
|
||||
case _:
|
||||
return False
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
from typing import Literal
|
||||
|
||||
from dzgui.const.enum import NotebookPage
|
||||
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk # noqa
|
||||
|
||||
class HelpMenuMixin:
|
||||
def _on_esc_keypress(self, widget: Gtk.Widget, event: Gdk.EventKey) -> Literal[True]:
|
||||
if event.keyval == Gdk.KEY_Escape:
|
||||
self.controller.open_page(NotebookPage.HELP)
|
||||
return True
|
||||
@@ -2,9 +2,11 @@ from dzgui.const.enum import VAdjustment
|
||||
from dzgui.const.constants import SCROLL_INCREMENT
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, Gdk # noqa
|
||||
|
||||
|
||||
class ScrollableMixin:
|
||||
def _on_keypress(self, widget: Gtk.Widget, event: Gdk.EventKey) -> None:
|
||||
match event.keyval:
|
||||
@@ -16,6 +18,8 @@ class ScrollableMixin:
|
||||
self._set_adjustment(VAdjustment.TOP)
|
||||
case Gdk.KEY_G:
|
||||
self._set_adjustment(VAdjustment.BOTTOM)
|
||||
case Gdk.KEY_l | Gdk.KEY_Right:
|
||||
self.controller.get_emitter().emit("request_button_box_focus")
|
||||
|
||||
def _set_adjustment(self, adjustment: VAdjustment) -> None:
|
||||
vadj = self.get_vadjustment()
|
||||
@@ -29,4 +33,3 @@ class ScrollableMixin:
|
||||
case VAdjustment.DOWN:
|
||||
adj = vadj.get_value() + SCROLL_INCREMENT
|
||||
vadj.set_value(adj)
|
||||
|
||||
Reference in new issue
Block a user