コード例 #1
0
ファイル: video.py プロジェクト: kfatehi/miro
    def __init__(self, text, size=0.77, color=WHITE):
        Widget.__init__(self)
        self.set_widget(gtk.EventBox())

        self.label = Label(text)

        self._widget.add(self.label._widget)
        self.label._widget.show()
        self._widget.set_above_child(False)
        self._widget.set_visible_window(False)

        self.set_size(size)
        self.set_color(color)

        self.wrapped_widget_connect('button-release-event', self.on_click)
        self.wrapped_widget_connect('enter-notify-event', self.on_enter_notify)
        self.wrapped_widget_connect('leave-notify-event', self.on_leave_notify)
        self.wrapped_widget_connect('unmap', self.on_unmap)
        self.create_signal('clicked')
コード例 #2
0
ファイル: video.py プロジェクト: kfatehi/miro
def make_label(text, handler, visible=True):
    if visible:
        lab = ClickableLabel(text)
        lab.connect('clicked', handler)
        return lab

    # if the widget isn't visible, then we stick in an empty string--we just
    # need a placeholder so that things don't move around when the item state
    # changes.
    lab = Label("")
    lab.set_size(0.77)
    return lab
コード例 #3
0
ファイル: video.py プロジェクト: willkg/miro
class ClickableLabel(Widget):
    """This is like a label and reimplements many of the Label things,
    but it's an EventBox with a Label child widget.
    """

    def __init__(self, text, size=0.77, color=WHITE):
        Widget.__init__(self)
        self.set_widget(gtk.EventBox())

        self.label = Label(text)

        self._widget.add(self.label._widget)
        self.label._widget.show()
        self._widget.set_above_child(False)
        self._widget.set_visible_window(False)

        self.set_size(size)
        self.set_color(color)

        self.wrapped_widget_connect("button-release-event", self.on_click)
        self.wrapped_widget_connect("enter-notify-event", self.on_enter_notify)
        self.wrapped_widget_connect("leave-notify-event", self.on_leave_notify)
        self.wrapped_widget_connect("unmap", self.on_unmap)
        self.create_signal("clicked")

    def on_click(self, widget, event):
        self.emit("clicked")
        return True

    def on_enter_notify(self, widget, event):
        self._widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))

    def on_leave_notify(self, widget, event):
        if self._widget.window:
            self._widget.window.set_cursor(None)

    def on_unmap(self, widget):
        if self._widget.window:
            self._widget.window.set_cursor(None)

    def set_size(self, size):
        self.label.set_size(size)

    def set_color(self, color):
        self.label.set_color(color)

    def set_text(self, text):
        self.label.set_text(text)

    def hide(self):
        self.label._widget.hide()

    def show(self):
        self.label._widget.show()
コード例 #4
0
ファイル: video.py プロジェクト: kfatehi/miro
class ClickableLabel(Widget):
    """This is like a label and reimplements many of the Label things,
    but it's an EventBox with a Label child widget.
    """
    def __init__(self, text, size=0.77, color=WHITE):
        Widget.__init__(self)
        self.set_widget(gtk.EventBox())

        self.label = Label(text)

        self._widget.add(self.label._widget)
        self.label._widget.show()
        self._widget.set_above_child(False)
        self._widget.set_visible_window(False)

        self.set_size(size)
        self.set_color(color)

        self.wrapped_widget_connect('button-release-event', self.on_click)
        self.wrapped_widget_connect('enter-notify-event', self.on_enter_notify)
        self.wrapped_widget_connect('leave-notify-event', self.on_leave_notify)
        self.wrapped_widget_connect('unmap', self.on_unmap)
        self.create_signal('clicked')

    def on_click(self, widget, event):
        self.emit('clicked')
        return True

    def on_enter_notify(self, widget, event):
        self._widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))

    def on_leave_notify(self, widget, event):
        if self._widget.window:
            self._widget.window.set_cursor(None)

    def on_unmap(self, widget):
        if self._widget.window:
            self._widget.window.set_cursor(None)

    def set_size(self, size):
        self.label.set_size(size)

    def set_color(self, color):
        self.label.set_color(color)

    def set_text(self, text):
        self.label.set_text(text)

    def hide(self):
        self.label._widget.hide()

    def show(self):
        self.label._widget.show()
コード例 #5
0
ファイル: video.py プロジェクト: ShriramK/miro
    def __init__(self, text, size=0.77, color=WHITE):
        Widget.__init__(self)
        self.set_widget(gtk.EventBox())

        self.label = Label(text)

        self._widget.add(self.label._widget)
        self.label._widget.show()
        self._widget.set_above_child(False)
        self._widget.set_visible_window(False)

        self.set_size(size)
        self.set_color(color)

        self.wrapped_widget_connect('button-release-event', self.on_click)
        self.wrapped_widget_connect('enter-notify-event', self.on_enter_notify)
        self.wrapped_widget_connect('leave-notify-event', self.on_leave_notify)
        self.wrapped_widget_connect('unmap', self.on_unmap)
        self.create_signal('clicked')
コード例 #6
0
ファイル: video.py プロジェクト: cool-RR/Miro
    def rebuild_video_details(self):
        # this removes the child widget if there is one
        self.remove()

        if not self.item_info:
            self.add(HBox())
            return

        info = self.item_info

        outer_hbox = HBox(5)

        if not info.is_external:
            if info.expiration_date is not None:
                text = displaytext.expiration_date(info.expiration_date)
                self._expiration_label = Label(text)
                self._expiration_label.set_size(0.77)
                self._expiration_label.set_color((152.0 / 255.0, 152.0 / 255.0, 152.0 / 255.0))
                outer_hbox.pack_start(_align_middle(self._expiration_label))
                outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

            lab = make_label(_("Keep"), self.handle_keep, info.expiration_date is not None)
            outer_hbox.pack_start(_align_middle(lab))
            outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

        self._subtitles_link = make_label(_("Subtitles"),
                                          self.handle_subtitles)
        outer_hbox.pack_start(_align_middle(self._subtitles_link))
        subtitles_image = make_image_button('images/subtitles_down.png',
                                            self.handle_subtitles)
        outer_hbox.pack_start(_align_middle(subtitles_image))

        outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

        self._delete_link = make_label(_("Delete"), self.handle_delete)
        outer_hbox.pack_start(_align_middle(self._delete_link))

        if not info.is_external:
            outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

            self._share_link = make_label(_("Share"), self.handle_share,
                                          info.has_sharable_url)
            outer_hbox.pack_start(_align_middle(self._share_link))
            outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

            if info.commentslink:
                self._permalink_link = make_label(_("Comments"),
                                                  self.handle_commentslink,
                                                  info.commentslink)
            else:
                self._permalink_link = make_label(_("Permalink"),
                                                  self.handle_permalink,
                                                  info.permalink)
            outer_hbox.pack_start(_align_middle(self._permalink_link))

        outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

        if app.playback_manager.is_fullscreen:
            fullscreen_link = make_label(_("Exit fullscreen"),
                                         self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_link))
            fullscreen_image = make_image_button('images/fullscreen_exit.png',
                                                 self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_image))
        else:
            fullscreen_link = make_label(_("Fullscreen"),
                                         self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_link))
            fullscreen_image = make_image_button('images/fullscreen_enter.png',
                                                 self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_image))

        if app.playback_manager.detached_window is not None:
            popin_link = make_label(_("Pop-in"), self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popin_link))
            popin_image = make_image_button('images/popin.png',
                                            self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popin_image))
        else:
            popout_link = make_label(_("Pop-out"), self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popout_link))
            popout_image = make_image_button('images/popout.png',
                                             self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popout_image))

        self.add(_align_right(outer_hbox, left_pad=15, right_pad=15))
コード例 #7
0
ファイル: video.py プロジェクト: cool-RR/Miro
class VideoDetailsWidget(Background):
    def __init__(self):
        Background.__init__(self)
        self.item_info = None
        self.rebuild_video_details()
        self._delete_link = None

    def rebuild_video_details(self):
        # this removes the child widget if there is one
        self.remove()

        if not self.item_info:
            self.add(HBox())
            return

        info = self.item_info

        outer_hbox = HBox(5)

        if not info.is_external:
            if info.expiration_date is not None:
                text = displaytext.expiration_date(info.expiration_date)
                self._expiration_label = Label(text)
                self._expiration_label.set_size(0.77)
                self._expiration_label.set_color((152.0 / 255.0, 152.0 / 255.0, 152.0 / 255.0))
                outer_hbox.pack_start(_align_middle(self._expiration_label))
                outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

            lab = make_label(_("Keep"), self.handle_keep, info.expiration_date is not None)
            outer_hbox.pack_start(_align_middle(lab))
            outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

        self._subtitles_link = make_label(_("Subtitles"),
                                          self.handle_subtitles)
        outer_hbox.pack_start(_align_middle(self._subtitles_link))
        subtitles_image = make_image_button('images/subtitles_down.png',
                                            self.handle_subtitles)
        outer_hbox.pack_start(_align_middle(subtitles_image))

        outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

        self._delete_link = make_label(_("Delete"), self.handle_delete)
        outer_hbox.pack_start(_align_middle(self._delete_link))

        if not info.is_external:
            outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

            self._share_link = make_label(_("Share"), self.handle_share,
                                          info.has_sharable_url)
            outer_hbox.pack_start(_align_middle(self._share_link))
            outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

            if info.commentslink:
                self._permalink_link = make_label(_("Comments"),
                                                  self.handle_commentslink,
                                                  info.commentslink)
            else:
                self._permalink_link = make_label(_("Permalink"),
                                                  self.handle_permalink,
                                                  info.permalink)
            outer_hbox.pack_start(_align_middle(self._permalink_link))

        outer_hbox.pack_start(_align_middle(Divider(), top_pad=3, bottom_pad=3, left_pad=5, right_pad=5))

        if app.playback_manager.is_fullscreen:
            fullscreen_link = make_label(_("Exit fullscreen"),
                                         self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_link))
            fullscreen_image = make_image_button('images/fullscreen_exit.png',
                                                 self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_image))
        else:
            fullscreen_link = make_label(_("Fullscreen"),
                                         self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_link))
            fullscreen_image = make_image_button('images/fullscreen_enter.png',
                                                 self.handle_fullscreen)
            outer_hbox.pack_start(_align_middle(fullscreen_image))

        if app.playback_manager.detached_window is not None:
            popin_link = make_label(_("Pop-in"), self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popin_link))
            popin_image = make_image_button('images/popin.png',
                                            self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popin_image))
        else:
            popout_link = make_label(_("Pop-out"), self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popout_link))
            popout_image = make_image_button('images/popout.png',
                                             self.handle_popin_popout)
            outer_hbox.pack_start(_align_middle(popout_image))

        self.add(_align_right(outer_hbox, left_pad=15, right_pad=15))

    def hide(self):
        self._widget.hide()

    def show(self):
        self._widget.show()

    def handle_fullscreen(self, widget, event=None):
        app.playback_manager.toggle_fullscreen()

    def handle_popin_popout(self, widget, event=None):
        if app.playback_manager.is_fullscreen:
            app.playback_manager.exit_fullscreen()
        app.playback_manager.toggle_detached_mode()

    def handle_keep(self, widget, event):
        messages.KeepVideo(self.item_info.id).send_to_backend()
        self._widget.window.set_cursor(None)

    def handle_delete(self, widget, event):
        item_info = self.item_info
        self.reset()
        app.widgetapp.remove_items([item_info])

    def handle_subtitles(self, widget, event):
        tracks = []
        menu = gtk.Menu()

        tracks = app.video_renderer.get_subtitle_tracks()

        if len(tracks) == 0:
            child = gtk.MenuItem(_("None Available"))
            child.set_sensitive(False)
            child.show()
            menu.append(child)
        else:
            enabled_track = app.video_renderer.get_enabled_subtitle_track()

            first_child = None
            for i, lang in tracks:
                child = gtk.RadioMenuItem(first_child, lang)
                if enabled_track == i:
                    child.set_active(True)
                child.connect('activate', self.handle_subtitle_change, i)
                child.show()
                menu.append(child)
                if first_child == None:
                    first_child = child

            sep = gtk.SeparatorMenuItem()
            sep.show()
            menu.append(sep)

            child = gtk.RadioMenuItem(first_child, _("Disable Subtitles"))
            if enabled_track == -1:
                child.set_active(True)
            child.connect('activate', self.handle_disable_subtitles)
            child.show()
            menu.append(child)

        sep = gtk.SeparatorMenuItem()
        sep.show()
        menu.append(sep)

        child = gtk.MenuItem(_("Select a Subtitles file..."))
        child.set_sensitive(True)
        child.connect('activate', self.handle_select_subtitle_file)
        child.show()
        menu.append(child)

        menu.popup(None, None, None, event.button, event.time)

    def handle_disable_subtitles(self, widget):
        if widget.active:
            app.video_renderer.disable_subtitles()
            app.widgetapp.window.on_playback_change(app.playback_manager)

    def handle_subtitle_change(self, widget, index):
        if widget.active:
            app.video_renderer.enable_subtitle_track(index)
            app.widgetapp.window.on_playback_change(app.playback_manager)

    def handle_select_subtitle_file(self, widget):
        app.playback_manager.open_subtitle_file()

    def handle_commentslink(self, widget, event):
        app.widgetapp.open_url(self.item_info.commentslink)

    def handle_share(self, widget, event):
        app.widgetapp.share_item(self.item_info)

    def handle_permalink(self, widget, event):
        app.widgetapp.open_url(self.item_info.permalink)

    def update_info(self, item_info):
        self.item_info = item_info
        self.rebuild_video_details()

    def set_video_details(self, item_info):
        """This gets called when the item is set to play.  It should make
        no assumptions about the state of the video details prior to being
        called.
        """
        self.update_info(item_info)

    def draw(self, context, layout):
        context.set_color(BLACK)
        context.rectangle(0, 0, context.width, context.height)
        context.fill()
        context.set_color((46.0 / 255.0, 46.0 / 255.0, 46.0 / 255.0))
        context.set_line_width(1)
        context.move_to(0, 0)
        context.rel_line_to(context.width, 0)
        context.stroke()

    def is_opaque(self):
        return True

    def reset(self):
        if self._delete_link:
            self._delete_link.on_leave_notify(None, None)