コード例 #1
0
    def export_current_playlist(self, *e):
        pl = self.main.get_current_playlist().playlist
        name = pl.get_name() + ".m3u"

        dialog = dialogs.FileOperationDialog(
            _("Export Current Playlist"),
            None,
            gtk.FILE_CHOOSER_ACTION_SAVE,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE,
                     gtk.RESPONSE_OK))

        extensions = {
            'm3u': _('M3U Playlist'),
            'pls': _('PLS Playlist'),
            'asx': _('ASX Playlist'),
            'xspf': _('XSPF Playlist')
        }

        dialog.add_extensions(extensions)
        dialog.set_current_name(name)

        result = dialog.run()
        if result == gtk.RESPONSE_OK:
            path = unicode(dialog.get_filename(), 'utf-8')
            try:
                _xpl.export_playlist(pl, path)
            except _xpl.InvalidPlaylistTypeException:
                path = path + ".m3u"
                try:
                    _xpl.export_playlist(pl, path)
                except _xpl.InvalidPlaylistTypeException:
                    dialogs.error(None,
                                  _('Invalid file extension, file not saved'))
        dialog.destroy()
コード例 #2
0
ファイル: __init__.py プロジェクト: lishuomountain/exaile-cn
    def export_current_playlist(self, *e):
        pl = self.main.get_current_playlist ().playlist
        name = pl.get_name() + ".m3u"

        dialog = dialogs.FileOperationDialog(_("Export Current Playlist"),
            None, gtk.FILE_CHOOSER_ACTION_SAVE,
            buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
            gtk.STOCK_SAVE, gtk.RESPONSE_OK))

        extensions = { 'm3u' : _('M3U Playlist'),
                       'pls' : _('PLS Playlist'),
                       'asx' : _('ASX Playlist'),
                       'xspf' : _('XSPF Playlist') }

        dialog.add_extensions(extensions)
        dialog.set_current_name (name)

        result = dialog.run()
        if result == gtk.RESPONSE_OK:
            path = unicode(dialog.get_filename(), 'utf-8')
            try:
                _xpl.export_playlist(pl, path)
            except _xpl.InvalidPlaylistTypeException:
                path = path + ".m3u"
                try:
                    _xpl.export_playlist(pl, path)
                except _xpl.InvalidPlaylistTypeException:
                    dialogs.error(None, _('Invalid file extension, file not saved'))
        dialog.destroy()
コード例 #3
0
    def ExportPlaylist(self, location):
        """
            Exports the current playlist
            to the specified location

            :param location: where to save the playlist at
            :type location: string
        """
        from xl import player, playlist

        if player.QUEUE.current_playlist is not None:
            playlist.export_playlist(player.QUEUE.current_playlist, location)
コード例 #4
0
ファイル: xldbus.py プロジェクト: exaile/exaile
    def ExportPlaylist(self, location):
        """
            Exports the current playlist
            to the specified location

            :param location: where to save the playlist at
            :type location: string
        """
        from xl import player, playlist

        if player.QUEUE.current_playlist is not None:
            playlist.export_playlist(player.QUEUE.current_playlist, location)
コード例 #5
0
    def on_response(self, dialog, response):
        """
            Exports the playlist if requested
        """
        self.hide()

        if response == gtk.RESPONSE_OK:
            path = unicode(self.get_uri(), 'utf-8')
            
            if not is_valid_playlist(path):
                path = '%s.m3u' % path

            options = PlaylistExportOptions(
                relative=self.relative_checkbox.get_active()
            )
            
            try:
                export_playlist(self.playlist, path, options)
            except InvalidPlaylistTypeError, e:
                self.emit('message', gtk.MESSAGE_ERROR, str(e))
            else:
                self.emit('message', gtk.MESSAGE_INFO,
                    _('Playlist saved as <b>%s</b>.') % path)