Exemple #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()
Exemple #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()
Exemple #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()
Exemple #4
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()
Exemple #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())
     # 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])
Exemple #6
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()
Exemple #7
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 = AlbumPopoverWidget(row.get_id(), genre_ids, [], False)
         popover.set_relative_to(row)
         popover.show()
     else:
         album = Album(row.get_id(), genre_ids, artist_ids)
         Lp().player.load(album.tracks[0])
Exemple #8
0
 def _on_button_press(self, widget, event):
     """
         Store pressed button
         @param widget as Gtk.ListBox
         @param event as Gdk.EventButton
     """
     if event.button != 1 and\
        Gtk.get_minor_version() > 16:
         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)
         if row.is_track:
             popover = TrackMenuPopover(row.id, TrackMenu(row.id))
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
         else:
             popover = AlbumPopoverWidget(row.id, None)
             popover.set_relative_to(widget)
             popover.set_pointing_to(rect)
             popover.show()
Exemple #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():
         if row.is_track:
             Lp().player.load(Track(row.get_id()))
         elif Gtk.get_minor_version() > 16:
             popover = AlbumPopoverWidget(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()
Exemple #10
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)
         self._context_widget = popover.get_widget()
         popover.connect('destroy', self._on_popover_destroyed)
         popover.show()