+66
-25
lines changedFilter options
+66
-25
lines changed Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
29
29
from .plugin_api import PLUGIN_PATH_PREFIX
30
30
from .settings import UI_SETTINGS
31
31
from .about import show_about
32
+
from .shortcuts import show_shortcuts
32
33
33
34
34
35
from typing import TYPE_CHECKING # pylint: disable=wrong-import-order
@@ -499,16 +500,7 @@ def close(self): # pylint: disable=arguments-differ
499
500
500
501
def _on_show_help(self, _action, _param=None):
501
502
# @TODO: refactor to use .set_help_overlay() ?
502
-
path = os.path.join(SCRIPT_DIR, 'shortcuts.ui')
503
-
obj_id = "shortcuts"
504
-
505
-
builder = Gtk.Builder.new_from_file(path)
506
-
overlay = builder.get_object(obj_id)
507
-
overlay.set_transient_for(self)
508
-
overlay.set_title("Oomox Keyboard Shortcuts")
509
-
overlay.set_wmclass("oomox", "Oomox")
510
-
overlay.set_role("Oomox-Shortcuts")
511
-
overlay.show()
503
+
show_shortcuts(self)
512
504
513
505
def _on_show_about(self, _action, _param=None):
514
506
show_about(self)
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
1
+
import os
2
+
3
+
from gi.repository import Gtk
4
+
5
+
from .config import SCRIPT_DIR
6
+
from .plugin_loader import PluginLoader
7
+
8
+
9
+
def show_shortcuts(parent_window):
10
+
path = os.path.join(SCRIPT_DIR, 'shortcuts.ui')
11
+
obj_id = "shortcuts"
12
+
builder = Gtk.Builder.new_from_file(path)
13
+
shortcuts_window = builder.get_object(obj_id)
14
+
shortcuts_window.set_transient_for(parent_window)
15
+
shortcuts_window.set_title("Oomox Keyboard Shortcuts")
16
+
shortcuts_window.set_wmclass("oomox", "Oomox")
17
+
shortcuts_window.set_role("Oomox-Shortcuts")
18
+
19
+
for section_id, plugin_list, get_text in (
20
+
(
21
+
"import_section",
22
+
PluginLoader.get_import_plugins(),
23
+
lambda plugin: (
24
+
plugin.import_text and
25
+
plugin.import_text.replace('_', '').replace('…', '') or
26
+
f"Import {plugin.display_name}"
27
+
),
28
+
),
29
+
(
30
+
"export_section",
31
+
PluginLoader.get_export_plugins(),
32
+
lambda plugin: (
33
+
plugin.export_text and
34
+
plugin.export_text.replace('_', '').replace('…', '') or
35
+
f"Export {plugin.display_name}"
36
+
),
37
+
),
38
+
):
39
+
section = builder.get_object(section_id)
40
+
for plugin in plugin_list.values():
41
+
if not plugin.shortcut:
42
+
continue
43
+
shortcut = Gtk.ShortcutsShortcut(
44
+
title=get_text(plugin),
45
+
accelerator = plugin.shortcut
46
+
)
47
+
section.add(shortcut)
48
+
49
+
shortcuts_window.show_all()
Original file line number Diff line number Diff line change
@@ -41,13 +41,6 @@
41
41
<object class="GtkShortcutsGroup">
42
42
<property name="visible">1</property>
43
43
<property name="title" translatable="yes">Presets Operations</property>
44
-
<child>
45
-
<object class="GtkShortcutsShortcut">
46
-
<property name="visible">1</property>
47
-
<property name="accelerator"><Primary>M</property>
48
-
<property name="title" translatable="yes">Import Theme menu</property>
49
-
</object>
50
-
</child>
51
44
<child>
52
45
<object class="GtkShortcutsShortcut">
53
46
<property name="visible">1</property>
@@ -80,7 +73,21 @@
80
73
</child>
81
74
82
75
<child>
83
-
<object class="GtkShortcutsGroup">
76
+
<object class="GtkShortcutsGroup" id="import_section">
77
+
<property name="visible">1</property>
78
+
<property name="title" translatable="yes">Import</property>
79
+
<child>
80
+
<object class="GtkShortcutsShortcut">
81
+
<property name="visible">1</property>
82
+
<property name="accelerator"><Primary>M</property>
83
+
<property name="title" translatable="yes">Import Theme menu</property>
84
+
</object>
85
+
</child>
86
+
</object>
87
+
</child>
88
+
89
+
<child>
90
+
<object class="GtkShortcutsGroup" id="export_section">
84
91
<property name="visible">1</property>
85
92
<property name="title" translatable="yes">Export</property>
86
93
<child>
@@ -104,13 +111,6 @@
104
111
<property name="title" translatable="yes">Export other themes</property>
105
112
</object>
106
113
</child>
107
-
<child>
108
-
<object class="GtkShortcutsShortcut">
109
-
<property name="visible">1</property>
110
-
<property name="accelerator"><Primary>X</property>
111
-
<property name="title" translatable="yes">Export Xresources theme</property>
112
-
</object>
113
-
</child>
114
114
</object>
115
115
</child>
116
116
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4