Ejemplo n.º 1
0
 def __init__(self, playlist_id, view_type):
     """
         Init PlaylistView
         @parma playlist_id as int
         @param view_type as ViewType
     """
     AlbumsListView.__init__(self, [], [], view_type |
                             ViewType.SCROLLED |
                             ViewType.OVERLAY)
     SizeAllocationHelper.__init__(self)
     self.__playlist_id = playlist_id
     self.box.set_width(Size.MEDIUM)
     if view_type & ViewType.DND:
         self.dnd_helper.connect("dnd-finished",
                                 self.__on_dnd_finished)
     self.__banner = PlaylistBannerWidget(playlist_id, self)
     self.__banner.show()
     self.add_widget(self.box, self.__banner)
     return [
             (App().playlists, "playlist-track-added",
              "_on_playlist_track_added"),
             (App().playlists, "playlist-track-removed",
              "_on_playlist_track_removed"),
             (App().playlists, "playlists-removed", "_on_playlist_removed"),
             (App().playlists, "playlists-renamed", "_on_playlist_renamed"),
             (App().playlists, "playlists-updated", "_on_playlist_updated")
     ]
Ejemplo n.º 2
0
 def __init__(self, view_type):
     """
         Init bannner
         @param view_type as ViewType
     """
     Gtk.Revealer.__init__(self)
     self._artwork = None
     self.__view_type = view_type | ViewType.BANNER
     self.__width = 1
     self.set_property("valign", Gtk.Align.START)
     if view_type & ViewType.OVERLAY:
         self._overlay = Overlay()
         self._overlay.show()
         self._artwork = Gtk.Image()
         self._artwork.show()
         if App().animations:
             self._artwork.set_opacity(0.99)
         self.get_style_context().add_class("default-banner")
         self._artwork.get_style_context().add_class("default-banner")
         eventbox = Gtk.EventBox.new()
         eventbox.show()
         eventbox.add_events(Gdk.EventMask.ALL_EVENTS_MASK)
         eventbox.add(self._artwork)
         self._overlay.add(eventbox)
         self.__event_controller = Gtk.EventControllerScroll.new(
             eventbox, Gtk.EventControllerScrollFlags.BOTH_AXES)
         self.__event_controller.set_propagation_phase(
             Gtk.PropagationPhase.TARGET)
         self.__event_controller.connect("scroll", self.__on_scroll)
         self.add(self._overlay)
     self.set_reveal_child(True)
     self.set_transition_duration(250)
     self.connect("destroy", self.__on_destroy)
     SizeAllocationHelper.__init__(self)
Ejemplo n.º 3
0
 def __init__(self):
     """
         Init helper
     """
     SizeAllocationHelper.__init__(self)
     self.__adjustment = self.scrolled.get_hadjustment()
     self.__adjustment.connect("value-changed", self.update_buttons)
     self._backward_button.connect("clicked",
                                   self.__on_backward_button_clicked)
     self._forward_button.connect("clicked",
                                  self.__on_forward_button_clicked)
     self.scrolled.get_hscrollbar().hide()
     self.scrolled.set_policy(Gtk.PolicyType.AUTOMATIC,
                              Gtk.PolicyType.NEVER)
Ejemplo n.º 4
0
 def __on_realize(self, widget):
     """
         Set initial orientation
         @param widget as Gtk.Widget
         @param orientation as Gtk.Orientation
     """
     if self._view_type & ViewType.SINGLE_COLUMN or\
             App().settings.get_value("force-single-column"):
         self._set_orientation(Gtk.Orientation.VERTICAL)
     elif self._view_type & ViewType.TWO_COLUMNS:
         self._set_orientation(Gtk.Orientation.HORIZONTAL)
     else:
         # We need to listen to parent allocation as currently, we have
         # no children
         SizeAllocationHelper.__init__(self, True)
Ejemplo n.º 5
0
 def _handle_width_allocate(self, allocation):
     """
         Update artwork
         @param allocation as Gtk.Allocation
         @return bool
     """
     if SizeAllocationHelper._handle_width_allocate(self, allocation):
         if allocation.width != self.__width:
             self.__width = allocation.width
             boxes_count = self.__width // self.__column_width
             if boxes_count < 1:
                 boxes_count = 1
             if self.__boxes_count == boxes_count:
                 return
             # Rework content
             if self.is_populated:
                 children = self.__get_children_sorted()
                 self.__remove_children()
                 self.__boxes_count = boxes_count
                 self.__populate(children)
             else:
                 self.__boxes_count = boxes_count
                 album_ids = App().albums.get_ids(self.__genre_ids,
                                                  self.__artist_ids,
                                                  self.storage_type, True)
                 self.__albums_count = len(album_ids)
                 LazyLoadingView.populate(self, album_ids)
             return True
     return False
Ejemplo n.º 6
0
 def _handle_width_allocate(self, allocation):
     """
         @param allocation as Gtk.Allocation
         @return True if allocation is valid
     """
     if SizeAllocationHelper._handle_width_allocate(self, allocation):
         self.update_buttons()
Ejemplo n.º 7
0
 def __init__(self, genre_ids, artist_ids, storage_type, view_type):
     """
         Init ArtistView
         @param genre_ids as [int]
         @param artist_ids as [int]
         @param storage_type as StorageType
         @param view_type as ViewType
     """
     LazyLoadingView.__init__(
         self, storage_type, view_type | ViewType.OVERLAY | ViewType.ARTIST)
     self.__boxes = []
     self.__others_boxes = []
     self.__width = 0
     self.__boxes_count = 0
     self.__current_box = 0
     self.__albums_count = 0
     self.__hovered_child = None
     self.__genre_ids = genre_ids
     self.__artist_ids = artist_ids
     self.__storage_type = storage_type
     self.__banner = ArtistBannerWidget(genre_ids, artist_ids, storage_type,
                                        self.view_type)
     self.__banner.show()
     self.__main_grid = Gtk.Grid.new()
     self.__main_grid.show()
     self.__main_grid.set_orientation(Gtk.Orientation.VERTICAL)
     self.__boxes_grid = Gtk.Grid.new()
     self.__boxes_grid.show()
     self.__boxes_grid.set_valign(Gtk.Align.START)
     self.__boxes_grid.set_halign(Gtk.Align.CENTER)
     self.__main_grid.add(self.__boxes_grid)
     self.add_widget(self.__main_grid, self.__banner)
     self.connect("populated", self.__on_populated)
     if App().settings.get_value("force-single-column"):
         self.__column_width = 1200
     else:
         self.__column_width = 600
     if App().animations:
         self.__event_controller = Gtk.EventControllerMotion.new(self)
         self.__event_controller.connect("motion", self.__on_motion)
     SizeAllocationHelper.__init__(self)
Ejemplo n.º 8
0
 def _handle_width_allocate(self, allocation):
     """
         Change columns disposition
         @param allocation as Gtk.Allocation
     """
     if SizeAllocationHelper._handle_width_allocate(self, allocation):
         if allocation.width >= Size.NORMAL:
             orientation = Gtk.Orientation.HORIZONTAL
         else:
             orientation = Gtk.Orientation.VERTICAL
         if self.__orientation != orientation:
             self._set_orientation(orientation)
Ejemplo n.º 9
0
 def _handle_width_allocate(self, allocation):
     """
         Update artwork
         @param allocation as Gtk.Allocation
         @return bool
     """
     if SizeAllocationHelper._handle_width_allocate(self, allocation):
         if allocation.width != self.__width:
             self.__width = allocation.width
             height = self.height
             if self._artwork is not None:
                 self._artwork.set_size_request(-1, height)
             emit_signal(self, "height-changed", height)
             return True
     return False
Ejemplo n.º 10
0
 def _handle_height_allocate(self, allocation):
     """
         Handle artwork sizing
         @param allocation as Gtk.Allocation
     """
     if SizeAllocationHelper._handle_height_allocate(self, allocation):
         # We use parent height because we may be collapsed
         parent = self.get_parent()
         if parent is None:
             height = allocation.height
         else:
             height = parent.get_allocated_height()
         self.__artwork_widget.set_artwork(
             allocation.width + 100, height + 100, self.__on_artwork,
             ArtBehaviour.BLUR_HARD | ArtBehaviour.DARKER)
Ejemplo n.º 11
0
 def __init__(self, window):
     """
         Init toolbar
         @param window as Window
     """
     Gtk.HeaderBar.__init__(self)
     SizeAllocationHelper.__init__(self)
     self.__width = Size.MINI
     self.__timeout_id = None
     self.set_title("Lollypop")
     self.__toolbar_playback = ToolbarPlayback(window)
     self.__toolbar_playback.show()
     self.__toolbar_info = ToolbarInfo()
     self.__toolbar_info.show()
     self.__toolbar_title = ToolbarTitle()
     self.__toolbar_end = ToolbarEnd(window)
     self.__toolbar_end.show()
     self.pack_start(self.__toolbar_playback)
     self.pack_start(self.__toolbar_info)
     self.set_custom_title(self.__toolbar_title)
     self.pack_end(self.__toolbar_end)
     return [(App().player, "current-changed", "_on_current_changed"),
             (App().window.container.widget, "notify::folded",
              "_on_container_folded")]
Ejemplo n.º 12
0
 def _handle_width_allocate(self, allocation):
     """
         Update artwork
         @param allocation as Gtk.Allocation
     """
     if SizeAllocationHelper._handle_width_allocate(self, allocation):
         width = self.__toolbar_playback.get_preferred_width()[1]
         width += self.__toolbar_end.get_preferred_width()[1]
         available = allocation.width - width
         if allocation.width < Size.BIG:
             title_width = available / 3
         else:
             title_width = available / 2.5
         self.__toolbar_title.set_width(title_width)
         self.__toolbar_info.set_width((available - title_width) / 2)
Ejemplo n.º 13
0
 def __init__(self):
     """
         Init mini player
     """
     Gtk.Overlay.__init__(self)
     SizeAllocationHelper.__init__(self)
     self.__previous_artwork_id = None
     self.__per_track_cover = App().settings.get_value(
         "allow-per-track-cover")
     self.get_style_context().add_class("black")
     self.__box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
     self.__box.show()
     self.__box.get_style_context().add_class("padding")
     self.__revealer = Gtk.Revealer.new()
     self.__revealer.show()
     self.__revealer_box = Gtk.Box.new(Gtk.Orientation.VERTICAL,
                                       MARGIN_SMALL)
     self.__revealer_box.show()
     bottom_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, MARGIN_SMALL)
     bottom_box.show()
     self.__progress_widget = ProgressPlayerWidget()
     self.__progress_widget.show()
     self.__progress_widget.set_vexpand(True)
     self.__progress_widget.set_margin_start(MARGIN)
     self.__progress_widget.set_margin_end(MARGIN)
     buttons_widget = ButtonsPlayerWidget(["banner-button-big"])
     buttons_widget.show()
     buttons_widget.update()
     buttons_widget.set_property("valign", Gtk.Align.CENTER)
     self.__artwork_widget = ArtworkPlayerWidget(ArtBehaviour.CACHE
                                                 | ArtBehaviour.CROP_SQUARE)
     self.__artwork_widget.show()
     self.__artwork_widget.set_vexpand(True)
     if App().lookup_action("miniplayer").get_state():
         self.__artwork_widget.set_art_size(ArtSize.MEDIUM, ArtSize.MEDIUM)
         self.__artwork_widget.set_opacity(0.5)
     else:
         self.__artwork_widget.set_art_size(ArtSize.MINIPLAYER,
                                            ArtSize.MINIPLAYER)
     self.__label_box = Gtk.Box(Gtk.Orientation.HORIZONTAL, MARGIN)
     self.__label_box.show()
     self.__label_widget = LabelPlayerWidget(False, 9)
     self.__label_widget.show()
     self.__label_widget.update()
     self.__artwork_button = Gtk.Image.new()
     self.__artwork_button.show()
     self.__label_box.pack_start(self.__artwork_button, False, False, 0)
     self.__label_box.pack_start(self.__label_widget, False, False, 0)
     button = Gtk.Button.new()
     button.show()
     button.get_style_context().add_class("banner-button-big")
     button.set_property("halign", Gtk.Align.START)
     button.set_property("valign", Gtk.Align.CENTER)
     button.connect("clicked", self.__on_button_clicked)
     button.set_image(self.__label_box)
     self.__background = Gtk.Image()
     self.__background.show()
     # Assemble UI
     self.__box.pack_start(self.__revealer, False, True, 0)
     self.__box.pack_start(bottom_box, False, False, 0)
     bottom_box.pack_start(button, True, True, 0)
     bottom_box.pack_end(buttons_widget, False, False, 0)
     bottom_box.set_size_request(-1, 68)
     self.__revealer.add(self.__revealer_box)
     self.__revealer_box.pack_start(self.__artwork_widget, False, True, 0)
     self.__revealer_box.pack_end(self.__progress_widget, False, True, 0)
     self.add(self.__background)
     self.add_overlay(self.__box)
     return [(App().player, "current-changed", "_on_current_changed")]