コード例 #1
0
ファイル: toolbar_info.py プロジェクト: aembleton/cinamp
    def __init__(self):
        """
            Init toolbar
        """
        Gtk.Bin.__init__(self)
        self.__width = 0
        horizontal_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 15)
        horizontal_box.show()
        self.__eventbox = Gtk.EventBox.new()
        self.__eventbox.add(horizontal_box)
        self.__eventbox.set_property("halign", Gtk.Align.START)
        self.__eventbox.show()
        self.__eventbox.connect("realize", set_cursor_type)
        self.add(self.__eventbox)
        GesturesHelper.__init__(self, self.__eventbox)
        self.special_headerbar_hack()

        self.__label = LabelPlayerWidget()
        self.__artwork = ArtworkPlayerWidget(ArtBehaviour.CROP_SQUARE
                                             | ArtBehaviour.CACHE)
        self.__artwork.set_property("has-tooltip", True)
        horizontal_box.pack_start(self.__artwork, False, False, 0)
        horizontal_box.pack_start(self.__label, False, False, 0)
        self.set_margin_start(MARGIN_SMALL)
        self.connect("realize", self.__on_realize)
コード例 #2
0
 def __init__(self, genre_ids, artist_ids, view_type):
     """
         Init widget
         @param genre_ids as int
         @param artist_ids as int
         @param view_type as ViewType
     """
     LazyLoadingView.__init__(self, StorageType.ALL, view_type)
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     self.__reveals = []
     # Calculate default album height based on current pango context
     # We may need to listen to screen changes
     self.__height = AlbumRow.get_best_height(self)
     self._box = ListBox()
     self._box.set_margin_bottom(MARGIN)
     self._box.set_margin_end(MARGIN)
     self._box.get_style_context().add_class("trackswidget")
     self._box.set_vexpand(True)
     self._box.set_selection_mode(Gtk.SelectionMode.NONE)
     self._box.show()
     GesturesHelper.__init__(self, self._box)
     if view_type & ViewType.DND:
         from lollypop.helper_dnd import DNDHelper
         self.__dnd_helper = DNDHelper(self._box, view_type)
         self.__dnd_helper.connect("dnd-insert", self.__on_dnd_insert)
     return [(App().player, "current-changed", "_on_current_changed"),
             (App().player, "duration-changed", "_on_duration_changed"),
             (App().art, "album-artwork-changed", "_on_artwork_changed")]
コード例 #3
0
ファイル: selectionlist.py プロジェクト: aembleton/cinamp
 def __init__(self, base_mask):
     """
         Init Selection list ui
         @param base_mask as SelectionListMask
     """
     LazyLoadingView.__init__(self, StorageType.ALL, ViewType.DEFAULT)
     self.__selection_pending_ids = []
     self.__base_mask = base_mask
     self.__mask = SelectionListMask.NONE
     self.__animation_timeout_id = None
     self.__height = SelectionListRow.get_best_height(self)
     self._box = Gtk.ListBox()
     self._box.set_selection_mode(Gtk.SelectionMode.MULTIPLE)
     self._box.show()
     GesturesHelper.__init__(self, self._box)
     self.__scrolled = Gtk.ScrolledWindow()
     self.__scrolled.show()
     self.__scrolled.set_policy(Gtk.PolicyType.NEVER,
                                Gtk.PolicyType.AUTOMATIC)
     self.__viewport = Gtk.Viewport()
     self.__scrolled.add(self.__viewport)
     self.__viewport.show()
     self.__viewport.add(self._box)
     self.connect("initialized", self.__on_initialized)
     self.get_style_context().add_class("sidebar")
     self.__scrolled.set_vexpand(True)
     if base_mask & SelectionListMask.FASTSCROLL:
         self.__overlay = Gtk.Overlay.new()
         self.__overlay.show()
         self.__overlay.add(self.__scrolled)
         self.__fastscroll = FastScroll(self._box,
                                        self.__scrolled)
         self.__overlay.add_overlay(self.__fastscroll)
         self.add(self.__overlay)
         App().settings.connect("changed::artist-artwork",
                                self.__on_artist_artwork_changed)
         App().art.connect("artist-artwork-changed",
                           self.__on_artist_artwork_changed)
     else:
         self.__overlay = None
         App().settings.connect("changed::show-sidebar-labels",
                                self.__on_show_sidebar_labels_changed)
         self.add(self.__scrolled)
         self.__menu_button = Gtk.Button.new_from_icon_name(
             "view-more-horizontal-symbolic", Gtk.IconSize.BUTTON)
         self.__menu_button.set_property("halign", Gtk.Align.CENTER)
         self.__menu_button.get_style_context().add_class("no-border")
         self.__menu_button.connect("clicked",
                                    lambda x: self.__popup_menu(None, x))
         self.__menu_button.show()
         self.add(self.__menu_button)
     if base_mask & SelectionListMask.SIDEBAR:
         App().window.container.widget.connect("notify::folded",
                                               self.__on_container_folded)
         self.__on_container_folded(None, App().window.folded)
     else:
         self.__base_mask |= SelectionListMask.LABEL
         self.__base_mask |= SelectionListMask.ELLIPSIZE
         self.__set_rows_mask(self.__base_mask | self.__mask)
コード例 #4
0
ファイル: widgets_cover.py プロジェクト: aembleton/cinamp
 def __init__(self, album, view_type):
     """
         Init widget
         @param album as Album
         @param view_type as ViewType
     """
     Gtk.EventBox.__init__(self)
     CoverWidgetBase.__init__(self, album, view_type)
     GesturesHelper.__init__(self, self)
     self.connect("realize", set_cursor_type)
     self.add(self._artwork)
コード例 #5
0
ファイル: widgets_tracks.py プロジェクト: aembleton/cinamp
 def __init__(self, view_type):
     """
         Init track widget
         @param view_type as ViewType
     """
     Gtk.ListBox.__init__(self)
     GesturesHelper.__init__(self, self)
     self.__view_type = view_type
     self.get_style_context().add_class("trackswidget")
     self.set_property("hexpand", True)
     self.set_selection_mode(Gtk.SelectionMode.NONE)
     return [(App().player, "queue-changed", "_on_queue_changed")]
コード例 #6
0
    def right_list(self):
        """
            Get right selection list
            @return SelectionList
        """
        def on_unmap(widget):
            """
                Hide right list on left list hidden
            """
            if not App().window.folded:
                self._hide_right_list()

        if self.__right_list is None:
            eventbox = Gtk.EventBox.new()
            eventbox.set_size_request(50, -1)
            eventbox.show()
            self.__right_list_grid = Gtk.Grid()
            style_context = self.__right_list_grid.get_style_context()
            style_context.add_class("left-gradient")
            style_context.add_class("opacity-transition-fast")
            self.__right_list = SelectionList(SelectionListMask.FASTSCROLL)
            self.__right_list.show()
            self.__right_list.scrolled.set_size_request(250, -1)
            self.__gesture = GesturesHelper(
                eventbox, primary_press_callback=self._hide_right_list)
            self.__right_list.listbox.connect("row-activated",
                                              self.__on_right_list_activated)
            self.__right_list_grid.add(eventbox)
            self.__right_list_grid.add(self.__right_list)
            self.__left_list.overlay.add_overlay(self.__right_list_grid)
            self.__left_list.connect("unmap", on_unmap)
            self.__left_list.connect("populated", self.__on_list_populated)
            self.__right_list.connect("populated", self.__on_list_populated)
        return self.__right_list
コード例 #7
0
 def __init__(self, album, view_type):
     """
         Init cover widget
         @param view_type as ViewType
     """
     Gtk.EventBox.__init__(self)
     GesturesHelper.__init__(self, self)
     self.set_property("halign", Gtk.Align.CENTER)
     self.set_property("valign", Gtk.Align.CENTER)
     self.__album = album
     self.__view_type = view_type
     self.__image_button = None
     self.__art_size = 1
     self.__artwork = Gtk.Image.new()
     self.__artwork.show()
     self.add(self.__artwork)
     self.connect("realize", set_cursor_type)
     return [(App().art, "album-artwork-changed",
              "_on_album_artwork_changed")]
コード例 #8
0
ファイル: widgets_album.py プロジェクト: aembleton/cinamp
 def populate(self):
     """
         Populate widget
     """
     self.__revealer = Gtk.Revealer.new()
     self.__revealer.show()
     self.__banner = AlbumBannerWidget(self.__album, self.__storage_type,
                                       self.__view_type)
     self.__banner.show()
     self.__banner.connect("populated", self.__on_banner_populated)
     self.__banner.populate()
     self.add(self.__banner)
     self.add(self.__revealer)
     self.__gesture = GesturesHelper(self.__banner,
                                     primary_press_callback=self._on_press)
     self.get_style_context().add_class("album-banner")
     if App().settings.get_value("show-artist-tracks"):
         self.__revealer.set_transition_type(
             Gtk.RevealerTransitionType.NONE)
         self.__populate()
コード例 #9
0
ファイル: view_information.py プロジェクト: aembleton/cinamp
 def populate(self, artist_id=None):
     """
         Show information for artists
         @param artist_id as int
     """
     builder = Gtk.Builder()
     builder.add_from_resource(
         "/org/gnome/Lollypop/ArtistInformation.ui")
     builder.connect_signals(self)
     self.__scrolled = builder.get_object("scrolled")
     widget = builder.get_object("widget")
     self.add(widget)
     self.__stack = builder.get_object("stack")
     self.__listbox = builder.get_object("listbox")
     self.__artist_label = builder.get_object("artist_label")
     title_label = builder.get_object("title_label")
     self.__artist_artwork = builder.get_object("artist_artwork")
     bio_eventbox = builder.get_object("bio_eventbox")
     artist_label_eventbox = builder.get_object("artist_label_eventbox")
     bio_eventbox.connect("realize", set_cursor_type)
     artist_label_eventbox.connect("realize", set_cursor_type)
     self.__gesture1 = GesturesHelper(
         bio_eventbox,
         primary_press_callback=self._on_info_label_press)
     self.__gesture2 = GesturesHelper(
         artist_label_eventbox,
         primary_press_callback=self._on_artist_label_press)
     self.__bio_label = builder.get_object("bio_label")
     if artist_id is None and App().player.current_track.id is not None:
         builder.get_object("header").show()
         if App().player.current_track.album.artist_ids[0] ==\
                 Type.COMPILATIONS:
             artist_id = App().player.current_track.artist_ids[0]
         else:
             artist_id = App().player.current_track.album.artist_ids[0]
         title_label.set_text(App().player.current_track.title)
     self.__artist_name = App().artists.get_name(artist_id)
     if self.__minimal:
         self.__bio_label.set_margin_start(MARGIN)
         self.__bio_label.set_margin_end(MARGIN)
         self.__bio_label.set_margin_top(MARGIN)
         self.__bio_label.set_margin_bottom(MARGIN)
         self.__artist_artwork.hide()
     else:
         self.__artist_artwork.set_margin_start(MARGIN_SMALL)
         builder.get_object("header").show()
         self.__artist_label.set_text(self.__artist_name)
         self.__artist_label.show()
         title_label.show()
         App().art_helper.set_artist_artwork(
                                 self.__artist_name,
                                 ArtSize.SMALL * 3,
                                 ArtSize.SMALL * 3,
                                 self.__artist_artwork.get_scale_factor(),
                                 ArtBehaviour.ROUNDED |
                                 ArtBehaviour.CROP_SQUARE |
                                 ArtBehaviour.CACHE,
                                 self.__on_artist_artwork)
         albums_view = AlbumsListView([], [],
                                      ViewType.SCROLLED)
         albums_view.set_size_request(300, -1)
         albums_view.show()
         albums_view.set_margin_start(5)
         albums_view.add_widget(albums_view.box)
         widget.attach(albums_view, 2, 1, 1, 2)
         albums = []
         storage_type = get_default_storage_type()
         for album_id in App().albums.get_ids([], [artist_id],
                                              storage_type, True):
             albums.append(Album(album_id))
         if not albums:
             albums = [App().player.current_track.album]
         albums_view.populate(albums)
     content = self.__information_store.get_information(self.__artist_name,
                                                        ARTISTS_PATH)
     if content is None:
         self.__bio_label.set_text(_("Loading information"))
         from lollypop.information_downloader import InformationDownloader
         downloader = InformationDownloader()
         downloader.get_information(self.__artist_name,
                                    self.__on_artist_information,
                                    self.__artist_name)
     else:
         App().task_helper.run(self.__to_markup, content,
                               callback=(self.__bio_label.set_markup,))
コード例 #10
0
 def __init__(self, album, storage_type, view_type):
     """
         Init cover widget
         @param album
         @param storage_type as int
         @param view_type as ViewType
     """
     BannerWidget.__init__(self, view_type)
     self.__album = album
     self.__storage_type = storage_type
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Lollypop/AlbumBannerWidget.ui")
     builder.connect_signals(self)
     self.__labels = builder.get_object("labels")
     self.__title_label = builder.get_object("title_label")
     self.__title_label.connect("query-tooltip", on_query_tooltip)
     self.__artist_label = builder.get_object("artist_label")
     self.__artist_label.connect("query-tooltip", on_query_tooltip)
     self.__year_label = builder.get_object("year_label")
     self.__duration_label = builder.get_object("duration_label")
     self.__play_button = builder.get_object("play_button")
     self.__add_button = builder.get_object("add_button")
     self.__menu_button = builder.get_object("menu_button")
     self.__widget = builder.get_object("widget")
     if view_type & ViewType.OVERLAY:
         style = "banner-button"
     else:
         style = "menu-button"
     self.__play_button.get_style_context().add_class(style)
     self.__add_button.get_style_context().add_class(style)
     self.__menu_button.get_style_context().add_class(style)
     self.__cover_widget = CoverWidget(album, view_type)
     self.__cover_widget.show()
     self.__title_label.set_label(album.name)
     if view_type & ViewType.ALBUM:
         self.__artist_label.show()
         self.__artist_label.set_label(", ".join(album.artists))
     else:
         self.__title_label.set_opacity(0.8)
         self.__year_label.set_opacity(0.7)
         self.__duration_label.set_opacity(0.6)
         self.__widget.get_style_context().add_class("album-banner")
     if album.year is not None:
         self.__year_label.set_label(str(album.year))
         self.__year_label.show()
     human_duration = get_human_duration(album.duration)
     self.__duration_label.set_text(human_duration)
     artist_eventbox = builder.get_object("artist_eventbox")
     artist_eventbox.connect("realize", set_cursor_type)
     self.__gesture1 = GesturesHelper(
         artist_eventbox, primary_press_callback=self._on_artist_press)
     year_eventbox = builder.get_object("year_eventbox")
     year_eventbox.connect("realize", set_cursor_type)
     self.__gesture2 = GesturesHelper(
         year_eventbox, primary_press_callback=self._on_year_press)
     self.__widget.attach(self.__cover_widget, 0, 0, 1, 3)
     self.__bottom_box = builder.get_object("bottom_box")
     self.__loved_widget = LovedWidget(album, Gtk.IconSize.INVALID)
     self.__loved_widget.show()
     self.__bottom_box.pack_start(self.__loved_widget, 0, False, False)
     self.__rating_widget = RatingWidget(album, Gtk.IconSize.INVALID)
     self.__rating_widget.show()
     self.__bottom_box.pack_start(self.__rating_widget, 0, True, True)
     if view_type & ViewType.OVERLAY:
         self._overlay.add_overlay(self.__widget)
         self._overlay.set_overlay_pass_through(self.__widget, True)
     else:
         self.add(self.__widget)
     self.__update_add_button()
     self.__set_internal_size()
     return [(App().window.container.widget, "notify::folded",
              "_on_container_folded"),
             (App().art, "album-artwork-changed",
              "_on_album_artwork_changed"),
             (App().player, "playback-added", "_on_playback_changed"),
             (App().player, "playback-updated", "_on_playback_changed"),
             (App().player, "playback-removed", "_on_playback_changed")]
コード例 #11
0
 def populate(self):
     """
         Populate the view
     """
     if self.__widget is not None:
         return
     self.__widget = Gtk.Grid.new()
     self.__widget.set_margin_start(MARGIN)
     self.__widget.set_margin_end(MARGIN_MEDIUM)
     self.__widget.set_margin_top(MARGIN_SMALL)
     self.__widget.set_margin_bottom(MARGIN_SMALL)
     self.__widget.set_row_spacing(MARGIN_SMALL)
     self.__widget.set_column_spacing(MARGIN_MEDIUM)
     self.__top_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
     self.__middle_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
     self.__bottom_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0)
     self.__labels_box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
     self.__top_box.set_vexpand(True)
     self.__middle_box.set_halign(Gtk.Align.END)
     self.__middle_box.set_valign(Gtk.Align.CENTER)
     self.__middle_box.set_hexpand(True)
     self.__bottom_box.set_vexpand(True)
     self.__year_eventbox = Gtk.EventBox.new()
     self.__year_eventbox.set_hexpand(True)
     self.__year_eventbox.set_halign(Gtk.Align.END)
     self.__year_label = Gtk.Label.new()
     self.__year_label.get_style_context().add_class("dim-label")
     self.__year_eventbox.add(self.__year_label)
     self.__year_eventbox.connect("realize", set_cursor_type)
     self.__gesture_year = GesturesHelper(
         self.__year_eventbox, primary_press_callback=self._on_year_press)
     self.__play_button = Gtk.Button.new_from_icon_name(
         "media-playback-start-symbolic", Gtk.IconSize.BUTTON)
     self.__add_button = Gtk.Button.new_from_icon_name(
         "list-add-symbolic", Gtk.IconSize.BUTTON)
     self.__menu_button = Gtk.Button.new_from_icon_name(
         "view-more-symbolic", Gtk.IconSize.BUTTON)
     self.__play_button.connect("clicked", self.__on_play_button_clicked)
     self.__add_button.connect("clicked", self.__on_add_button_clicked)
     self.__menu_button.connect("clicked", self.__on_menu_button_clicked)
     self.__title_label = Gtk.Label.new()
     self.__title_label.set_valign(Gtk.Align.END)
     self.__title_label.set_vexpand(True)
     self.__title_label.connect("query-tooltip", on_query_tooltip)
     self.__title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self.__title_label.set_halign(Gtk.Align.START)
     self.__title_label.set_xalign(0)
     self.__artist_label = Gtk.Label.new()
     self.__artist_eventbox = Gtk.EventBox.new()
     self.__artist_eventbox.set_valign(Gtk.Align.START)
     self.__artist_eventbox.add(self.__artist_label)
     self.__artist_eventbox.connect("realize", set_cursor_type)
     self.__artist_label.connect("query-tooltip", on_query_tooltip)
     self.__artist_label.set_ellipsize(Pango.EllipsizeMode.END)
     self.__artist_label.set_halign(Gtk.Align.START)
     self.__artist_label.set_xalign(0)
     self.__gesture_artist = GesturesHelper(
         self.__artist_eventbox,
         primary_press_callback=self._on_artist_press)
     self.__duration_label = Gtk.Label.new()
     self.__duration_label.get_style_context().add_class("dim-label")
     self.__top_box.pack_end(self.__year_eventbox, False, True, 0)
     self.__middle_box.add(self.__play_button)
     self.__middle_box.add(self.__add_button)
     self.__middle_box.add(self.__menu_button)
     self.__middle_box.get_style_context().add_class("linked")
     self.__bottom_box.pack_end(self.__duration_label, False, True, 0)
     self.__labels_box.add(self.__title_label)
     self.__labels_box.add(self.__artist_eventbox)
     self.__widget.attach(self.__top_box, 2, 0, 1, 1)
     self.__widget.attach(self.__middle_box, 2, 1, 1, 1)
     self.__widget.attach(self.__bottom_box, 1, 2, 2, 1)
     self.__widget.attach(self.__labels_box, 1, 0, 1, 2)
     self.__widget.show_all()
     if self.view_type & ViewType.OVERLAY:
         style = "banner-button"
     else:
         style = "menu-button"
     self.__play_button.get_style_context().add_class(style)
     self.__add_button.get_style_context().add_class(style)
     self.__menu_button.get_style_context().add_class(style)
     self.__title_label.set_label(self.__album.name)
     if self.view_type & ViewType.ALBUM:
         self.__cover_widget = EditCoverWidget(self.__album, self.view_type)
         self.__artist_label.get_style_context().add_class("dim-label")
         self.__artist_label.set_label(", ".join(self.__album.artists))
     else:
         self.__artist_label.hide()
         self.__cover_widget = CoverWidget(self.__album, self.view_type)
         self.__cover_widget.set_margin_top(MARGIN_MEDIUM)
         self.__cover_widget.set_margin_bottom(MARGIN_MEDIUM)
         self.__cover_widget.connect("populated",
                                     self.__on_cover_populated)
     self.__cover_widget.show()
     if self.__album.year is not None:
         self.__year_label.set_label(str(self.__album.year))
         self.__year_label.show()
     human_duration = get_human_duration(self.__album.duration)
     self.__duration_label.set_text(human_duration)
     self.__widget.attach(self.__cover_widget, 0, 0, 1, 3)
     self.__loved_widget = LovedWidget(self.__album, Gtk.IconSize.INVALID)
     self.__loved_widget.show()
     self.__bottom_box.pack_start(self.__loved_widget, 0, False, False)
     self.__rating_widget = RatingWidget(self.__album, Gtk.IconSize.INVALID)
     self.__rating_widget.show()
     self.__bottom_box.pack_start(self.__rating_widget, 0, True, True)
     if self.view_type & ViewType.OVERLAY:
         self._overlay.add_overlay(self.__widget)
         self._overlay.set_overlay_pass_through(self.__widget, True)
     else:
         self.add(self.__widget)
     self.__update_add_button()
     self.__set_internal_size()