def __popup_menu(self, view, library): model, itr = view.get_selection().get_selected() if itr is None: return songs = list(model[itr][0]) songs = filter(lambda s: isinstance(s, AudioFile), songs) menu = SongsMenu(library, songs, playlists=False, remove=False, ratings=False) menu.preseparate() def _remove(model, itr): playlist = model[itr][0] dialog = ConfirmRemovePlaylistDialog(self, playlist) if dialog.run() == Gtk.ResponseType.YES: playlist.delete() model.get_model().remove(model.convert_iter_to_child_iter(itr)) rem = MenuItem(_("_Delete"), Icons.EDIT_DELETE) connect_obj(rem, "activate", _remove, model, itr) menu.prepend(rem) def _rename(path): self.__render.set_property("editable", True) view.set_cursor(path, view.get_columns()[0], start_editing=True) ren = qltk.MenuItem(_("_Rename"), Icons.EDIT) qltk.add_fake_accel(ren, "F2") connect_obj(ren, "activate", _rename, model.get_path(itr)) menu.prepend(ren) playlist = model[itr][0] PLAYLIST_HANDLER.populate_menu(menu, library, self, [playlist]) menu.show_all() return view.popup_menu(menu, 0, Gtk.get_current_event_time())
def __popup_menu(self, view, library): model, itr = view.get_selection().get_selected() if itr is None: return songs = list(model[itr][0]) songs = [s for s in songs if isinstance(s, AudioFile)] menu = SongsMenu(library, songs, playlists=False, remove=False, ratings=False) menu.preseparate() def _remove(model, itr): playlist = model[itr][0] dialog = ConfirmRemovePlaylistDialog(self, playlist) if dialog.run() == Gtk.ResponseType.YES: playlist.delete() model.get_model().remove( model.convert_iter_to_child_iter(itr)) rem = MenuItem(_("_Delete"), Icons.EDIT_DELETE) connect_obj(rem, 'activate', _remove, model, itr) menu.prepend(rem) def _rename(path): self._start_rename(path) ren = qltk.MenuItem(_("_Rename"), Icons.EDIT) qltk.add_fake_accel(ren, "F2") connect_obj(ren, 'activate', _rename, model.get_path(itr)) menu.prepend(ren) playlist = model[itr][0] PLAYLIST_HANDLER.populate_menu(menu, library, self, [playlist]) menu.show_all() return view.popup_menu(menu, 0, Gtk.get_current_event_time())
def __popup(self, library): songs = self.get_selected_songs() if not songs: return menu = SongsMenu(library, songs, queue=False, remove=False, delete=False, ratings=False) menu.preseparate() remove = MenuItem(_("_Remove"), Icons.LIST_REMOVE) qltk.add_fake_accel(remove, "Delete") remove.connect("activate", self.__remove) menu.prepend(remove) menu.show_all() return self.popup_menu(menu, 0, Gtk.get_current_event_time())
def __popup(self, library): songs = self.get_selected_songs() if not songs: return menu = SongsMenu( library, songs, queue=False, remove=False, delete=False, parent=self) menu.preseparate() remove = gtk.ImageMenuItem(gtk.STOCK_REMOVE) remove.connect('activate', self.__remove) menu.prepend(remove) menu.show_all() return self.popup_menu(menu, 0, gtk.get_current_event_time())
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, use_stock=True) 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.AccelFlags.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"), use_underline=True) eject.set_image( Gtk.Image.new_from_icon_name("media-eject", Gtk.IconSize.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, use_stock=True) refresh.set_sensitive(device.is_connected()) refresh.connect_object('activate', self.__refresh, True) menu.prepend(refresh) menu.show_all() return view.popup_menu(menu, 0, Gtk.get_current_event_time())
def Menu(self, songs, songlist, library): menu = SongsMenu(library, songs, remove=self.__remove_songs, delete=True, accels=songlist.accelerators, parent=self) i = qltk.MenuItem(_("_Add to Library"), gtk.STOCK_ADD) i.set_sensitive(False) i.connect('activate', self.__add_songs, songs) for song in songs: if song not in self.__glibrary: i.set_sensitive(True) break menu.preseparate() menu.prepend(i) return menu
def __popup(self, library): songs = self.get_selected_songs() if not songs: return menu = SongsMenu( library, songs, queue=False, remove=False, delete=False, ratings=False) menu.preseparate() remove = Gtk.ImageMenuItem(Gtk.STOCK_REMOVE, use_stock=True) qltk.add_fake_accel(remove, "Delete") remove.connect('activate', self.__remove) menu.prepend(remove) menu.show_all() return self.popup_menu(menu, 0, Gtk.get_current_event_time())
def __popup(self, widget, library): songs = self.get_selected_songs() if not songs: return menu = SongsMenu( library, songs, queue=False, remove=False, delete=False, ratings=False) menu.preseparate() remove = MenuItem(_("_Remove"), Icons.LIST_REMOVE) qltk.add_fake_accel(remove, "Delete") remove.connect('activate', self.__remove) menu.prepend(remove) menu.show_all() return self.popup_menu(menu, 0, Gtk.get_current_event_time())
def Menu(self, songs, songlist, library): menu = SongsMenu(library, songs, parent=self) if len(songs) == 1: item = qltk.MenuItem(_("_Download..."), Gtk.STOCK_CONNECT) item.connect('activate', self.__download, songs[0]("~uri")) item.set_sensitive(not songs[0].is_file) else: songs = filter(lambda s: not s.is_file, songs) uris = [song("~uri") for song in songs] item = qltk.MenuItem(_("_Download..."), Gtk.STOCK_CONNECT) item.connect('activate', self.__download_many, uris) item.set_sensitive(bool(songs)) menu.preseparate() menu.prepend(item) return menu
def Menu(self, songs, songlist, library): menu = SongsMenu(library, songs, remove=self.__remove_songs, delete=True, parent=self) i = qltk.MenuItem(_("_Add to Library"), Gtk.STOCK_ADD) i.set_sensitive(False) i.connect('activate', self.__add_songs, songs) for song in songs: if song not in self.__glibrary: i.set_sensitive(True) break menu.preseparate() menu.prepend(i) return menu
def Menu(self, songs, songlist, library): menu = SongsMenu( library, songs, accels=songlist.accelerators, parent=self) if len(songs) == 1: item = qltk.MenuItem(_("_Download..."), gtk.STOCK_CONNECT) item.connect('activate', self.__download, songs[0]("~uri")) item.set_sensitive(not songs[0].is_file) else: songs = filter(lambda s: not s.is_file, songs) uris = [song("~uri") for song in songs] item = qltk.MenuItem(_("_Download..."), gtk.STOCK_CONNECT) item.connect('activate', self.__download_many, uris) item.set_sensitive(bool(songs)) menu.preseparate() menu.prepend(item) return menu
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_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) menu.preseparate() props = Gtk.ImageMenuItem(Gtk.STOCK_PROPERTIES, use_stock=True) connect_obj(props, '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.AccelFlags.VISIBLE) def rename(path): self.__render.set_property('editable', True) view.set_cursor(path, view.get_columns()[0], start_editing=True) connect_obj(ren, 'activate', rename, model.get_path(iter)) menu.prepend(ren) menu.preseparate() eject = Gtk.ImageMenuItem(_("_Eject"), use_underline=True) eject.set_image( Gtk.Image.new_from_icon_name("media-eject", Gtk.IconSize.MENU)) eject.set_sensitive( not self.__busy and device.eject and device.is_connected()) connect_obj(eject, 'activate', self.__eject, None) menu.prepend(eject) refresh = Gtk.ImageMenuItem(Gtk.STOCK_REFRESH, use_stock=True) refresh.set_sensitive(device.is_connected()) connect_obj(refresh, 'activate', self.__refresh, True) menu.prepend(refresh) menu.show_all() return view.popup_menu(menu, 0, Gtk.get_current_event_time())
def __popup_menu(self, view, library): model, itr = view.get_selection().get_selected() if itr is None: return songs = list(model[itr][0]) songs = [s for s in songs if isinstance(s, AudioFile)] menu = SongsMenu(library, songs, playlists=False, remove=False, ratings=False) menu.preseparate() def _remove(model, itr): playlist = model[itr][0] response = confirm_remove_playlist_dialog_invoke( self, playlist, self.Confirmer) if response: playlist.delete() else: print_d("Playlist removal cancelled through prompt") rem = MenuItem(_("_Delete"), Icons.EDIT_DELETE) connect_obj(rem, 'activate', _remove, model, itr) menu.prepend(rem) def _rename(path): self._start_rename(path) ren = qltk.MenuItem(_("_Rename"), Icons.EDIT) qltk.add_fake_accel(ren, "F2") connect_obj(ren, 'activate', _rename, model.get_path(itr)) menu.prepend(ren) playlist = model[itr][0] PLAYLIST_HANDLER.populate_menu(menu, library, self, [playlist]) menu.show_all() return view.popup_menu(menu, 0, Gtk.get_current_event_time())
def __popup_menu(self, view, library): model, itr = view.get_selection().get_selected() if itr is None: return songs = list(model[itr][0]) songs = filter(lambda s: isinstance(s, AudioFile), songs) menu = SongsMenu(library, songs, playlists=False, remove=False, ratings=False) menu.preseparate() def _remove(model, itr): playlist = model[itr][0] dialog = ConfirmRemovePlaylistDialog(self, playlist) if dialog.run() == Gtk.ResponseType.YES: playlist.delete() model.get_model().remove(model.convert_iter_to_child_iter(itr)) rem = Gtk.ImageMenuItem(Gtk.STOCK_DELETE, use_stock=True) connect_obj(rem, 'activate', _remove, model, itr) menu.prepend(rem) def _rename(path): self.__render.set_property('editable', True) view.set_cursor(path, view.get_columns()[0], start_editing=True) ren = qltk.MenuItem(_("_Rename"), Gtk.STOCK_EDIT) qltk.add_fake_accel(ren, "F2") connect_obj(ren, 'activate', _rename, model.get_path(itr)) menu.prepend(ren) playlist = model[itr][0] PLAYLIST_HANDLER.populate_menu(menu, library, self, [playlist]) menu.show_all() return view.popup_menu(menu, 0, Gtk.get_current_event_time())
def __popup_menu(self, view, library): # TODO: Consider allowing plugins to expose themselves in playlist model, itr = view.get_selection().get_selected() if itr is None: return songs = list(model[itr][0]) songs = filter(lambda s: isinstance(s, AudioFile), songs) menu = SongsMenu( library, songs, playlists=False, remove=False, parent=self) menu.preseparate() def _de_duplicate(model, itr): playlist = model[itr][0] unique = set() dupes = list() for s in songs: if s in unique: dupes.append(s) else: unique.add(s) if len(dupes) < 1: print_d("No duplicates in this playlist") return dialog = ConfirmRemoveDuplicatesDialog(self, playlist, len(dupes)) if dialog.run() == gtk.RESPONSE_YES: playlist.remove_songs(dupes, library, True) Playlists.changed(playlist) self.activate() de_dupe = gtk.MenuItem(_("Remove Duplicates")) de_dupe.connect_object('activate', _de_duplicate, model, itr) de_dupe.set_sensitive(not model[itr][0].has_duplicates()) menu.prepend(de_dupe) def _shuffle(model, itr): playlist = model[itr][0] playlist.shuffle() self.activate() shuffle = gtk.MenuItem(_("_Shuffle")) shuffle .connect_object('activate', _shuffle, model, itr) shuffle.set_sensitive(bool(len(model[itr][0]))) menu.prepend(shuffle) menu.prepend(gtk.SeparatorMenuItem()) def _remove(model, itr): playlist = model[itr][0] dialog = ConfirmRemovePlaylistDialog(self, playlist) if dialog.run() == gtk.RESPONSE_YES: playlist.delete() model.get_model().remove( model.convert_iter_to_child_iter(None, itr)) rem = gtk.ImageMenuItem(gtk.STOCK_DELETE) rem.connect_object('activate', _remove, model, itr) menu.prepend(rem) def _rename(path): self.__render.set_property('editable', True) view.set_cursor(path, view.get_columns()[0], start_editing=True) ren = qltk.MenuItem(_("_Rename"), gtk.STOCK_EDIT) keyval, mod = gtk.accelerator_parse("F2") ren.add_accelerator( 'activate', self.accelerators, keyval, mod, gtk.ACCEL_VISIBLE) ren.connect_object('activate', _rename, model.get_path(itr)) menu.prepend(ren) menu.show_all() return view.popup_menu(menu, 0, gtk.get_current_event_time())