Esempio n. 1
0
def confirm_song_removal_invoke(parent, songs):
    songs = set(songs)
    if not songs:
        return True

    count = len(songs)
    song = next(iter(songs))
    title = (ngettext("Remove track: \"%%(title)s\" from library?",
                      "Remove %(count)d tracks from library?",
                      count) % {'count': count}) % {
                'title': song('title') or song('~basename')}

    prompt = ConfirmationPrompt(parent, title, "", _("Remove from Library"),
                                ok_button_icon=Icons.LIST_REMOVE)
    return prompt.run() == ConfirmationPrompt.RESPONSE_INVOKE
Esempio n. 2
0
def confirm_multi_album_invoke(parent, plugin_name, count):
    """Dialog to confirm invoking a plugin with X albums in case X is high"""
    title = ngettext("Run the plugin \"%(name)s\" on %(count)d album?",
                     "Run the plugin \"%(name)s\" on %(count)d albums?",
                     count) % {"name": plugin_name, "count": count}
    description = ""
    ok_text = _("_Run Plugin")
    prompt = ConfirmationPrompt(parent, title, description, ok_text).run()
    return prompt == ConfirmationPrompt.RESPONSE_INVOKE
Esempio n. 3
0
 def __remove(self, view) -> None:
     selection = self.view.get_selection()
     model, paths = selection.get_selected_rows()
     gone_dirs = [model[p][0] for p in paths or []]
     total = len(gone_dirs)
     if not total:
         return
     msg = (_("Remove {dir!r} and all its tracks?").format(
         dir=gone_dirs[0]) if total == 1 else
            _("Remove {n} library paths and their tracks?").format(n=total))
     title = ngettext("Remove library path?", "Remove library paths?",
                      total)
     prompt = ConfirmationPrompt(self,
                                 title,
                                 msg,
                                 _("Remove"),
                                 ok_button_icon=Icons.LIST_REMOVE)
     if prompt.run() == ConfirmationPrompt.RESPONSE_INVOKE:
         view.remove_selection()
         self.__save()
Esempio n. 4
0
def confirm_multi_playlist_invoke(parent, plugin_name, count):
    """Dialog to confirm invoking a plugin with X playlists
    in case X is high
    """
    params = {"name": plugin_name, "count": format_int_locale(count)}
    title = ngettext("Run the plugin \"%(name)s\" on %(count)s playlist?",
                     "Run the plugin \"%(name)s\" on %(count)s playlists?",
                     count) % params
    description = ""
    ok_text = _("_Run Plugin")
    prompt = ConfirmationPrompt(parent, title, description, ok_text).run()
    return prompt == ConfirmationPrompt.RESPONSE_INVOKE
Esempio n. 5
0
def confirm_song_removal_invoke(parent, songs):
    songs = set(songs)
    if not songs:
        return True

    count = len(songs)
    song = next(iter(songs))
    title = ngettext("Remove track: \"%(title)s\" from library?",
                     "Remove %(count)d tracks from library?",
                     count) % {'title': song('title') or song('~basename'),
                               'count': count}

    return ConfirmationPrompt.RESPONSE_INVOKE == ConfirmationPrompt(
               parent, title, "", _("Remove from Library")).run()
Esempio n. 6
0
 def __move(self, widget):
     selection = self.view.get_selection()
     model, paths = selection.get_selected_rows()
     rows = [model[p] for p in paths or []]
     if len(rows) > 1:
         print_w("Can't do multiple moves at once")
         return
     elif not rows:
         return
     base_dir = rows[0][0]
     chooser = _get_chooser(_("Select This Directory"), _("_Cancel"))
     chooser.set_title(
         _("Select Actual / New Directory for {dir!r}").format(
             dir=base_dir))
     chooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
     chooser.set_local_only(True)
     chooser.set_select_multiple(False)
     results = _run_chooser(self, chooser)
     if not results:
         return
     new_dir = results[0]
     desc = (_("This will move QL metadata:\n\n"
               "{old!r} -> {new!r}\n\n"
               "The audio files themselves are not moved by this.\n"
               "Nonetheless, a backup is recommended "
               "(including the Quodlibet 'songs' file)").format(
                   old=base_dir, new=new_dir))
     title = _("Move scan root {dir!r}?").format(dir=base_dir)
     value = ConfirmationPrompt(self,
                                title=title,
                                description=desc,
                                ok_button_text=_("OK, move it!")).run()
     if value != ConfirmationPrompt.RESPONSE_INVOKE:
         print_d("User aborted")
         return
     print_d(f"Migrate from {base_dir} -> {new_dir}")
     copool.add(app.librarian.move_root, base_dir, new_dir)
     path = paths[0]
     self.model[path] = [new_dir]
     self.model.row_changed(path, rows[0].iter)
     self.__save()
Esempio n. 7
0
 def __move(self, widget):
     selection = self.view.get_selection()
     model, paths = selection.get_selected_rows()
     rows = [model[p] for p in paths or []]
     if len(rows) > 1:
         print_w("Can't do multiple moves at once")
         return
     base_dir = rows[0][0]
     chooser = _get_chooser(_("Select New Directory"), _("_Cancel"))
     chooser.set_title(
         _("Select New Directory for {dir}").format(dir=base_dir))
     chooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
     chooser.set_local_only(True)
     chooser.set_select_multiple(False)
     results = _run_chooser(self, chooser)
     if not results:
         return
     new_dir = results[0]
     desc = (_("This will move:\n\n"
               "%(old)r -> %(new)r\n\n"
               "Taking a backup is recommended "
               "(including the Quodlibet 'songs' file)") % {
                   "old": base_dir,
                   "new": new_dir
               })
     value = ConfirmationPrompt(self,
                                title=_("Move library root %r?") % base_dir,
                                description=desc,
                                ok_button_text=_("OK, move it!")).run()
     if value != ConfirmationPrompt.RESPONSE_INVOKE:
         print_d("User aborted")
         return
     print_d(f"Migrate from {base_dir} -> {new_dir}")
     copool.add(app.librarian.move_root, base_dir, new_dir)
     path = paths[0]
     self.model[path] = [new_dir]
     self.model.row_changed(path, rows[0].iter)
     self.__save()