def _on_album_updated(self, scanner, album_id, destroy):
     """
         On album modified, disable it
         @param scanner as CollectionScanner
         @param album id as int
         @param destroy as bool
     """
     if self._album.id != album_id:
         return
     removed = False
     for dic in [self._tracks_left, self._tracks_right]:
         for widget in dic.values():
             for child in widget.get_children():
                 track = Track(child.id)
                 if track.album.id == Type.NONE:
                     removed = True
     if removed:
         for dic in [self._tracks_left, self._tracks_right]:
             for widget in dic.values():
                 for child in widget.get_children():
                     child.destroy()
         self.__discs = self._album.discs
         self.__set_duration()
         self.populate()
     AlbumWidget._on_album_updated(self, scanner, album_id, destroy)
Esempio n. 2
0
 def populate(self):
     """
         Init widget content
     """
     self.get_style_context().remove_class('loading')
     AlbumWidget.__init__(self, None)
     self._widget = Gtk.EventBox()
     self._widget.connect('enter-notify-event', self._on_enter_notify)
     self._widget.connect('leave-notify-event', self._on_leave_notify)
     self._cover = Gtk.Image()
     self._cover.set_property('halign', Gtk.Align.CENTER)
     self._cover.set_size_request(ArtSize.BIG, ArtSize.BIG)
     self._title_label = Gtk.Label()
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._title_label.set_property('halign', Gtk.Align.CENTER)
     self._title_label.set_text(self._name)
     self._title_label.set_property('has-tooltip', True)
     self._title_label.connect('query-tooltip', self._on_query_tooltip)
     self._overlay = Gtk.Overlay()
     frame = Gtk.Frame()
     frame.get_style_context().add_class('cover-frame')
     frame.add(self._cover)
     self._overlay.add(frame)
     grid = Gtk.Grid()
     grid.set_orientation(Gtk.Orientation.VERTICAL)
     self._overlay.get_style_context().add_class('white')
     grid.add(self._overlay)
     grid.add(self._title_label)
     self._widget.add(grid)
     self.set_property('halign', Gtk.Align.CENTER)
     self.set_property('valign', Gtk.Align.CENTER)
     self.add(self._widget)
     self.set_cover()
     self.update_state()
     self.show_all()
Esempio n. 3
0
 def populate(self):
     """
         Init widget content
     """
     self.get_style_context().remove_class('loading')
     AlbumWidget.__init__(self, None)
     self._widget = Gtk.EventBox()
     self._widget.connect('enter-notify-event', self._on_enter_notify)
     self._widget.connect('leave-notify-event', self._on_leave_notify)
     self._cover = Gtk.Image()
     self._cover.set_property('halign', Gtk.Align.CENTER)
     self._cover.set_size_request(ArtSize.BIG, ArtSize.BIG)
     self.__title_label = Gtk.Label()
     self.__title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self.__title_label.set_property('halign', Gtk.Align.CENTER)
     self.__title_label.set_text(self._name)
     self.__title_label.set_property('has-tooltip', True)
     self.__title_label.connect('query-tooltip', self._on_query_tooltip)
     self._overlay = Gtk.Overlay()
     frame = Gtk.Frame()
     frame.get_style_context().add_class('cover-frame')
     frame.add(self._cover)
     self._overlay.add(frame)
     grid = Gtk.Grid()
     grid.set_orientation(Gtk.Orientation.VERTICAL)
     self._overlay.get_style_context().add_class('white')
     grid.add(self._overlay)
     grid.add(self.__title_label)
     self._widget.add(grid)
     self.set_property('halign', Gtk.Align.CENTER)
     self.set_property('valign', Gtk.Align.CENTER)
     self.add(self._widget)
     self.set_cover()
     self.update_state()
     self.show_all()
Esempio n. 4
0
 def _on_album_updated(self, scanner, album_id, destroy):
     """
         On album modified, disable it
         @param scanner as CollectionScanner
         @param album id as int
         @param destroy as bool
     """
     if self._album.id != album_id:
         return
     removed = False
     for dic in [self._tracks_left, self._tracks_right]:
         for widget in dic.values():
             for child in widget.get_children():
                 track = Track(child.id)
                 if track.album.id == Type.NONE:
                     removed = True
     if removed:
         for dic in [self._tracks_left, self._tracks_right]:
             for widget in dic.values():
                 for child in widget.get_children():
                     child.destroy()
         self.__discs = self._album.discs
         self.__set_duration()
         self.populate()
     AlbumWidget._on_album_updated(self, scanner, album_id, destroy)
Esempio n. 5
0
 def _on_album_updated(self, scanner, album_id, destroy):
     """
         On album modified, disable it
         @param scanner as CollectionScanner
         @param album id as int
         @param destroy as bool
     """
     TracksView._on_album_updated(self, scanner, album_id, destroy)
     AlbumWidget._on_album_updated(self, scanner, album_id, destroy)
Esempio n. 6
0
 def _show_overlay_func(self, set):
     """
         Set overlay
         @param set as bool
     """
     if self._lock_overlay or\
        self._show_overlay == set or\
        (set is True and Lp().player.locked):
         return
     if set:
         # Play button
         self._play_event = Gtk.EventBox()
         self._play_event.set_property('has-tooltip', True)
         self._play_event.set_tooltip_text(_("Play"))
         self._play_event.set_hexpand(True)
         self._play_event.set_property('valign', Gtk.Align.CENTER)
         self._play_event.set_property('halign', Gtk.Align.CENTER)
         self._play_event.connect('realize', self._on_eventbox_realize)
         self._play_event.connect('button-press-event',
                                  self._on_play_press_event)
         self._play_button = Gtk.Image.new_from_icon_name(
                                            'media-playback-start-symbolic',
                                            Gtk.IconSize.DND)
         self._play_button.set_opacity(0)
         # Edit button
         self._artwork_event = Gtk.EventBox()
         self._artwork_event.set_margin_bottom(5)
         self._artwork_event.set_margin_end(5)
         self._artwork_event.set_property('has-tooltip', True)
         self._artwork_event.set_tooltip_text(_("Modify radio"))
         self._artwork_event.set_property('halign', Gtk.Align.END)
         self._artwork_event.connect('realize', self._on_eventbox_realize)
         self._artwork_event.connect('button-press-event',
                                     self._on_edit_press_event)
         self._artwork_event.set_property('valign', Gtk.Align.END)
         self._artwork_event.set_property('halign', Gtk.Align.END)
         self._artwork_button = Gtk.Image.new_from_icon_name(
                                            'document-properties-symbolic',
                                            Gtk.IconSize.BUTTON)
         self._artwork_button.set_opacity(0)
         self._play_event.add(self._play_button)
         self._artwork_event.add(self._artwork_button)
         self._overlay.add_overlay(self._play_event)
         self._overlay.add_overlay(self._artwork_event)
         self._overlay.show_all()
         AlbumWidget._show_overlay_func(self, True)
     else:
         AlbumWidget._show_overlay_func(self, False)
         self._play_event.destroy()
         self._play_event = None
         self._play_button.destroy()
         self._play_button = None
         self._artwork_event.destroy()
         self._artwork_event = None
         self._artwork_button.destroy()
         self._artwork_button = None
Esempio n. 7
0
 def _show_overlay_func(self, set):
     """
         Set overlay
         @param set as bool
     """
     if self._lock_overlay or\
        self._show_overlay == set or\
        (set is True and Lp().player.locked):
         return
     if set:
         # Play button
         self._play_event = Gtk.EventBox()
         self._play_event.set_property('has-tooltip', True)
         self._play_event.set_tooltip_text(_("Play"))
         self._play_event.set_hexpand(True)
         self._play_event.set_property('valign', Gtk.Align.CENTER)
         self._play_event.set_property('halign', Gtk.Align.CENTER)
         self._play_event.connect('realize', self._on_eventbox_realize)
         self._play_event.connect('button-press-event',
                                  self._on_play_press_event)
         self._play_button = Gtk.Image.new_from_icon_name(
             'media-playback-start-symbolic', Gtk.IconSize.DND)
         self._play_button.set_opacity(0)
         # Edit button
         self._artwork_event = Gtk.EventBox()
         self._artwork_event.set_margin_bottom(5)
         self._artwork_event.set_margin_end(5)
         self._artwork_event.set_property('has-tooltip', True)
         self._artwork_event.set_tooltip_text(_("Modify radio"))
         self._artwork_event.set_property('halign', Gtk.Align.END)
         self._artwork_event.connect('realize', self._on_eventbox_realize)
         self._artwork_event.connect('button-press-event',
                                     self._on_edit_press_event)
         self._artwork_event.set_property('valign', Gtk.Align.END)
         self._artwork_event.set_property('halign', Gtk.Align.END)
         self._artwork_button = Gtk.Image.new_from_icon_name(
             'document-properties-symbolic', Gtk.IconSize.BUTTON)
         self._artwork_button.set_opacity(0)
         self._play_event.add(self._play_button)
         self._artwork_event.add(self._artwork_button)
         self._overlay.add_overlay(self._play_event)
         self._overlay.add_overlay(self._artwork_event)
         self._overlay.show_all()
         AlbumWidget._show_overlay_func(self, True)
     else:
         AlbumWidget._show_overlay_func(self, False)
         self._play_event.destroy()
         self._play_event = None
         self._play_button.destroy()
         self._play_button = None
         self._artwork_event.destroy()
         self._artwork_event = None
         self._artwork_button.destroy()
         self._artwork_button = None
Esempio n. 8
0
 def __init__(self, album_id, genre_ids, artist_ids):
     """
         Init simple album widget
         @param album id as int
         @param genre ids as [int]
         @param artist_ids as [int]
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.FlowBoxChild.__init__(self)
     self.set_size_request(ArtSize.BIG, ArtSize.BIG)
     self.get_style_context().add_class('loading')
     AlbumWidget.__init__(self, album_id, genre_ids, artist_ids)
 def __init__(self, album, genre_ids, artist_ids):
     """
         Init simple album widget
         @param album as Album
         @param genre ids as [int]
         @param artist_ids as [int]
     """
     self.__widget = None
     # We do not use Gtk.Builder for speed reasons
     Gtk.FlowBoxChild.__init__(self)
     self.set_size_request(ArtSize.BIG, ArtSize.BIG + self.LABEL_HEIGHT)
     AlbumWidget.__init__(self, album, genre_ids, artist_ids)
 def __init__(self, album_id, genre_ids, artist_ids):
     """
         Init simple album widget
         @param album id as int
         @param genre ids as [int]
         @param artist_ids as [int]
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.FlowBoxChild.__init__(self)
     self.set_size_request(ArtSize.BIG, ArtSize.BIG)
     self.get_style_context().add_class('loading')
     AlbumWidget.__init__(self, album_id, genre_ids,
                          artist_ids, ArtSize.BIG)
Esempio n. 11
0
 def __init__(self, album, genre_ids, artist_ids, view_type, font_height):
     """
         Init simple album widget
         @param album as Album
         @param genre_ids as [int]
         @param artist_ids as [int]
         @param view_type as ViewType
         @parma font_height as int
     """
     self.__widget = None
     self.__font_height = font_height
     # We do not use Gtk.Builder for speed reasons
     Gtk.FlowBoxChild.__init__(self)
     self.set_view_type(view_type)
     AlbumWidget.__init__(self, album, genre_ids, artist_ids)
Esempio n. 12
0
 def __init__(self, album, genre_ids, artist_ids, show_cover):
     """
         Init detailed album widget
         @param album as Album
         @param label_height as int
         @param genre ids as [int]
         @param artist ids as [int]
         @param show_cover as bool
     """
     Gtk.Bin.__init__(self)
     AlbumWidget.__init__(self, album, genre_ids, artist_ids)
     TracksView.__init__(self, RowListType.TWO_COLUMNS)
     self._widget = None
     self.__show_cover = show_cover
     self.__width_allocation = 0
     self.connect("size-allocate", self.__on_size_allocate)
 def __init__(self, album, genre_ids, artist_ids, view_type):
     """
         Init detailed album widget
         @param album as Album
         @param label_height as int
         @param genre_ids as [int]
         @param artist_ids as [int]
         @param view_type as ViewType
     """
     Gtk.Grid.__init__(self)
     AlbumWidget.__init__(self, album, genre_ids, artist_ids)
     TracksView.__init__(self, view_type)
     self.set_row_spacing(2)
     self.set_orientation(Gtk.Orientation.VERTICAL)
     self.__width_allocation = 0
     self.__banner = None
     self.connect("size-allocate", self.__on_size_allocate)
Esempio n. 14
0
    def __init__(self, name, radios_manager):
        AlbumWidget.__init__(self, None)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/RadioWidget.ui')
        builder.connect_signals(self)
        self._cover = builder.get_object('cover')

        self._name = name
        self._radios_manager = radios_manager
        self._popover = None

        self._title = builder.get_object('title')
        self._title.set_label(name)

        self.add(builder.get_object('widget'))
        self.set_cover()
        self.set_property('halign', Gtk.Align.START)
        # Set minimum width
        self.set_property('width-request', ArtSize.BIG+ArtSize.BORDER*2)
Esempio n. 15
0
 def __init__(self, name, radios_manager):
     """
         Init radio widget
         @param name as string
         @param radios_manager as RadiosManager
     """
     Gtk.Bin.__init__(self)
     AlbumWidget.__init__(self, None)
     builder = Gtk.Builder()
     builder.add_from_resource('/org/gnome/Lollypop/RadioWidget.ui')
     builder.connect_signals(self)
     self._cover = builder.get_object('cover')
     self._color = builder.get_object('color')
     self._name = name
     self._radios_manager = radios_manager
     self._popover = None
     self._title = builder.get_object('title')
     self._title.set_label(name)
     self.update_state()
     self.add(builder.get_object('widget'))
     self.set_cover()
     self.set_property('halign', Gtk.Align.START)
Esempio n. 16
0
 def __init__(self, name, radios_manager):
     """
         Init radio widget
         @param name as string
         @param radios_manager as RadiosManager
     """
     Gtk.Bin.__init__(self)
     AlbumWidget.__init__(self, None)
     builder = Gtk.Builder()
     builder.add_from_resource('/org/gnome/Lollypop/RadioWidget.ui')
     builder.connect_signals(self)
     self._cover = builder.get_object('cover')
     self._color = builder.get_object('color')
     self._name = name
     self._radios_manager = radios_manager
     self._popover = None
     self._title = builder.get_object('title')
     self._title.set_label(name)
     self.update_state()
     self.add(builder.get_object('widget'))
     self.set_cover()
     self.set_property('halign', Gtk.Align.START)
Esempio n. 17
0
    def __init__(self, name, radios_manager):
        """
            Init radio widget
            @param name as string
            @param radios_manager as RadiosManager
        """
        AlbumWidget.__init__(self, None)
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/RadioWidget.ui")
        builder.connect_signals(self)
        self._cover = builder.get_object("cover")

        self._name = name
        self._radios_manager = radios_manager
        self._popover = None

        self._title = builder.get_object("title")
        self._title.set_label(name)

        self.add(builder.get_object("widget"))
        self.set_cover()
        self.set_property("halign", Gtk.Align.START)
Esempio n. 18
0
 def _get_child(self, album_id):
     """
         Get an album view widget
         @param album_id as int
         @return AlbumView
     """
     if self.destroyed:
         return None
     album = Album(album_id, self.__genre_ids, self.__artist_ids)
     widget = AlbumWidget(album, self.storage_type, ViewType.ARTIST)
     widget.show()
     widget.set_property("valign", Gtk.Align.START)
     box = self.__get_box_at_index(self.__current_box)
     box.add(widget)
     box.show()
     self.__current_box += 1
     if self.__current_box == self.__boxes_count:
         self.__current_box = 0
     return widget
Esempio n. 19
0
 def _show_overlay_func(self, set):
     """
         Set overlay
         @param set as bool
     """
     if self._lock_overlay or\
        self._show_overlay == set:
         return
     if set:
         # Play button
         self._play_event = Gtk.EventBox()
         self._play_event.set_property('has-tooltip', True)
         self._play_event.set_tooltip_text(_("Play"))
         self._play_event.connect('realize', self._on_eventbox_realize)
         self._play_event.connect('button-press-event',
                                  self._on_play_press_event)
         self._play_button = Gtk.Image.new_from_icon_name(
             'media-playback-start-symbolic', Gtk.IconSize.BUTTON)
         self._play_button.set_opacity(0)
         # Play all button
         self._play_all_event = Gtk.EventBox()
         self._play_all_event.set_property('has-tooltip', True)
         self._play_all_event.set_tooltip_text(_("Play albums"))
         self._play_all_event.set_property('halign', Gtk.Align.END)
         self._play_all_event.connect('realize', self._on_eventbox_realize)
         self._play_all_event.connect('button-press-event',
                                      self.__on_play_all_press_event)
         self._play_all_button = Gtk.Image.new()
         self._play_all_button.set_opacity(0)
         # Artwork button
         self._artwork_event = Gtk.EventBox()
         self._artwork_event.set_property('has-tooltip', True)
         self._artwork_event.set_tooltip_text(_("Change artwork"))
         self._artwork_event.set_property('halign', Gtk.Align.END)
         self._artwork_event.connect('realize', self._on_eventbox_realize)
         self._artwork_event.connect('button-press-event',
                                     self._on_artwork_press_event)
         self._artwork_button = Gtk.Image.new_from_icon_name(
             'image-x-generic-symbolic', Gtk.IconSize.BUTTON)
         self._artwork_button.set_opacity(0)
         # Action button
         self._action_event = Gtk.EventBox()
         self._action_event.set_property('has-tooltip', True)
         self._action_event.set_property('halign', Gtk.Align.END)
         self._action_event.connect('realize', self._on_eventbox_realize)
         self._action_event.connect('button-press-event',
                                    self._on_action_press_event)
         self._action_button = Gtk.Image.new()
         self._action_button.set_opacity(0)
         self.__overlay_grid.set_orientation(self._overlay_orientation)
         if self._overlay_orientation == Gtk.Orientation.VERTICAL:
             self._play_event.set_hexpand(False)
             self._play_event.set_vexpand(True)
             self._play_event.set_property('halign', Gtk.Align.END)
             self._play_event.set_property('valign', Gtk.Align.START)
             self.__overlay_grid.set_property('valign', Gtk.Align.FILL)
             self.__overlay_grid.set_property('halign', Gtk.Align.END)
         else:
             self._play_event.set_hexpand(True)
             self._play_event.set_vexpand(False)
             self._play_event.set_property('halign', Gtk.Align.START)
             self._play_event.set_property('valign', Gtk.Align.END)
             self.__overlay_grid.set_property('halign', Gtk.Align.FILL)
             self.__overlay_grid.set_property('valign', Gtk.Align.END)
         self._play_event.add(self._play_button)
         self._play_all_event.add(self._play_all_button)
         self._artwork_event.add(self._artwork_button)
         self._action_event.add(self._action_button)
         self.__overlay_grid.add(self._play_event)
         self.__overlay_grid.add(self._play_all_event)
         self.__overlay_grid.add(self._action_event)
         self.__overlay_grid.add(self._artwork_event)
         self.__overlay_grid.show_all()
         AlbumWidget._show_overlay_func(self, True)
     else:
         AlbumWidget._show_overlay_func(self, False)
         self._play_event.destroy()
         self._play_event = None
         self._play_button.destroy()
         self._play_button = None
         self._play_all_event.destroy()
         self._play_all_event = None
         self._play_all_button.destroy()
         self._play_all_button = None
         self._action_event.destroy()
         self._action_event = None
         self._action_button.destroy()
         self._action_button = None
         self._artwork_event.destroy()
         self._artwork_event = None
         self._artwork_button.destroy()
         self._artwork_button = None
Esempio n. 20
0
    def __init__(self, album_id, genre_ids, artist_ids, art_size):
        """
            Init detailed album widget
            @param album id as int
            @param genre ids as [int]
            @param artist ids as [int]
            @param lazy as LazyLoadingView
            @param art size as ArtSize
        """
        Gtk.Bin.__init__(self)
        AlbumWidget.__init__(self, album_id, genre_ids, artist_ids, art_size)
        self._rounded_class = "rounded-icon-small"
        self.__width = None
        self.__context = None
        # Cover + rating + spacing
        self.__height = ArtSize.BIG + 26
        self.__orientation = None
        self.__child_height = TrackRow.get_best_height(self)
        # Header + separator + spacing + margin
        self.__requested_height = self.__child_height + 6
        # Discs to load, will be emptied
        self.__discs = self._album.discs
        self.__locked_widget_right = True
        self.set_property("height-request", self.__height)
        self.connect("size-allocate", self.__on_size_allocate)
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Lollypop/AlbumDetailedWidget.ui")
        builder.connect_signals(self)
        self._widget = builder.get_object("widget")
        album_info = builder.get_object("albuminfo")
        title_label = builder.get_object("title")
        title_label.set_property("has-tooltip", True)
        artist_label = builder.get_object("artist")
        artist_label.set_property("has-tooltip", True)
        year_label = builder.get_object("year")
        self.__header = builder.get_object("header")
        self.__overlay = builder.get_object("overlay")
        self.__duration_label = builder.get_object("duration")
        self.__context_button = builder.get_object("context")

        if art_size == ArtSize.NONE:
            self._cover = None
            rating = RatingWidget(self._album)
            rating.set_hexpand(True)
            rating.set_property("halign", Gtk.Align.END)
            rating.set_property("valign", Gtk.Align.CENTER)
            rating.show()
            self.__header.attach(rating, 4, 0, 1, 1)
            loved = LovedWidget(self._album)
            loved.set_property("halign", Gtk.Align.END)
            loved.set_property("valign", Gtk.Align.CENTER)
            loved.show()
            self.__header.attach(loved, 5, 0, 1, 1)

            artist_label.set_text(", ".join(self._album.artists))
            artist_label.show()
            if self._album.year is not None:
                year_label.set_label(str(self._album.year))
                year_label.show()
        else:
            self.__duration_label.set_hexpand(True)
            builder = Gtk.Builder()
            builder.add_from_resource("/org/gnome/Lollypop/CoverBox.ui")
            builder.connect_signals(self)
            self._play_button = builder.get_object("play-button")
            self._action_button = builder.get_object("action-button")
            self._action_event = builder.get_object("action-event")
            self._cover = builder.get_object("cover")
            self.__coverbox = builder.get_object("coverbox")
            # 6 for 2*3px (application.css)
            self.__coverbox.set_property("width-request", art_size + 6)
            if art_size == ArtSize.BIG:
                self._cover.get_style_context().add_class("cover-frame")
                self._artwork_button = builder.get_object("artwork-button")
                if self._album.year is not None:
                    year_label.set_label(str(self._album.year))
                    year_label.show()
                grid = Gtk.Grid()
                grid.set_column_spacing(10)
                grid.set_property("halign", Gtk.Align.CENTER)
                grid.show()
                rating = RatingWidget(self._album)
                loved = LovedWidget(self._album)
                rating.show()
                loved.show()
                grid.add(rating)
                grid.add(loved)
                self.__coverbox.add(grid)
                self._widget.attach(self.__coverbox, 0, 0, 1, 1)
                if Lp().window.get_view_width() < WindowSize.MEDIUM:
                    self.__coverbox.hide()
                if len(artist_ids) > 1:
                    artist_label.set_text(", ".join(self._album.artists))
                    artist_label.show()
            elif art_size == ArtSize.HEADER:
                # Here we are working around default CoverBox ui
                # Do we really need to have another ui file?
                # So just hack values on the fly
                self._cover.get_style_context().add_class("small-cover-frame")
                overlay_grid = builder.get_object("overlay-grid")
                overlay_grid.set_margin_bottom(2)
                overlay_grid.set_margin_end(2)
                overlay_grid.set_column_spacing(0)
                play_event = builder.get_object("play-event")
                play_event.set_margin_start(2)
                play_event.set_margin_bottom(2)
                album_info.attach(self.__coverbox, 0, 0, 1, 1)
                artist_label.set_text(", ".join(self._album.artists))
                artist_label.show()

        self.__set_duration()

        self.__box = Gtk.Grid()
        self.__box.set_column_homogeneous(True)
        self.__box.set_property("valign", Gtk.Align.START)
        self.__box.show()
        album_info.add(self.__box)

        self._tracks_left = {}
        self._tracks_right = {}

        self.set_cover()
        self.update_state()

        title_label.set_label(self._album.name)

        for disc in self.__discs:
            self.__add_disc_container(disc.number)
            self.__set_disc_height(disc)

        self.add(self._widget)
        # We start transparent, we switch opaque at size allocation
        # This prevent artifacts
        self.set_opacity(0)

        self._lock_overlay = False
Esempio n. 21
0
 def init_widget(self):
     """
         Init widget content
     """
     self.get_style_context().remove_class('loading')
     AlbumWidget.__init__(self, None)
     self._widget = Gtk.EventBox()
     self._widget.connect('enter-notify-event', self._on_enter_notify)
     self._widget.connect('leave-notify-event', self._on_leave_notify)
     grid = Gtk.Grid()
     grid.set_orientation(Gtk.Orientation.VERTICAL)
     frame = Gtk.Frame()
     frame.set_property('halign', Gtk.Align.CENTER)
     frame.get_style_context().add_class('cover-frame')
     self._color = Gtk.Frame()
     self._color.get_style_context().add_class('cover-frame-border')
     self._cover = Gtk.Image()
     self._cover.set_size_request(ArtSize.BIG, ArtSize.BIG)
     self._cover.get_style_context().add_class('white')
     self._title_label = Gtk.Label()
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._title_label.set_property('halign', Gtk.Align.CENTER)
     self._title_label.set_text(self._name)
     self._widget.add(grid)
     grid.add(frame)
     grid.add(self._title_label)
     frame.add(self._color)
     overlay = Gtk.Overlay.new()
     overlay.get_style_context().add_class('white')
     # Play button
     play_event = Gtk.EventBox()
     play_event.set_property('has-tooltip', True)
     play_event.set_tooltip_text(_("Play"))
     play_event.set_hexpand(True)
     play_event.set_property('valign', Gtk.Align.CENTER)
     play_event.set_property('halign', Gtk.Align.CENTER)
     play_event.connect('realize', self._on_eventbox_realize)
     play_event.connect('button-press-event',
                        self._on_play_press_event)
     self._play_button = Gtk.Image.new_from_icon_name(
                                        'media-playback-start-symbolic',
                                        Gtk.IconSize.DND)
     self._play_button.set_opacity(0)
     # Edit button
     edit_event = Gtk.EventBox()
     edit_event.set_property('has-tooltip', True)
     edit_event.set_tooltip_text(_("Change artwork"))
     edit_event.set_property('halign', Gtk.Align.END)
     edit_event.connect('realize', self._on_eventbox_realize)
     edit_event.connect('button-press-event',
                        self._on_edit_press_event)
     edit_event.set_property('valign', Gtk.Align.END)
     edit_event.set_property('halign', Gtk.Align.END)
     self._edit_button = Gtk.Image.new_from_icon_name(
                                        'document-properties-symbolic',
                                        Gtk.IconSize.BUTTON)
     self._edit_button.set_opacity(0)
     overlay.add(self._cover)
     overlay.add_overlay(play_event)
     overlay.add_overlay(edit_event)
     self._color.add(overlay)
     self.add(self._widget)
     self.set_cover()
     self.update_state()
     self._widget.set_property('halign', Gtk.Align.CENTER)
     self._widget.set_property('valign', Gtk.Align.CENTER)
     self.show_all()
     play_event.add(self._play_button)
     edit_event.add(self._edit_button)
    def __init__(self, album_id, genre_ids, artist_ids, art_size):
        """
            Init detailed album widget
            @param album id as int
            @param genre ids as [int]
            @param artist ids as [int]
            @param lazy as LazyLoadingView
            @param art size as ArtSize
        """
        Gtk.Bin.__init__(self)
        AlbumWidget.__init__(self, album_id, genre_ids, artist_ids, art_size)
        self._album.set_artists(artist_ids)
        self.__width = None
        self.__context = None
        # Cover + rating + spacing
        self.__height = ArtSize.BIG + 26
        self.__orientation = None
        self.__child_height = TrackRow.get_best_height(self)
        # Header + separator + spacing + margin
        self.__requested_height = self.__child_height + 6
        # Discs to load, will be emptied
        self.__discs = self._album.discs
        self.__locked_widget_right = True
        self.set_property('height-request', self.__height)
        self.connect('size-allocate', self.__on_size_allocate)
        builder = Gtk.Builder()
        builder.add_from_resource('/org/gnome/Lollypop/AlbumDetailedWidget.ui')
        builder.connect_signals(self)
        self._widget = builder.get_object('widget')
        album_info = builder.get_object('albuminfo')
        title_label = builder.get_object('title')
        title_label.set_property('has-tooltip', True)
        artist_label = builder.get_object('artist')
        artist_label.set_property('has-tooltip', True)
        year_label = builder.get_object('year')
        self.__header = builder.get_object('header')
        self.__overlay = builder.get_object('overlay')
        self.__duration_label = builder.get_object('duration')
        self.__context_button = builder.get_object('context')

        if art_size == ArtSize.NONE:
            self._cover = None
            rating = RatingWidget(self._album)
            rating.set_hexpand(True)
            rating.set_property('halign', Gtk.Align.END)
            rating.set_property('valign', Gtk.Align.CENTER)
            rating.show()
            self.__header.attach(rating, 4, 0, 1, 1)
            loved = LovedWidget(self._album)
            loved.set_property('halign', Gtk.Align.END)
            loved.set_property('valign', Gtk.Align.CENTER)
            loved.show()
            self.__header.attach(loved, 5, 0, 1, 1)

            artist_label.set_text(", ".join(self._album.artists))
            artist_label.show()
            if self._album.year:
                year_label.set_label(self._album.year)
                year_label.show()
        else:
            self.__duration_label.set_hexpand(True)
            builder = Gtk.Builder()
            builder.add_from_resource('/org/gnome/Lollypop/CoverBox.ui')
            builder.connect_signals(self)
            self._play_button = builder.get_object('play-button')
            self._action_button = builder.get_object('action-button')
            self._action_event = builder.get_object('action-event')
            self._cover = builder.get_object('cover')
            self.__coverbox = builder.get_object('coverbox')
            # 6 for 2*3px (application.css)
            self.__coverbox.set_property('width-request', art_size + 6)
            if art_size == ArtSize.BIG:
                self._cover.get_style_context().add_class('cover-frame')
                self._artwork_button = builder.get_object('artwork-button')
                if self._album.year:
                    year_label.set_label(self._album.year)
                    year_label.show()
                grid = Gtk.Grid()
                grid.set_column_spacing(10)
                grid.set_property('halign', Gtk.Align.CENTER)
                grid.show()
                rating = RatingWidget(self._album)
                loved = LovedWidget(self._album)
                rating.show()
                loved.show()
                grid.add(rating)
                grid.add(loved)
                self.__coverbox.add(grid)
                self._widget.attach(self.__coverbox, 0, 0, 1, 1)
                if Lp().window.get_view_width() < WindowSize.MEDIUM:
                    self.__coverbox.hide()
                if len(artist_ids) > 1:
                    artist_label.set_text(", ".join(self._album.artists))
                    artist_label.show()
            elif art_size == ArtSize.HEADER:
                # Here we are working around default CoverBox ui
                # Do we really need to have another ui file?
                # So just hack values on the fly
                self._cover.set_halign(Gtk.Align.CENTER)
                self._cover.get_style_context().add_class('small-cover-frame')
                self.__coverbox.set_margin_bottom(5)
                # We want a smaller button, so reload image
                self._rounded_class = "rounded-icon-small"
                self._play_button.set_from_icon_name(
                                               "media-playback-start-symbolic",
                                               Gtk.IconSize.MENU)
                overlay_grid = builder.get_object('overlay-grid')
                overlay_grid.set_margin_bottom(2)
                overlay_grid.set_margin_end(2)
                overlay_grid.set_column_spacing(0)
                self._play_button.set_margin_start(2)
                self._play_button.set_margin_bottom(2)
                play_event = builder.get_object('play-event')
                play_event.set_property('halign', Gtk.Align.START)
                play_event.set_property('valign', Gtk.Align.END)
                album_info.attach(self.__coverbox, 0, 0, 1, 1)
                artist_label.set_text(", ".join(self._album.artists))
                artist_label.show()

        self.__set_duration()

        self.__box = Gtk.Grid()
        self.__box.set_column_homogeneous(True)
        self.__box.set_property('valign', Gtk.Align.START)
        self.__box.show()
        album_info.add(self.__box)

        self._tracks_left = {}
        self._tracks_right = {}

        self.set_cover()
        self.update_state()

        title_label.set_label(self._album.name)

        for disc in self.__discs:
            self.__add_disc_container(disc.number)
            self.__set_disc_height(disc)

        self.add(self._widget)
        # We start transparent, we switch opaque at size allocation
        # This prevent artifacts
        self.set_opacity(0)

        if self._album.is_web and self._cover is not None:
            self._cover.get_style_context().add_class(
                                                'cover-frame-web')
 def _show_overlay_func(self, set):
     """
         Set overlay
         @param set as bool
     """
     if self._lock_overlay or\
        self._show_overlay == set:
         return
     if set:
         # Play button
         self._play_event = Gtk.EventBox()
         self._play_event.set_property('has-tooltip', True)
         self._play_event.set_tooltip_text(_("Play"))
         self._play_event.connect('realize', self._on_eventbox_realize)
         self._play_event.connect('button-press-event',
                                  self._on_play_press_event)
         self._play_button = Gtk.Image.new_from_icon_name(
                                            'media-playback-start-symbolic',
                                            Gtk.IconSize.BUTTON)
         self._play_button.set_opacity(0)
         # Play all button
         self._play_all_event = Gtk.EventBox()
         self._play_all_event.set_property('has-tooltip', True)
         self._play_all_event.set_tooltip_text(_("Play albums"))
         self._play_all_event.set_property('halign', Gtk.Align.END)
         self._play_all_event.connect('realize', self._on_eventbox_realize)
         self._play_all_event.connect('button-press-event',
                                      self.__on_play_all_press_event)
         self._play_all_button = Gtk.Image.new()
         self._play_all_button.set_opacity(0)
         # Artwork button
         self._artwork_event = Gtk.EventBox()
         self._artwork_event.set_property('has-tooltip', True)
         self._artwork_event.set_tooltip_text(_("Change artwork"))
         self._artwork_event.set_property('halign', Gtk.Align.END)
         self._artwork_event.connect('realize', self._on_eventbox_realize)
         self._artwork_event.connect('button-press-event',
                                     self._on_artwork_press_event)
         self._artwork_button = Gtk.Image.new_from_icon_name(
                                            'image-x-generic-symbolic',
                                            Gtk.IconSize.BUTTON)
         self._artwork_button.set_opacity(0)
         # Action button
         self._action_event = Gtk.EventBox()
         self._action_event.set_property('has-tooltip', True)
         self._action_event.set_property('halign', Gtk.Align.END)
         self._action_event.connect('realize', self._on_eventbox_realize)
         self._action_event.connect('button-press-event',
                                    self._on_action_press_event)
         self._action_button = Gtk.Image.new()
         self._action_button.set_opacity(0)
         self.__overlay_grid.set_orientation(self._overlay_orientation)
         if self._overlay_orientation == Gtk.Orientation.VERTICAL:
             self._play_event.set_hexpand(False)
             self._play_event.set_vexpand(True)
             self._play_event.set_property('halign', Gtk.Align.END)
             self._play_event.set_property('valign', Gtk.Align.START)
             self.__overlay_grid.set_property('valign', Gtk.Align.FILL)
             self.__overlay_grid.set_property('halign', Gtk.Align.END)
         else:
             self._play_event.set_hexpand(True)
             self._play_event.set_vexpand(False)
             self._play_event.set_property('halign', Gtk.Align.START)
             self._play_event.set_property('valign', Gtk.Align.END)
             self.__overlay_grid.set_property('halign', Gtk.Align.FILL)
             self.__overlay_grid.set_property('valign', Gtk.Align.END)
         self._play_event.add(self._play_button)
         self._play_all_event.add(self._play_all_button)
         self._artwork_event.add(self._artwork_button)
         self._action_event.add(self._action_button)
         self.__overlay_grid.add(self._play_event)
         self.__overlay_grid.add(self._play_all_event)
         self.__overlay_grid.add(self._action_event)
         self.__overlay_grid.add(self._artwork_event)
         self.__overlay_grid.show_all()
         AlbumWidget._show_overlay_func(self, True)
     else:
         AlbumWidget._show_overlay_func(self, False)
         self._play_event.destroy()
         self._play_event = None
         self._play_button.destroy()
         self._play_button = None
         self._play_all_event.destroy()
         self._play_all_event = None
         self._play_all_button.destroy()
         self._play_all_button = None
         self._action_event.destroy()
         self._action_event = None
         self._action_button.destroy()
         self._action_button = None
         self._artwork_event.destroy()
         self._artwork_event = None
         self._artwork_button.destroy()
         self._artwork_button = None
Esempio n. 24
0
 def populate(self):
     """
         Init widget content
     """
     self.get_style_context().remove_class('loading')
     AlbumWidget.__init__(self, None)
     self._widget = Gtk.EventBox()
     self._widget.connect('enter-notify-event', self._on_enter_notify)
     self._widget.connect('leave-notify-event', self._on_leave_notify)
     self._cover = Gtk.Image()
     self._cover.get_style_context().add_class('cover-frame')
     self._cover.set_property('halign', Gtk.Align.CENTER)
     self._cover.set_size_request(ArtSize.BIG, ArtSize.BIG)
     self._cover.get_style_context().add_class('white')
     self._title_label = Gtk.Label()
     self._title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._title_label.set_property('halign', Gtk.Align.CENTER)
     self._title_label.set_text(self._name)
     overlay = Gtk.Overlay.new()
     overlay.get_style_context().add_class('white')
     overlay.set_property('halign', Gtk.Align.CENTER)
     overlay.set_property('valign', Gtk.Align.CENTER)
     # Play button
     play_event = Gtk.EventBox()
     play_event.set_property('has-tooltip', True)
     play_event.set_tooltip_text(_("Play"))
     play_event.set_hexpand(True)
     play_event.set_property('valign', Gtk.Align.CENTER)
     play_event.set_property('halign', Gtk.Align.CENTER)
     play_event.connect('realize', self._on_eventbox_realize)
     play_event.connect('button-press-event',
                        self._on_play_press_event)
     self._play_button = Gtk.Image.new_from_icon_name(
                                        'media-playback-start-symbolic',
                                        Gtk.IconSize.DND)
     self._play_button.set_opacity(0)
     # Edit button
     edit_event = Gtk.EventBox()
     edit_event.set_margin_bottom(5)
     edit_event.set_margin_end(5)
     edit_event.set_property('has-tooltip', True)
     edit_event.set_tooltip_text(_("Change artwork"))
     edit_event.set_property('halign', Gtk.Align.END)
     edit_event.connect('realize', self._on_eventbox_realize)
     edit_event.connect('button-press-event',
                        self._on_edit_press_event)
     edit_event.set_property('valign', Gtk.Align.END)
     edit_event.set_property('halign', Gtk.Align.END)
     self._edit_button = Gtk.Image.new_from_icon_name(
                                        'document-properties-symbolic',
                                        Gtk.IconSize.BUTTON)
     self._edit_button.set_opacity(0)
     overlay.add(self._cover)
     overlay.add_overlay(play_event)
     overlay.add_overlay(edit_event)
     grid = Gtk.Grid()
     grid.set_orientation(Gtk.Orientation.VERTICAL)
     grid.add(overlay)
     grid.add(self._title_label)
     self._widget.add(grid)
     self._widget.set_property('halign', Gtk.Align.CENTER)
     self._widget.set_property('valign', Gtk.Align.CENTER)
     self.add(self._widget)
     self.set_cover()
     self.update_state()
     self.show_all()
     play_event.add(self._play_button)
     edit_event.add(self._edit_button)