aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib/shortcuts.py
blob: d5fbc9137f2e6a370c84ef5881e1d97cc6b30d28 (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. short = Gtk.ShortcutsShortcut(title=desc, accelerator=accel)
  24. short.show()
  25. compose_group.add(short)
  26. section.add(compose_group)
  27. source_group = Gtk.ShortcutsGroup(title="Source Selection")
  28. source_group.show()
  29. num = len(Config.getlist('mix', 'sources'))
  30. source_items = [
  31. ("1...{}".format(num),
  32. "Select Source as A-Source"),
  33. ("<ctrl>1...<ctrl>{}".format(num),
  34. "Select Source as B-Source"),
  35. ("<alt>1...<alt>{}".format(num),
  36. "Select Source as Fullscreen")
  37. ]
  38. for accel, desc in source_items:
  39. short = Gtk.ShortcutsShortcut(title=desc, accelerator=accel)
  40. short.show()
  41. source_group.add(short)
  42. section.add(source_group)
  43. if Config.getboolean('misc', 'cut'):
  44. other_group = Gtk.ShortcutsGroup(title="Other")
  45. other_group.show()
  46. short = Gtk.ShortcutsShortcut(title="Send Cut message",
  47. accelerator="t")
  48. short.show()
  49. other_group.add(short)
  50. section.add(other_group)
  51. self.add(section)
  52. else:
  53. def show_shortcuts(win):
  54. pass