示例#1
0
 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)
示例#2
0
文件: menu.py 项目: WammKD/quodlibet
 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 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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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()
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
 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)
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
 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)
示例#13
0
    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)
示例#14
0
    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)
示例#15
0
    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)
示例#16
0
    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)
示例#17
0
 def song_properties_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = SongProperties(librarian, songs, parent)
     window.show()
示例#18
0
 def trash_cb(item):
     parent = get_menu_item_top_parent(item)
     trash_songs(parent, songs, librarian)
示例#19
0
 def remove_cb(item, songs, library):
     parent = get_menu_item_top_parent(item)
     if self._confirm_song_removal(parent, songs):
         library.remove(songs)
示例#20
0
 def __on_activate(self, item, plugin, library, songs):
     parent = get_menu_item_top_parent(item)
     self.__handle(item, plugin, library, songs, parent)
示例#21
0
 def __on_activate(self, item, plugin, library, browser, playlists):
     parent = get_menu_item_top_parent(item)
     self.__handle(plugin, library, browser, playlists, parent)
示例#22
0
 def __on_activate(self, item, plugin, library, browser, playlists):
     parent = get_menu_item_top_parent(item)
     self.__handle(plugin, library, browser, playlists, parent)
示例#23
0
 def song_properties_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = SongProperties(librarian, songs, parent)
     window.show()
示例#24
0
 def plugin_window(self):
     return get_menu_item_top_parent(self)
示例#25
0
 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)
示例#26
0
 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)
示例#27
0
 def __on_activate(self, item, plugin, library, songs):
     parent = get_menu_item_top_parent(item)
     self.__handle(item, plugin, library, songs, parent)
示例#28
0
 def trash_cb(item):
     parent = get_menu_item_top_parent(item)
     trash_songs(parent, songs, librarian)
示例#29
0
 def information_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = Information(librarian, songs, parent)
     window.show()
示例#30
0
 def remove_cb(item, songs, library):
     parent = get_menu_item_top_parent(item)
     if self._confirm_song_removal(parent, songs):
         library.remove(songs)
示例#31
0
文件: gui.py 项目: thisfred/quodlibet
 def plugin_window(self):
     return get_menu_item_top_parent(self)
示例#32
0
 def information_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = Information(librarian, songs, parent)
     window.show()