Пример #1
0
 def _on_row_activated(self, widget, row):
     """
         Play searched item when selected
         @param widget as Gtk.ListBox
         @param row as SearchRow
     """
     if Lp().player.is_party() or Lp().player.locked or Lp().player.queued:
         if row.is_track():
             if Lp().player.locked or Lp().player.queued:
                 if row.get_id() in Lp().player.get_queue():
                     Lp().player.del_from_queue(row.get_id())
                 else:
                     Lp().player.append_to_queue(row.get_id())
                 row.destroy()
             else:
                 Lp().player.load(Track(row.get_id()))
         elif Gtk.get_minor_version() > 16:
             popover = AlbumPopover(row.get_id(), [], [])
             popover.set_relative_to(row)
             popover.show()
         else:
             t = Thread(target=self._play_search, args=(row.get_id(),
                                                        row.is_track()))
             t.daemon = True
             t.start()
     else:
         t = Thread(target=self._play_search, args=(row.get_id(),
                                                    row.is_track()))
         t.daemon = True
         t.start()
Пример #2
0
 def _on_item_activated(self, flowbox, album_widget):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param album_widget as AlbumSimpleWidget
     """
     if FlowBoxView._on_item_activated(self, flowbox, album_widget):
         return
     if album_widget.artwork is None:
         return
     # If widget top not on screen, popover will fail to show
     # FIXME: Report a bug and check always true
     (x, y) = album_widget.translate_coordinates(self._scrolled, 0, 0)
     if y < 0:
         y = album_widget.translate_coordinates(self._box, 0, 0)[1]
         self._scrolled.get_allocation().height + y
         self._scrolled.get_vadjustment().set_value(y)
     from lollypop.pop_album import AlbumPopover
     popover = AlbumPopover(album_widget.album, ArtSize.NONE)
     popover.set_relative_to(album_widget.artwork)
     popover.set_position(Gtk.PositionType.BOTTOM)
     album_widget.show_overlay(False)
     album_widget.lock_overlay(True)
     popover.connect("closed", self.__on_album_popover_closed, album_widget)
     popover.popup()
     album_widget.artwork.set_opacity(0.9)
Пример #3
0
 def __on_button_press(self, widget, event):
     """
         Store pressed button
         @param widget as Gtk.ListBox
         @param event as Gdk.EventButton
     """
     rect = widget.get_allocation()
     rect.x = event.x
     rect.y = event.y
     rect.width = rect.height = 1
     row = widget.get_row_at_y(event.y)
     # Internal track/album
     if event.button != 1 and row.id is not None:
         if row.is_track:
             track = Track(row.id)
             popover = TrackMenuPopover(track,
                                        TrackMenu(track))
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
         else:
             popover = AlbumPopover(row.id, [],
                                    row.artist_ids)
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
Пример #4
0
 def __on_album_activated(self, flowbox, album_widget):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param album_widget as AlbumSimpleWidget
     """
     # Here some code for touch screens
     # If mouse pointer activate Gtk.FlowBoxChild, overlay is on,
     # as enter notify event enabled it
     # Else, we are in touch screen, first time show overlay, next time
     # show popover
     if not album_widget.is_overlay:
         album_widget.show_overlay(True)
         return
     cover = album_widget.get_cover()
     if cover is None:
         return
     # If widget top not on screen, popover will fail to show
     # FIXME: Report a bug and check always true
     (x, y) = album_widget.translate_coordinates(self._scrolled, 0, 0)
     if y < 0:
         y = album_widget.translate_coordinates(self._box, 0, 0)[1]
         self._scrolled.get_allocation().height + y
         self._scrolled.get_vadjustment().set_value(y)
     allocation = self.get_allocation()
     (x, top_height) = album_widget.translate_coordinates(self, 0, 0)
     bottom_height = allocation.height -\
         album_widget.get_allocation().height -\
         top_height
     if bottom_height > top_height:
         height = bottom_height
     else:
         height = top_height
     popover = AlbumPopover(album_widget.id,
                            self.__genre_ids,
                            self.__artist_ids,
                            allocation.width,
                            height,
                            ArtSize.NONE)
     popover.set_relative_to(cover)
     popover.set_position(Gtk.PositionType.BOTTOM)
     album_widget.show_overlay(False)
     album_widget.lock_overlay(True)
     popover.connect("closed", self.__on_album_popover_closed, album_widget)
     popover.show()
     self.__current = album_widget
     cover.set_opacity(0.9)
Пример #5
0
 def _on_row_activated(self, widget, row):
     """
         Play searched item when selected
         @param widget as Gtk.ListBox
         @param row as AlbumRow
     """
     genre_ids = Lp().player.get_genre_ids(row.get_id())
     artist_ids = Lp().player.get_artist_ids(row.get_id())
     # TODO Remove this later
     if Gtk.get_minor_version() > 16:
         popover = AlbumPopover(
                                  row.get_id(),
                                  genre_ids,
                                  [])
         popover.set_relative_to(row)
         popover.show()
     else:
         album = Album(row.get_id(), genre_ids, artist_ids)
         Lp().player.load(album.tracks[0])
Пример #6
0
 def __on_album_activated(self, flowbox, album_widget):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param album_widget as AlbumSimpleWidget
     """
     cover = album_widget.get_cover()
     if cover is None:
         return
     # If widget top not on screen, popover will fail to show
     # FIXME: Report a bug and check always true
     (x, y) = album_widget.translate_coordinates(self._scrolled, 0, 0)
     if y < 0:
         y = album_widget.translate_coordinates(self.__albumbox, 0, 0)[1]
         self._scrolled.get_allocation().height + y
         self._scrolled.get_vadjustment().set_value(y)
     if self.__press_rect is not None:
         album = Album(album_widget.id)
         if self.__genre_ids and self.__genre_ids[0] == Type.CHARTS:
             popover = AlbumMenuPopover(album, None)
             popover.set_relative_to(cover)
         elif album.is_youtube:
             popover = AlbumMenuPopover(album, AlbumMenu(album, True))
             popover.set_relative_to(cover)
         else:
             popover = Gtk.Popover.new_from_model(cover,
                                                  AlbumMenu(album, True))
         popover.set_position(Gtk.PositionType.BOTTOM)
         popover.set_pointing_to(self.__press_rect)
     else:
         allocation = self.get_allocation()
         (x, top_height) = album_widget.translate_coordinates(self, 0, 0)
         bottom_height = allocation.height -\
             album_widget.get_allocation().height -\
             top_height
         if bottom_height > top_height:
             height = bottom_height
         else:
             height = top_height
         popover = AlbumPopover(album_widget.id,
                                self.__genre_ids,
                                self.__artist_ids,
                                allocation.width,
                                height,
                                False)
         popover.set_relative_to(cover)
         popover.set_position(Gtk.PositionType.BOTTOM)
     album_widget.show_overlay(False)
     album_widget.lock_overlay(True)
     popover.connect('closed', self.__on_popover_closed, album_widget)
     popover.show()
     cover.set_opacity(0.9)
Пример #7
0
 def _on_album_activated(self, flowbox, album_widget):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param album_widget as AlbumSimpleWidget
     """
     cover = album_widget.get_cover()
     if cover is None:
         return
     # If widget top not on screen, popover will fail to show
     # FIXME: Report a bug and check always true
     (x, y) = album_widget.translate_coordinates(self._scrolled, 0, 0)
     if y < 0:
         y = album_widget.translate_coordinates(self._albumbox, 0, 0)[1]
         self._scrolled.get_allocation().height + y
         self._scrolled.get_vadjustment().set_value(y)
     if self._press_rect is not None:
         pop_menu = AlbumMenu(Album(album_widget.get_id()))
         popover = Gtk.Popover.new_from_model(cover, pop_menu)
         popover.set_position(Gtk.PositionType.BOTTOM)
         popover.set_pointing_to(self._press_rect)
     else:
         allocation = self.get_allocation()
         (x, top_height) = album_widget.translate_coordinates(self, 0, 0)
         bottom_height = allocation.height -\
             album_widget.get_allocation().height -\
             top_height
         if bottom_height > top_height:
             height = bottom_height
         else:
             height = top_height
         popover = AlbumPopover(album_widget.get_id(),
                                self._genre_ids,
                                self._artist_ids,
                                allocation.width,
                                height,
                                False)
         popover.set_relative_to(cover)
         popover.set_position(Gtk.PositionType.BOTTOM)
     album_widget.show_overlay(False)
     album_widget.lock_overlay(True)
     popover.connect('closed', self._on_popover_closed, album_widget)
     popover.show()
     cover.set_opacity(0.9)
Пример #8
0
 def __on_row_activated(self, widget, row):
     """
         Play searched item when selected
         @param widget as Gtk.ListBox
         @param row as AlbumRow
     """
     genre_ids = Lp().player.get_genre_ids(row.id)
     artist_ids = Lp().player.get_artist_ids(row.id)
     # TODO Remove this later
     if Gtk.get_minor_version() > 16:
         popover = AlbumPopover(row.id, genre_ids, [])
         popover.set_relative_to(row)
         popover.show()
     else:
         album = Album(row.id, genre_ids, artist_ids)
         Lp().player.load(album.tracks[0])
Пример #9
0
 def __on_row_activated(self, widget, row):
     """
         Play searched item when selected
         @param widget as Gtk.ListBox
         @param row as SearchRow
     """
     if Lp().player.is_party or Lp().player.locked:
         # External track/album
         if row.id is None:
             pass
         elif row.is_track:
             if Lp().player.locked:
                 if row.id in Lp().player.get_queue():
                     Lp().player.del_from_queue(row.id)
                 else:
                     Lp().player.append_to_queue(row.id)
                 row.destroy()
             else:
                 Lp().player.load(Track(row.id))
         elif Gtk.get_minor_version() > 16:
             popover = AlbumPopover(row.id, [], [])
             popover.set_relative_to(row)
             popover.show()
         else:
             t = Thread(target=self.__play_search, args=(row.id,
                                                         row.is_track))
             t.daemon = True
             t.start()
     else:
         if row.id is None:
             row.play()
         else:
             t = Thread(target=self.__play_search, args=(row.id,
                                                         row.is_track))
             t.daemon = True
             t.start()