当前位置: 首页>>代码示例>>Python>>正文


Python pop_tunein.TuneinPopover类代码示例

本文整理汇总了Python中lollypop.pop_tunein.TuneinPopover的典型用法代码示例。如果您正苦于以下问题:Python TuneinPopover类的具体用法?Python TuneinPopover怎么用?Python TuneinPopover使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TuneinPopover类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _on_title_release_event

 def _on_title_release_event(self, widget, event):
     """
         Show track information popover
         On long press/right click: show current track menu
         @param widget as Gtk.Widget
         @param event as Gdk.Event
     """
     if self._timeout_id is not None:
         GLib.source_remove(self._timeout_id)
         self._timeout_id = None
         if Lp().player.current_track.id == Type.EXTERNALS:
             expopover = ExternalsPopover()
             expopover.set_relative_to(widget)
             expopover.populate()
             expopover.show()
         elif Lp().player.current_track.id is not None:
             if event.button == 1:
                 if Lp().player.current_track.id == Type.RADIOS:
                     if self._pop_tunein is None:
                         self._pop_tunein = TuneinPopover()
                         self._pop_tunein.populate()
                         self._pop_tunein.set_relative_to(widget)
                     self._pop_tunein.show()
                 else:
                     if self._pop_info is None:
                         self._pop_info = InfoPopover()
                         self._pop_info.set_relative_to(widget)
                     self._pop_info.show()
             else:
                 self._show_track_menu()
     return True
开发者ID:ferranroig,项目名称:lollypop,代码行数:31,代码来源:toolbar_info.py

示例2: _on_infobox_clicked

 def _on_infobox_clicked(self, eventbox, event):
     """
         Pop albums from current artistleft click
         Show playlist menu on right
         @param eventbox as Gtk.EventBox
         @param event as Gdk.Event
     """
     if Lp().player.current_track.id == Type.EXTERNALS:
         expopover = ExternalsPopover()
         expopover.set_relative_to(eventbox)
         expopover.populate()
         expopover.show()
     elif Lp().player.current_track.id is not None:
         if event.button == 1:
             if Lp().player.current_track.id == Type.RADIOS:
                 if self._pop_tunein is None:
                     self._pop_tunein = TuneinPopover()
                     self._pop_tunein.populate()
                     self._pop_tunein.set_relative_to(self._infobox)
                 self._pop_tunein.show()
             else:
                 if self._pop_infos is None:
                     self._pop_infos = InfosPopover()
                     self._pop_infos.set_relative_to(self._infobox)
                 self._pop_infos.show()
         elif Lp().player.current_track.id >= 0:
             menu = PopToolbarMenu(Lp().player.current_track.id)
             popover = TrackMenuPopover(
                         Lp().player.current_track.id,
                         PopToolbarMenu(Lp().player.current_track.id))
             popover.set_relative_to(self._infobox)
             popover.show()
         return True
开发者ID:oleastre,项目名称:lollypop,代码行数:33,代码来源:toolbar_infos.py

示例3: __init__

    def __init__(self):
        View.__init__(self)

        self._signal = None

        self._radios_manager = RadiosManager()
        self._radios_manager.connect('playlists-changed',
                                     self._on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
        builder.connect_signals(self)
        widget = builder.get_object('widget')

        self._pop_tunein = TuneinPopover(self._radios_manager)
        self._pop_tunein.set_relative_to(builder.get_object('search_btn'))

        self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)

        self._radiobox = Gtk.FlowBox()
        self._radiobox.set_sort_func(self._sort_radios)
        self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._radiobox.connect("child-activated", self._on_album_activated)
        self._radiobox.set_property('column-spacing', 5)
        self._radiobox.set_property('row-spacing', 5)
        self._radiobox.set_homogeneous(True)
        self._radiobox.set_max_children_per_line(1000)
        self._radiobox.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._viewport.add(self._radiobox)
        self._scrolledWindow.set_property('expand', True)

        self.add(widget)
        self.add(self._scrolledWindow)
开发者ID:yoseforb,项目名称:lollypop,代码行数:35,代码来源:view_radios.py

示例4: __on_info_short

 def __on_info_short(self, args):
     """
         Show track information popover
         @param args as []
     """
     if Lp().player.current_track.id == Type.EXTERNALS:
         from lollypop.pop_externals import ExternalsPopover
         expopover = ExternalsPopover()
         expopover.set_relative_to(self._infobox)
         expopover.populate()
         expopover.show()
     elif Lp().player.current_track.id is not None:
         if Lp().player.current_track.id == Type.RADIOS:
             if self.__pop_tunein is None:
                 from lollypop.pop_tunein import TuneinPopover
                 self.__pop_tunein = TuneinPopover()
                 self.__pop_tunein.populate()
                 self.__pop_tunein.set_relative_to(self._infobox)
             self.__pop_tunein.show()
         else:
             if self.__pop_info is None:
                 from lollypop.pop_info import InfoPopover
                 self.__pop_info = InfoPopover()
                 self.__pop_info.set_relative_to(self._infobox)
             self.__pop_info.show()
开发者ID:blackjackshellac,项目名称:lollypop,代码行数:25,代码来源:toolbar_info.py

示例5: __init__

    def __init__(self):
        """
            Init view
        """
        View.__init__(self)
        self._signal = Lp().art.connect('radio-artwork-changed',
                                        self._on_logo_changed)

        self._radios_manager = Radios()
        self._radios_manager.connect('radios-changed',
                                     self._on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
        builder.connect_signals(self)
        widget = builder.get_object('widget')
        self._empty = builder.get_object('empty')

        self._pop_tunein = TuneinPopover(self._radios_manager)
        self._pop_tunein.set_relative_to(builder.get_object('search_btn'))

        self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)

        self._radiobox = Gtk.FlowBox()
        self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._radiobox.connect("child-activated", self._on_album_activated)
        self._radiobox.set_property('column-spacing', 5)
        self._radiobox.set_property('row-spacing', 5)
        self._radiobox.set_homogeneous(True)
        self._radiobox.set_max_children_per_line(1000)
        self._radiobox.show()

        self._stack = Gtk.Stack()
        self._stack.set_transition_duration(500)
        self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self._stack.add(self._scrolled)
        self._stack.add(self._empty)
        self._stack.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._viewport.add(self._radiobox)
        self._scrolled.set_property('expand', True)

        self.add(widget)
        self.add(self._stack)
开发者ID:kmf,项目名称:lollypop,代码行数:45,代码来源:view_radios.py

示例6: __init__

    def __init__(self):
        Gtk.Bin.__init__(self)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/ToolbarInfos.ui')
        builder.connect_signals(self)

        infobox = builder.get_object('infos')
        infobox.set_property('has-tooltip', True)
        self.add(infobox)

        self._title_label = builder.get_object('title')
        self._artist_label = builder.get_object('artist')
        self._cover = builder.get_object('cover')
        self._pop_albums = AlbumsPopover()
        self._pop_albums.set_relative_to(infobox)
        self._pop_tunein = TuneinPopover(RadiosManager())
        self._pop_tunein.set_relative_to(infobox)

        Lp.art.connect('cover-changed', self._update_cover)
        Lp.art.connect('logo-changed', self._update_logo)
开发者ID:yoseforb,项目名称:lollypop,代码行数:20,代码来源:toolbar_infos.py

示例7: __init__

    def __init__(self):
        """
            Init view
        """
        LazyLoadingView.__init__(self, True)
        self.__signal = Lp().art.connect('radio-artwork-changed',
                                         self.__on_logo_changed)

        self.__radios_manager = Radios()
        self.__radios_manager.connect('radios-changed',
                                      self.__on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
        builder.connect_signals(self)
        widget = builder.get_object('widget')
        self.__empty = builder.get_object('empty')

        self.__pop_tunein = TuneinPopover(self.__radios_manager)
        self.__pop_tunein.set_relative_to(builder.get_object('search_btn'))

        self._box = Gtk.FlowBox()
        self._box.set_selection_mode(Gtk.SelectionMode.NONE)
        # Allow lazy loading to not jump up and down
        self._box.set_homogeneous(True)
        self._box.set_max_children_per_line(1000)
        self._box.set_filter_func(self._filter_func)
        self._box.show()

        self.__stack = Gtk.Stack()
        self.__stack.set_transition_duration(500)
        self.__stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self.__stack.add(self._scrolled)
        self.__stack.add(self.__empty)
        self.__stack.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._scrolled.set_property('expand', True)

        self.add(widget)
        self.add(self.__stack)
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:41,代码来源:view_radios.py

示例8: ToolbarInfo


#.........这里部分代码省略.........
            @param art as Art
            @param name as str
        """
        if Lp().player.current_track.album_artist == name:
            pixbuf = Lp().art.get_radio_artwork(name, ArtSize.SMALL)
            self._cover.set_from_surface(pixbuf)
            del pixbuf

    def _show_track_menu(self):
        """
            Show current track menu
        """
        self._timeout_id = None
        if Lp().player.current_track.id >= 0:
            popover = TrackMenuPopover(
                        Lp().player.current_track.id,
                        PopToolbarMenu(Lp().player.current_track.id))
            popover.set_relative_to(self._infobox)
            popover.show()

    def _on_title_press_event(self, widget, event):
        """
            On long press: show current track menu
            @param widget as Gtk.Widget
            @param event as Gdk.Event

        """
        self._timeout_id = GLib.timeout_add(500, self._show_track_menu)
        return True

    def _on_title_release_event(self, widget, event):
        """
            Show track information popover
            On long press/right click: show current track menu
            @param widget as Gtk.Widget
            @param event as Gdk.Event
        """
        if self._timeout_id is not None:
            GLib.source_remove(self._timeout_id)
            self._timeout_id = None
            if Lp().player.current_track.id == Type.EXTERNALS:
                expopover = ExternalsPopover()
                expopover.set_relative_to(widget)
                expopover.populate()
                expopover.show()
            elif Lp().player.current_track.id is not None:
                if event.button == 1:
                    if Lp().player.current_track.id == Type.RADIOS:
                        if self._pop_tunein is None:
                            self._pop_tunein = TuneinPopover()
                            self._pop_tunein.populate()
                            self._pop_tunein.set_relative_to(widget)
                        self._pop_tunein.show()
                    else:
                        if self._pop_info is None:
                            self._pop_info = InfoPopover()
                            self._pop_info.set_relative_to(widget)
                        self._pop_info.show()
                else:
                    self._show_track_menu()
        return True

    def _on_query_tooltip(self, widget, x, y, keyboard, tooltip):
        """
            Show tooltip if needed
            @param widget as Gtk.Widget
            @param x as int
            @param y as int
            @param keyboard as bool
            @param tooltip as Gtk.Tooltip
        """
        # Can't add a \n in markup
        # GTK bug => https://bugzilla.gnome.org/show_bug.cgi?id=749965
        layout_title = self._title_label.get_layout()
        layout_artist = self._artist_label.get_layout()
        if layout_title.is_ellipsized() or layout_artist.is_ellipsized():
            artist = escape(self._artist_label.get_text())
            title = escape(self._title_label.get_text())
            tooltip.set_markup("<b>%s</b> - %s" % (artist, title))
        else:
            return False
        return True

    def _on_realize(self, toolbar):
        """
            @param toolbar as ToolbarInfos
        """
        style = self.get_style_context()
        padding = style.get_padding(style.get_state())
        self._artsize = self.get_allocated_height()\
            - padding.top - padding.bottom
        # Since GTK 3.20, we can set cover full height
        if Gtk.get_minor_version() < 20:
            self._artsize -= 2

    def _on_eventbox_realize(self, eventbox):
        """
            Show hand cursor over
        """
        eventbox.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.HAND1))
开发者ID:ferranroig,项目名称:lollypop,代码行数:101,代码来源:toolbar_info.py

示例9: ToolbarInfos

class ToolbarInfos(Gtk.Bin):
    """
        Init infos toolbar
    """
    def __init__(self):
        Gtk.Bin.__init__(self)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/ToolbarInfos.ui')
        builder.connect_signals(self)

        infobox = builder.get_object('infos')
        infobox.set_property('has-tooltip', True)
        self.add(infobox)

        self._title_label = builder.get_object('title')
        self._artist_label = builder.get_object('artist')
        self._cover = builder.get_object('cover')
        self._pop_albums = AlbumsPopover()
        self._pop_albums.set_relative_to(infobox)
        self._pop_tunein = TuneinPopover(RadiosManager())
        self._pop_tunein.set_relative_to(infobox)

        Lp.art.connect('cover-changed', self._update_cover)
        Lp.art.connect('logo-changed', self._update_logo)

    """
        Update toolbar on current changed
        @param player as Player
    """
    def on_current_changed(self, player):
        art = None
        self._artist_label.set_text(player.current_track.artist)
        self._title_label.set_text(player.current_track.title)

        if player.current_track.id == Type.RADIOS:
            art = Lp.art.get_radio(player.current_track.artist,
                                   ArtSize.SMALL)
        elif player.current_track.id == Type.EXTERNALS:
            art = Lp.art.get_cover_for_uri(player.current_track.uri,
                                           ArtSize.SMALL,
                                           False)
        else:
            art = Lp.art.get_album(player.current_track.album_id,
                                   ArtSize.SMALL)
        if art is not None:
            self._cover.set_from_pixbuf(art)
            del art
            self._cover.set_tooltip_text(player.current_track.album)
            self._cover.show()
        else:
            self._cover.hide()

    """
        Update infos on status changed
        @param player as Player
    """
    def on_status_changed(self, player):
        pass

#######################
# PRIVATE             #
#######################
    """
        Update cover for album_id
        @param art as Art
        @param album id as int
    """
    def _update_cover(self, art, album_id):
        if Lp.player.current_track.album_id == album_id:
            pixbuf = Lp.art.get_album(album_id, ArtSize.SMALL)
            self._cover.set_from_pixbuf(pixbuf)
            del pixbuf

    """
        Update logo for name
        @param art as Art
        @param name as str
    """
    def _update_logo(self, art, name):
        if Lp.player.current_track.artist == name:
            pixbuf = Lp.art.get_radio(name, ArtSize.SMALL)
            self._cover.set_from_pixbuf(pixbuf)
            del pixbuf

    """
        Pop albums from current artistleft click
        Show playlist menu on right
        @param eventbox as Gtk.EventBox
        @param event as Gdk.Event
    """
    def _on_infobox_clicked(self, eventbox, event):
        if Lp.player.current_track.id == Type.EXTERNALS:
            expopover = ExternalsPopover()
            expopover.set_relative_to(eventbox)
            expopover.populate()
            expopover.show()
        elif Lp.player.current_track.id is not None:
            if event.button == 1:
                if Lp.player.current_track.id == Type.RADIOS:
                    self._pop_tunein.populate()
#.........这里部分代码省略.........
开发者ID:yoseforb,项目名称:lollypop,代码行数:101,代码来源:toolbar_infos.py

示例10: RadiosView

class RadiosView(View):
    """
        Show radios in a grid
    """

    def __init__(self):
        """
            Init view
        """
        View.__init__(self)
        self._signal = Lp().art.connect('radio-artwork-changed',
                                        self._on_logo_changed)

        self._radios_manager = Radios()
        self._radios_manager.connect('radios-changed',
                                     self._on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
        builder.connect_signals(self)
        widget = builder.get_object('widget')
        self._empty = builder.get_object('empty')

        self._pop_tunein = TuneinPopover(self._radios_manager)
        self._pop_tunein.set_relative_to(builder.get_object('search_btn'))

        self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)

        self._radiobox = Gtk.FlowBox()
        self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._radiobox.connect("child-activated", self._on_album_activated)
        self._radiobox.set_property('column-spacing', 5)
        self._radiobox.set_property('row-spacing', 5)
        self._radiobox.set_homogeneous(True)
        self._radiobox.set_max_children_per_line(1000)
        self._radiobox.show()

        self._stack = Gtk.Stack()
        self._stack.set_transition_duration(500)
        self._stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self._stack.add(self._scrolled)
        self._stack.add(self._empty)
        self._stack.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._viewport.add(self._radiobox)
        self._scrolled.set_property('expand', True)

        self.add(widget)
        self.add(self._stack)

    def populate(self):
        """
            Populate view with tracks from playlist
            Thread safe
        """
        Lp().player.set_radios(self._radios_manager.get())
        if Lp().player.current_track.id == Type.RADIOS:
            Lp().player.set_next()  # We force next update
            Lp().player.set_prev()  # We force prev update
        t = Thread(target=self._populate)
        t.daemon = True
        t.start()

#######################
# PRIVATE             #
#######################
    def _populate(self):
        """
            Populate view with tracks from playlist
            Thread safe
        """
        radios = []
        # Get radios name
        for (name, url) in self._radios_manager.get():
            radios.append(name)
        GLib.idle_add(self._show_stack, radios)

    def _get_children(self):
        """
            Return view children
            @return [RadioWidget]
        """
        children = []
        for child in self._radiobox.get_children():
            widget = child.get_child()
            children.append(widget)
        return children

    def _on_destroy(self, widget):
        """
            Disconnect signals
            @param widget as Gtk.Widget
        """
        if self._signal is not None:
            Lp().art.disconnect(self._signal)

    def _on_new_clicked(self, widget):
        """
            Show popover for adding a new radio
#.........这里部分代码省略.........
开发者ID:kmf,项目名称:lollypop,代码行数:101,代码来源:view_radios.py

示例11: ToolbarInfos


#.........这里部分代码省略.........
        if Lp.player.current_track.album.id == album_id:
            pixbuf = Lp.art.get_album(Lp.player.current_track.album,
                                      ArtSize.SMALL)
            self._cover.set_from_surface(pixbuf)
            del pixbuf

    def _update_logo(self, art, name):
        """
            Update logo for name
            @param art as Art
            @param name as str
        """
        if Lp.player.current_track.artist == name:
            pixbuf = Lp.art.get_radio(name, ArtSize.SMALL)
            self._cover.set_from_surface(pixbuf)
            del pixbuf

    def _on_infobox_clicked(self, eventbox, event):
        """
            Pop albums from current artistleft click
            Show playlist menu on right
            @param eventbox as Gtk.EventBox
            @param event as Gdk.Event
        """
        if Lp.player.current_track.id == Type.EXTERNALS:
            expopover = ExternalsPopover()
            expopover.set_relative_to(eventbox)
            expopover.populate()
            expopover.show()
        elif Lp.player.current_track.id is not None:
            if event.button == 1:
                if Lp.player.current_track.id == Type.RADIOS:
                    if self._pop_tunein is None:
                        self._pop_tunein = TuneinPopover()
                        self._pop_tunein.populate()
                        self._pop_tunein.set_relative_to(self._infobox)
                    self._pop_tunein.show()
                else:
                    if self._pop_infos is None:
                        self._pop_infos = InfosPopover()
                        self._pop_infos.set_relative_to(self._infobox)
                    self._pop_infos.show()
            elif Lp.player.current_track.id >= 0:
                menu = PopToolbarMenu(Lp.player.current_track.id, None)
                popover = Gtk.Popover.new_from_model(eventbox, menu)
                rating = RatingWidget(Lp.player.current_track)
                rating.set_margin_top(5)
                rating.set_margin_bottom(5)
                rating.set_property('halign', Gtk.Align.START)
                rating.set_property('hexpand', True)
                rating.show()
                loved = LovedWidget(Lp.player.current_track.id)
                loved.set_margin_end(5)
                loved.set_margin_top(5)
                loved.set_margin_bottom(5)
                loved.set_property('halign', Gtk.Align.END)
                loved.set_property('hexpand', True)
                loved.show()
                # Hack to add two widgets in popover
                # Use a Gtk.PopoverMenu later
                # (GTK>3.16 available on Debian stable)
                stack = Gtk.Stack()
                grid = Gtk.Grid()
                grid.set_orientation(Gtk.Orientation.VERTICAL)
                stack.add_named(grid, 'main')
                stack.show_all()
开发者ID:kenden,项目名称:lollypop,代码行数:67,代码来源:toolbar_infos.py

示例12: _on_infobox_clicked

 def _on_infobox_clicked(self, eventbox, event):
     """
         Pop albums from current artistleft click
         Show playlist menu on right
         @param eventbox as Gtk.EventBox
         @param event as Gdk.Event
     """
     if Lp.player.current_track.id == Type.EXTERNALS:
         expopover = ExternalsPopover()
         expopover.set_relative_to(eventbox)
         expopover.populate()
         expopover.show()
     elif Lp.player.current_track.id is not None:
         if event.button == 1:
             if Lp.player.current_track.id == Type.RADIOS:
                 if self._pop_tunein is None:
                     self._pop_tunein = TuneinPopover()
                     self._pop_tunein.populate()
                     self._pop_tunein.set_relative_to(self._infobox)
                 self._pop_tunein.show()
             else:
                 if self._pop_infos is None:
                     self._pop_infos = InfosPopover()
                     self._pop_infos.set_relative_to(self._infobox)
                 self._pop_infos.show()
         elif Lp.player.current_track.id >= 0:
             menu = PopToolbarMenu(Lp.player.current_track.id, None)
             popover = Gtk.Popover.new_from_model(eventbox, menu)
             rating = RatingWidget(Lp.player.current_track)
             rating.set_margin_top(5)
             rating.set_margin_bottom(5)
             rating.set_property('halign', Gtk.Align.START)
             rating.set_property('hexpand', True)
             rating.show()
             loved = LovedWidget(Lp.player.current_track.id)
             loved.set_margin_end(5)
             loved.set_margin_top(5)
             loved.set_margin_bottom(5)
             loved.set_property('halign', Gtk.Align.END)
             loved.set_property('hexpand', True)
             loved.show()
             # Hack to add two widgets in popover
             # Use a Gtk.PopoverMenu later
             # (GTK>3.16 available on Debian stable)
             stack = Gtk.Stack()
             grid = Gtk.Grid()
             grid.set_orientation(Gtk.Orientation.VERTICAL)
             stack.add_named(grid, 'main')
             stack.show_all()
             menu_widget = popover.get_child()
             menu_widget.reparent(grid)
             separator = Gtk.Separator()
             separator.show()
             grid.add(separator)
             hgrid = Gtk.Grid()
             hgrid.add(rating)
             hgrid.add(loved)
             hgrid.show()
             grid.add(hgrid)
             popover.add(stack)
             popover.show()
         return True
开发者ID:kenden,项目名称:lollypop,代码行数:62,代码来源:toolbar_infos.py

示例13: RadiosView

class RadiosView(View):
    """
        Init radios ui with a scrolled grid of radios widgets
    """
    def __init__(self):
        View.__init__(self)

        self._signal = None

        self._radios_manager = RadiosManager()
        self._radios_manager.connect('playlists-changed',
                                     self._on_radios_changed)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadiosView.ui')
        builder.connect_signals(self)
        widget = builder.get_object('widget')

        self._pop_tunein = TuneinPopover(self._radios_manager)
        self._pop_tunein.set_relative_to(builder.get_object('search_btn'))

        self._sizegroup = Gtk.SizeGroup(mode=Gtk.SizeGroupMode.BOTH)

        self._radiobox = Gtk.FlowBox()
        self._radiobox.set_sort_func(self._sort_radios)
        self._radiobox.set_selection_mode(Gtk.SelectionMode.NONE)
        self._radiobox.connect("child-activated", self._on_album_activated)
        self._radiobox.set_property('column-spacing', 5)
        self._radiobox.set_property('row-spacing', 5)
        self._radiobox.set_homogeneous(True)
        self._radiobox.set_max_children_per_line(1000)
        self._radiobox.show()

        self._viewport.set_property("valign", Gtk.Align.START)
        self._viewport.set_property('margin', 5)
        self._viewport.add(self._radiobox)
        self._scrolledWindow.set_property('expand', True)

        self.add(widget)
        self.add(self._scrolledWindow)

    """
        Populate view with tracks from playlist
        Thread safe
    """
    def populate(self):
        radios_name = []
        # Get radios name
        for (i, name) in self._radios_manager.get():
            radios_name.append(name)
        GLib.idle_add(self._add_radios, radios_name)

    """
        Connect player signal
    """
    def do_show(self):
        View.do_show(self)
        self._signal = Lp.art.connect('logo-changed',
                                      self._on_logo_changed)

    """
        Disconnect player signal
    """
    def do_hide(self):
        View.do_hide(self)
        if self._signal is not None:
            Lp.art.disconnect(self._signal)

#######################
# PRIVATE             #
#######################
    """
        Return view children
        @return [RadioWidget]
    """
    def _get_children(self):
        children = []
        for child in self._radiobox.get_children():
            widget = child.get_child()
            children.append(widget)
        return children

    """
        Sort radios
        @param a as Gtk.FlowBoxChild
        @param b as Gtk.FlowBoxChild
    """
    def _sort_radios(self, a, b):
        child1 = a.get_children()[0]
        child2 = b.get_children()[0]
        return child1.get_name().lower() > child2.get_name().lower()

    """
        Show popover for adding a new radio
        @param widget as Gtk.Widget
    """
    def _on_new_clicked(self, widget):
        popover = RadioPopover('', self._radios_manager)
        popover.set_relative_to(widget)
        popover.show()

#.........这里部分代码省略.........
开发者ID:yoseforb,项目名称:lollypop,代码行数:101,代码来源:view_radios.py

示例14: ToolbarInfos


#.........这里部分代码省略.........
            self._cover_frame.hide()

    def on_status_changed(self, player):
        """
            Update infos on status changed
            @param player as Player
        """
        pass

#######################
# PRIVATE             #
#######################
    def _update_cover(self, art, album_id):
        """
            Update cover for album_id
            @param art as Art
            @param album id as int
        """
        if Lp().player.current_track.album.id == album_id:
            surface = Lp().art.get_album_artwork(
                                       Lp().player.current_track.album,
                                       self._cover_size)
            self._cover.set_from_surface(surface)
            del surface

    def _update_logo(self, art, name):
        """
            Update logo for name
            @param art as Art
            @param name as str
        """
        if Lp().player.current_track.artist == name:
            pixbuf = Lp().art.get_radio_artwork(name, self._cover_size)
            self._cover.set_from_surface(pixbuf)
            del pixbuf

    def _on_infobox_clicked(self, eventbox, event):
        """
            Pop albums from current artistleft click
            Show playlist menu on right
            @param eventbox as Gtk.EventBox
            @param event as Gdk.Event
        """
        if Lp().player.current_track.id == Type.EXTERNALS:
            expopover = ExternalsPopover()
            expopover.set_relative_to(eventbox)
            expopover.populate()
            expopover.show()
        elif Lp().player.current_track.id is not None:
            if event.button == 1:
                if Lp().player.current_track.id == Type.RADIOS:
                    if self._pop_tunein is None:
                        self._pop_tunein = TuneinPopover()
                        self._pop_tunein.populate()
                        self._pop_tunein.set_relative_to(self._infobox)
                    self._pop_tunein.show()
                else:
                    if self._pop_infos is None:
                        self._pop_infos = InfosPopover()
                        self._pop_infos.set_relative_to(self._infobox)
                    self._pop_infos.show()
            elif Lp().player.current_track.id >= 0:
                menu = PopToolbarMenu(Lp().player.current_track.id)
                popover = TrackMenuPopover(
                            Lp().player.current_track.id,
                            PopToolbarMenu(Lp().player.current_track.id))
                popover.set_relative_to(self._infobox)
                popover.show()
            return True

    def _on_query_tooltip(self, widget, x, y, keyboard, tooltip):
        """
            Show tooltip if needed
            @param widget as Gtk.Widget
            @param x as int
            @param y as int
            @param keyboard as bool
            @param tooltip as Gtk.Tooltip
        """
        # Can't add a \n in markup
        # GTK bug => https://bugzilla.gnome.org/show_bug.cgi?id=749965
        layout_title = self._title_label.get_layout()
        layout_artist = self._artist_label.get_layout()
        if layout_title.is_ellipsized() or layout_artist.is_ellipsized():
            artist = escape(self._artist_label.get_text())
            title = escape(self._title_label.get_text())
            tooltip.set_markup("<b>%s</b> - %s" % (artist, title))
        else:
            return False
        return True

    def _on_eventbox_realize(self, eventbox):
        """
            Show hand cursor over
        """
        style = self.get_style_context()
        padding = style.get_padding(style.get_state())
        self._cover_size = self.get_allocated_height()\
            - padding.top - padding.bottom
        eventbox.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.HAND1))
开发者ID:oleastre,项目名称:lollypop,代码行数:101,代码来源:toolbar_infos.py

示例15: ToolbarInfo


#.........这里部分代码省略.........

    def __update_logo(self, art, name):
        """
            Update logo for name
            @param art as Art
            @param name as str
        """
        if Lp().player.current_track.album_artist == name:
            pixbuf = Lp().art.get_radio_artwork(name, self._artsize)
            self._cover.set_from_surface(pixbuf)
            del pixbuf

    def __on_info_long(self, args):
        """
            Show current track menu
            @param args as []
        """
        if Lp().player.current_track.id >= 0:
            from lollypop.pop_menu import PlaylistsMenu
            from lollypop.pop_menu import TrackMenuPopover
            popover = TrackMenuPopover(
                        Lp().player.current_track,
                        PlaylistsMenu(Lp().player.current_track))
            popover.set_relative_to(self._infobox)
            popover.show()

    def __on_info_short(self, args):
        """
            Show track information popover
            @param args as []
        """
        if Lp().player.current_track.id == Type.EXTERNALS:
            from lollypop.pop_externals import ExternalsPopover
            expopover = ExternalsPopover()
            expopover.set_relative_to(self._infobox)
            expopover.populate()
            expopover.show()
        elif Lp().player.current_track.id is not None:
            if Lp().player.current_track.id == Type.RADIOS:
                if self.__pop_tunein is None:
                    from lollypop.pop_tunein import TuneinPopover
                    self.__pop_tunein = TuneinPopover()
                    self.__pop_tunein.populate()
                    self.__pop_tunein.set_relative_to(self._infobox)
                self.__pop_tunein.show()
            else:
                if self.__pop_info is None:
                    from lollypop.pop_info import InfoPopover
                    self.__pop_info = InfoPopover()
                    self.__pop_info.set_relative_to(self._infobox)
                self.__pop_info.show()

    def __on_loading_changed(self, player, show):
        """
            Show spinner based on loading status
            @param player as player
            @param show as bool
        """
        if show:
            self._title_label.hide()
            self._artist_label.hide()
            self._cover.hide()
            self._spinner.show()
            self._spinner.start()
            self._infobox.show()
        else:
            self._spinner.hide()
            self._spinner.stop()

    def __on_realize(self, toolbar):
        """
            Calculate art size
            @param toolbar as ToolbarInfos
        """
        style = self.get_style_context()
        padding = style.get_padding(style.get_state())
        self._artsize = self.get_allocated_height()\
            - padding.top - padding.bottom
        # Since GTK 3.20, we can set cover full height
        if Gtk.get_minor_version() < 20:
            self._artsize -= 2

    def __on_query_tooltip(self, widget, x, y, keyboard, tooltip):
        """
            Show tooltip if needed
            @param widget as Gtk.Widget
            @param x as int
            @param y as int
            @param keyboard as bool
            @param tooltip as Gtk.Tooltip
        """
        layout_title = self._title_label.get_layout()
        layout_artist = self._artist_label.get_layout()
        if layout_title.is_ellipsized() or layout_artist.is_ellipsized():
            artist = GLib.markup_escape_text(self._artist_label.get_text())
            title = GLib.markup_escape_text(self._title_label.get_text())
            tooltip.set_markup("<b>%s</b> - %s" % (artist, title))
        else:
            return False
        return True
开发者ID:blackjackshellac,项目名称:lollypop,代码行数:101,代码来源:toolbar_info.py


注:本文中的lollypop.pop_tunein.TuneinPopover类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。