aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib/videopreviews.py
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2016-09-15 09:08:36 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2016-09-15 22:55:24 +0200
commit746d75dee7fb6291a900e0162345354e6eb41c13 (patch)
tree8837a57482ccecebb44a4e9030804654c9526a92 /voctogui/lib/videopreviews.py
parent27f9bb1c2aeebae5c1482d9b5f33e990f6cfb68b (diff)
voctogui: pep8ify
* Indent by 4 spaces * Use spaces around infix operators * Reformat some argument lists * One import per line * Start line comments with '# ' * Two newlines before free functions * One newline before methods
Diffstat (limited to 'voctogui/lib/videopreviews.py')
-rw-r--r--voctogui/lib/videopreviews.py195
1 files changed, 101 insertions, 94 deletions
diff --git a/voctogui/lib/videopreviews.py b/voctogui/lib/videopreviews.py
index 3490a4d..9adb76f 100644
--- a/voctogui/lib/videopreviews.py
+++ b/voctogui/lib/videopreviews.py
@@ -5,133 +5,140 @@ from lib.config import Config
from lib.videodisplay import VideoDisplay
import lib.connection as Connection
-class VideoPreviewsController(object):
- """ Displays Video-Previews and selection Buttons for them """
-
- def __init__(self, drawing_area, win, uibuilder):
- self.log = logging.getLogger('VideoPreviewsController')
- self.drawing_area = drawing_area
- self.win = win
-
- self.sources = Config.getlist('mix', 'sources')
- self.preview_players = {}
- self.previews = {}
- self.a_btns = {}
- self.b_btns = {}
+class VideoPreviewsController(object):
+ """Displays Video-Previews and selection Buttons for them"""
- self.current_source = {'a': None, 'b': None}
+ def __init__(self, drawing_area, win, uibuilder):
+ self.log = logging.getLogger('VideoPreviewsController')
- try:
- width = Config.getint('previews', 'width')
- self.log.debug('Preview-Width configured to %u', width)
- except:
- width = 320
- self.log.debug('Preview-Width selected as %u', width)
+ self.drawing_area = drawing_area
+ self.win = win
- try:
- height = Config.getint('previews', 'height')
- self.log.debug('Preview-Height configured to %u', height)
- except:
- height = width*9/16
- self.log.debug('Preview-Height calculated to %u', height)
+ self.sources = Config.getlist('mix', 'sources')
+ self.preview_players = {}
+ self.previews = {}
+ self.a_btns = {}
+ self.b_btns = {}
- # Accelerators
- accelerators = Gtk.AccelGroup()
- win.add_accel_group(accelerators)
+ self.current_source = {'a': None, 'b': None}
- group_a = None
- group_b = None
+ try:
+ width = Config.getint('previews', 'width')
+ self.log.debug('Preview-Width configured to %u', width)
+ except:
+ width = 320
+ self.log.debug('Preview-Width selected as %u', width)
- for idx, source in enumerate(self.sources):
- self.log.info('Initializing Video Preview %s', source)
+ try:
+ height = Config.getint('previews', 'height')
+ self.log.debug('Preview-Height configured to %u', height)
+ except:
+ height = width * 9 / 16
+ self.log.debug('Preview-Height calculated to %u', height)
- preview = uibuilder.get_check_widget('widget_preview', clone=True)
- video = uibuilder.find_widget_recursive(preview, 'video')
+ # Accelerators
+ accelerators = Gtk.AccelGroup()
+ win.add_accel_group(accelerators)
- video.set_size_request(width, height)
- drawing_area.pack_start(preview, fill=False, expand=False, padding=0)
+ group_a = None
+ group_b = None
- player = VideoDisplay(video, port=13000 + idx, width=width, height=height)
+ for idx, source in enumerate(self.sources):
+ self.log.info('Initializing Video Preview %s', source)
- uibuilder.find_widget_recursive(preview, 'label').set_label(source)
- btn_a = uibuilder.find_widget_recursive(preview, 'btn_a')
- btn_b = uibuilder.find_widget_recursive(preview, 'btn_b')
+ preview = uibuilder.get_check_widget('widget_preview', clone=True)
+ video = uibuilder.find_widget_recursive(preview, 'video')
- btn_a.set_name("%c %u" % ('a', idx))
- btn_b.set_name("%c %u" % ('b', idx))
+ video.set_size_request(width, height)
+ drawing_area.pack_start(preview, fill=False,
+ expand=False, padding=0)
- if not group_a:
- group_a = btn_a
- else:
- btn_a.join_group(group_a)
+ player = VideoDisplay(video, port=13000 + idx,
+ width=width, height=height)
+ uibuilder.find_widget_recursive(preview, 'label').set_label(source)
+ btn_a = uibuilder.find_widget_recursive(preview, 'btn_a')
+ btn_b = uibuilder.find_widget_recursive(preview, 'btn_b')
- if not group_b:
- group_b = btn_b
- else:
- btn_b.join_group(group_b)
+ btn_a.set_name("%c %u" % ('a', idx))
+ btn_b.set_name("%c %u" % ('b', idx))
+ if not group_a:
+ group_a = btn_a
+ else:
+ btn_a.join_group(group_a)
- btn_a.connect('toggled', self.btn_toggled)
- btn_b.connect('toggled', self.btn_toggled)
+ if not group_b:
+ group_b = btn_b
+ else:
+ btn_b.join_group(group_b)
- key, mod = Gtk.accelerator_parse('%u' % (idx+1))
- btn_a.add_accelerator('activate', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
+ btn_a.connect('toggled', self.btn_toggled)
+ btn_b.connect('toggled', self.btn_toggled)
- key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx+1))
- btn_b.add_accelerator('activate', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
+ key, mod = Gtk.accelerator_parse('%u' % (idx + 1))
+ btn_a.add_accelerator('activate', accelerators,
+ key, mod, Gtk.AccelFlags.VISIBLE)
- btn_fullscreen = uibuilder.find_widget_recursive(preview, 'btn_fullscreen')
- btn_fullscreen.set_name("%c %u" % ('f', idx))
+ key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx + 1))
+ btn_b.add_accelerator('activate', accelerators,
+ key, mod, Gtk.AccelFlags.VISIBLE)
- btn_fullscreen.connect('clicked', self.btn_fullscreen_clicked)
+ btn_fullscreen = uibuilder.find_widget_recursive(preview,
+ 'btn_fullscreen')
+ btn_fullscreen.set_name("%c %u" % ('f', idx))
- key, mod = Gtk.accelerator_parse('<Alt>%u' % (idx+1))
- btn_fullscreen.add_accelerator('activate', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
+ btn_fullscreen.connect('clicked', self.btn_fullscreen_clicked)
- self.preview_players[source] = player
- self.previews[source] = preview
- self.a_btns[source] = btn_a
- self.b_btns[source] = btn_b
+ key, mod = Gtk.accelerator_parse('<Alt>%u' % (idx + 1))
+ btn_fullscreen.add_accelerator('activate', accelerators,
+ key, mod, Gtk.AccelFlags.VISIBLE)
+ self.preview_players[source] = player
+ self.previews[source] = preview
+ self.a_btns[source] = btn_a
+ self.b_btns[source] = btn_b
- # connect event-handler and request initial state
- Connection.on('video_status', self.on_video_status)
- Connection.send('get_video')
+ # connect event-handler and request initial state
+ Connection.on('video_status', self.on_video_status)
+ Connection.send('get_video')
- def btn_toggled(self, btn):
- if not btn.get_active():
- return
+ def btn_toggled(self, btn):
+ if not btn.get_active():
+ return
- btn_name = btn.get_name()
- self.log.debug('btn_toggled: %s', btn_name)
+ btn_name = btn.get_name()
+ self.log.debug('btn_toggled: %s', btn_name)
- channel, idx = btn_name.split(' ')[:2]
- source_name = self.sources[int(idx)]
+ channel, idx = btn_name.split(' ')[:2]
+ source_name = self.sources[int(idx)]
- if self.current_source[channel] == source_name:
- self.log.info('video-channel %s already on %s', channel, source_name)
- return
+ if self.current_source[channel] == source_name:
+ self.log.info('video-channel %s already on %s',
+ channel, source_name)
+ return
- self.log.info('video-channel %s changed to %s', channel, source_name)
- Connection.send('set_video_'+channel, source_name)
+ self.log.info('video-channel %s changed to %s', channel, source_name)
+ Connection.send('set_video_' + channel, source_name)
- def btn_fullscreen_clicked(self, btn):
- btn_name = btn.get_name()
- self.log.debug('btn_fullscreen_clicked: %s', btn_name)
+ def btn_fullscreen_clicked(self, btn):
+ btn_name = btn.get_name()
+ self.log.debug('btn_fullscreen_clicked: %s', btn_name)
- channel, idx = btn_name.split(' ')[:2]
- source_name = self.sources[int(idx)]
+ channel, idx = btn_name.split(' ')[:2]
+ source_name = self.sources[int(idx)]
- self.log.info('selcting video %s for fullscreen', source_name)
- Connection.send('set_videos_and_composite', source_name, '*', 'fullscreen')
+ self.log.info('selcting video %s for fullscreen', source_name)
+ Connection.send('set_videos_and_composite',
+ source_name, '*', 'fullscreen')
- def on_video_status(self, source_a, source_b):
- self.log.info('on_video_status callback w/ sources: %s and %s', source_a, source_b)
+ def on_video_status(self, source_a, source_b):
+ self.log.info('on_video_status callback w/ sources: %s and %s',
+ source_a, source_b)
- self.current_source['a'] = source_a
- self.current_source['b'] = source_b
+ self.current_source['a'] = source_a
+ self.current_source['b'] = source_b
- self.a_btns[source_a].set_active(True)
- self.b_btns[source_b].set_active(True)
+ self.a_btns[source_a].set_active(True)
+ self.b_btns[source_b].set_active(True)