aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib/toolbar/misc.py
blob: 9528b6758c473b7fbafe216816b75541a035190f (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, key, mod, Gtk.AccelFlags.VISIBLE)
  20. def on_closebtn_clicked(self, btn):
  21. self.log.info('close-button clicked')
  22. Gtk.main_quit()
  23. def on_cutbtn_clicked(self, btn):
  24. self.log.info('cut-button clicked')
  25. Connection.send('message', 'cut')