aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib/toolbar/misc.py
blob: 894736802be0073055af60be93ce668a4a66eff0 (plain)
  1. import logging
  2. from gi.repository import Gtk
  3. from lib.config import Config
  4. import lib.connection as Connection
  5. class MiscToolbarController(object):
  6. """Manages Accelerators and Clicks Misc buttons"""
  7. def __init__(self, drawing_area, win, uibuilder):
  8. self.log = logging.getLogger('MiscToolbarController')
  9. # Accelerators
  10. accelerators = Gtk.AccelGroup()
  11. win.add_accel_group(accelerators)
  12. closebtn = uibuilder.find_widget_recursive(drawing_area, 'close')
  13. closebtn.set_visible(Config.getboolean('misc', 'close'))
  14. closebtn.connect('clicked', self.on_closebtn_clicked)
  15. cutbtn = uibuilder.find_widget_recursive(drawing_area, 'cut')
  16. cutbtn.set_visible(Config.getboolean('misc', 'cut'))
  17. cutbtn.connect('clicked', self.on_cutbtn_clicked)
  18. key, mod = Gtk.accelerator_parse('t')
  19. cutbtn.add_accelerator('clicked', accelerators,
  20. key, mod, Gtk.AccelFlags.VISIBLE)
  21. tooltip = Gtk.accelerator_get_label(key, mod)
  22. cutbtn.set_tooltip_text(tooltip)
  23. def on_closebtn_clicked(self, btn):
  24. self.log.info('close-button clicked')
  25. Gtk.main_quit()
  26. def on_cutbtn_clicked(self, btn):
  27. self.log.info('cut-button clicked')
  28. Connection.send('message', 'cut')