def __popup_menu(self, view, library): model, iter = view.get_selection().get_selected() device = model[iter][0] if device.is_connected() and not self.__busy: songs = self.__list_songs(device) else: songs = [] menu = SongsMenu(library, songs, playlists=False, devices=False, remove=False, parent=self) menu.preseparate() props = gtk.ImageMenuItem(gtk.STOCK_PROPERTIES) props.connect_object('activate', self.__properties, model[iter][0]) props.set_sensitive(not self.__busy) menu.prepend(props) ren = qltk.MenuItem(_("_Rename"), gtk.STOCK_EDIT) keyval, mod = gtk.accelerator_parse("F2") ren.add_accelerator( 'activate', self.accelerators, keyval, mod, gtk.ACCEL_VISIBLE) def rename(path): self.__render.set_property('editable', True) view.set_cursor(path, view.get_columns()[0], start_editing=True) ren.connect_object('activate', rename, model.get_path(iter)) menu.prepend(ren) menu.preseparate() eject = gtk.ImageMenuItem(_("_Eject")) eject.set_image( gtk.image_new_from_icon_name("media-eject", gtk.ICON_SIZE_MENU)) eject.set_sensitive( not self.__busy and device.eject and device.is_connected()) eject.connect_object('activate', self.__eject, None) menu.prepend(eject) refresh = gtk.ImageMenuItem(gtk.STOCK_REFRESH) refresh.set_sensitive(device.is_connected()) refresh.connect_object('activate', self.__refresh, True) menu.prepend(refresh) menu.show_all() menu.popup(None, None, None, 0, gtk.get_current_event_time()) return True
def __popup(self, view, event, library): x = int(event.x) y = int(event.y) current_path = view.get_path_at_pos(x, y) if event.button == Gdk.BUTTON_SECONDARY and current_path: if not view.path_is_selected(current_path): view.unselect_all() view.select_path(current_path) albums = self.__get_selected_albums() songs = self.__get_songs_from_albums(albums) items = [] num = len(albums) button = MenuItem( ngettext("Reload album _cover", "Reload album _covers", num), Icons.VIEW_REFRESH) button.connect('activate', self.__refresh_album, view) items.append(button) menu = SongsMenu(library, songs, items=[items]) menu.show_all() menu.popup(None, None, None, event.button, event.time, Gtk.get_current_event_time())