Esempio n. 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)
Esempio n. 2
0
 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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()
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 17
0
 def song_properties_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = SongProperties(librarian, songs, parent)
     window.show()
Esempio n. 18
0
 def trash_cb(item):
     parent = get_menu_item_top_parent(item)
     trash_songs(parent, songs, librarian)
Esempio n. 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)
Esempio n. 20
0
 def __on_activate(self, item, plugin, library, songs):
     parent = get_menu_item_top_parent(item)
     self.__handle(item, plugin, library, songs, parent)
Esempio n. 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)
Esempio n. 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)
Esempio n. 23
0
 def song_properties_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = SongProperties(librarian, songs, parent)
     window.show()
Esempio n. 24
0
 def plugin_window(self):
     return get_menu_item_top_parent(self)
Esempio n. 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)
Esempio n. 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)
Esempio n. 27
0
 def __on_activate(self, item, plugin, library, songs):
     parent = get_menu_item_top_parent(item)
     self.__handle(item, plugin, library, songs, parent)
Esempio n. 28
0
 def trash_cb(item):
     parent = get_menu_item_top_parent(item)
     trash_songs(parent, songs, librarian)
Esempio n. 29
0
 def information_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = Information(librarian, songs, parent)
     window.show()
Esempio n. 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)
Esempio n. 31
0
 def plugin_window(self):
     return get_menu_item_top_parent(self)
Esempio n. 32
0
 def information_cb(menu_item):
     parent = get_menu_item_top_parent(menu_item)
     window = Information(librarian, songs, parent)
     window.show()