aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib/shortcuts.py
blob: 5ad2bbfcc9098c66a1ef56af02c30c5c66b9ee0a (plain)
  1. from gi.repository import Gtk
  2. from lib.config import Config
  3. if hasattr(Gtk, "ShortcutsWindow"):
  4. def show_shortcuts(win):
  5. shortcuts_window = ShortcutsWindow(win)
  6. shortcuts_window.show()
  7. class ShortcutsWindow(Gtk.ShortcutsWindow):
  8. def __init__(self, win):
  9. Gtk.ShortcutsWindow.__init__(self)
  10. self.build()
  11. self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
  12. self.set_transient_for(win)
  13. self.set_modal(True)
  14. def build(self):
  15. section = Gtk.ShortcutsSection()
  16. section.show()
  17. compose_group = Gtk.ShortcutsGroup(title="Composition modes")
  18. compose_group.show()
  19. for accel, desc in [("F1", "Select fullscreen mode"),
  20. ("F2", "Select Picture in Picture mode"),
  21. ("F3", "Select Side-by-Side Equal mode"),
  22. ("F4", "Select Side-by-Side Preview mode"),
  23. ("F5", "Select Matrix Two-by-two mode")]:
  24. short = Gtk.ShortcutsShortcut(title=desc, accelerator=accel)
  25. short.show()
  26. compose_group.add(short)
  27. section.add(compose_group)
  28. source_group = Gtk.ShortcutsGroup(title="Source Selection")
  29. source_group.show()
  30. num = len(Config.getlist('mix', 'sources'))
  31. source_items = [
  32. ("1...{}".format(num),
  33. "Select Source as A-Source"),
  34. ("<ctrl>1...<ctrl>{}".format(num),
  35. "Select Source as B-Source"),
  36. ("<alt>1...<alt>{}".format(num),
  37. "Select Source as Fullscreen")
  38. ]
  39. for accel, desc in source_items:
  40. short = Gtk.ShortcutsShortcut(title=desc, accelerator=accel)
  41. short.show()
  42. source_group.add(short)
  43. section.add(source_group)
  44. if Config.getboolean('misc', 'cut'):
  45. other_group = Gtk.ShortcutsGroup(title="Other")
  46. other_group.show()
  47. short = Gtk.ShortcutsShortcut(title="Send Cut message",
  48. accelerator="t")
  49. short.show()
  50. other_group.add(short)
  51. section.add(other_group)
  52. self.add(section)
  53. else:
  54. def show_shortcuts(win):
  55. pass