def __popup_menu(self, widget): """ Popup menu for track @param widget as Gtk.Widget """ from lollypop.view_playlists_manager import PlaylistsManagerView from lollypop.menu_selectionlist import SelectionListMenu from lollypop.widgets_utils import Popover menu = SelectionListMenu(self.get_ancestor(PlaylistsManagerView), self.data, SelectionListMask.PLAYLISTS) popover = Popover() popover.bind_model(menu, None) popover.set_relative_to(widget) popover.popup()
def __popup_menu(self, widget): """ Popup menu for track @param widget as Gtk.Widget """ if App().settings.get_value("show-sidebar"): return from lollypop.view_artists_rounded import RoundedArtistsView from lollypop.menu_selectionlist import SelectionListMenu from lollypop.widgets_utils import Popover menu = SelectionListMenu(self.get_ancestor(RoundedArtistsView), self.data, SelectionListMask.ARTISTS_VIEW) popover = Popover() popover.bind_model(menu, None) popover.set_relative_to(widget) popover.popup()
def __on_button_release_event(self, listbox, event): """ Handle modifier @param listbox as Gtk.ListBox @param event as Gdk.Event """ if event.button != 1 and\ self.__base_type in [SelectionListMask.LIST_ONE, SelectionListMask.LIST_TWO]: from lollypop.menu_selectionlist import SelectionListMenu from lollypop.widgets_utils import Popover row = listbox.get_row_at_y(event.y) if row is not None: menu = SelectionListMenu(self, row.id, self.mask) popover = Popover() popover.bind_model(menu, None) popover.set_relative_to(listbox) rect = Gdk.Rectangle() rect.x = event.x rect.y = event.y rect.width = rect.height = 1 popover.set_pointing_to(rect) popover.popup() return True elif event.button == 1: state = event.get_state() static_selected = self.selected_ids and self.selected_ids[0] < 0 if (not state & Gdk.ModifierType.CONTROL_MASK and not state & Gdk.ModifierType.SHIFT_MASK) or\ static_selected: listbox.set_selection_mode(Gtk.SelectionMode.SINGLE) row = listbox.get_row_at_y(event.y) if row is not None and not (row.id < 0 and self.selected_ids): # User clicked on random, clear cached one if row.id == Type.RANDOMS: App().albums.clear_cached_randoms() App().tracks.clear_cached_randoms() listbox.set_selection_mode(Gtk.SelectionMode.MULTIPLE)