mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make quitting hopefully more robust on windows. Add code for loading fontconfig on BSD systems.
This commit is contained in:
parent
cb6599bbc1
commit
d3bd57de6e
@ -51,7 +51,7 @@ def get_font_path(name):
|
||||
font_mod = __import__('calibre.ebooks.lrf.fonts.prs500', {}, {},
|
||||
[fname], -1)
|
||||
getattr(font_mod, fname)
|
||||
except ImportError, AttributeError:
|
||||
except (ImportError, AttributeError):
|
||||
font_mod = __import__('calibre.ebooks.lrf.fonts.liberation', {}, {},
|
||||
[LIBERATION_FONT_MAP[name]], -1)
|
||||
p = PersistentTemporaryFile('.ttf', 'font_')
|
||||
|
@ -1424,7 +1424,12 @@ in which you want to store your books files. Any existing books will be automati
|
||||
self.memory_view.write_settings()
|
||||
|
||||
def quit(self, checked, restart=False):
|
||||
if self.shutdown():
|
||||
if not self.confirm_quit():
|
||||
return
|
||||
try:
|
||||
self.shutdown()
|
||||
except:
|
||||
pass
|
||||
self.restart_after_quit = restart
|
||||
QApplication.instance().quit()
|
||||
|
||||
@ -1457,22 +1462,26 @@ in which you want to store your books files. Any existing books will be automati
|
||||
QDesktopServices.openUrl(QUrl.fromLocalFile(pt.name))
|
||||
|
||||
|
||||
def shutdown(self):
|
||||
def confirm_quit(self):
|
||||
if self.job_manager.has_jobs():
|
||||
msg = _('There are active jobs. Are you sure you want to quit?')
|
||||
if self.job_manager.has_device_jobs():
|
||||
msg = '<p>'+__appname__ + _(''' is communicating with the device!<br>
|
||||
'Quitting may cause corruption on the device.<br>
|
||||
'Are you sure you want to quit?''')+'</p>'
|
||||
if self.job_manager.has_jobs():
|
||||
|
||||
d = QMessageBox(QMessageBox.Warning, _('WARNING: Active jobs'), msg,
|
||||
QMessageBox.Yes|QMessageBox.No, self)
|
||||
d.setIconPixmap(QPixmap(':/images/dialog_warning.svg'))
|
||||
d.setDefaultButton(QMessageBox.No)
|
||||
if d.exec_() != QMessageBox.Yes:
|
||||
return False
|
||||
return True
|
||||
|
||||
self.job_manager.terminate_all_jobs()
|
||||
|
||||
def shutdown(self):
|
||||
self.write_settings()
|
||||
self.job_manager.terminate_all_jobs()
|
||||
self.device_manager.keep_going = False
|
||||
self.cover_cache.stop()
|
||||
self.hide()
|
||||
@ -1498,7 +1507,11 @@ in which you want to store your books files. Any existing books will be automati
|
||||
self.hide()
|
||||
e.ignore()
|
||||
else:
|
||||
if self.shutdown():
|
||||
if self.confirm_quit():
|
||||
try:
|
||||
self.shutdown()
|
||||
except:
|
||||
pass
|
||||
e.accept()
|
||||
else:
|
||||
e.ignore()
|
||||
|
@ -22,7 +22,7 @@ match to a given font specification. The main functions in this module are:
|
||||
.. autofunction:: match
|
||||
'''
|
||||
|
||||
import sys, os, locale, codecs
|
||||
import sys, os, locale, codecs, subprocess, re
|
||||
from ctypes import cdll, c_void_p, Structure, c_int, POINTER, c_ubyte, c_char, util, \
|
||||
pointer, byref, create_string_buffer, Union, c_char_p, c_double
|
||||
|
||||
@ -58,6 +58,13 @@ def load_library():
|
||||
return cdll.LoadLibrary(lib)
|
||||
elif iswindows:
|
||||
return cdll.LoadLibrary('libfontconfig-1')
|
||||
elif isbsd:
|
||||
raw = subprocess.Popen('pkg-config --libs-only-L fontconfig'.split(),
|
||||
stdout=subprocess.PIPE).stdout.read().strip()
|
||||
match = re.search(r'-L([^\s,]+)', raw)
|
||||
if not match:
|
||||
return cdll.LoadLibrary('libfontconfig.so')
|
||||
return cdll.LoadLibrary(match.group(1)+'/libfontconfig.so')
|
||||
else:
|
||||
try:
|
||||
return cdll.LoadLibrary(util.find_library('fontconfig'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user