Exemplo n.º 1
0
 def __pop_menu(self, widget):
     """
         Popup menu for album
         @param widget as Gtk.Button
         @param album id as int
     """
     ancestor = self.get_ancestor(Gtk.Popover)
     # Get album real genre ids (not contextual)
     genre_ids = Lp().albums.get_genre_ids(self._album.id)
     if genre_ids and genre_ids[0] == Type.CHARTS:
         popover = AlbumMenuPopover(self._album, None)
         popover.set_relative_to(widget)
         popover.set_position(Gtk.PositionType.BOTTOM)
     elif self._album.is_web:
         popover = AlbumMenuPopover(
             self._album, AlbumMenu(self._album, ancestor is not None))
         popover.set_relative_to(widget)
     else:
         popover = Gtk.Popover.new_from_model(
             widget, AlbumMenu(self._album, ancestor is not None))
     if ancestor is not None:
         Lp().window.view.show_popover(popover)
     else:
         popover.connect('closed', self.__on_pop_menu_closed)
         self.get_style_context().add_class('album-menu-selected')
         popover.show()
Exemplo n.º 2
0
 def __on_button_press(self, eventbox, event):
     """
         Store pressed button
         @param flowbox as Gtk.EventBox
         @param event as Gdk.EventButton
     """
     if event.button != 1:
         if self._album.genre_ids and\
                 self._album.genre_ids[0] == Type.CHARTS:
             popover = AlbumMenuPopover(self._album, None)
             popover.set_relative_to(self._cover)
         elif self._album.is_web:
             popover = AlbumMenuPopover(self._album, AlbumMenu(self._album,
                                                               True))
             popover.set_relative_to(self._cover)
         else:
             popover = Gtk.Popover.new_from_model(self._cover,
                                                  AlbumMenu(self._album,
                                                            True))
         popover.set_position(Gtk.PositionType.BOTTOM)
         rect = Gdk.Rectangle()
         rect.x = event.x
         rect.y = event.y
         rect.width = rect.height = 1
         popover.set_pointing_to(rect)
         popover.connect("closed", self.__on_album_popover_closed)
         popover.show()
Exemplo n.º 3
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)
     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_web:
             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,
                                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.º 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
     """
     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)
Exemplo n.º 5
0
 def __pop_menu(self, widget):
     """
         Popup menu for album
         @param widget as Gtk.Button
         @param album id as int
     """
     if self._album.is_youtube:
         popover = AlbumMenuPopover(self._album, AlbumMenu(self._album))
         popover.set_relative_to(widget)
     else:
         popover = Gtk.Popover.new_from_model(widget,
                                              AlbumMenu(self._album))
     popover.connect('closed', self.__on_pop_menu_closed)
     self.get_style_context().add_class('album-menu-selected')
     popover.show()
Exemplo n.º 6
0
 def _pop_menu(self, widget):
     """
         Popup menu for album
         @param widget as Gtk.Button
         @param album id as int
     """
     pop_menu = AlbumMenu(self._album)
     popover = Gtk.Popover.new_from_model(self._menu, pop_menu)
     popover.connect('closed', self._on_pop_menu_closed)
     self.get_style_context().add_class('album-menu-selected')
     popover.show()
Exemplo n.º 7
0
 def __pop_menu(self, widget):
     """
         Popup menu for album
         @param widget as Gtk.Button
         @param album id as int
     """
     ancestor = self.get_ancestor(Gtk.Popover)
     # Get album real genre ids (not contextual)
     popover = Gtk.Popover.new_from_model(
         widget, AlbumMenu(self._album, ancestor is not None))
     if ancestor is not None:
         Lp().window.view.show_popover(popover)
     else:
         popover.connect("closed", self.__on_pop_menu_closed)
         self.get_style_context().add_class("album-menu-selected")
         popover.show()
Exemplo n.º 8
0
 def __on_button_press(self, eventbox, event):
     """
         Store pressed button
         @param eventbox as Gtk.EventBox
         @param event as Gdk.EventButton
     """
     if event.button != 1:
         popover = Gtk.Popover.new_from_model(self._cover,
                                              AlbumMenu(self._album, True))
         popover.set_position(Gtk.PositionType.BOTTOM)
         rect = Gdk.Rectangle()
         rect.x = event.x
         rect.y = event.y
         rect.width = rect.height = 1
         popover.set_pointing_to(rect)
         popover.connect("closed", self.__on_album_popover_closed)
         popover.show()
Exemplo n.º 9
0
 def _on_button_press(self, eventbox, event):
     """
         Handle album mouse click
         @param eventbox as Gtk.EventBox
         @param event as Gdk.EventButton
     """
     if event.button != 1:
         from lollypop.pop_menu import AlbumMenu
         popover = Popover.new_from_model(
             self._artwork, AlbumMenu(self._album, self._artist_ids == []))
         popover.set_position(Gtk.PositionType.BOTTOM)
         rect = Gdk.Rectangle()
         rect.x = event.x
         rect.y = event.y
         rect.width = rect.height = 1
         popover.set_pointing_to(rect)
         popover.connect("closed", self._on_album_popover_closed)
         popover.popup()