Ejemplo n.º 1
0
 def _on_album_activated(self, flowbox, child):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param child as Gtk.FlowboxChild
     """
     album_widget = child.get_child()
     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) = child.translate_coordinates(self._scrolled, 0, 0)
     if y < 0:
         y = child.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:
         popover = AlbumPopoverWidget(album_widget.get_id(),
                                      self._genre_ids,
                                      self._artist_ids,
                                      self.get_allocation().width,
                                      False)
         popover.set_relative_to(cover)
         popover.set_position(Gtk.PositionType.BOTTOM)
     popover.connect('closed', self._on_popover_closed, cover)
     popover.show()
     cover.set_opacity(0.9)
     album_widget.update_overlay()
Ejemplo n.º 2
0
 def _on_album_activated(self, flowbox, child):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param child as Gtk.FlowboxChild
     """
     album_widget = child.get_child()
     if self._press_rect is None:
         if self._context_album_id == album_widget.get_id():
             self._context_album_id = None
             self._context.hide()
             self._context_widget.destroy()
             self._context_widget = None
         else:
             self._init_context_position()
             self._context_album_id = album_widget.get_id()
             self._populate_context(self._context_album_id)
             self._context.show()
     else:
         if self._context_album_id is not None:
             self._context_album_id = None
             self._context.hide()
             self._context_widget.destroy()
             self._context_widget = None
         popover = AlbumPopoverWidget(album_widget.get_id(),
                                      self._genre_ids,
                                      self._artist_ids)
         popover.set_relative_to(album_widget)
         popover.set_pointing_to(self._press_rect)
         album_widget.update_overlay()
         popover.show()
Ejemplo n.º 3
0
 def _on_album_activated(self, flowbox, child):
     """
         Show Context view for activated album
         @param flowbox as Gtk.Flowbox
         @param child as Gtk.FlowboxChild
     """
     album_widget = child.get_child()
     if self._press_rect is None:
         if self._context_album_id == album_widget.get_id():
             self._context_album_id = None
             self._context.hide()
             self._context_widget.destroy()
             self._context_widget = None
         else:
             if Lp().settings.get_value('auto-play'):
                 album = Album(album_widget.get_id())
                 track = Track(album.tracks_ids[0])
                 Lp().player.load(track)
                 Lp().player.set_albums(track.id, None,
                                        self._genre_id)
             else:
                 self._context_album_id = album_widget.get_id()
                 self._populate_context(self._context_album_id)
                 self._context.show()
     else:
         if self._context_album_id is not None:
             self._context_album_id = None
             self._context.hide()
             self._context_widget.destroy()
             self._context_widget = None
         popover = AlbumPopoverWidget(album_widget.get_id(),
                                      self._genre_id)
         popover.set_relative_to(album_widget)
         popover.set_pointing_to(self._press_rect)
         popover.show()
Ejemplo n.º 4
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())
     # TODO Remove this later
     if Gtk.get_minor_version() > 16:
         popover = AlbumPopoverWidget(
                                  row.get_id(),
                                  genre_ids,
                                  [],
                                  False)
         popover.set_relative_to(row)
         popover.show()
     else:
         album = Album(row.get_id(), genre_ids)
         Lp().player.load(album.tracks[0])
Ejemplo n.º 5
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():
         if row.is_track:
             Lp().player.load(Track(row.id))
         elif Gtk.get_minor_version() > 18:
             popover = AlbumPopoverWidget(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:
         t = Thread(target=self._play_search, args=(row.id, row.is_track))
         t.daemon = True
         t.start()