IGN:Various miscellaneous fixes.

This commit is contained in:
Kovid Goyal 2009-08-10 15:48:18 -06:00
parent efddafa088
commit bad5db6d57
5 changed files with 29 additions and 10 deletions

View File

@ -9,7 +9,7 @@ from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
ORG_NAME = 'KovidsBrain'
APP_UID = 'libprs500'
from calibre import islinux, iswindows
from calibre import islinux, iswindows, isosx
from calibre.startup import get_lang
from calibre.utils.config import Config, ConfigProxy, dynamic
import calibre.resources as resources
@ -110,7 +110,7 @@ class CopyButton(QPushButton):
def copied(self):
self.emit(SIGNAL('copy()'))
self.setDisabled(True)
self.setText(_('Copied to clipboard'))
self.setText(_('Copied'))
def keyPressEvent(self, ev):
@ -139,7 +139,7 @@ class MessageBox(QMessageBox):
self.det_msg = det_msg
self.setDetailedText(det_msg)
# Cannot set keyboard shortcut as the event is not easy to filter
self.cb = CopyButton(_('Copy to Clipboard'))
self.cb = CopyButton(_('Copy') if isosx else _('Copy to Clipboard'))
self.connect(self.cb, SIGNAL('copy()'), self.copy_to_clipboard)
self.addButton(self.cb, QMessageBox.ActionRole)
default_button = self.button(self.Ok)
@ -158,6 +158,7 @@ class MessageBox(QMessageBox):
def warning_dialog(parent, title, msg, det_msg='', show=False):
d = MessageBox(QMessageBox.Warning, 'WARNING: '+title, msg, QMessageBox.Ok,
parent, det_msg)
d.setEscapeButton(QMessageBox.Ok)
d.setIconPixmap(QPixmap(':/images/dialog_warning.svg'))
if show:
return d.exec_()
@ -167,6 +168,7 @@ def error_dialog(parent, title, msg, det_msg='', show=False):
d = MessageBox(QMessageBox.Critical, 'ERROR: '+title, msg, QMessageBox.Ok,
parent, det_msg)
d.setIconPixmap(QPixmap(':/images/dialog_error.svg'))
d.setEscapeButton(QMessageBox.Ok)
if show:
return d.exec_()
return d
@ -175,6 +177,7 @@ def question_dialog(parent, title, msg, det_msg=''):
d = MessageBox(QMessageBox.Question, title, msg, QMessageBox.Yes|QMessageBox.No,
parent, det_msg)
d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
d.setEscapeButton(QMessageBox.No)
return d.exec_() == QMessageBox.Yes
def info_dialog(parent, title, msg, det_msg='', show=False):

View File

@ -166,7 +166,8 @@ class PluginModel(QAbstractItemModel):
if index.internalId() == 0:
if role == Qt.DisplayRole:
category = self.categories[index.row()]
return QVariant(category + _(' plugins'))
return QVariant(_("%(plugin_type)s %(plugins)s")%\
dict(plugin_type=category, plugins=_('plugins')))
else:
plugin = self.index_to_plugin(index)
if role == Qt.DisplayRole:

View File

@ -1788,7 +1788,7 @@ def init_qt(args):
parser = option_parser()
opts, args = parser.parse_args(args)
if opts.with_library is not None and os.path.isdir(opts.with_library):
prefs.set('library_path', opts.with_library)
prefs.set('library_path', os.path.abspath(opts.with_library))
print 'Using library at', prefs['library_path']
app = Application(args)
actions = tuple(Main.create_application_menubar())

View File

@ -14,6 +14,7 @@ from calibre.ptempfile import PersistentTemporaryFile
if iswindows:
import win32process
_windows_null_file = open(os.devnull, 'wb')
class Worker(object):
'''
@ -149,9 +150,20 @@ class Worker(object):
self._file = PersistentTemporaryFile('_worker_redirect.log')
args['stdout'] = self._file._fd
args['stderr'] = subprocess.STDOUT
if iswindows:
args['stdin'] = subprocess.PIPE
ret = self._file.name
if iswindows and 'stdin' not in args:
# On windows when usingthepythonw interpreter,
# stdout, stderr and stdin may not be valid
args['stdin'] = subprocess.PIPE
args['stdout'] = _windows_null_file
args['stderr'] = subprocess.STDOUT
self.child = subprocess.Popen(cmd, **args)
if 'stdin' in args:
self.child.stdin.close()
self.log_path = ret
return ret

View File

@ -78,7 +78,8 @@ class ConnectedWorker(Thread):
self._returncode = r
return r
class CriticalError(Exception):
pass
class Server(Thread):
@ -112,6 +113,8 @@ class Server(Thread):
id = self.launched_worker_count
rfile = os.path.join(tempfile.gettempdir(),
'calibre_ipc_result_%d_%d.pickle'%(self.id, id))
if redirect_output is None:
redirect_output = not gui
env = {
'CALIBRE_WORKER_ADDRESS' :
@ -126,14 +129,12 @@ class Server(Thread):
if isinstance(cw, ConnectedWorker):
break
if isinstance(cw, basestring):
raise Exception('Failed to launch worker process:\n'+cw)
raise CriticalError('Failed to launch worker process:\n'+cw)
return cw
def do_launch(self, env, gui, redirect_output, rfile):
w = Worker(env, gui=gui)
if redirect_output is None:
redirect_output = not gui
try:
w(redirect_output=redirect_output)
conn = self.listener.accept()
@ -191,7 +192,9 @@ class Server(Thread):
if len(self.pool) + len(self.workers) < self.pool_size:
try:
self.pool.append(self.launch_worker())
except Exception, err:
except CriticalError:
raise
except Exception:
pass
if len(self.pool) > 0 and len(self.waiting_jobs) > 0: