aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--voctogui/lib/shortcuts.py59
-rw-r--r--voctogui/lib/toolbar/composition.py3
-rw-r--r--voctogui/lib/toolbar/misc.py2
-rw-r--r--voctogui/lib/ui.py9
-rw-r--r--voctogui/lib/videopreviews.py6
5 files changed, 79 insertions, 0 deletions
diff --git a/voctogui/lib/shortcuts.py b/voctogui/lib/shortcuts.py
new file mode 100644
index 0000000..d591a03
--- /dev/null
+++ b/voctogui/lib/shortcuts.py
@@ -0,0 +1,59 @@
+from gi.repository import Gtk
+
+from lib.config import Config
+
+
+class ShortcutsWindow(Gtk.ShortcutsWindow):
+ def __init__(self, win):
+ Gtk.ShortcutsWindow.__init__(self)
+ self.build()
+ self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
+ self.set_transient_for(win)
+ self.set_modal(True)
+
+ def build(self):
+ section = Gtk.ShortcutsSection()
+ section.show()
+
+ compose_group = Gtk.ShortcutsGroup(title="Composition modes")
+ compose_group.show()
+ for accel, desc in [("F1", "Select fullscreen mode"),
+ ("F2", "Select Picture in Picture mode"),
+ ("F3", "Select Side-by-Side Equal mode"),
+ ("F4", "Select Side-by-Side Preview mode")]:
+ short = Gtk.ShortcutsShortcut(title=desc, accelerator=accel)
+ short.show()
+ compose_group.add(short)
+ section.add(compose_group)
+
+ source_group = Gtk.ShortcutsGroup(title="Source Selection")
+ source_group.show()
+ num = len(Config.getlist('mix', 'sources'))
+ source_items = [
+ ("1...{}".format(num), "Select Source as A-Source"),
+ ("<ctrl>1...<ctrl>{}".format(num), "Select Source as B-Source"),
+ ("<alt>1...<alt>{}".format(num), "Select Source as Fullscreen")
+ ]
+ for accel, desc in source_items:
+ short = Gtk.ShortcutsShortcut(title=desc, accelerator=accel)
+ short.show()
+ source_group.add(short)
+ section.add(source_group)
+
+ if Config.getboolean('misc', 'cut'):
+ other_group = Gtk.ShortcutsGroup(title="Other")
+ other_group.show()
+ short = Gtk.ShortcutsShortcut(title="Send Cut message",
+ accelerator="t")
+ short.show()
+ other_group.add(short)
+ section.add(other_group)
+
+ self.add(section)
+
+
+def show_shortcuts(win):
+ if not hasattr(Gtk, "ShortcutsWindow"):
+ return
+ shortcuts_window = ShortcutsWindow(win)
+ shortcuts_window.show()
diff --git a/voctogui/lib/toolbar/composition.py b/voctogui/lib/toolbar/composition.py
index 2674260..b55254a 100644
--- a/voctogui/lib/toolbar/composition.py
+++ b/voctogui/lib/toolbar/composition.py
@@ -31,6 +31,9 @@ class CompositionToolbarController(object):
)
btn.set_name(name)
+ tooltip = Gtk.accelerator_get_label(key, mod)
+ btn.set_tooltip_text(tooltip)
+
# Thanks to http://stackoverflow.com/a/19739855/1659732
btn.get_child().add_accelerator('clicked', accelerators,
key, mod, Gtk.AccelFlags.VISIBLE)
diff --git a/voctogui/lib/toolbar/misc.py b/voctogui/lib/toolbar/misc.py
index 530bbad..8947368 100644
--- a/voctogui/lib/toolbar/misc.py
+++ b/voctogui/lib/toolbar/misc.py
@@ -26,6 +26,8 @@ class MiscToolbarController(object):
key, mod = Gtk.accelerator_parse('t')
cutbtn.add_accelerator('clicked', accelerators,
key, mod, Gtk.AccelFlags.VISIBLE)
+ tooltip = Gtk.accelerator_get_label(key, mod)
+ cutbtn.set_tooltip_text(tooltip)
def on_closebtn_clicked(self, btn):
self.log.info('close-button clicked')
diff --git a/voctogui/lib/ui.py b/voctogui/lib/ui.py
index 63f6c33..7da3ba4 100644
--- a/voctogui/lib/ui.py
+++ b/voctogui/lib/ui.py
@@ -16,6 +16,8 @@ from lib.toolbar.composition import CompositionToolbarController
from lib.toolbar.streamblank import StreamblankToolbarController
from lib.toolbar.misc import MiscToolbarController
+from lib.shortcuts import show_shortcuts
+
class Ui(UiBuilder):
@@ -92,6 +94,13 @@ class Ui(UiBuilder):
uibuilder=self
)
+ # Setup Shortcuts window
+ self.win.connect('key-press-event', self.handle_keypress)
+
+ def handle_keypress(self, window, event):
+ if event.keyval == Gdk.KEY_question:
+ show_shortcuts(window)
+
def show(self):
self.log.info('Showing Main-Window')
self.win.show_all()
diff --git a/voctogui/lib/videopreviews.py b/voctogui/lib/videopreviews.py
index 9adb76f..b8c99ac 100644
--- a/voctogui/lib/videopreviews.py
+++ b/voctogui/lib/videopreviews.py
@@ -80,10 +80,14 @@ class VideoPreviewsController(object):
key, mod = Gtk.accelerator_parse('%u' % (idx + 1))
btn_a.add_accelerator('activate', accelerators,
key, mod, Gtk.AccelFlags.VISIBLE)
+ tooltip = Gtk.accelerator_get_label(key, mod)
+ btn_a.set_tooltip_text(tooltip)
key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx + 1))
btn_b.add_accelerator('activate', accelerators,
key, mod, Gtk.AccelFlags.VISIBLE)
+ tooltip = Gtk.accelerator_get_label(key, mod)
+ btn_b.set_tooltip_text(tooltip)
btn_fullscreen = uibuilder.find_widget_recursive(preview,
'btn_fullscreen')
@@ -94,6 +98,8 @@ class VideoPreviewsController(object):
key, mod = Gtk.accelerator_parse('<Alt>%u' % (idx + 1))
btn_fullscreen.add_accelerator('activate', accelerators,
key, mod, Gtk.AccelFlags.VISIBLE)
+ tooltip = Gtk.accelerator_get_label(key, mod)
+ btn_fullscreen.set_tooltip_text(tooltip)
self.preview_players[source] = player
self.previews[source] = preview