コード例 #1
0
    def __init__(self, drawing_area, win, uibuilder):
        self.log = logging.getLogger('AudioSelectorController')

        self.drawing_area = drawing_area
        self.win = win

        combo = uibuilder.find_widget_recursive(win, 'combo_audio')
        combo.connect('changed', self.on_changed)
        #combo.set_sensitive(True)
        self.combo = combo

        eventbox = uibuilder.find_widget_recursive(win, 'combo_audio_events')
        eventbox.connect('button_press_event', self.on_button_press_event)
        eventbox.set_property('above_child', True)
        self.eventbox = eventbox

        combo.remove_all()
        for name in Config.getlist('mix', 'sources'):
            combo.append(name, name)

        # connect event-handler and request initial state
        Connection.on('audio_status', self.on_audio_status)
        Connection.send('get_audio')

        self.timer_iteration = 0
コード例 #2
0
ファイル: composition.py プロジェクト: jhenstridge/voctomix
	def __init__(self, drawing_area, win, uibuilder):
		self.log = logging.getLogger('CompositionToolbarController')

		accelerators = Gtk.AccelGroup()
		win.add_accel_group(accelerators)

		composites = [
			'fullscreen',
			'picture_in_picture',
			'side_by_side_equal',
			'side_by_side_preview'
		]

		self.composite_btns = {}

		for idx, name in enumerate(composites):
			key, mod = Gtk.accelerator_parse('F%u' % (idx+1))
			btn = uibuilder.find_widget_recursive(drawing_area, 'composite-'+name.replace('_', '-'))
			btn.set_name(name)

			# Thanks to http://stackoverflow.com/a/19739855/1659732
			btn.get_child().add_accelerator('clicked', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)
			btn.connect('toggled', self.on_btn_toggled)

			self.composite_btns[name] = btn

		# connect event-handler and request initial state
		Connection.on('composite_mode', self.on_composite_mode)
		Connection.send('get_composite_mode')
コード例 #3
0
ファイル: composition.py プロジェクト: nueces/voctomix
    def __init__(self, drawing_area, win, uibuilder):
        self.log = logging.getLogger('CompositionToolbarController')

        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        composites = [
            'fullscreen', 'picture_in_picture', 'side_by_side_equal',
            'side_by_side_preview'
        ]

        self.composite_btns = {}
        self.current_composition = None

        for idx, name in enumerate(composites):
            key, mod = Gtk.accelerator_parse('F%u' % (idx + 1))
            btn = uibuilder.find_widget_recursive(
                drawing_area, 'composite-' + name.replace('_', '-'))
            btn.set_name(name)

            # Thanks to http://stackoverflow.com/a/19739855/1659732
            btn.get_child().add_accelerator('clicked', accelerators, key, mod,
                                            Gtk.AccelFlags.VISIBLE)
            btn.connect('toggled', self.on_btn_toggled)

            self.composite_btns[name] = btn

        # connect event-handler and request initial state
        Connection.on('composite_mode', self.on_composite_mode)
        Connection.send('get_composite_mode')
コード例 #4
0
ファイル: audioselector.py プロジェクト: CarlFK/voctomix
	def __init__(self, drawing_area, win, uibuilder):
		self.log = logging.getLogger('AudioSelectorController')

		self.drawing_area = drawing_area
		self.win = win

		combo = uibuilder.find_widget_recursive(win, 'combo_audio')
		combo.connect('changed', self.on_changed)
		#combo.set_sensitive(True)
		self.combo = combo

		eventbox = uibuilder.find_widget_recursive(win, 'combo_audio_events')
		eventbox.connect('button_press_event', self.on_button_press_event)
		eventbox.set_property('above_child', True)
		self.eventbox = eventbox

		combo.remove_all()
		for name in Config.getlist('mix', 'sources'):
			combo.append(name, name)

		# connect event-handler and request initial state
		Connection.on('audio_status', self.on_audio_status)
		Connection.send('get_audio')

		self.timer_iteration = 0
コード例 #5
0
    def __init__(self, drawing_area, win, uibuilder, warning_overlay):
        self.log = logging.getLogger('StreamblankToolbarController')

        self.warning_overlay = warning_overlay

        livebtn = uibuilder.find_widget_recursive(drawing_area, 'stream_live')
        blankbtn = uibuilder.find_widget_recursive(drawing_area,
                                                   'stream_blank')

        blankbtn_pos = drawing_area.get_item_index(blankbtn)

        if not Config.getboolean('stream-blanker', 'enabled'):
            self.log.info(
                'disabling stream-blanker features because the server does not support them: %s',
                Config.getboolean('stream-blanker', 'enabled'))
            stream_blank_separator = uibuilder.find_widget_recursive(
                drawing_area, 'stream_blank_separator')

            drawing_area.remove(livebtn)
            drawing_area.remove(blankbtn)
            drawing_area.remove(stream_blank_separator)
            return

        blank_sources = Config.getlist('stream-blanker', 'sources')
        self.status_btns = {}

        self.current_status = None

        livebtn.connect('toggled', self.on_btn_toggled)
        livebtn.set_name('live')

        self.livebtn = livebtn
        self.blank_btns = {}

        for idx, name in enumerate(blank_sources):
            if idx == 0:
                new_btn = blankbtn
            else:
                new_icon = Gtk.Image.new_from_pixbuf(
                    blankbtn.get_icon_widget().get_pixbuf())
                new_btn = Gtk.RadioToolButton(group=livebtn)
                new_btn.set_icon_widget(new_icon)
                drawing_area.insert(new_btn, blankbtn_pos + 1)

            new_btn.set_label("Stream %s" % name)
            new_btn.connect('toggled', self.on_btn_toggled)
            new_btn.set_name(name)

            self.blank_btns[name] = new_btn

        # connect event-handler and request initial state
        Connection.on('stream_status', self.on_stream_status)
        Connection.send('get_stream_status')
コード例 #6
0
ファイル: streamblank.py プロジェクト: CarlFK/voctomix
	def __init__(self, drawing_area, win, uibuilder, warning_overlay):
		self.log = logging.getLogger('StreamblankToolbarController')

		self.warning_overlay = warning_overlay

		livebtn = uibuilder.find_widget_recursive(drawing_area, 'stream_live')
		blankbtn = uibuilder.find_widget_recursive(drawing_area, 'stream_blank')

		blankbtn_pos = drawing_area.get_item_index(blankbtn)

		if not Config.getboolean('stream-blanker', 'enabled'):
			self.log.info('disabling stream-blanker features because the server does not support them: %s', Config.getboolean('stream-blanker', 'enabled'))
			stream_blank_separator = uibuilder.find_widget_recursive(drawing_area, 'stream_blank_separator')

			drawing_area.remove(livebtn)
			drawing_area.remove(blankbtn)
			drawing_area.remove(stream_blank_separator)
			return

		blank_sources = Config.getlist('stream-blanker', 'sources')
		self.status_btns = {}

		self.current_status = None

		livebtn.connect('toggled', self.on_btn_toggled)
		livebtn.set_name('live')

		self.livebtn = livebtn
		self.blank_btns = {}

		for idx, name in enumerate(blank_sources):
			if idx == 0:
				new_btn = blankbtn
			else:
				new_icon = Gtk.Image.new_from_pixbuf(blankbtn.get_icon_widget().get_pixbuf())
				new_btn = Gtk.RadioToolButton(group=livebtn)
				new_btn.set_icon_widget(new_icon)
				drawing_area.insert(new_btn, blankbtn_pos+1)

			new_btn.set_label("Stream %s" % name)
			new_btn.connect('toggled', self.on_btn_toggled)
			new_btn.set_name(name)

			self.blank_btns[name] = new_btn

		# connect event-handler and request initial state
		Connection.on('stream_status', self.on_stream_status)
		Connection.send('get_stream_status')
コード例 #7
0
    def __init__(self, drawing_area, win, uibuilder):
        self.log = logging.getLogger('MiscToolbarController')
        self.recbtn = uibuilder.find_widget_recursive(drawing_area, 'rec_btn')
        self.recbtn.set_visible(Config.getboolean('misc', 'rec'))
        self.recbtn.connect('clicked', self.on_recbtn_clicked)

        self.timelabel = uibuilder.find_widget_recursive(drawing_area, 'rec_time')
        self.sizelabel = uibuilder.find_widget_recursive(drawing_area, 'rec_size')
        self.ratelabel = uibuilder.find_widget_recursive(drawing_area, 'rec_rate')

        self.timelabel.set_text("--:--:--.--")
        self.sizelabel.set_text("")
        self.ratelabel.set_text("")

        Connection.on('message', self.on_message)
        Connection.send('message get_rec')
コード例 #8
0
ファイル: playground.py プロジェクト: zo-edv/voctoconfig
def main():
    docolor = (Args.color == 'always') or (Args.color == 'auto'
                                           and sys.stderr.isatty())
    loghandler = LogHandler(docolor, Args.timestamp)
    logging.root.addHandler(loghandler)
    if Args.verbose >= 2:
        level = logging.DEBUG
    elif Args.verbose == 1:
        level = logging.INFO
    else:
        level = logging.WARNING

    logging.root.setLevel(level)
    logging.debug('setting SIGINT handler')
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    Connection.establish(Args.host)
    Connection.enterNonblockingMode()
    Connection.on("message", testCallback)
    mainloop = GObject.MainLoop()
    mainloop.run()
    while True:
        logging.debug("mimimi...")
        Connection.send("message", "test2")
        time.sleep(10)
コード例 #9
0
ファイル: streamblank.py プロジェクト: h01ger/voctomix
    def __init__(self, toolbar, win, uibuilder, warning_overlay):
        self.log = logging.getLogger('StreamblankToolbarController')

        self.warning_overlay = warning_overlay

        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        livebtn = uibuilder.find_widget_recursive(toolbar, 'stream_live')
        blankbtn = uibuilder.find_widget_recursive(toolbar, 'stream_blank')

        blankbtn_pos = toolbar.get_item_index(blankbtn)

        if not Config.getboolean('stream-blanker', 'enabled'):
            self.log.info('disabling stream-blanker features '
                          'because the server does not support them: %s',
                          Config.getboolean('stream-blanker', 'enabled'))

            toolbar.remove(livebtn)
            toolbar.remove(blankbtn)
            return

        blank_sources = Config.getlist('stream-blanker', 'sources')

        self.current_status = None

        key, mod = Gtk.accelerator_parse('F12')
        livebtn.connect('toggled', self.on_btn_toggled)
        livebtn.set_name('live')
        livebtn.set_label(livebtn.get_label() + "\nF12")

        tooltip = Gtk.accelerator_get_label(key, mod)
        livebtn.set_tooltip_text(tooltip)

        livebtn.get_child().add_accelerator('clicked', accelerators,
                                            key, mod, Gtk.AccelFlags.VISIBLE)

        self.livebtn = livebtn
        self.blank_btns = {}

        accel_f_key = 11

        for idx, name in enumerate(blank_sources):
            key, mod = Gtk.accelerator_parse('F%u' % accel_f_key)

            if idx == 0:
                new_btn = blankbtn
            else:
                new_icon = Gtk.Image.new_from_pixbuf(blankbtn.get_icon_widget()
                                                     .get_pixbuf())
                new_btn = Gtk.RadioToolButton(group=livebtn)
                new_btn.set_icon_widget(new_icon)
                toolbar.insert(new_btn, blankbtn_pos)

            new_btn.set_label("Stream %s\nF%s" % (name, accel_f_key))
            new_btn.connect('toggled', self.on_btn_toggled)
            new_btn.set_name(name)

            tooltip = Gtk.accelerator_get_label(key, mod)
            new_btn.set_tooltip_text(tooltip)

            new_btn.get_child().add_accelerator(
                'clicked', accelerators,
                key, mod, Gtk.AccelFlags.VISIBLE)

            self.blank_btns[name] = new_btn
            accel_f_key = accel_f_key - 1

        # connect event-handler and request initial state
        Connection.on('stream_status', self.on_stream_status)
        Connection.send('get_stream_status')
コード例 #10
0
    def __init__(self, preview_box, win, uibuilder):
        self.log = logging.getLogger('VideoPreviewsController')

        self.preview_box = preview_box
        self.win = win

        self.sources = Config.getlist('mix', 'sources')
        self.preview_players = {}
        self.previews = {}
        self.a_btns = {}
        self.b_btns = {}

        self.current_source = {'a': None, 'b': None}

        try:
            width = Config.getint('previews', 'width')
            self.log.debug('Preview-Width configured to %u', width)
        except NoOptionError:
            width = 320
            self.log.debug('Preview-Width selected as %u', width)

        try:
            height = Config.getint('previews', 'height')
            self.log.debug('Preview-Height configured to %u', height)
        except NoOptionError:
            height = int(width * 9 / 16)
            self.log.debug('Preview-Height calculated to %u', height)

        # Accelerators
        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        group_a = None
        group_b = None

        for idx, source in enumerate(self.sources):
            self.log.info('Initializing Video Preview %s', source)

            preview = uibuilder.get_check_widget('widget_preview', clone=True)
            video = uibuilder.find_widget_recursive(preview, 'video')

            video.set_size_request(width, height)
            preview_box.pack_start(preview, fill=False,
                                   expand=False, padding=0)

            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')

            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)

            if not group_b:
                group_b = btn_b
            else:
                btn_b.join_group(group_b)

            btn_a.connect('toggled', self.btn_toggled)
            btn_b.connect('toggled', self.btn_toggled)

            key, mod = Gtk.accelerator_parse('%u' % (idx + 1))
            btn_a.add_accelerator('activate', accelerators,
                                  key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_a.set_tooltip_text(tooltip)

            key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx + 1))
            btn_b.add_accelerator('activate', accelerators,
                                  key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_b.set_tooltip_text(tooltip)

            btn_fullscreen = uibuilder.find_widget_recursive(preview,
                                                             'btn_fullscreen')
            btn_fullscreen.set_name("%c %u" % ('f', idx))

            btn_fullscreen.connect('clicked', self.btn_fullscreen_clicked)

            key, mod = Gtk.accelerator_parse('<Alt>%u' % (idx + 1))
            btn_fullscreen.add_accelerator('activate', accelerators,
                                           key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_fullscreen.set_tooltip_text(tooltip)

            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')
コード例 #11
0
ファイル: videopreviews.py プロジェクト: nueces/voctomix
	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 = {}

		self.current_source = {'a': None, '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)

		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)

		# Accelerators
		accelerators = Gtk.AccelGroup()
		win.add_accel_group(accelerators)

		group_a = None
		group_b = None

		for idx, source in enumerate(self.sources):
			self.log.info('Initializing Video Preview %s', source)

			preview = uibuilder.get_check_widget('widget_preview', clone=True)
			video = uibuilder.find_widget_recursive(preview, 'video')

			video.set_size_request(width, height)
			drawing_area.pack_start(preview, fill=False, expand=False, padding=0)

			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')

			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)


			if not group_b:
				group_b = btn_b
			else:
				btn_b.join_group(group_b)


			btn_a.connect('toggled', self.btn_toggled)
			btn_b.connect('toggled', self.btn_toggled)

			key, mod = Gtk.accelerator_parse('%u' % (idx+1))
			btn_a.add_accelerator('activate', accelerators, key, mod, Gtk.AccelFlags.VISIBLE)

			key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx+1))
			btn_b.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))

			btn_fullscreen.connect('clicked', self.btn_fullscreen_clicked)

			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')
コード例 #12
0
ファイル: streamblank.py プロジェクト: wcmckee/voctomix
    def __init__(self, toolbar, win, uibuilder, warning_overlay):
        self.log = logging.getLogger('StreamblankToolbarController')

        self.warning_overlay = warning_overlay

        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        livebtn = uibuilder.find_widget_recursive(toolbar, 'stream_live')
        blankbtn = uibuilder.find_widget_recursive(toolbar, 'stream_blank')

        blankbtn_pos = toolbar.get_item_index(blankbtn)

        if not Config.getboolean('stream-blanker', 'enabled'):
            self.log.info(
                'disabling stream-blanker features '
                'because the server does not support them: %s',
                Config.getboolean('stream-blanker', 'enabled'))

            toolbar.remove(livebtn)
            toolbar.remove(blankbtn)
            return

        blank_sources = Config.getlist('stream-blanker', 'sources')

        self.current_status = None

        key, mod = Gtk.accelerator_parse('F12')
        livebtn.connect('toggled', self.on_btn_toggled)
        livebtn.set_name('live')

        tooltip = Gtk.accelerator_get_label(key, mod)
        livebtn.set_tooltip_text(tooltip)

        livebtn.get_child().add_accelerator('clicked', accelerators, key, mod,
                                            Gtk.AccelFlags.VISIBLE)

        self.livebtn = livebtn
        self.blank_btns = {}

        accel_f_key = 11

        for idx, name in enumerate(blank_sources):
            key, mod = Gtk.accelerator_parse('F%u' % accel_f_key)
            accel_f_key = accel_f_key - 1

            if idx == 0:
                new_btn = blankbtn
            else:
                new_icon = Gtk.Image.new_from_pixbuf(
                    blankbtn.get_icon_widget().get_pixbuf())
                new_btn = Gtk.RadioToolButton(group=livebtn)
                new_btn.set_icon_widget(new_icon)
                toolbar.insert(new_btn, blankbtn_pos)

            new_btn.set_label("Stream %s" % name)
            new_btn.connect('toggled', self.on_btn_toggled)
            new_btn.set_name(name)

            tooltip = Gtk.accelerator_get_label(key, mod)
            new_btn.set_tooltip_text(tooltip)

            new_btn.get_child().add_accelerator('clicked', accelerators, key,
                                                mod, Gtk.AccelFlags.VISIBLE)

            self.blank_btns[name] = new_btn

        # connect event-handler and request initial state
        Connection.on('stream_status', self.on_stream_status)
        Connection.send('get_stream_status')
コード例 #13
0
    def __init__(self, preview_box, win, uibuilder):
        self.log = logging.getLogger('VideoPreviewsController')

        self.preview_box = preview_box
        self.win = win

        self.sources = Config.getlist('mix', 'sources')
        self.preview_players = {}
        self.previews = {}
        self.a_btns = {}
        self.b_btns = {}
        self.volume_sliders = {}

        self.current_source = {'a': None, 'b': None}

        try:
            width = Config.getint('previews', 'width')
            self.log.debug('Preview-Width configured to %u', width)
        except NoOptionError:
            width = 320
            self.log.debug('Preview-Width selected as %u', width)

        try:
            height = Config.getint('previews', 'height')
            self.log.debug('Preview-Height configured to %u', height)
        except NoOptionError:
            height = int(width * 9 / 16)
            self.log.debug('Preview-Height calculated to %u', height)

        # Accelerators
        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        group_a = None
        group_b = None

        # Check if there is a fixed audio source configured.
        # If so, we will remove the volume sliders entirely
        # instead of setting them up.
        volume_control = \
            Config.getboolean('audio', 'volumecontrol', fallback=True) or \
            Config.getboolean('audio', 'forcevolumecontrol', fallback=False)

        for idx, source in enumerate(self.sources):
            self.log.info('Initializing Video Preview %s', source)

            preview = uibuilder.load_check_widget(
                'widget_preview',
                os.path.dirname(uibuilder.uifile) + "/widgetpreview.ui")
            video = uibuilder.find_widget_recursive(preview, 'video')

            video.set_size_request(width, height)
            preview_box.pack_start(preview, fill=False,
                                   expand=False, padding=0)

            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')

            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)

            if not group_b:
                group_b = btn_b
            else:
                btn_b.join_group(group_b)

            btn_a.connect('toggled', self.btn_toggled)
            btn_b.connect('toggled', self.btn_toggled)

            key, mod = Gtk.accelerator_parse('%u' % (idx + 1))
            btn_a.add_accelerator('activate', accelerators,
                                  key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_a.set_tooltip_text(tooltip)

            key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx + 1))
            btn_b.add_accelerator('activate', accelerators,
                                  key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_b.set_tooltip_text(tooltip)

            volume_slider = uibuilder.find_widget_recursive(preview,
                                                            'audio_level')

            if not volume_control:
                box = uibuilder.find_widget_recursive(preview, 'box')
                box.remove(volume_slider)
            else:
                volume_slider.set_name("volume {}".format(source))
                volume_signal = volume_slider.connect('value-changed',
                                                      self.slider_changed)

                def slider_format(scale, value):
                    if value == -20.0:
                        return "-\u221e\u202fdB"
                    else:
                        return "{:.{}f}\u202fdB".format(value,
                                                        scale.get_digits())

                volume_slider.connect('format-value', slider_format)
                self.volume_sliders[source] = (volume_slider, volume_signal)

            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')

        if volume_control:
            Connection.on('audio_status', self.on_audio_status)
            Connection.send('get_audio')
コード例 #14
0
ファイル: videopreviews.py プロジェクト: jhenstridge/voctomix
    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 = {}

        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)

        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)

            # Accelerators
        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        group_a = None
        group_b = None

        for idx, source in enumerate(self.sources):
            self.log.info("Initializing Video Preview %s", source)

            preview = uibuilder.get_check_widget("widget_preview", clone=True)
            video = uibuilder.find_widget_recursive(preview, "video")

            video.set_size_request(width, height)
            drawing_area.pack_start(preview, fill=False, expand=False, padding=0)

            player = VideoDisplay(video, port=13000 + idx)

            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")

            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)

            if not group_b:
                group_b = btn_b
            else:
                btn_b.join_group(group_b)

            btn_a.connect("toggled", self.btn_toggled)
            btn_b.connect("toggled", self.btn_toggled)

            key, mod = Gtk.accelerator_parse("%u" % (idx + 1))
            btn_a.add_accelerator("activate", accelerators, key, mod, Gtk.AccelFlags.VISIBLE)

            key, mod = Gtk.accelerator_parse("<Ctrl>%u" % (idx + 1))
            btn_b.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")
コード例 #15
0
ファイル: composition.py プロジェクト: h01ger/voctomix
    def __init__(self, toolbar, win, uibuilder):
        self.log = logging.getLogger('CompositionToolbarController')

        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        composites = [
            'picture_in_picture',
            'side_by_side_equal',
            'side_by_side_preview'
        ]

        sources = Config.getlist('mix', 'sources')

        self.composite_btns = {}
        self.current_composition = None

        fullscreen_btn = uibuilder.find_widget_recursive(
            toolbar, 'composite-fullscreen')

        fullscreen_btn_pos = toolbar.get_item_index(fullscreen_btn)

        accel_f_key = 1

        for idx, name in enumerate(sources):
            key, mod = Gtk.accelerator_parse('F%u' % accel_f_key)

            if idx == 0:
                new_btn = fullscreen_btn
            else:
                new_icon = Gtk.Image.new_from_pixbuf(
                    fullscreen_btn.get_icon_widget().get_pixbuf())
                new_btn = Gtk.RadioToolButton(group=fullscreen_btn)
                new_btn.set_icon_widget(new_icon)
                toolbar.insert(new_btn, fullscreen_btn_pos + idx)

            new_btn.set_label("Fullscreen %s\nF%s" % (name, accel_f_key))
            new_btn.connect('toggled', self.on_btn_toggled)
            new_btn.set_name('fullscreen %s' % name)

            tooltip = Gtk.accelerator_get_label(key, mod)
            new_btn.set_tooltip_text(tooltip)

            new_btn.get_child().add_accelerator(
                'clicked', accelerators,
                key, mod, Gtk.AccelFlags.VISIBLE)

            self.composite_btns['fullscreen %s' % name] = new_btn
            accel_f_key = accel_f_key + 1

        for idx, name in enumerate(composites):
            key, mod = Gtk.accelerator_parse('F%u' % accel_f_key)

            btn = uibuilder.find_widget_recursive(
                toolbar,
                'composite-' + name.replace('_', '-')
            )
            btn.set_name(name)

            btn.set_label(btn.get_label() + "\nF%s" % accel_f_key)

            tooltip = Gtk.accelerator_get_label(key, mod)
            btn.set_tooltip_text(tooltip)

            # Thanks to http://stackoverflow.com/a/19739855/1659732
            btn.get_child().add_accelerator('clicked', accelerators,
                                            key, mod, Gtk.AccelFlags.VISIBLE)
            btn.connect('toggled', self.on_btn_toggled)

            self.composite_btns[name] = btn
            accel_f_key = accel_f_key + 1

        # connect event-handler and request initial state
        Connection.on('composite_mode_and_video_status',
                      self.on_composite_mode_and_video_status)

        Connection.send('get_composite_mode_and_video_status')