コード例 #1
0
 def show_files_cb(menu_item):
     print_d("Trying to show files...")
     if not show_songs(songs):
         msg = ErrorMessage(
             self.plugin_window, _("Unable to show files"),
             _("Error showing files, "
               "or no program available to show them."))
         msg.run()
コード例 #2
0
ファイル: songsmenu.py プロジェクト: zsau/quodlibet
 def show_files_cb(menu_item):
     print_d("Trying to show files...")
     if not show_songs(songs):
         msg = ErrorMessage(self.plugin_window,
                      _("Unable to show files"),
                      _("Error showing files, "
                        "or no program available to show them."))
         msg.run()
コード例 #3
0
ファイル: songsmenu.py プロジェクト: azarmadr/quodlibet
 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()
コード例 #4
0
 def plugin_songs(self, songs):
     if not get_api_key():
         ErrorMessage(self, _("API Key Missing"),
             _("You have to specify an acoustid.org API key in the plugin "
             "preferences before you can submit fingerprints.")).run()
     else:
         FingerprintDialog(songs)
コード例 #5
0
def _do_trash_songs(parent, songs, librarian):
    dialog = TrashDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            trash.trash(filename)
        except trash.TrashError as e:
            print_w("Couldn't trash file (%s)" % e)
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to move to trash"),
                     _("Moving one or more files to the trash failed.")).run()

    if ok:
        librarian.remove(ok)
コード例 #6
0
 def plugin_songs(self, songs):
     songs = [s for s in songs if s.is_file]
     print_d("Trying to browse folders...")
     if not self._handle(songs):
         ErrorMessage(self.plugin_window,
                      _("Unable to open folders"),
                      _("No program available to open folders.")).run()
コード例 #7
0
def _do_trash_files(parent, paths):
    dialog = TrashDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != TrashDialog.RESPONSE_TRASH:
        return

    window_title = _("Moving %(current)d/%(total)d.")
    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            trash.trash(path)
        except trash.TrashError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to move to trash"),
                     _("Moving one or more files to the trash failed.")).run()
コード例 #8
0
def do_import(parent, library):
    db_path = expanduser(BansheeImport.USR_PATH)

    importer = BansheeDBImporter(library)
    try:
        db = sqlite3.connect(db_path)
        importer.read(db)
        db.close()
    except sqlite3.OperationalError:
        msg = _("Specified Banshee database is malformed or missing")
        WarningMessage(parent, BansheeImport.PLUGIN_NAME, msg).run()
    except Exception:
        util.print_exc()
        importer.finish()
        msg = _("Import Failed")
        # FIXME: don't depend on the plugin class here
        ErrorMessage(parent, BansheeImport.PLUGIN_NAME, msg).run()
    else:
        count = importer.finish()
        msg = ngettext(
            "Successfully imported ratings and statistics for %d song",
            "Successfully imported ratings and statistics for %d songs",
            count) % count
        Message(Gtk.MessageType.INFO, parent, BansheeImport.PLUGIN_NAME,
                msg).run()
コード例 #9
0
def _do_delete_songs(parent, songs, librarian):
    dialog = DeleteDialog.for_songs(parent, songs)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(songs), window_title)
    w.show()

    ok = []
    failed = []
    for song in songs:
        filename = song("~filename")
        try:
            os.unlink(filename)
        except EnvironmentError:
            failed.append(song)
        else:
            ok.append(song)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to delete files"),
                     _("Deleting one or more files failed.")).run()

    if ok:
        librarian.remove(ok)
コード例 #10
0
def _do_delete_files(parent, paths):
    dialog = DeleteDialog.for_files(parent, paths)
    resp = dialog.run()
    if resp != DeleteDialog.RESPONSE_DELETE:
        return

    window_title = _("Deleting %(current)d/%(total)d.")

    w = WaitLoadWindow(parent, len(paths), window_title)
    w.show()

    ok = []
    failed = []
    for path in paths:
        try:
            os.unlink(path)
        except EnvironmentError:
            failed.append(path)
        else:
            ok.append(path)
        w.step()
    w.destroy()

    if failed:
        ErrorMessage(parent, _("Unable to delete files"),
                     _("Deleting one or more files failed.")).run()
コード例 #11
0
    def __drag_data_received(self, view, ctx, x, y, sel, tid, etime):
        view.emit_stop_by_name('drag-data-received')
        targets = [
            ("text/uri-list", 0, DND_URI_LIST),
            ("text/x-moz-url", 0, DND_MOZ_URL)
        ]
        targets = [Gtk.TargetEntry.new(*t) for t in targets]

        view.drag_dest_set(Gtk.DestDefaults.ALL, targets, Gdk.DragAction.COPY)
        if tid == DND_URI_LIST:
            uri = sel.get_uris()[0]
        elif tid == DND_MOZ_URL:
            uri = sel.data.decode('utf16', 'replace').split('\n')[0]
        else:
            ctx.finish(False, False, etime)
            return

        ctx.finish(True, False, etime)

        feed = Feed(uri.encode("ascii", "replace"))
        feed.changed = feed.parse()
        if feed:
            self.__feeds.append(row=[feed])
            AudioFeeds.write()
        else:
            ErrorMessage(
                self, _("Unable to add feed"),
                _("%s could not be added. The server may be down, "
                  "or the location may not be an audio feed.") %
                util.bold(util.escape(feed.uri))).run()
コード例 #12
0
ファイル: export_to_folder.py プロジェクト: weblate/quodlibet
 def __copy_songs(self, task, songs, directory, pattern, parent=None):
     """Generator for copool to copy songs to the folder"""
     self.__cancel = False
     total = len(songs)
     print_d("Copying %d song(s) to directory %s. "
             "This might take a while..." % (total, directory))
     for i, song in enumerate(songs):
         if self.__cancel:
             print_d("Cancelled export to directory.")
             self.__cancel = False
             break
         # Actually do the copy
         try:
             self._copy_file(song, directory, i + 1, pattern)
         except OSError as e:
             print_d("Unable to copy file: {}".format(e))
             ErrorMessage(
                 parent, _("Unable to export playlist"),
                 _("Ensure you have write access to the destination.")).run(
                 )
             break
         task.update(float(i) / total)
         yield True
     print_d("Finished export to directory.")
     task.finish()
コード例 #13
0
    def open_chooser(self, action):
        if not os.path.exists(self.last_dir):
            self.last_dir = const.HOME

        if action.get_name() == "AddFolders":
            chooser = FolderChooser(self, _("Add Music"), self.last_dir)
            cb = gtk.CheckButton(_("Watch this folder for new songs"))
            cb.set_active(not config.get("settings", "scan"))
            cb.show()
            chooser.set_extra_widget(cb)
        else:
            chooser = FileChooser(
                self, _("Add Music"), formats.filter, self.last_dir)
            cb = None

        fns = chooser.run()
        chooser.destroy()
        if fns:
            if action.get_name() == "AddFolders":
                self.last_dir = fns[0]
                copool.add(self.__library.scan, fns, funcid="library")
            else:
                self.last_dir = os.path.basename(fns[0])
                for filename in map(os.path.realpath, map(util.fsnative, fns)):
                    if filename in self.__library: continue
                    song = self.__library.add_filename(filename)
                    if not song:
                        from traceback import format_exception_only as feo
                        tb = feo(sys.last_type, sys.last_value)
                        msg = _("%s could not be added to your library.\n\n")
                        msg %= util.escape(util.fsdecode(
                            os.path.basename(filename)))
                        msg += util.escape("".join(tb).decode(
                            const.ENCODING, "replace"))
                        d = ErrorMessage(self, _("Unable to add song"), msg)
                        d.label.set_selectable(True)
                        d.run()
                        continue

        if cb and cb.get_active():
            dirs = util.split_scan_dirs(config.get("settings", "scan"))
            for fn in fns:
                if fn not in dirs: dirs.append(fn)
            dirs = ":".join(dirs)
            config.set("settings", "scan", dirs)
コード例 #14
0
 def open_location(self, action):
     name = GetStringDialog(self, _("Add a Location"),
         _("Enter the location of an audio file:"),
         okbutton=Gtk.STOCK_ADD).run()
     if name:
         if not util.uri_is_valid(name):
             ErrorMessage(
                 self, _("Unable to add location"),
                 _("<b>%s</b> is not a valid location.") % (
                 util.escape(name))).run()
         elif not app.player.can_play_uri(name):
             ErrorMessage(
                 self, _("Unable to add location"),
                 _("<b>%s</b> uses an unsupported protocol.") % (
                 util.escape(name))).run()
         else:
             if name not in self.__library:
                 self.__library.add([RemoteFile(name)])
コード例 #15
0
 def open_location(self, action):
     name = GetStringDialog(self, _("Add a Location"),
         _("Enter the location of an audio file:"),
         button_label=_("_Add"), button_icon=Icons.LIST_ADD).run()
     if name:
         if not uri_is_valid(name):
             ErrorMessage(
                 self, _("Unable to add location"),
                 _("%s is not a valid location.") % (
                 util.bold(util.escape(name)))).run()
         elif not app.player.can_play_uri(name):
             ErrorMessage(
                 self, _("Unable to add location"),
                 _("%s uses an unsupported protocol.") % (
                 util.bold(util.escape(name)))).run()
         else:
             if name not in self.__library:
                 self.__library.add([RemoteFile(name)])
コード例 #16
0
 def __error(self, player, song, error, librarian):
     newstr = u"%s: %s\n\n" % (
         decode(time.asctime(), const.ENCODING), error)
     self.__errors_in_a_row += 1
     if self.__errors_in_a_row > MAX_ERRORS:
         self.__errors_in_a_row = 0
         ErrorMessage(None, _("Too Many Errors"),
                      _("Stopping playback because there were %d errors "
                        "in a row.") % MAX_ERRORS).run()
         player.go_to(None)
         player.paused = True
     song["~errors"] = newstr + song.get("~errors", "")
コード例 #17
0
 def __new_feed(self, activator):
     feed = AddFeedDialog(self).run()
     if feed is not None:
         feed.changed = feed.parse()
         if feed:
             self.__feeds.append(row=[feed])
             AudioFeeds.write()
         else:
             ErrorMessage(
                 self, _("Unable to add feed"),
                 _("%s could not be added. The server may be down, "
                   "or the location may not be an audio feed.") %
                 util.bold(util.escape(feed.uri))).run()
コード例 #18
0
    def _set_paused(self, paused):
        if paused == self._paused:
            return
        self._paused = paused

        if not self.song:
            if paused:
                # Something wants us to pause between songs, or when
                # we've got no song playing (probably StopAfterMenu).
                self.emit('paused')
                self.__destroy_pipeline()
            return

        if paused:
            if self.bin:
                if self.song.is_file:
                    # fast path
                    self.bin.set_state(Gst.State.PAUSED)
                else:
                    # seekable streams (seem to) have a duration >= 0
                    ok, d = self.bin.query_duration(Gst.Format.TIME)
                    if not ok:
                        d = -1

                    if d >= 0:
                        self.bin.set_state(Gst.State.PAUSED)
                    else:
                        # destroy so that we rebuffer on resume
                        self.__destroy_pipeline()
        else:
            if self.bin:
                self.bin.set_state(Gst.State.PLAYING)
            else:
                if self.__init_pipeline():
                    self.bin.set_state(Gst.State.PLAYING)
                else:
                    # Backend error; show message and halt playback
                    ErrorMessage(None, _("Output Error"),
                        _("GStreamer output pipeline could not be "
                          "initialized. The pipeline might be invalid, "
                          "or the device may be in use. Check the "
                          "player preferences.")).run()
                    self.emit((paused and 'paused') or 'unpaused')
                    self._paused = paused = True

        self.emit((paused and 'paused') or 'unpaused')
コード例 #19
0
ファイル: rbimport.py プロジェクト: azarmadr/quodlibet
def do_import(parent, library):
    db_path = expanduser("~/.local/share/rhythmbox/rhythmdb.xml")
    handler = RBDBContentHandler(library)
    try:
        xml.sax.parse(db_path, handler)
    except Exception:
        util.print_exc()
        handler.finish()
        msg = _("Import Failed")
        # FIXME: don't depend on the plugin class here..
        ErrorMessage(parent, RBImport.PLUGIN_NAME, msg).run()
    else:
        count = handler.finish()
        msg = _("Successfully imported ratings and statistics "
                "for %d songs") % count
        # FIXME: this is just a warning so it works with older QL
        WarningMessage(parent, RBImport.PLUGIN_NAME, msg).run()
コード例 #20
0
def do_import(parent, library):
    plist_path = expanduser("~/Music/iTunes/iTunes Music Library.xml")
    importer = iTunesimporter(library)
    try:
        plist = plistlib.readPlist(plist_path)
        importer.read(plist)
    except Exception:
        util.print_exc()
        importer.finish()
        msg = _("Import Failed")
        # FIXME: don't depend on the plugin class here..
        ErrorMessage(parent, iTunesImport.PLUGIN_NAME, msg).run()
    else:
        count = importer.finish()
        msg = _("Successfully imported ratings and statistics "
                "for %d songs") % count
        # FIXME: this is just a warning so it works with older QL
        WarningMessage(parent, iTunesimport.PLUGIN_NAME, msg).run()
コード例 #21
0
    def __drag_data_received(self, widget, ctx, x, y, sel, tid, etime):
        assert tid == DND_URI_LIST

        uris = sel.get_uris()

        dirs = []
        error = False
        for uri in uris:
            try:
                uri = URI(uri)
            except ValueError:
                continue

            if uri.is_filename:
                loc = os.path.normpath(uri.filename)
                if os.path.isdir(loc):
                    dirs.append(loc)
                else:
                    loc = os.path.realpath(loc)
                    if loc not in self.__library:
                        self.__library.add_filename(loc)
            elif app.player.can_play_uri(uri):
                if uri not in self.__library:
                    self.__library.add([RemoteFile(uri)])
            else:
                error = True
                break
        Gtk.drag_finish(ctx, not error, False, etime)
        if error:
            ErrorMessage(
                self, _("Unable to add songs"),
                _("%s uses an unsupported protocol.") % util.bold(uri)).run()
        else:
            if dirs:
                copool.add(self.__library.scan,
                           dirs,
                           cofuncid="library",
                           funcid="library")
コード例 #22
0
ファイル: test_qltk_msg.py プロジェクト: yaoml/quodlibet
 def test_ctr(self):
     ErrorMessage(None, "title", "description").destroy()
コード例 #23
0
 def _error_msg(self, message):
     title = _("Error in %s") % self.PLUGIN_NAME
     ErrorMessage(app.window, title, message).run()
コード例 #24
0
ファイル: audiofeeds.py プロジェクト: WammKD/quodlibet
 def feed_error(self, feed: Feed) -> ErrorMessage:
     return ErrorMessage(
         self, _("Unable to add feed"),
         _("%s could not be added. The server may be down, "
           "or the location may not be an audio feed.") %
         util.bold(util.escape(feed.uri)))
コード例 #25
0
 def on_preview_button_clicked(self, button):
     if app.player.info is not None:
         if not self.plugin_instance.show_notification(app.player.info):
             ErrorMessage(
                 self, _("Connection Error"),
                 _("Couldn't connect to notification daemon.")).run()
コード例 #26
0
 def plugin_single_song(self, song):
     songs = [s for s in [song] if s.is_file]
     print_d("Trying to browse files...")
     if not self.handle(songs):
         ErrorMessage(self.plugin_window, _("Unable to browse files"),
                      _("No program available to browse files.")).run()