aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib/toolbar/streamblank.py
blob: 074fb8088293b4d43c88574735bb53c4a28db821 (plain)
  1. import logging
  2. from gi.repository import Gtk
  3. class StreamblankToolbarController(object):
  4. """ Manages Accelerators and Clicks on the Composition Toolbar-Buttons """
  5. def __init__(self, drawing_area, win, uibuilder, warning_overlay):
  6. self.log = logging.getLogger('StreamblankToolbarController')
  7. self.warning_overlay = warning_overlay
  8. blank_sources = ['pause', 'nostream']
  9. livebtn = uibuilder.find_widget_recursive(drawing_area, 'stream_live')
  10. blankbtn = uibuilder.find_widget_recursive(drawing_area, 'stream_blank')
  11. blankbtn_pos = drawing_area.get_item_index(blankbtn)
  12. livebtn.connect('toggled', self.on_btn_toggled)
  13. livebtn.set_name('live')
  14. for idx, name in enumerate(blank_sources):
  15. if idx == 0:
  16. new_btn = blankbtn
  17. else:
  18. new_icon = Gtk.Image.new_from_pixbuf(blankbtn.get_icon_widget().get_pixbuf())
  19. new_btn = Gtk.RadioToolButton(group=livebtn)
  20. new_btn.set_icon_widget(new_icon)
  21. drawing_area.insert(new_btn, blankbtn_pos+1)
  22. new_btn.set_label("Stream %s" % name)
  23. new_btn.connect('toggled', self.on_btn_toggled)
  24. new_btn.set_name(name)
  25. def on_btn_toggled(self, btn):
  26. if not btn.get_active():
  27. return
  28. self.log.info("on_btn_toggled: %s", btn.get_name())
  29. if btn.get_name() == 'live':
  30. self.warning_overlay.disable()
  31. else:
  32. self.warning_overlay.enable(btn.get_name())