def _popup(self, *p): """Open a popup window for temporary anchoring the player video. """ if self.player is None: return None w = Gtk.Window() vbox = Gtk.VBox() d = get_drawable() w.add(vbox) vbox.add(d) w.show_all() self.player.set_widget(d, vbox) return w
def _popup(self, *p): """Open a popup window for temporary anchoring the player video. """ if self.player is None: return None w = Gtk.Window() d = get_drawable() w.add(d) w.show_all() try: self.player.set_widget(d) except AttributeError: self.player.set_visual(d.get_id()) return w
def fullscreen(self, connect=None): def keypress(widget, event): if event.keyval == Gdk.KEY_Escape: self.unfullscreen() return True return False def buttonpress(widget, event): if event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS: self.unfullscreen() return True return False if self.fullscreen_window is None: self.fullscreen_window = Gtk.Window() self.fullscreen_window.set_name("fullscreen_player") self.fullscreen_window.connect('key-press-event', keypress) self.fullscreen_window.connect('button-press-event', buttonpress) self.fullscreen_window.connect('destroy', self.unfullscreen) self.fullscreen_drawable = get_drawable() self.fullscreen_drawable.add_events( Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK | Gdk.EventMask.SCROLL_MASK) self.fullscreen_window.add(self.fullscreen_drawable) self.fullscreen_window.show_all() if connect is not None: connect(self.fullscreen_drawable) # Use black background css_provider = Gtk.CssProvider() css_provider.load_from_data( b"#fullscreen_player { color:#fff; background-color: #000; }") context = Gtk.StyleContext() context.add_provider_for_screen( Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) self.fullscreen_window.show_all() self.fullscreen_window.get_window().fullscreen() self.fullscreen_window.grab_focus() # Do not use set_visual/set_widget so that the player does not # update self.xid and keep it as a reference self.reparent(self.fullscreen_drawable.get_id())
def fullscreen(self, connect=None): def keypress(widget, event): if event.keyval == Gdk.KEY_Escape: self.unfullscreen() return True return False def buttonpress(widget, event): if event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS: self.unfullscreen() return True return False if self.fullscreen_window is None: self.fullscreen_window = Gtk.Window() self.fullscreen_window.set_name("fullscreen_player") self.fullscreen_window.connect('key-press-event', keypress) self.fullscreen_window.connect('button-press-event', buttonpress) self.fullscreen_window.connect('destroy', self.unfullscreen) self.fullscreen_drawable = get_drawable() self.fullscreen_drawable.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK | Gdk.EventMask.SCROLL_MASK) self.fullscreen_window.add(self.fullscreen_drawable) self.fullscreen_window.show_all() if connect is not None: connect(self.fullscreen_drawable) # Use black background css_provider = Gtk.CssProvider() css_provider.load_from_data(b"#fullscreen_player { color:#fff; background-color: #000; }") context = Gtk.StyleContext() context.add_provider_for_screen(Gdk.Screen.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) self.fullscreen_window.show_all() self.fullscreen_window.get_window().fullscreen() self.fullscreen_window.grab_focus() # Do not use set_visual/set_widget so that the player does not # update self.xid and keep it as a reference self.reparent(self.fullscreen_drawable.get_id())
def build_widget(self): vbox = Gtk.VBox() self.player = self.controller.playerfactory.get_player() self.player.sound_mute() self.drawable = get_drawable() black = Gdk.Color(0, 0, 0) for state in (Gtk.StateType.ACTIVE, Gtk.StateType.NORMAL, Gtk.StateType.SELECTED, Gtk.StateType.INSENSITIVE, Gtk.StateType.PRELIGHT): self.drawable.modify_bg(state, black) self.drawable.set_size_request(320, 200) self.toolbar = Gtk.Toolbar() self.toolbar.set_style(Gtk.ToolbarStyle.ICONS) # Append the volume control to the toolbar def volume_change(scale, value): if self.player.sound_get_volume() != int(value * 100): self.player.sound_set_volume(int(value * 100)) return True self.audio_volume = Gtk.VolumeButton() self.audio_volume.set_value(self.player.sound_get_volume() / 100.0) ti = Gtk.ToolItem() ti.add(self.audio_volume) self.audio_volume.connect('value-changed', volume_change) self.toolbar.insert(ti, -1) sync_button = Gtk.ToolButton(Gtk.STOCK_CONNECT) sync_button.set_tooltip_text(_("Synchronize")) sync_button.connect('clicked', self.synchronize) self.toolbar.insert(sync_button, -1) def offset_changed(spin): self.offset = int(spin.get_value()) return True ti = Gtk.ToolItem() self.offset_spin = Gtk.SpinButton.new( Gtk.Adjustment.new(self.offset, -24 * 60 * 60 * 1000, 24 * 60 * 60 * 1000, self.controller.frame2time(1), 1000, 500), 1000, 0) self.offset_spin.get_adjustment().connect('value-changed', offset_changed) ti.add(self.offset_spin) self.offset_spin.set_tooltip_text(_("Offset in ms")) self.toolbar.insert(ti, -1) self.label = Gtk.Label() self.label.set_alignment(0, 0) self.label.modify_font(Pango.FontDescription("sans 10")) timestamp_button = get_pixmap_button('set-to-now.png') timestamp_button.set_tooltip_text( _("Drag and drop to get player time")) enable_drag_source( timestamp_button, lambda: int(self.player.get_stream_information().position), self.controller) # Cannot use a Gtk.ToolButton since it cannot be drag_source ti = Gtk.ToolItem() ti.add(timestamp_button) self.toolbar.insert(ti, -1) black = Gdk.color_parse('black') white = Gdk.color_parse('white') eb = Gtk.EventBox() eb.add(self.label) for state in (Gtk.StateType.ACTIVE, Gtk.StateType.NORMAL, Gtk.StateType.SELECTED, Gtk.StateType.INSENSITIVE, Gtk.StateType.PRELIGHT): self.label.modify_bg(state, black) eb.modify_bg(state, black) self.label.modify_fg(state, white) vbox.add(self.drawable) vbox.pack_start(eb, False, True, 0) vbox.pack_start(self.toolbar, False, True, 0) self.drawable.connect_after('realize', self.register_drawable) # Accept annotation/timestamp drop, to adjust time offset vbox.connect('drag-data-received', self.drag_received_cb) vbox.drag_dest_set( Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.ALL, config.data.get_target_types('annotation', 'timestamp'), Gdk.DragAction.COPY | Gdk.DragAction.LINK | Gdk.DragAction.MOVE) vbox.show_all() return vbox