def test_get_menu_item_top_parent(self): item = Gtk.MenuItem() menu = Gtk.Menu() menu.append(item) window = Gtk.Window() menu.attach_to_widget(window, None) self.assertEqual(qltk.get_menu_item_top_parent(item), window)
def _on_new_playlist_activate(self, item, songs) -> Optional[Playlist]: parent = get_menu_item_top_parent(item) title = Playlist.suggested_name_for(songs) title = self._get_new_name(parent, title) if title is None: return None return self.pl_lib.create_from_songs(songs, title=title)
def _on_new_playlist_activate(self, item, songs): parent = get_menu_item_top_parent(item) title = Playlist.suggested_name_for(songs) title = GetPlaylistName(qltk.get_top_parent(parent)).run(title) if title is None: return playlist = FileBackedPlaylist.new(PLAYLISTS, title) playlist.extend(songs) PlaylistsBrowser.changed(playlist)
def show_files_cb(menu_item): print_d("Trying to show files...") if not show_songs(songs): parent = get_menu_item_top_parent(menu_item) msg = ErrorMessage( parent, _("Unable to show files"), _("Error showing files, " "or no program available to show them.")) msg.run()
def _on_new_playlist_activate(self, item, songs): parent = get_menu_item_top_parent(item) title = Playlist.suggested_name_for(songs) title = self._get_new_name(parent, title) if title is None: return playlist = FileBackedPlaylist.new(PLAYLISTS, title, library=app.library) playlist.extend(songs) self._emit_new(playlist)
def _on_new_playlist_activate(self, item, songs): parent = get_menu_item_top_parent(item) title = Playlist.suggested_name_for(songs) title = self._get_new_name(parent, title) if title is None: return playlist = FileBackedPlaylist.new(PLAYLISTS, title, library=self.librarian) playlist.extend(songs) self._emit_new(playlist)
def set_rating(self, value, songs, librarian): count = len(songs) if (count > 1 and config.getboolean("browsers", "rating_confirm_multiple")): parent = qltk.get_menu_item_top_parent(self) dialog = ConfirmRateMultipleDialog(parent, count, value) if dialog.run() != Gtk.ResponseType.YES: return for song in songs: song["~#rating"] = value librarian.changed(songs)
def set_rating(self, value, songs, librarian): count = len(songs) if (count > 1 and config.getboolean("browsers", "rating_confirm_multiple")): parent = qltk.get_menu_item_top_parent(self) dialog = ConfirmRateMultipleDialog( parent, _("Change _Rating"), count, value) if dialog.run() != Gtk.ResponseType.YES: return for song in songs: song["~#rating"] = value librarian.changed(songs)
def remove_rating(self, songs, librarian): count = len(songs) if (count > 1 and config.getboolean("browsers", "rating_confirm_multiple")): parent = qltk.get_menu_item_top_parent(self) dialog = ConfirmRateMultipleDialog(parent, count, None) if dialog.run() != Gtk.ResponseType.YES: return reset = [] for song in songs: if "~#rating" in song: del song["~#rating"] reset.append(song) librarian.changed(reset)
def remove_rating(self, songs, librarian): count = len(songs) if (count > 1 and config.getboolean("browsers", "rating_confirm_multiple")): parent = qltk.get_menu_item_top_parent(self) dialog = ConfirmRateMultipleDialog( parent, _("_Remove Rating"), count, None) if dialog.run() != Gtk.ResponseType.YES: return reset = [] for song in songs: if "~#rating" in song: del song["~#rating"] reset.append(song) librarian.changed(reset)
def _on_toggle_playlist_activate(self, item, playlist, songs): parent = get_menu_item_top_parent(item) has_some, has_all = playlist.has_songs(songs) if has_all: playlist.remove_songs(songs) elif has_some: resp = ConfirmMultipleSongsAction(parent, playlist, songs).run() if resp == ConfirmMultipleSongsAction.REMOVE: playlist.remove_songs(songs) elif resp == ConfirmMultipleSongsAction.ADD: playlist.extend(songs) return else: playlist.extend(songs)
def _on_new_playlist_activate(self, item, songs): parent = get_menu_item_top_parent(item) if len(songs) == 1: title = songs[0].comma("title") else: title = ngettext("%(title)s and %(count)d more", "%(title)s and %(count)d more", len(songs) - 1) % { 'title': songs[0].comma("title"), 'count': len(songs) - 1 } title = GetPlaylistName(qltk.get_top_parent(parent)).run(title) if title is None: return playlist = Playlist.new(PLAYLISTS, title) playlist.extend(songs) PlaylistsBrowser.changed(playlist)
def _on_new_playlist_activate(self, item, songs): parent = get_menu_item_top_parent(item) if len(songs) == 1: title = songs[0].comma("title") else: title = ngettext( "%(title)s and %(count)d more", "%(title)s and %(count)d more", len(songs) - 1) % { 'title': songs[0].comma("title"), 'count': len(songs) - 1 } title = GetPlaylistName(qltk.get_top_parent(parent)).run(title) if title is None: return playlist = Playlist.new(PLAYLISTS, title) playlist.extend(songs) PlaylistsBrowser.changed(playlist)
def song_properties_cb(menu_item): parent = get_menu_item_top_parent(menu_item) window = SongProperties(librarian, songs, parent) window.show()
def trash_cb(item): parent = get_menu_item_top_parent(item) trash_songs(parent, songs, librarian)
def remove_cb(item, songs, library): parent = get_menu_item_top_parent(item) if self._confirm_song_removal(parent, songs): library.remove(songs)
def __on_activate(self, item, plugin, library, songs): parent = get_menu_item_top_parent(item) self.__handle(item, plugin, library, songs, parent)
def __on_activate(self, item, plugin, library, browser, playlists): parent = get_menu_item_top_parent(item) self.__handle(plugin, library, browser, playlists, parent)
def plugin_window(self): return get_menu_item_top_parent(self)
def test_get_menu_item_top_parent_unattached(self): item = Gtk.MenuItem() menu = Gtk.Menu() menu.append(item) self.assertTrue(qltk.get_menu_item_top_parent(item) is None)
def information_cb(menu_item): parent = get_menu_item_top_parent(menu_item) window = Information(librarian, songs, parent) window.show()