Exemplo n.º 1
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)
Exemplo n.º 2
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()
Exemplo n.º 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()