|
1 | | -from .TimerSourceActionBase import TimerSourceActionBase |
| 1 | +from .TimerSourceActionCore import TimerSourceActionCore |
| 2 | +from src.backend.PluginManager.EventAssigner import EventAssigner |
| 3 | +from src.backend.DeckManagement.InputIdentifier import Input |
2 | 4 |
|
3 | 5 | from loguru import logger as log |
4 | | -import os |
5 | 6 | from uuid import UUID |
6 | 7 |
|
7 | | -# Import gtk modules |
8 | 8 | import gi |
9 | 9 | gi.require_version("Gtk", "4.0") |
10 | 10 | gi.require_version("Adw", "1") |
11 | 11 | from gi.repository import Gtk, Adw, Gio |
12 | 12 |
|
13 | | -class SetLayoutPath(TimerSourceActionBase): |
| 13 | + |
| 14 | +class SetLayoutPath(TimerSourceActionCore): |
14 | 15 | def __init__(self, *args, **kwargs): |
15 | 16 | super().__init__(*args, **kwargs) |
16 | 17 |
|
| 18 | + def get_icon_name(self) -> str: |
| 19 | + return "set-layout-path.png" |
| 20 | + |
17 | 21 | def get_config_rows(self) -> list: |
18 | 22 | self.layout_path_settings = Adw.PreferencesGroup() |
19 | 23 | self.layout_path_settings.set_title( |
@@ -101,27 +105,21 @@ def on_layout_path_dialog_response(self, dialog, async_result): |
101 | 105 | return |
102 | 106 | self.layout_path_entry.set_text(path.get_path()) |
103 | 107 |
|
104 | | - def on_ready(self): |
105 | | - if self.plugin_base.backend is None: |
106 | | - return |
107 | | - |
108 | | - # Connect to obs if not connected |
109 | | - if not self.plugin_base.get_connected(): |
110 | | - self.reconnect_obs() |
111 | | - |
112 | | - image = "set-layout-path.png" |
113 | | - self.set_media( |
114 | | - media_path=os.path.join(self.plugin_base.PATH, "assets", image) |
| 108 | + def create_event_assigners(self): |
| 109 | + self.add_event_assigner( |
| 110 | + EventAssigner( |
| 111 | + id="set_layout_path", |
| 112 | + ui_label="Set Layout Path", |
| 113 | + default_event=Input.Key.Events.DOWN, |
| 114 | + callback=self._on_set_layout_path, |
| 115 | + ) |
115 | 116 | ) |
116 | 117 |
|
117 | | - def on_key_down(self): |
118 | | - if not self.plugin_base.backend.get_connected(): |
119 | | - # Try to reconnect once. |
120 | | - self._reconnect_obs() |
121 | | - if not self.plugin_base.backend.get_connected(): |
122 | | - return |
| 118 | + def _on_set_layout_path(self, data): |
| 119 | + if not self.ensure_connection(): |
| 120 | + return |
123 | 121 |
|
124 | | - uuid_str = self.get_settings().get("source-uuid") |
| 122 | + uuid_str = self.get_source_uuid() |
125 | 123 | if not uuid_str: |
126 | 124 | log.debug("No source UUID set") |
127 | 125 | return |
|
0 commit comments