mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
isosx -> ismacos
This commit is contained in:
parent
052af8c646
commit
13552bef07
@ -11,13 +11,13 @@ from contextlib import contextmanager
|
|||||||
|
|
||||||
is64bit = platform.architecture()[0] == '64bit'
|
is64bit = platform.architecture()[0] == '64bit'
|
||||||
iswindows = re.search('win(32|64)', sys.platform)
|
iswindows = re.search('win(32|64)', sys.platform)
|
||||||
isosx = 'darwin' in sys.platform
|
ismacos = 'darwin' in sys.platform
|
||||||
isfreebsd = 'freebsd' in sys.platform
|
isfreebsd = 'freebsd' in sys.platform
|
||||||
isnetbsd = 'netbsd' in sys.platform
|
isnetbsd = 'netbsd' in sys.platform
|
||||||
isdragonflybsd = 'dragonfly' in sys.platform
|
isdragonflybsd = 'dragonfly' in sys.platform
|
||||||
isbsd = isnetbsd or isfreebsd or isdragonflybsd
|
isbsd = isnetbsd or isfreebsd or isdragonflybsd
|
||||||
ishaiku = 'haiku1' in sys.platform
|
ishaiku = 'haiku1' in sys.platform
|
||||||
islinux = not isosx and not iswindows and not isbsd and not ishaiku
|
islinux = not ismacos and not iswindows and not isbsd and not ishaiku
|
||||||
sys.setup_dir = os.path.dirname(os.path.abspath(__file__))
|
sys.setup_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
SRC = os.path.abspath(os.path.join(os.path.dirname(sys.setup_dir), 'src'))
|
SRC = os.path.abspath(os.path.join(os.path.dirname(sys.setup_dir), 'src'))
|
||||||
sys.path.insert(0, SRC)
|
sys.path.insert(0, SRC)
|
||||||
@ -160,7 +160,7 @@ class Command(object):
|
|||||||
self.real_user = os.environ.get('SUDO_USER', None)
|
self.real_user = os.environ.get('SUDO_USER', None)
|
||||||
|
|
||||||
def drop_privileges(self):
|
def drop_privileges(self):
|
||||||
if not islinux or isosx or isfreebsd:
|
if not islinux or ismacos or isfreebsd:
|
||||||
return
|
return
|
||||||
if self.real_user is not None:
|
if self.real_user is not None:
|
||||||
self.info('Dropping privileges to those of', self.real_user+':',
|
self.info('Dropping privileges to those of', self.real_user+':',
|
||||||
@ -171,7 +171,7 @@ class Command(object):
|
|||||||
os.seteuid(int(self.real_uid))
|
os.seteuid(int(self.real_uid))
|
||||||
|
|
||||||
def regain_privileges(self):
|
def regain_privileges(self):
|
||||||
if not islinux or isosx or isfreebsd:
|
if not islinux or ismacos or isfreebsd:
|
||||||
return
|
return
|
||||||
if os.geteuid() != 0 and self.orig_euid == 0:
|
if os.geteuid() != 0 and self.orig_euid == 0:
|
||||||
self.info('Trying to get root privileges')
|
self.info('Trying to get root privileges')
|
||||||
|
@ -8,8 +8,8 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import textwrap, os, shlex, subprocess, glob, shutil, re, sys, json
|
import textwrap, os, shlex, subprocess, glob, shutil, re, sys, json
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from setup import Command, islinux, isbsd, isfreebsd, isosx, ishaiku, SRC, iswindows, __version__
|
from setup import Command, islinux, isbsd, isfreebsd, ismacos, ishaiku, SRC, iswindows, __version__
|
||||||
isunix = islinux or isosx or isbsd or ishaiku
|
isunix = islinux or ismacos or isbsd or ishaiku
|
||||||
|
|
||||||
py_lib = os.path.join(sys.prefix, 'libs', 'python%d%d.lib' % sys.version_info[:2])
|
py_lib = os.path.join(sys.prefix, 'libs', 'python%d%d.lib' % sys.version_info[:2])
|
||||||
CompileCommand = namedtuple('CompileCommand', 'cmd src dest')
|
CompileCommand = namedtuple('CompileCommand', 'cmd src dest')
|
||||||
@ -118,7 +118,7 @@ def parse_extension(ext):
|
|||||||
ans = ext.pop(k, default)
|
ans = ext.pop(k, default)
|
||||||
if iswindows:
|
if iswindows:
|
||||||
ans = ext.pop('windows_' + k, ans)
|
ans = ext.pop('windows_' + k, ans)
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
ans = ext.pop('osx_' + k, ans)
|
ans = ext.pop('osx_' + k, ans)
|
||||||
elif isbsd:
|
elif isbsd:
|
||||||
ans = ext.pop('bsd_' + k, ans)
|
ans = ext.pop('bsd_' + k, ans)
|
||||||
@ -192,7 +192,7 @@ def init_env():
|
|||||||
ldflags.append('-lpython{}{}'.format(
|
ldflags.append('-lpython{}{}'.format(
|
||||||
sysconfig.get_config_var('VERSION'), getattr(sys, 'abiflags', '')))
|
sysconfig.get_config_var('VERSION'), getattr(sys, 'abiflags', '')))
|
||||||
|
|
||||||
if isosx:
|
if ismacos:
|
||||||
cflags.append('-D_OSX')
|
cflags.append('-D_OSX')
|
||||||
ldflags.extend('-bundle -undefined dynamic_lookup'.split())
|
ldflags.extend('-bundle -undefined dynamic_lookup'.split())
|
||||||
cflags.extend(['-fno-common', '-dynamic'])
|
cflags.extend(['-fno-common', '-dynamic'])
|
||||||
@ -420,7 +420,7 @@ class Build(Command):
|
|||||||
'calibre/headless/headless_backingstore.cpp',
|
'calibre/headless/headless_backingstore.cpp',
|
||||||
'calibre/headless/headless_integration.cpp',
|
'calibre/headless/headless_integration.cpp',
|
||||||
])
|
])
|
||||||
if isosx:
|
if ismacos:
|
||||||
sources.extend(a(['calibre/headless/coretext_fontdatabase.mm']))
|
sources.extend(a(['calibre/headless/coretext_fontdatabase.mm']))
|
||||||
else:
|
else:
|
||||||
headers.extend(a(['calibre/headless/fontconfig_database.h']))
|
headers.extend(a(['calibre/headless/fontconfig_database.h']))
|
||||||
@ -462,7 +462,7 @@ class Build(Command):
|
|||||||
self.check_call([self.env.make] + ['-j%d'%(cpu_count or 1)])
|
self.check_call([self.env.make] + ['-j%d'%(cpu_count or 1)])
|
||||||
finally:
|
finally:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
if isosx:
|
if ismacos:
|
||||||
os.rename(self.j(self.d(target), 'libheadless.dylib'), self.j(self.d(target), 'headless.so'))
|
os.rename(self.j(self.d(target), 'libheadless.dylib'), self.j(self.d(target), 'headless.so'))
|
||||||
|
|
||||||
def get_sip_commands(self, ext):
|
def get_sip_commands(self, ext):
|
||||||
@ -524,7 +524,7 @@ class Build(Command):
|
|||||||
)
|
)
|
||||||
for incdir in ext.inc_dirs:
|
for incdir in ext.inc_dirs:
|
||||||
pro += '\nINCLUDEPATH += ' + incdir
|
pro += '\nINCLUDEPATH += ' + incdir
|
||||||
if not iswindows and not isosx:
|
if not iswindows and not ismacos:
|
||||||
# Ensure that only the init symbol is exported
|
# Ensure that only the init symbol is exported
|
||||||
pro += '\nQMAKE_LFLAGS += -Wl,--version-script=%s.exp' % sip['target']
|
pro += '\nQMAKE_LFLAGS += -Wl,--version-script=%s.exp' % sip['target']
|
||||||
with open(os.path.join(src_dir, sip['target'] + '.exp'), 'wb') as f:
|
with open(os.path.join(src_dir, sip['target'] + '.exp'), 'wb') as f:
|
||||||
@ -539,7 +539,7 @@ class Build(Command):
|
|||||||
qmc = []
|
qmc = []
|
||||||
if iswindows:
|
if iswindows:
|
||||||
qmc += ['-spec', qmakespec]
|
qmc += ['-spec', qmakespec]
|
||||||
fext = 'dll' if iswindows else 'dylib' if isosx else 'so'
|
fext = 'dll' if iswindows else 'dylib' if ismacos else 'so'
|
||||||
name = '%s%s.%s' % ('release/' if iswindows else 'lib', sip['target'], fext)
|
name = '%s%s.%s' % ('release/' if iswindows else 'lib', sip['target'], fext)
|
||||||
try:
|
try:
|
||||||
os.chdir(src_dir)
|
os.chdir(src_dir)
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, subprocess, re, sys, sysconfig
|
import os, subprocess, re, sys, sysconfig
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
|
|
||||||
from setup import isfreebsd, isosx, iswindows, is64bit, islinux, ishaiku
|
from setup import isfreebsd, ismacos, iswindows, is64bit, islinux, ishaiku
|
||||||
is64bit
|
is64bit
|
||||||
|
|
||||||
NMAKE = RC = msvc = MT = win_inc = win_lib = None
|
NMAKE = RC = msvc = MT = win_inc = win_lib = None
|
||||||
@ -162,7 +162,7 @@ if iswindows:
|
|||||||
zlib_lib_dirs = [sw_lib_dir]
|
zlib_lib_dirs = [sw_lib_dir]
|
||||||
podofo_inc = os.path.join(sw_inc_dir, 'podofo')
|
podofo_inc = os.path.join(sw_inc_dir, 'podofo')
|
||||||
podofo_lib = sw_lib_dir
|
podofo_lib = sw_lib_dir
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
sw = os.environ.get('SW', os.path.expanduser('~/sw'))
|
sw = os.environ.get('SW', os.path.expanduser('~/sw'))
|
||||||
sw_inc_dir = os.path.join(sw, 'include')
|
sw_inc_dir = os.path.join(sw, 'include')
|
||||||
sw_lib_dir = os.path.join(sw, 'lib')
|
sw_lib_dir = os.path.join(sw, 'lib')
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from setup import Command, islinux, isosx, iswindows, SRC
|
from setup import Command, islinux, ismacos, iswindows, SRC
|
||||||
|
|
||||||
TEST_MODULES = frozenset('srv db polish opf css docx cfi matcher icu smartypants build misc dbcli ebooks'.split())
|
TEST_MODULES = frozenset('srv db polish opf css docx cfi matcher icu smartypants build misc dbcli ebooks'.split())
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class TestImports(unittest.TestCase):
|
|||||||
if not iswindows:
|
if not iswindows:
|
||||||
exclude_modules |= {'calibre.utils.iphlpapi', 'calibre.utils.open_with.windows', 'calibre.devices.winusb'}
|
exclude_modules |= {'calibre.utils.iphlpapi', 'calibre.utils.open_with.windows', 'calibre.devices.winusb'}
|
||||||
exclude_packages |= {'calibre.utils.winreg'}
|
exclude_packages |= {'calibre.utils.winreg'}
|
||||||
if not isosx:
|
if not ismacos:
|
||||||
exclude_modules.add('calibre.utils.open_with.osx')
|
exclude_modules.add('calibre.utils.open_with.osx')
|
||||||
if not islinux:
|
if not islinux:
|
||||||
exclude_modules |= {
|
exclude_modules |= {
|
||||||
|
@ -16,7 +16,7 @@ try:
|
|||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
os.chdir(os.path.expanduser('~'))
|
os.chdir(os.path.expanduser('~'))
|
||||||
|
|
||||||
from calibre.constants import (iswindows, isosx, islinux, isfrozen,
|
from calibre.constants import (iswindows, ismacos, islinux, isfrozen,
|
||||||
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
||||||
win32event, win32api, winerror, fcntl,
|
win32event, win32api, winerror, fcntl,
|
||||||
filesystem_encoding, plugins, config_dir)
|
filesystem_encoding, plugins, config_dir)
|
||||||
@ -94,7 +94,7 @@ def unicode_path(path, abs=False):
|
|||||||
|
|
||||||
|
|
||||||
def osx_version():
|
def osx_version():
|
||||||
if isosx:
|
if ismacos:
|
||||||
import platform
|
import platform
|
||||||
src = platform.mac_ver()[0]
|
src = platform.mac_ver()[0]
|
||||||
m = re.match(r'(\d+)\.(\d+)\.(\d+)', src)
|
m = re.match(r'(\d+)\.(\d+)\.(\d+)', src)
|
||||||
@ -169,7 +169,7 @@ def setup_cli_handlers(logger, level):
|
|||||||
def load_library(name, cdll):
|
def load_library(name, cdll):
|
||||||
if iswindows:
|
if iswindows:
|
||||||
return cdll.LoadLibrary(name)
|
return cdll.LoadLibrary(name)
|
||||||
if isosx:
|
if ismacos:
|
||||||
name += '.dylib'
|
name += '.dylib'
|
||||||
if hasattr(sys, 'frameworks_dir'):
|
if hasattr(sys, 'frameworks_dir'):
|
||||||
return cdll.LoadLibrary(os.path.join(getattr(sys, 'frameworks_dir'), name))
|
return cdll.LoadLibrary(os.path.join(getattr(sys, 'frameworks_dir'), name))
|
||||||
|
@ -17,16 +17,16 @@ Various run time constants.
|
|||||||
|
|
||||||
_plat = sys.platform.lower()
|
_plat = sys.platform.lower()
|
||||||
iswindows = 'win32' in _plat or 'win64' in _plat
|
iswindows = 'win32' in _plat or 'win64' in _plat
|
||||||
isosx = 'darwin' in _plat
|
ismacos = isosx = 'darwin' in _plat
|
||||||
isnewosx = isosx and getattr(sys, 'new_app_bundle', False)
|
isnewosx = ismacos and getattr(sys, 'new_app_bundle', False)
|
||||||
isfreebsd = 'freebsd' in _plat
|
isfreebsd = 'freebsd' in _plat
|
||||||
isnetbsd = 'netbsd' in _plat
|
isnetbsd = 'netbsd' in _plat
|
||||||
isdragonflybsd = 'dragonfly' in _plat
|
isdragonflybsd = 'dragonfly' in _plat
|
||||||
isbsd = isfreebsd or isnetbsd or isdragonflybsd
|
isbsd = isfreebsd or isnetbsd or isdragonflybsd
|
||||||
ishaiku = 'haiku1' in _plat
|
ishaiku = 'haiku1' in _plat
|
||||||
islinux = not(iswindows or isosx or isbsd or ishaiku)
|
islinux = not(iswindows or ismacos or isbsd or ishaiku)
|
||||||
isfrozen = hasattr(sys, 'frozen')
|
isfrozen = hasattr(sys, 'frozen')
|
||||||
isunix = isosx or islinux or ishaiku
|
isunix = ismacos or islinux or ishaiku
|
||||||
isportable = hasenv('CALIBRE_PORTABLE_BUILD')
|
isportable = hasenv('CALIBRE_PORTABLE_BUILD')
|
||||||
ispy3 = sys.version_info.major > 2
|
ispy3 = sys.version_info.major > 2
|
||||||
isxp = isoldvista = False
|
isxp = isoldvista = False
|
||||||
@ -143,7 +143,7 @@ def _get_cache_dir():
|
|||||||
candidate = os.path.join(w.special_folder_path(w.CSIDL_LOCAL_APPDATA), '%s-cache'%__appname__)
|
candidate = os.path.join(w.special_folder_path(w.CSIDL_LOCAL_APPDATA), '%s-cache'%__appname__)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return confcache
|
return confcache
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
candidate = os.path.join(os.path.expanduser('~/Library/Caches'), __appname__)
|
candidate = os.path.join(os.path.expanduser('~/Library/Caches'), __appname__)
|
||||||
else:
|
else:
|
||||||
candidate = getenv('XDG_CACHE_HOME', '~/.cache')
|
candidate = getenv('XDG_CACHE_HOME', '~/.cache')
|
||||||
@ -203,10 +203,10 @@ class Plugins(collections.Mapping):
|
|||||||
]
|
]
|
||||||
if iswindows:
|
if iswindows:
|
||||||
plugins.extend(['winutil', 'wpd', 'winfonts'])
|
plugins.extend(['winutil', 'wpd', 'winfonts'])
|
||||||
if isosx:
|
if ismacos:
|
||||||
plugins.append('usbobserver')
|
plugins.append('usbobserver')
|
||||||
plugins.append('cocoa')
|
plugins.append('cocoa')
|
||||||
if isfreebsd or ishaiku or islinux or isosx:
|
if isfreebsd or ishaiku or islinux or ismacos:
|
||||||
plugins.append('libusb')
|
plugins.append('libusb')
|
||||||
plugins.append('libmtp')
|
plugins.append('libmtp')
|
||||||
self.plugins = frozenset(plugins)
|
self.plugins = frozenset(plugins)
|
||||||
@ -269,7 +269,7 @@ elif iswindows:
|
|||||||
if not config_dir or not os.access(config_dir, os.W_OK|os.X_OK):
|
if not config_dir or not os.access(config_dir, os.W_OK|os.X_OK):
|
||||||
config_dir = os.path.expanduser('~')
|
config_dir = os.path.expanduser('~')
|
||||||
config_dir = os.path.join(config_dir, 'calibre')
|
config_dir = os.path.join(config_dir, 'calibre')
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
config_dir = os.path.expanduser('~/Library/Preferences/calibre')
|
config_dir = os.path.expanduser('~/Library/Preferences/calibre')
|
||||||
else:
|
else:
|
||||||
bdir = os.path.abspath(os.path.expanduser(getenv('XDG_CONFIG_HOME', '~/.config')))
|
bdir = os.path.abspath(os.path.expanduser(getenv('XDG_CONFIG_HOME', '~/.config')))
|
||||||
|
@ -4,14 +4,14 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import os, sys, zipfile, importlib
|
import os, sys, zipfile, importlib
|
||||||
|
|
||||||
from calibre.constants import numeric_version, iswindows, isosx
|
from calibre.constants import numeric_version, iswindows, ismacos
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
platform = 'linux'
|
platform = 'linux'
|
||||||
if iswindows:
|
if iswindows:
|
||||||
platform = 'windows'
|
platform = 'windows'
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
platform = 'osx'
|
platform = 'osx'
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from contextlib import contextmanager
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import iswindows, isosx, filesystem_encoding
|
from calibre.constants import iswindows, ismacos, filesystem_encoding
|
||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ def metadata_extensions():
|
|||||||
return _metadata_extensions
|
return _metadata_extensions
|
||||||
|
|
||||||
|
|
||||||
if iswindows or isosx:
|
if iswindows or ismacos:
|
||||||
unicode_listdir = os.listdir
|
unicode_listdir = os.listdir
|
||||||
else:
|
else:
|
||||||
def unicode_listdir(root):
|
def unicode_listdir(root):
|
||||||
|
@ -8,7 +8,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import os, tempfile, shutil, errno, time, atexit
|
import os, tempfile, shutil, errno, time, atexit
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from calibre.constants import isosx, plugins
|
from calibre.constants import ismacos, plugins
|
||||||
from calibre.ptempfile import remove_dir
|
from calibre.ptempfile import remove_dir
|
||||||
from calibre.utils.filenames import remove_dir_if_empty
|
from calibre.utils.filenames import remove_dir_if_empty
|
||||||
from calibre.utils.recycle_bin import delete_tree, delete_file
|
from calibre.utils.recycle_bin import delete_tree, delete_file
|
||||||
@ -34,7 +34,7 @@ class DeleteService(Thread):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
self.requests = Queue()
|
self.requests = Queue()
|
||||||
if isosx:
|
if ismacos:
|
||||||
plugins['cocoa'][0].enable_cocoa_multithreading()
|
plugins['cocoa'][0].enable_cocoa_multithreading()
|
||||||
|
|
||||||
def shutdown(self, timeout=20):
|
def shutdown(self, timeout=20):
|
||||||
|
@ -181,7 +181,7 @@ def print_basic_debug_info(out=None):
|
|||||||
out = sys.stdout
|
out = sys.stdout
|
||||||
out = functools.partial(prints, file=out)
|
out = functools.partial(prints, file=out)
|
||||||
import platform
|
import platform
|
||||||
from calibre.constants import (__appname__, get_version, isportable, isosx,
|
from calibre.constants import (__appname__, get_version, isportable, ismacos,
|
||||||
isfrozen, is64bit)
|
isfrozen, is64bit)
|
||||||
from calibre.utils.localization import set_translators
|
from calibre.utils.localization import set_translators
|
||||||
out(__appname__, get_version(), 'Portable' if isportable else '',
|
out(__appname__, get_version(), 'Portable' if isportable else '',
|
||||||
@ -200,7 +200,7 @@ def print_basic_debug_info(out=None):
|
|||||||
try:
|
try:
|
||||||
if iswindows:
|
if iswindows:
|
||||||
out('Windows:', platform.win32_ver())
|
out('Windows:', platform.win32_ver())
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
out('OSX:', platform.mac_ver())
|
out('OSX:', platform.mac_ver())
|
||||||
else:
|
else:
|
||||||
out('Linux:', platform.linux_distribution())
|
out('Linux:', platform.linux_distribution())
|
||||||
|
@ -72,7 +72,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
|||||||
from calibre.customize.ui import device_plugins, disabled_device_plugins
|
from calibre.customize.ui import device_plugins, disabled_device_plugins
|
||||||
from calibre.debug import print_basic_debug_info
|
from calibre.debug import print_basic_debug_info
|
||||||
from calibre.devices.scanner import DeviceScanner
|
from calibre.devices.scanner import DeviceScanner
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, ismacos
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from polyglot.io import PolyglotStringIO
|
from polyglot.io import PolyglotStringIO
|
||||||
oldo, olde = sys.stdout, sys.stderr
|
oldo, olde = sys.stdout, sys.stderr
|
||||||
@ -108,7 +108,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
|||||||
out(pprint.pformat(devices))
|
out(pprint.pformat(devices))
|
||||||
|
|
||||||
ioreg = None
|
ioreg = None
|
||||||
if isosx:
|
if ismacos:
|
||||||
from calibre.devices.usbms.device import Device
|
from calibre.devices.usbms.device import Device
|
||||||
mount = '\n'.join(repr(x) for x in Device.osx_run_mount().splitlines())
|
mount = '\n'.join(repr(x) for x in Device.osx_run_mount().splitlines())
|
||||||
drives = pprint.pformat(Device.osx_get_usb_drives())
|
drives = pprint.pformat(Device.osx_get_usb_drives())
|
||||||
|
@ -11,7 +11,7 @@ from collections import namedtuple
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import prints, as_unicode, force_unicode
|
from calibre import prints, as_unicode, force_unicode
|
||||||
from calibre.constants import plugins, islinux, isosx
|
from calibre.constants import plugins, islinux, ismacos
|
||||||
from calibre.ptempfile import SpooledTemporaryFile
|
from calibre.ptempfile import SpooledTemporaryFile
|
||||||
from calibre.devices.errors import OpenFailed, DeviceError, BlacklistedDevice, OpenActionNeeded
|
from calibre.devices.errors import OpenFailed, DeviceError, BlacklistedDevice, OpenActionNeeded
|
||||||
from calibre.devices.mtp.base import MTPDeviceBase, synchronous, debug
|
from calibre.devices.mtp.base import MTPDeviceBase, synchronous, debug
|
||||||
@ -51,7 +51,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
if islinux:
|
if islinux:
|
||||||
from calibre.devices.mtp.unix.sysfs import MTPDetect
|
from calibre.devices.mtp.unix.sysfs import MTPDetect
|
||||||
self._is_device_mtp = MTPDetect()
|
self._is_device_mtp = MTPDetect()
|
||||||
if isosx and 'osx' in self.supported_platforms:
|
if ismacos and 'osx' in self.supported_platforms:
|
||||||
self.usbobserver, err = plugins['usbobserver']
|
self.usbobserver, err = plugins['usbobserver']
|
||||||
if err:
|
if err:
|
||||||
raise RuntimeError(err)
|
raise RuntimeError(err)
|
||||||
|
@ -11,7 +11,7 @@ from collections import namedtuple
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from calibre import prints, as_unicode
|
from calibre import prints, as_unicode
|
||||||
from calibre.constants import (iswindows, isosx, plugins, islinux, isfreebsd,
|
from calibre.constants import (iswindows, ismacos, plugins, islinux, isfreebsd,
|
||||||
isnetbsd)
|
isnetbsd)
|
||||||
from polyglot.builtins import range
|
from polyglot.builtins import range
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ if islinux:
|
|||||||
linux_scanner = LinuxScanner()
|
linux_scanner = LinuxScanner()
|
||||||
|
|
||||||
libusb_scanner = LibUSBScanner()
|
libusb_scanner = LibUSBScanner()
|
||||||
if False and isosx:
|
if False and ismacos:
|
||||||
# Apparently libusb causes mem leaks on some Macs and hangs on others and
|
# Apparently libusb causes mem leaks on some Macs and hangs on others and
|
||||||
# works on a few. OS X users will just have to live without MTP support.
|
# works on a few. OS X users will just have to live without MTP support.
|
||||||
# See https://bugs.launchpad.net/calibre/+bug/1044706
|
# See https://bugs.launchpad.net/calibre/+bug/1044706
|
||||||
@ -196,7 +196,7 @@ class DeviceScanner(object):
|
|||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
if iswindows:
|
if iswindows:
|
||||||
from calibre.devices.winusb import scan_usb_devices as win_scanner
|
from calibre.devices.winusb import scan_usb_devices as win_scanner
|
||||||
self.scanner = (win_scanner if iswindows else osx_scanner if isosx else
|
self.scanner = (win_scanner if iswindows else osx_scanner if ismacos else
|
||||||
freebsd_scanner if isfreebsd else netbsd_scanner if isnetbsd
|
freebsd_scanner if isfreebsd else netbsd_scanner if isnetbsd
|
||||||
else linux_scanner if islinux else libusb_scanner)
|
else linux_scanner if islinux else libusb_scanner)
|
||||||
if self.scanner is None:
|
if self.scanner is None:
|
||||||
|
@ -21,11 +21,11 @@ from calibre.constants import DEBUG
|
|||||||
from calibre.devices.interface import DevicePlugin
|
from calibre.devices.interface import DevicePlugin
|
||||||
from calibre.devices.errors import DeviceError
|
from calibre.devices.errors import DeviceError
|
||||||
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
||||||
from calibre.constants import iswindows, islinux, isosx, isfreebsd, plugins
|
from calibre.constants import iswindows, islinux, ismacos, isfreebsd, plugins
|
||||||
from calibre.utils.filenames import ascii_filename as sanitize
|
from calibre.utils.filenames import ascii_filename as sanitize
|
||||||
from polyglot.builtins import iteritems, string_or_bytes, map
|
from polyglot.builtins import iteritems, string_or_bytes, map
|
||||||
|
|
||||||
if isosx:
|
if ismacos:
|
||||||
usbobserver, usbobserver_err = plugins['usbobserver']
|
usbobserver, usbobserver_err = plugins['usbobserver']
|
||||||
osx_sanitize_name_pat = re.compile(r'[.-]')
|
osx_sanitize_name_pat = re.compile(r'[.-]')
|
||||||
|
|
||||||
@ -819,7 +819,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
self.open_freebsd()
|
self.open_freebsd()
|
||||||
if iswindows:
|
if iswindows:
|
||||||
self.open_windows()
|
self.open_windows()
|
||||||
if isosx:
|
if ismacos:
|
||||||
try:
|
try:
|
||||||
self.open_osx()
|
self.open_osx()
|
||||||
except DeviceError:
|
except DeviceError:
|
||||||
@ -891,7 +891,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
self.eject_windows()
|
self.eject_windows()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if isosx:
|
if ismacos:
|
||||||
try:
|
try:
|
||||||
self.eject_osx()
|
self.eject_osx()
|
||||||
except:
|
except:
|
||||||
|
@ -10,7 +10,7 @@ import re
|
|||||||
from struct import pack
|
from struct import pack
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, ismacos
|
||||||
from calibre.ebooks.mobi.utils import (utf8_text, to_base)
|
from calibre.ebooks.mobi.utils import (utf8_text, to_base)
|
||||||
from calibre.utils.localization import lang_as_iso639_1
|
from calibre.utils.localization import lang_as_iso639_1
|
||||||
from calibre.ebooks.metadata import authors_to_sort_string
|
from calibre.ebooks.metadata import authors_to_sort_string
|
||||||
@ -154,7 +154,7 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False,
|
|||||||
nrecs += 1
|
nrecs += 1
|
||||||
|
|
||||||
if be_kindlegen2:
|
if be_kindlegen2:
|
||||||
mv = 200 if iswindows else 202 if isosx else 201
|
mv = 200 if iswindows else 202 if ismacos else 201
|
||||||
vals = {204:mv, 205:2, 206:9, 207:0}
|
vals = {204:mv, 205:2, 206:9, 207:0}
|
||||||
elif is_periodical:
|
elif is_periodical:
|
||||||
# Pretend to be amazon's super secret periodical generator
|
# Pretend to be amazon's super secret periodical generator
|
||||||
|
@ -10,7 +10,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from calibre import CurrentDir, prints, xml_replace_entities
|
from calibre import CurrentDir, prints, xml_replace_entities
|
||||||
from calibre.constants import isbsd, islinux, isosx, iswindows
|
from calibre.constants import isbsd, islinux, ismacos, iswindows
|
||||||
from calibre.ebooks import ConversionError, DRMError
|
from calibre.ebooks import ConversionError, DRMError
|
||||||
from calibre.ebooks.chardet import xml_to_unicode
|
from calibre.ebooks.chardet import xml_to_unicode
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
@ -26,7 +26,7 @@ def popen(cmd, **kw):
|
|||||||
return subprocess.Popen(cmd, **kw)
|
return subprocess.Popen(cmd, **kw)
|
||||||
|
|
||||||
|
|
||||||
if isosx and hasattr(sys, 'frameworks_dir'):
|
if ismacos and hasattr(sys, 'frameworks_dir'):
|
||||||
base = os.path.join(os.path.dirname(sys.frameworks_dir), 'utils.app', 'Contents', 'MacOS')
|
base = os.path.join(os.path.dirname(sys.frameworks_dir), 'utils.app', 'Contents', 'MacOS')
|
||||||
PDFTOHTML = os.path.join(base, PDFTOHTML)
|
PDFTOHTML = os.path.join(base, PDFTOHTML)
|
||||||
if iswindows and hasattr(sys, 'frozen'):
|
if iswindows and hasattr(sys, 'frozen'):
|
||||||
|
@ -25,7 +25,7 @@ from PyQt5.QtWidgets import QStyle # Gives a nicer error message than import fr
|
|||||||
from calibre import as_unicode, prints
|
from calibre import as_unicode, prints
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
DEBUG, __appname__ as APP_UID, __version__, config_dir, filesystem_encoding,
|
DEBUG, __appname__ as APP_UID, __version__, config_dir, filesystem_encoding,
|
||||||
is_running_from_develop, isbsd, isfrozen, islinux, isosx, iswindows, isxp,
|
is_running_from_develop, isbsd, isfrozen, islinux, ismacos, iswindows, isxp,
|
||||||
plugins, plugins_loc
|
plugins, plugins_loc
|
||||||
)
|
)
|
||||||
from calibre.ebooks.metadata import MetaInformation
|
from calibre.ebooks.metadata import MetaInformation
|
||||||
@ -69,7 +69,7 @@ native_menubar_defaults = {
|
|||||||
|
|
||||||
def create_defs():
|
def create_defs():
|
||||||
defs = gprefs.defaults
|
defs = gprefs.defaults
|
||||||
if isosx:
|
if ismacos:
|
||||||
defs['action-layout-menubar'] = native_menubar_defaults['action-layout-menubar']
|
defs['action-layout-menubar'] = native_menubar_defaults['action-layout-menubar']
|
||||||
defs['action-layout-menubar-device'] = native_menubar_defaults['action-layout-menubar-device']
|
defs['action-layout-menubar-device'] = native_menubar_defaults['action-layout-menubar-device']
|
||||||
defs['action-layout-toolbar'] = (
|
defs['action-layout-toolbar'] = (
|
||||||
@ -147,7 +147,7 @@ def create_defs():
|
|||||||
defs['blocked_auto_formats'] = []
|
defs['blocked_auto_formats'] = []
|
||||||
defs['auto_add_auto_convert'] = True
|
defs['auto_add_auto_convert'] = True
|
||||||
defs['auto_add_everything'] = False
|
defs['auto_add_everything'] = False
|
||||||
defs['ui_style'] = 'calibre' if iswindows or isosx else 'system'
|
defs['ui_style'] = 'calibre' if iswindows or ismacos else 'system'
|
||||||
defs['tag_browser_old_look'] = False
|
defs['tag_browser_old_look'] = False
|
||||||
defs['tag_browser_hide_empty_categories'] = False
|
defs['tag_browser_hide_empty_categories'] = False
|
||||||
defs['tag_browser_always_autocollapse'] = False
|
defs['tag_browser_always_autocollapse'] = False
|
||||||
@ -663,7 +663,7 @@ if iswindows and 'CALIBRE_NO_NATIVE_FILEDIALOGS' not in os.environ:
|
|||||||
from calibre.gui2.win_file_dialogs import is_ok as has_windows_file_dialog_helper
|
from calibre.gui2.win_file_dialogs import is_ok as has_windows_file_dialog_helper
|
||||||
has_windows_file_dialog_helper = has_windows_file_dialog_helper()
|
has_windows_file_dialog_helper = has_windows_file_dialog_helper()
|
||||||
has_linux_file_dialog_helper = False
|
has_linux_file_dialog_helper = False
|
||||||
if not iswindows and not isosx and 'CALIBRE_NO_NATIVE_FILEDIALOGS' not in os.environ and getattr(sys, 'frozen', False):
|
if not iswindows and not ismacos and 'CALIBRE_NO_NATIVE_FILEDIALOGS' not in os.environ and getattr(sys, 'frozen', False):
|
||||||
has_linux_file_dialog_helper = check_for_linux_native_dialogs()
|
has_linux_file_dialog_helper = check_for_linux_native_dialogs()
|
||||||
|
|
||||||
if has_windows_file_dialog_helper:
|
if has_windows_file_dialog_helper:
|
||||||
@ -883,7 +883,7 @@ class Application(QApplication):
|
|||||||
self.pi, pi_err = plugins['progress_indicator']
|
self.pi, pi_err = plugins['progress_indicator']
|
||||||
if pi_err:
|
if pi_err:
|
||||||
raise RuntimeError('Failed to load the progress_indicator C extension, with error: {}'.format(pi_err))
|
raise RuntimeError('Failed to load the progress_indicator C extension, with error: {}'.format(pi_err))
|
||||||
if not isosx and not headless:
|
if not ismacos and not headless:
|
||||||
# On OS X high dpi scaling is turned on automatically by the OS, so we dont need to set it explicitly
|
# On OS X high dpi scaling is turned on automatically by the OS, so we dont need to set it explicitly
|
||||||
setup_hidpi()
|
setup_hidpi()
|
||||||
QApplication.setOrganizationName('calibre-ebook.com')
|
QApplication.setOrganizationName('calibre-ebook.com')
|
||||||
@ -897,7 +897,7 @@ class Application(QApplication):
|
|||||||
sh = self.styleHints()
|
sh = self.styleHints()
|
||||||
if hasattr(sh, 'setShowShortcutsInContextMenus'):
|
if hasattr(sh, 'setShowShortcutsInContextMenus'):
|
||||||
sh.setShowShortcutsInContextMenus(True)
|
sh.setShowShortcutsInContextMenus(True)
|
||||||
if isosx:
|
if ismacos:
|
||||||
plugins['cocoa'][0].disable_cocoa_ui_elements()
|
plugins['cocoa'][0].disable_cocoa_ui_elements()
|
||||||
self.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
self.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
||||||
self.setAttribute(Qt.AA_SynthesizeTouchForUnhandledMouseEvents, False)
|
self.setAttribute(Qt.AA_SynthesizeTouchForUnhandledMouseEvents, False)
|
||||||
@ -929,7 +929,7 @@ class Application(QApplication):
|
|||||||
if s is not None:
|
if s is not None:
|
||||||
font.setStretch(s)
|
font.setStretch(s)
|
||||||
QApplication.setFont(font)
|
QApplication.setFont(font)
|
||||||
if not isosx and not iswindows:
|
if not ismacos and not iswindows:
|
||||||
# Qt 5.10.1 on Linux resets the global font on first event loop tick.
|
# Qt 5.10.1 on Linux resets the global font on first event loop tick.
|
||||||
# So workaround it by setting the font once again in a timer.
|
# So workaround it by setting the font once again in a timer.
|
||||||
font_from_prefs = self.font()
|
font_from_prefs = self.font()
|
||||||
@ -947,7 +947,7 @@ class Application(QApplication):
|
|||||||
self._file_open_paths = []
|
self._file_open_paths = []
|
||||||
self._file_open_lock = RLock()
|
self._file_open_lock = RLock()
|
||||||
|
|
||||||
if not isosx:
|
if not ismacos:
|
||||||
# OS X uses a native color dialog that does not support custom
|
# OS X uses a native color dialog that does not support custom
|
||||||
# colors
|
# colors
|
||||||
self.color_prefs = color_prefs
|
self.color_prefs = color_prefs
|
||||||
@ -975,7 +975,7 @@ class Application(QApplication):
|
|||||||
# Qt 5 bug: https://bugreports.qt-project.org/browse/QTBUG-41125
|
# Qt 5 bug: https://bugreports.qt-project.org/browse/QTBUG-41125
|
||||||
self.aboutToQuit.connect(self.flush_clipboard)
|
self.aboutToQuit.connect(self.flush_clipboard)
|
||||||
|
|
||||||
if isosx:
|
if ismacos:
|
||||||
cocoa, err = plugins['cocoa']
|
cocoa, err = plugins['cocoa']
|
||||||
if err:
|
if err:
|
||||||
raise RuntimeError('Failed to load cocoa plugin with error: {}'.format(err))
|
raise RuntimeError('Failed to load cocoa plugin with error: {}'.format(err))
|
||||||
@ -1038,7 +1038,7 @@ class Application(QApplication):
|
|||||||
self.set_palette(dark_palette())
|
self.set_palette(dark_palette())
|
||||||
|
|
||||||
def setup_styles(self, force_calibre_style):
|
def setup_styles(self, force_calibre_style):
|
||||||
if iswindows or isosx:
|
if iswindows or ismacos:
|
||||||
using_calibre_style = gprefs['ui_style'] != 'system'
|
using_calibre_style = gprefs['ui_style'] != 'system'
|
||||||
else:
|
else:
|
||||||
using_calibre_style = os.environ.get('CALIBRE_USE_SYSTEM_THEME', '0') == '0'
|
using_calibre_style = os.environ.get('CALIBRE_USE_SYSTEM_THEME', '0') == '0'
|
||||||
@ -1047,7 +1047,7 @@ class Application(QApplication):
|
|||||||
if using_calibre_style:
|
if using_calibre_style:
|
||||||
use_dark_palette = False
|
use_dark_palette = False
|
||||||
if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
|
if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
|
||||||
if not isosx:
|
if not ismacos:
|
||||||
use_dark_palette = os.environ['CALIBRE_USE_DARK_PALETTE'] != '0'
|
use_dark_palette = os.environ['CALIBRE_USE_DARK_PALETTE'] != '0'
|
||||||
else:
|
else:
|
||||||
if iswindows:
|
if iswindows:
|
||||||
@ -1087,7 +1087,7 @@ class Application(QApplication):
|
|||||||
return
|
return
|
||||||
self.is_dark_theme = is_dark_theme()
|
self.is_dark_theme = is_dark_theme()
|
||||||
self.setProperty('is_dark_theme', self.is_dark_theme)
|
self.setProperty('is_dark_theme', self.is_dark_theme)
|
||||||
if isosx and self.is_dark_theme and self.using_calibre_style:
|
if ismacos and self.is_dark_theme and self.using_calibre_style:
|
||||||
QTimer.singleShot(0, self.fix_combobox_text_color)
|
QTimer.singleShot(0, self.fix_combobox_text_color)
|
||||||
if self.using_calibre_style:
|
if self.using_calibre_style:
|
||||||
ss = 'QTabBar::tab:selected { font-style: italic }\n\n'
|
ss = 'QTabBar::tab:selected { font-style: italic }\n\n'
|
||||||
@ -1132,7 +1132,7 @@ class Application(QApplication):
|
|||||||
v = pcache[v]
|
v = pcache[v]
|
||||||
icon_map[getattr(QStyle, 'SP_'+k)] = v
|
icon_map[getattr(QStyle, 'SP_'+k)] = v
|
||||||
transient_scroller = 0
|
transient_scroller = 0
|
||||||
if isosx:
|
if ismacos:
|
||||||
transient_scroller = plugins['cocoa'][0].transient_scroller()
|
transient_scroller = plugins['cocoa'][0].transient_scroller()
|
||||||
icon_map[QStyle.SP_CustomBase + 1] = I('close-for-light-theme.png')
|
icon_map[QStyle.SP_CustomBase + 1] = I('close-for-light-theme.png')
|
||||||
icon_map[QStyle.SP_CustomBase + 2] = I('close-for-dark-theme.png')
|
icon_map[QStyle.SP_CustomBase + 2] = I('close-for-dark-theme.png')
|
||||||
@ -1215,7 +1215,7 @@ def sanitize_env_vars():
|
|||||||
env_vars = {'LD_LIBRARY_PATH':'/lib'}
|
env_vars = {'LD_LIBRARY_PATH':'/lib'}
|
||||||
elif iswindows:
|
elif iswindows:
|
||||||
env_vars = {}
|
env_vars = {}
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
env_vars = {k:None for k in (
|
env_vars = {k:None for k in (
|
||||||
'FONTCONFIG_FILE FONTCONFIG_PATH SSL_CERT_FILE').split()}
|
'FONTCONFIG_FILE FONTCONFIG_PATH SSL_CERT_FILE').split()}
|
||||||
else:
|
else:
|
||||||
@ -1300,10 +1300,10 @@ def ensure_app(headless=True):
|
|||||||
with _ea_lock:
|
with _ea_lock:
|
||||||
if _store_app is None and QApplication.instance() is None:
|
if _store_app is None and QApplication.instance() is None:
|
||||||
args = sys.argv[:1]
|
args = sys.argv[:1]
|
||||||
has_headless = isosx or islinux or isbsd
|
has_headless = ismacos or islinux or isbsd
|
||||||
if headless and has_headless:
|
if headless and has_headless:
|
||||||
args += ['-platformpluginpath', plugins_loc, '-platform', 'headless']
|
args += ['-platformpluginpath', plugins_loc, '-platform', 'headless']
|
||||||
if isosx:
|
if ismacos:
|
||||||
os.environ['QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM'] = '1'
|
os.environ['QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM'] = '1'
|
||||||
if headless and iswindows:
|
if headless and iswindows:
|
||||||
QApplication.setAttribute(Qt.AA_UseSoftwareOpenGL, True)
|
QApplication.setAttribute(Qt.AA_UseSoftwareOpenGL, True)
|
||||||
|
@ -13,7 +13,7 @@ from PyQt5.Qt import (QToolButton, QAction, QIcon, QObject, QMenu,
|
|||||||
QKeySequence)
|
QKeySequence)
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import Dispatcher
|
from calibre.gui2 import Dispatcher
|
||||||
from calibre.gui2.keyboard import NameConflict
|
from calibre.gui2.keyboard import NameConflict
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
from polyglot.builtins import unicode_type, string_or_bytes
|
||||||
@ -201,7 +201,7 @@ class InterfaceAction(QObject):
|
|||||||
QKeySequence.PortableText) for key in keys])
|
QKeySequence.PortableText) for key in keys])
|
||||||
else:
|
else:
|
||||||
self.shortcut_action_for_context_menu = shortcut_action
|
self.shortcut_action_for_context_menu = shortcut_action
|
||||||
if isosx:
|
if ismacos:
|
||||||
# In Qt 5 keyboard shortcuts dont work unless the
|
# In Qt 5 keyboard shortcuts dont work unless the
|
||||||
# action is explicitly added to the main window
|
# action is explicitly added to the main window
|
||||||
self.gui.addAction(shortcut_action)
|
self.gui.addAction(shortcut_action)
|
||||||
|
@ -18,7 +18,7 @@ from PyQt5.Qt import (
|
|||||||
QScrollArea, QVBoxLayout, Qt, QListWidgetItem, QListWidget, QSize)
|
QScrollArea, QVBoxLayout, Qt, QListWidgetItem, QListWidget, QSize)
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2 import (error_dialog, Dispatcher, warning_dialog, gprefs,
|
from calibre.gui2 import (error_dialog, Dispatcher, warning_dialog, gprefs,
|
||||||
info_dialog, choose_dir)
|
info_dialog, choose_dir)
|
||||||
@ -374,7 +374,7 @@ class CopyToLibraryAction(InterfaceAction):
|
|||||||
self.menu.addAction(_('Choose library...'), self.choose_library)
|
self.menu.addAction(_('Choose library...'), self.choose_library)
|
||||||
|
|
||||||
self.qaction.setVisible(bool(locations))
|
self.qaction.setVisible(bool(locations))
|
||||||
if isosx:
|
if ismacos:
|
||||||
# The cloned action has to have its menu updated
|
# The cloned action has to have its menu updated
|
||||||
self.qaction.changed.emit()
|
self.qaction.changed.emit()
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from collections import Counter
|
|||||||
|
|
||||||
from PyQt5.Qt import QObject, QTimer, QModelIndex
|
from PyQt5.Qt import QObject, QTimer, QModelIndex
|
||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import error_dialog, question_dialog
|
from calibre.gui2 import error_dialog, question_dialog
|
||||||
from calibre.gui2.dialogs.delete_matching_from_device import DeleteMatchingFromDeviceDialog
|
from calibre.gui2.dialogs.delete_matching_from_device import DeleteMatchingFromDeviceDialog
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
@ -87,7 +87,7 @@ class MultiDeleter(QObject): # {{{
|
|||||||
class DeleteAction(InterfaceAction):
|
class DeleteAction(InterfaceAction):
|
||||||
|
|
||||||
name = 'Remove Books'
|
name = 'Remove Books'
|
||||||
action_spec = (_('Remove books'), 'remove_books.png', _('Delete books'), 'Backspace' if isosx else 'Del')
|
action_spec = (_('Remove books'), 'remove_books.png', _('Delete books'), 'Backspace' if ismacos else 'Del')
|
||||||
action_type = 'current'
|
action_type = 'current'
|
||||||
action_add_menu = True
|
action_add_menu = True
|
||||||
action_menu_clone_qaction = _('Remove selected books')
|
action_menu_clone_qaction = _('Remove selected books')
|
||||||
|
@ -13,7 +13,7 @@ from PyQt5.Qt import QIcon, Qt
|
|||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.preferences.main import Preferences
|
from calibre.gui2.preferences.main import Preferences
|
||||||
from calibre.gui2 import error_dialog, show_restart_warning
|
from calibre.gui2 import error_dialog, show_restart_warning
|
||||||
from calibre.constants import DEBUG, isosx
|
from calibre.constants import DEBUG, ismacos
|
||||||
|
|
||||||
|
|
||||||
class PreferencesAction(InterfaceAction):
|
class PreferencesAction(InterfaceAction):
|
||||||
@ -26,7 +26,7 @@ class PreferencesAction(InterfaceAction):
|
|||||||
def genesis(self):
|
def genesis(self):
|
||||||
pm = self.qaction.menu()
|
pm = self.qaction.menu()
|
||||||
cm = partial(self.create_menu_action, pm)
|
cm = partial(self.create_menu_action, pm)
|
||||||
if isosx:
|
if ismacos:
|
||||||
pm.addAction(QIcon(I('config.png')), _('Preferences'), self.do_config)
|
pm.addAction(QIcon(I('config.png')), _('Preferences'), self.do_config)
|
||||||
cm('welcome wizard', _('Run Welcome wizard'),
|
cm('welcome wizard', _('Run Welcome wizard'),
|
||||||
icon='wizard.png', triggered=self.gui.run_wizard)
|
icon='wizard.png', triggered=self.gui.run_wizard)
|
||||||
|
@ -12,7 +12,7 @@ from PyQt5.Qt import (QDialog, QVBoxLayout, QHBoxLayout, QRadioButton, QFrame,
|
|||||||
QPushButton, QLabel, QGroupBox, QGridLayout, QIcon, QSize, QTimer)
|
QPushButton, QLabel, QGroupBox, QGridLayout, QIcon, QSize, QTimer)
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import error_dialog, question_dialog, open_local_file, gprefs
|
from calibre.gui2 import error_dialog, question_dialog, open_local_file, gprefs
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.ptempfile import (PersistentTemporaryDirectory,
|
from calibre.ptempfile import (PersistentTemporaryDirectory,
|
||||||
@ -255,7 +255,7 @@ class UnpackBook(QDialog):
|
|||||||
self.reject()
|
self.reject()
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
if isosx and self._exploded:
|
if ismacos and self._exploded:
|
||||||
try:
|
try:
|
||||||
import appscript
|
import appscript
|
||||||
self.finder = appscript.app('Finder')
|
self.finder = appscript.app('Finder')
|
||||||
|
@ -11,7 +11,7 @@ from functools import partial
|
|||||||
|
|
||||||
from PyQt5.Qt import Qt, QAction, pyqtSignal
|
from PyQt5.Qt import Qt, QAction, pyqtSignal
|
||||||
|
|
||||||
from calibre.constants import isosx, iswindows, plugins
|
from calibre.constants import ismacos, iswindows, plugins
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
error_dialog, Dispatcher, question_dialog, config, open_local_file,
|
error_dialog, Dispatcher, question_dialog, config, open_local_file,
|
||||||
info_dialog, elided_text)
|
info_dialog, elided_text)
|
||||||
@ -135,7 +135,7 @@ class ViewAction(InterfaceAction):
|
|||||||
try:
|
try:
|
||||||
if internal:
|
if internal:
|
||||||
args = [viewer]
|
args = [viewer]
|
||||||
if isosx and 'ebook' in viewer:
|
if ismacos and 'ebook' in viewer:
|
||||||
args.append('--raise-window')
|
args.append('--raise-window')
|
||||||
|
|
||||||
if name is not None:
|
if name is not None:
|
||||||
@ -247,7 +247,7 @@ class ViewAction(InterfaceAction):
|
|||||||
for i, row in enumerate(rows):
|
for i, row in enumerate(rows):
|
||||||
path = self.gui.library_view.model().db.abspath(row.row())
|
path = self.gui.library_view.model().db.abspath(row.row())
|
||||||
open_local_file(path)
|
open_local_file(path)
|
||||||
if isosx and i < len(rows) - 1:
|
if ismacos and i < len(rows) - 1:
|
||||||
time.sleep(0.1) # Finder cannot handle multiple folder opens
|
time.sleep(0.1) # Finder cannot handle multiple folder opens
|
||||||
|
|
||||||
def view_folder_for_id(self, id_):
|
def view_folder_for_id(self, id_):
|
||||||
|
@ -14,7 +14,7 @@ from polyglot.builtins import iteritems, map, unicode_type, string_or_bytes
|
|||||||
from PyQt5.Qt import QObject, Qt, pyqtSignal
|
from PyQt5.Qt import QObject, Qt, pyqtSignal
|
||||||
|
|
||||||
from calibre import prints, as_unicode
|
from calibre import prints, as_unicode
|
||||||
from calibre.constants import DEBUG, iswindows, isosx, filesystem_encoding
|
from calibre.constants import DEBUG, iswindows, ismacos, filesystem_encoding
|
||||||
from calibre.customize.ui import run_plugins_on_postimport, run_plugins_on_postadd
|
from calibre.customize.ui import run_plugins_on_postimport, run_plugins_on_postadd
|
||||||
from calibre.db.adding import find_books_in_directory, compile_rule
|
from calibre.db.adding import find_books_in_directory, compile_rule
|
||||||
from calibre.db.utils import find_identical_books
|
from calibre.db.utils import find_identical_books
|
||||||
@ -134,7 +134,7 @@ class Adder(QObject):
|
|||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
if iswindows or isosx:
|
if iswindows or ismacos:
|
||||||
def find_files(root):
|
def find_files(root):
|
||||||
for dirpath, dirnames, filenames in os.walk(root):
|
for dirpath, dirnames, filenames in os.walk(root):
|
||||||
for files in find_books_in_directory(dirpath, self.single_book_per_directory, compiled_rules=compiled_rules):
|
for files in find_books_in_directory(dirpath, self.single_book_per_directory, compiled_rules=compiled_rules):
|
||||||
|
@ -15,7 +15,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import sip
|
import sip
|
||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import gprefs, native_menubar_defaults, config
|
from calibre.gui2 import gprefs, native_menubar_defaults, config
|
||||||
from calibre.gui2.throbber import ThrobbingButton
|
from calibre.gui2.throbber import ThrobbingButton
|
||||||
from polyglot.builtins import itervalues, unicode_type, map, range
|
from polyglot.builtins import itervalues, unicode_type, map, range
|
||||||
@ -334,7 +334,7 @@ class MenuAction(QAction): # {{{
|
|||||||
# MenuBar {{{
|
# MenuBar {{{
|
||||||
|
|
||||||
|
|
||||||
if isosx:
|
if ismacos:
|
||||||
# On OS X we need special handling for the application global menu bar and
|
# On OS X we need special handling for the application global menu bar and
|
||||||
# the context menus, since Qt does not handle dynamic menus or menus in
|
# the context menus, since Qt does not handle dynamic menus or menus in
|
||||||
# which the same action occurs in more than one place.
|
# which the same action occurs in more than one place.
|
||||||
@ -617,11 +617,11 @@ class AdaptMenuBarForDialog(object):
|
|||||||
self.menu_bar = menu_bar
|
self.menu_bar = menu_bar
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
if isosx and self.menu_bar.is_native_menubar:
|
if ismacos and self.menu_bar.is_native_menubar:
|
||||||
self.menu_bar.adapt_for_dialog(True)
|
self.menu_bar.adapt_for_dialog(True)
|
||||||
|
|
||||||
def __exit__(self, *a):
|
def __exit__(self, *a):
|
||||||
if isosx and self.menu_bar.is_native_menubar:
|
if ismacos and self.menu_bar.is_native_menubar:
|
||||||
self.menu_bar.adapt_for_dialog(False)
|
self.menu_bar.adapt_for_dialog(False)
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
from PyQt5.Qt import QWidget, QListWidgetItem, Qt, QVBoxLayout, QLabel, QListWidget
|
from PyQt5.Qt import QWidget, QListWidgetItem, Qt, QVBoxLayout, QLabel, QListWidget
|
||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.ui import get_gui
|
from calibre.gui2.ui import get_gui
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
@ -53,7 +53,7 @@ class PluginWidget(QWidget):
|
|||||||
l.addWidget(la)
|
l.addWidget(la)
|
||||||
self.db_fields.setDragEnabled(True)
|
self.db_fields.setDragEnabled(True)
|
||||||
self.db_fields.setDragDropMode(QListWidget.InternalMove)
|
self.db_fields.setDragDropMode(QListWidget.InternalMove)
|
||||||
self.db_fields.setDefaultDropAction(Qt.CopyAction if isosx else Qt.MoveAction)
|
self.db_fields.setDefaultDropAction(Qt.CopyAction if ismacos else Qt.MoveAction)
|
||||||
self.db_fields.setAlternatingRowColors(True)
|
self.db_fields.setAlternatingRowColors(True)
|
||||||
self.db_fields.setObjectName("db_fields")
|
self.db_fields.setObjectName("db_fields")
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import sip
|
import sip
|
||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.utils.icu import sort_key, primary_startswith, primary_contains
|
from calibre.utils.icu import sort_key, primary_startswith, primary_contains
|
||||||
from calibre.gui2.widgets import EnComboBox, LineEditECM
|
from calibre.gui2.widgets import EnComboBox, LineEditECM
|
||||||
from calibre.utils.config import tweaks
|
from calibre.utils.config import tweaks
|
||||||
@ -250,7 +250,7 @@ class Completer(QListView): # {{{
|
|||||||
self.hide()
|
self.hide()
|
||||||
if e.isAccepted():
|
if e.isAccepted():
|
||||||
return True
|
return True
|
||||||
elif isosx and etype == e.InputMethodQuery and e.queries() == (Qt.ImHints | Qt.ImEnabled) and self.isVisible():
|
elif ismacos and etype == e.InputMethodQuery and e.queries() == (Qt.ImHints | Qt.ImEnabled) and self.isVisible():
|
||||||
# In Qt 5 the Esc key causes this event and the line edit does not
|
# In Qt 5 the Esc key causes this event and the line edit does not
|
||||||
# handle it, which causes the parent dialog to be closed
|
# handle it, which causes the parent dialog to be closed
|
||||||
# See https://bugreports.qt-project.org/browse/QTBUG-41806
|
# See https://bugreports.qt-project.org/browse/QTBUG-41806
|
||||||
|
@ -10,7 +10,7 @@ import time, sys, weakref
|
|||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QObject, QMenuBar, QAction, QEvent, QSystemTrayIcon, QApplication, Qt)
|
QObject, QMenuBar, QAction, QEvent, QSystemTrayIcon, QApplication, Qt)
|
||||||
|
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, ismacos
|
||||||
from polyglot.builtins import range, unicode_type
|
from polyglot.builtins import range, unicode_type
|
||||||
|
|
||||||
UNITY_WINDOW_REGISTRAR = ('com.canonical.AppMenu.Registrar', '/com/canonical/AppMenu/Registrar', 'com.canonical.AppMenu.Registrar')
|
UNITY_WINDOW_REGISTRAR = ('com.canonical.AppMenu.Registrar', '/com/canonical/AppMenu/Registrar', 'com.canonical.AppMenu.Registrar')
|
||||||
@ -117,7 +117,7 @@ class Factory(QObject):
|
|||||||
def __init__(self, app_id=None):
|
def __init__(self, app_id=None):
|
||||||
QObject.__init__(self)
|
QObject.__init__(self)
|
||||||
self.app_id = app_id or QApplication.instance().applicationName() or 'unknown_application'
|
self.app_id = app_id or QApplication.instance().applicationName() or 'unknown_application'
|
||||||
if iswindows or isosx:
|
if iswindows or ismacos:
|
||||||
self.dbus = None
|
self.dbus = None
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@ -228,7 +228,7 @@ class Factory(QObject):
|
|||||||
self.prune_dead_refs()
|
self.prune_dead_refs()
|
||||||
self.status_notifiers.append(weakref.ref(ans))
|
self.status_notifiers.append(weakref.ref(ans))
|
||||||
return ans
|
return ans
|
||||||
if iswindows or isosx:
|
if iswindows or ismacos:
|
||||||
return QSystemTrayIcon(parent)
|
return QSystemTrayIcon(parent)
|
||||||
|
|
||||||
def bus_disconnected(self):
|
def bus_disconnected(self):
|
||||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (Qt, QUrl, QFrame, QVBoxLayout, QLabel, QBrush, QTextEdit,
|
|||||||
QFont, QPixmap, QSize, QLineEdit)
|
QFont, QPixmap, QSize, QLineEdit)
|
||||||
|
|
||||||
from calibre import browser, prints
|
from calibre import browser, prints
|
||||||
from calibre.constants import numeric_version, iswindows, isosx, DEBUG, __appname__, __version__
|
from calibre.constants import numeric_version, iswindows, ismacos, DEBUG, __appname__, __version__
|
||||||
from calibre.customize.ui import (
|
from calibre.customize.ui import (
|
||||||
initialized_plugins, is_disabled, remove_plugin, add_plugin, enable_plugin, disable_plugin,
|
initialized_plugins, is_disabled, remove_plugin, add_plugin, enable_plugin, disable_plugin,
|
||||||
NameConflict, has_external_plugins)
|
NameConflict, has_external_plugins)
|
||||||
@ -229,7 +229,7 @@ class DisplayPlugin(object):
|
|||||||
def is_valid_platform(self):
|
def is_valid_platform(self):
|
||||||
if iswindows:
|
if iswindows:
|
||||||
return 'windows' in self.platforms
|
return 'windows' in self.platforms
|
||||||
if isosx:
|
if ismacos:
|
||||||
return 'osx' in self.platforms
|
return 'osx' in self.platforms
|
||||||
return 'linux' in self.platforms
|
return 'linux' in self.platforms
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from PyQt5.Qt import (
|
|||||||
QToolButton, QVBoxLayout, QWidget
|
QToolButton, QVBoxLayout, QWidget
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.constants import __appname__, get_version, isosx
|
from calibre.constants import __appname__, get_version, ismacos
|
||||||
from calibre.customize.ui import find_plugin
|
from calibre.customize.ui import find_plugin
|
||||||
from calibre.gui2 import config, error_dialog, gprefs, is_widescreen, open_url
|
from calibre.gui2 import config, error_dialog, gprefs, is_widescreen, open_url
|
||||||
from calibre.gui2.book_details import BookDetails
|
from calibre.gui2.book_details import BookDetails
|
||||||
@ -618,7 +618,7 @@ class LayoutMixin(object): # {{{
|
|||||||
button = self.search_bar_button
|
button = self.search_bar_button
|
||||||
self.layout_buttons.append(button)
|
self.layout_buttons.append(button)
|
||||||
button.setVisible(False)
|
button.setVisible(False)
|
||||||
if isosx and stylename != 'Calibre':
|
if ismacos and stylename != 'Calibre':
|
||||||
button.setStyleSheet('''
|
button.setStyleSheet('''
|
||||||
QToolButton { background: none; border:none; padding: 0px; }
|
QToolButton { background: none; border:none; padding: 0px; }
|
||||||
QToolButton:checked { background: rgba(0, 0, 0, 25%); }
|
QToolButton:checked { background: rgba(0, 0, 0, 25%); }
|
||||||
|
@ -16,7 +16,7 @@ from PyQt5.Qt import QCoreApplication, QIcon, QObject, QTimer
|
|||||||
from calibre import force_unicode, plugins, prints
|
from calibre import force_unicode, plugins, prints
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
DEBUG, MAIN_APP_UID, __appname__, filesystem_encoding, get_portable_base,
|
DEBUG, MAIN_APP_UID, __appname__, filesystem_encoding, get_portable_base,
|
||||||
islinux, isosx, iswindows
|
islinux, ismacos, iswindows
|
||||||
)
|
)
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
Application, choose_dir, error_dialog, gprefs, initialize_file_icon_provider,
|
Application, choose_dir, error_dialog, gprefs, initialize_file_icon_provider,
|
||||||
@ -382,7 +382,7 @@ def run_gui(opts, args, listener, app, gui_debug=None):
|
|||||||
wizard().exec_()
|
wizard().exec_()
|
||||||
dynamic.set('welcome_wizard_was_run', True)
|
dynamic.set('welcome_wizard_was_run', True)
|
||||||
from calibre.gui2.ui import Main
|
from calibre.gui2.ui import Main
|
||||||
if isosx:
|
if ismacos:
|
||||||
actions = tuple(Main.create_application_menubar())
|
actions = tuple(Main.create_application_menubar())
|
||||||
else:
|
else:
|
||||||
actions = tuple(Main.get_menubar_actions())
|
actions = tuple(Main.get_menubar_actions())
|
||||||
@ -446,7 +446,7 @@ def cant_start(msg=_('If you are sure it is not running')+', ',
|
|||||||
listener_failed=False):
|
listener_failed=False):
|
||||||
base = '<p>%s</p><p>%s %s'
|
base = '<p>%s</p><p>%s %s'
|
||||||
where = __appname__ + ' '+_('may be running in the system tray, in the')+' '
|
where = __appname__ + ' '+_('may be running in the system tray, in the')+' '
|
||||||
if isosx:
|
if ismacos:
|
||||||
where += _('upper right region of the screen.')
|
where += _('upper right region of the screen.')
|
||||||
else:
|
else:
|
||||||
where += _('lower right region of the screen.')
|
where += _('lower right region of the screen.')
|
||||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton, QAppli
|
|||||||
QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem, QInputDialog,
|
QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem, QInputDialog,
|
||||||
QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut, QDialog)
|
QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut, QDialog)
|
||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.ebooks.metadata import authors_to_string, string_to_authors
|
from calibre.ebooks.metadata import authors_to_string, string_to_authors
|
||||||
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data
|
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data
|
||||||
@ -158,7 +158,7 @@ class MetadataSingleDialogBase(QDialog):
|
|||||||
'change author sort from red to green. There is a menu of '
|
'change author sort from red to green. There is a menu of '
|
||||||
'functions available under this button. Click and hold '
|
'functions available under this button. Click and hold '
|
||||||
'on the button to see it.') + '</p>')
|
'on the button to see it.') + '</p>')
|
||||||
if isosx:
|
if ismacos:
|
||||||
# Workaround for https://bugreports.qt-project.org/browse/QTBUG-41017
|
# Workaround for https://bugreports.qt-project.org/browse/QTBUG-41017
|
||||||
class Menu(QMenu):
|
class Menu(QMenu):
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import islinux, isosx, get_osx_version, DEBUG, plugins
|
from calibre.constants import islinux, ismacos, get_osx_version, DEBUG, plugins
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ class QtNotifier(Notifier):
|
|||||||
try:
|
try:
|
||||||
if not isinstance(body, unicode_type):
|
if not isinstance(body, unicode_type):
|
||||||
body = body.decode('utf-8')
|
body = body.decode('utf-8')
|
||||||
if isosx and not self.systray.isVisible():
|
if ismacos and not self.systray.isVisible():
|
||||||
self.systray.show()
|
self.systray.show()
|
||||||
hide = True
|
hide = True
|
||||||
self.systray.showMessage(summary, body, self.systray.Information,
|
self.systray.showMessage(summary, body, self.systray.Information,
|
||||||
@ -161,7 +161,7 @@ def get_notifier(systray=None):
|
|||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
ans = None
|
ans = None
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
if get_osx_version() >= (10, 8, 0):
|
if get_osx_version() >= (10, 8, 0):
|
||||||
ans = AppleNotifier()
|
ans = AppleNotifier()
|
||||||
if not ans.ok:
|
if not ans.ok:
|
||||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (
|
|||||||
QBuffer, QPixmap, QAction, QKeySequence)
|
QBuffer, QPixmap, QAction, QKeySequence)
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, ismacos
|
||||||
from calibre.gui2 import error_dialog, choose_files, choose_images, elided_text, sanitize_env_vars, Application, choose_osx_app
|
from calibre.gui2 import error_dialog, choose_files, choose_images, elided_text, sanitize_env_vars, Application, choose_osx_app
|
||||||
from calibre.gui2.widgets2 import Dialog
|
from calibre.gui2.widgets2 import Dialog
|
||||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||||
@ -146,7 +146,7 @@ if iswindows:
|
|||||||
det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
|
det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
# macOS {{{
|
# macOS {{{
|
||||||
oprefs = JSONConfig('osx_open_with')
|
oprefs = JSONConfig('osx_open_with')
|
||||||
from calibre.utils.open_with.osx import find_programs, get_icon, entry_to_cmdline, get_bundle_data
|
from calibre.utils.open_with.osx import find_programs, get_icon, entry_to_cmdline, get_bundle_data
|
||||||
|
@ -20,7 +20,7 @@ from PyQt5.Qt import (
|
|||||||
|
|
||||||
from calibre import human_readable
|
from calibre import human_readable
|
||||||
from calibre.ebooks.metadata.book.render import DEFAULT_AUTHOR_LINK
|
from calibre.ebooks.metadata.book.render import DEFAULT_AUTHOR_LINK
|
||||||
from calibre.constants import isosx, iswindows
|
from calibre.constants import ismacos, iswindows
|
||||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||||
from calibre.gui2 import default_author_link
|
from calibre.gui2 import default_author_link
|
||||||
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
||||||
@ -383,7 +383,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
|
|
||||||
def genesis(self, gui):
|
def genesis(self, gui):
|
||||||
self.gui = gui
|
self.gui = gui
|
||||||
if not isosx and not iswindows:
|
if not ismacos and not iswindows:
|
||||||
self.label_widget_style.setVisible(False)
|
self.label_widget_style.setVisible(False)
|
||||||
self.opt_ui_style.setVisible(False)
|
self.opt_ui_style.setVisible(False)
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.default_author_link.changed_signal.connect(self.changed_signal)
|
self.default_author_link.changed_signal.connect(self.changed_signal)
|
||||||
r('gui_layout', config, restart_required=True, choices=[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')])
|
r('gui_layout', config, restart_required=True, choices=[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')])
|
||||||
r('hidpi', gprefs, restart_required=True, choices=[(_('Automatic'), 'auto'), (_('On'), 'on'), (_('Off'), 'off')])
|
r('hidpi', gprefs, restart_required=True, choices=[(_('Automatic'), 'auto'), (_('On'), 'on'), (_('Off'), 'off')])
|
||||||
if isosx:
|
if ismacos:
|
||||||
self.opt_hidpi.setVisible(False), self.label_hidpi.setVisible(False)
|
self.opt_hidpi.setVisible(False), self.label_hidpi.setVisible(False)
|
||||||
r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')])
|
r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')])
|
||||||
r('book_list_tooltips', gprefs)
|
r('book_list_tooltips', gprefs)
|
||||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (
|
|||||||
QToolButton, QIcon, QHBoxLayout, QPushButton, QListWidget, QListWidgetItem,
|
QToolButton, QIcon, QHBoxLayout, QPushButton, QListWidget, QListWidgetItem,
|
||||||
QGridLayout, QPlainTextEdit, QLabel, QFrame, QDialog, QDialogButtonBox)
|
QGridLayout, QPlainTextEdit, QLabel, QFrame, QDialog, QDialogButtonBox)
|
||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
from calibre.gui2.tweak_book.editor import all_text_syntaxes
|
from calibre.gui2.tweak_book.editor import all_text_syntaxes
|
||||||
from calibre.gui2.tweak_book.editor.smarts.utils import get_text_before_cursor
|
from calibre.gui2.tweak_book.editor.smarts.utils import get_text_before_cursor
|
||||||
@ -27,7 +27,7 @@ from polyglot.builtins import codepoint_to_chr, iteritems, itervalues, unicode_t
|
|||||||
|
|
||||||
string_length = lambda x: strlen(unicode_type(x)) # Needed on narrow python builds, as subclasses of unicode dont work
|
string_length = lambda x: strlen(unicode_type(x)) # Needed on narrow python builds, as subclasses of unicode dont work
|
||||||
KEY = Qt.Key_J
|
KEY = Qt.Key_J
|
||||||
MODIFIER = Qt.META if isosx else Qt.CTRL
|
MODIFIER = Qt.META if ismacos else Qt.CTRL
|
||||||
|
|
||||||
SnipKey = namedtuple('SnipKey', 'trigger syntaxes')
|
SnipKey = namedtuple('SnipKey', 'trigger syntaxes')
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ from PyQt5.Qt import (
|
|||||||
QMenu, QHBoxLayout, QTimer, QUrl, QSize)
|
QMenu, QHBoxLayout, QTimer, QUrl, QSize)
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import __appname__, get_version, isosx, DEBUG
|
from calibre.constants import __appname__, get_version, ismacos, DEBUG
|
||||||
from calibre.customize.ui import find_plugin
|
from calibre.customize.ui import find_plugin
|
||||||
from calibre.gui2 import elided_text, open_url
|
from calibre.gui2 import elided_text, open_url
|
||||||
from calibre.gui2.dbus_export.widgets import factory
|
from calibre.gui2.dbus_export.widgets import factory
|
||||||
@ -357,9 +357,9 @@ class Main(MainWindow):
|
|||||||
'edit-previous-file', 'Ctrl+Alt+Up', _('Edit the previous file in the spine'))
|
'edit-previous-file', 'Ctrl+Alt+Up', _('Edit the previous file in the spine'))
|
||||||
# Qt does not generate shortcut overrides for cmd+arrow on os x which
|
# Qt does not generate shortcut overrides for cmd+arrow on os x which
|
||||||
# means these shortcuts interfere with editing
|
# means these shortcuts interfere with editing
|
||||||
self.action_global_undo = treg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', () if isosx else 'Ctrl+Left',
|
self.action_global_undo = treg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', () if ismacos else 'Ctrl+Left',
|
||||||
_('Revert book to before the last action (Undo)'))
|
_('Revert book to before the last action (Undo)'))
|
||||||
self.action_global_redo = treg('forward.png', _('&Revert to after'), self.boss.do_global_redo, 'global-redo', () if isosx else 'Ctrl+Right',
|
self.action_global_redo = treg('forward.png', _('&Revert to after'), self.boss.do_global_redo, 'global-redo', () if ismacos else 'Ctrl+Right',
|
||||||
_('Revert book state to after the next action (Redo)'))
|
_('Revert book state to after the next action (Redo)'))
|
||||||
self.action_save = treg('save.png', _('&Save'), self.boss.save_book, 'save-book', 'Ctrl+S', _('Save book'))
|
self.action_save = treg('save.png', _('&Save'), self.boss.save_book, 'save-book', 'Ctrl+S', _('Save book'))
|
||||||
self.action_save.setEnabled(False)
|
self.action_save.setEnabled(False)
|
||||||
@ -531,7 +531,7 @@ class Main(MainWindow):
|
|||||||
create_plugin_actions(actions, toolbar_actions, self.plugin_menu_actions)
|
create_plugin_actions(actions, toolbar_actions, self.plugin_menu_actions)
|
||||||
|
|
||||||
def create_menubar(self):
|
def create_menubar(self):
|
||||||
if isosx:
|
if ismacos:
|
||||||
p, q = self.create_application_menubar()
|
p, q = self.create_application_menubar()
|
||||||
q.triggered.connect(self.action_quit.trigger)
|
q.triggered.connect(self.action_quit.trigger)
|
||||||
p.triggered.connect(self.action_preferences.trigger)
|
p.triggered.connect(self.action_preferences.trigger)
|
||||||
|
@ -21,7 +21,7 @@ from PyQt5.Qt import (
|
|||||||
|
|
||||||
from calibre import prints, force_unicode, detect_ncpus
|
from calibre import prints, force_unicode, detect_ncpus
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
__appname__, isosx, iswindows, filesystem_encoding, DEBUG, config_dir)
|
__appname__, ismacos, iswindows, filesystem_encoding, DEBUG, config_dir)
|
||||||
from calibre.utils.config import prefs, dynamic
|
from calibre.utils.config import prefs, dynamic
|
||||||
from calibre.utils.ipc.pool import Pool
|
from calibre.utils.ipc.pool import Pool
|
||||||
from calibre.db.legacy import LibraryDatabase
|
from calibre.db.legacy import LibraryDatabase
|
||||||
@ -271,7 +271,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
self.system_tray_icon = factory(app_id='com.calibre-ebook.gui').create_system_tray_icon(parent=self, title='calibre')
|
self.system_tray_icon = factory(app_id='com.calibre-ebook.gui').create_system_tray_icon(parent=self, title='calibre')
|
||||||
if self.system_tray_icon is not None:
|
if self.system_tray_icon is not None:
|
||||||
self.system_tray_icon.setIcon(QIcon(I('lt.png', allow_user_override=False)))
|
self.system_tray_icon.setIcon(QIcon(I('lt.png', allow_user_override=False)))
|
||||||
if not (iswindows or isosx):
|
if not (iswindows or ismacos):
|
||||||
self.system_tray_icon.setIcon(QIcon.fromTheme('calibre-tray', self.system_tray_icon.icon()))
|
self.system_tray_icon.setIcon(QIcon.fromTheme('calibre-tray', self.system_tray_icon.icon()))
|
||||||
self.system_tray_icon.setToolTip(self.jobs_button.tray_tooltip())
|
self.system_tray_icon.setToolTip(self.jobs_button.tray_tooltip())
|
||||||
self.system_tray_icon.setVisible(True)
|
self.system_tray_icon.setVisible(True)
|
||||||
@ -1069,7 +1069,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
return
|
return
|
||||||
self.write_settings()
|
self.write_settings()
|
||||||
if self.system_tray_icon is not None and self.system_tray_icon.isVisible():
|
if self.system_tray_icon is not None and self.system_tray_icon.isVisible():
|
||||||
if not dynamic['systray_msg'] and not isosx:
|
if not dynamic['systray_msg'] and not ismacos:
|
||||||
info_dialog(self, 'calibre', 'calibre '+
|
info_dialog(self, 'calibre', 'calibre '+
|
||||||
_('will keep running in the system tray. To close it, '
|
_('will keep running in the system tray. To close it, '
|
||||||
'choose <b>Quit</b> in the context menu of the '
|
'choose <b>Quit</b> in the context menu of the '
|
||||||
|
@ -9,7 +9,7 @@ from threading import Thread, Event
|
|||||||
from PyQt5.Qt import (QObject, pyqtSignal, Qt, QUrl, QDialog, QGridLayout,
|
from PyQt5.Qt import (QObject, pyqtSignal, Qt, QUrl, QDialog, QGridLayout,
|
||||||
QLabel, QCheckBox, QDialogButtonBox, QIcon)
|
QLabel, QCheckBox, QDialogButtonBox, QIcon)
|
||||||
|
|
||||||
from calibre.constants import (__appname__, __version__, iswindows, isosx,
|
from calibre.constants import (__appname__, __version__, iswindows, ismacos,
|
||||||
isportable, is64bit, numeric_version)
|
isportable, is64bit, numeric_version)
|
||||||
from calibre import prints, as_unicode
|
from calibre import prints, as_unicode
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
@ -28,7 +28,7 @@ NO_CALIBRE_UPDATE = (0, 0, 0)
|
|||||||
|
|
||||||
def get_download_url():
|
def get_download_url():
|
||||||
which = ('portable' if isportable else 'windows' if iswindows
|
which = ('portable' if isportable else 'windows' if iswindows
|
||||||
else 'osx' if isosx else 'linux')
|
else 'osx' if ismacos else 'linux')
|
||||||
if which == 'windows' and is64bit:
|
if which == 'windows' and is64bit:
|
||||||
which += '64'
|
which += '64'
|
||||||
return localize_website_link('https://calibre-ebook.com/download_' + which)
|
return localize_website_link('https://calibre-ebook.com/download_' + which)
|
||||||
@ -41,7 +41,7 @@ def get_newest_version():
|
|||||||
icon_theme_name = ''
|
icon_theme_name = ''
|
||||||
headers={
|
headers={
|
||||||
'CALIBRE-VERSION':__version__,
|
'CALIBRE-VERSION':__version__,
|
||||||
'CALIBRE-OS': ('win' if iswindows else 'osx' if isosx else 'oth'),
|
'CALIBRE-OS': ('win' if iswindows else 'osx' if ismacos else 'oth'),
|
||||||
'CALIBRE-INSTALL-UUID': prefs['installation_uuid'],
|
'CALIBRE-INSTALL-UUID': prefs['installation_uuid'],
|
||||||
'CALIBRE-ICON-THEME': icon_theme_name,
|
'CALIBRE-ICON-THEME': icon_theme_name,
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ from PyQt5.Qt import (
|
|||||||
)
|
)
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
||||||
|
|
||||||
from calibre.constants import isosx
|
from calibre.constants import ismacos
|
||||||
from calibre.gui2 import elided_text
|
from calibre.gui2 import elided_text
|
||||||
from calibre.gui2.viewer.config import get_session_pref
|
from calibre.gui2.viewer.config import get_session_pref
|
||||||
from calibre.gui2.viewer.shortcuts import index_to_key_sequence
|
from calibre.gui2.viewer.shortcuts import index_to_key_sequence
|
||||||
@ -313,7 +313,7 @@ class ActionsList(QListWidget):
|
|||||||
self.viewport().setAcceptDrops(True)
|
self.viewport().setAcceptDrops(True)
|
||||||
self.setDropIndicatorShown(True)
|
self.setDropIndicatorShown(True)
|
||||||
self.setDragDropMode(self.InternalMove)
|
self.setDragDropMode(self.InternalMove)
|
||||||
self.setDefaultDropAction(Qt.CopyAction if isosx else Qt.MoveAction)
|
self.setDefaultDropAction(Qt.CopyAction if ismacos else Qt.MoveAction)
|
||||||
self.setMinimumHeight(400)
|
self.setMinimumHeight(400)
|
||||||
self.is_source = is_source
|
self.is_source = is_source
|
||||||
if is_source:
|
if is_source:
|
||||||
|
@ -20,7 +20,7 @@ from PyQt5.QtWebEngineWidgets import (
|
|||||||
from calibre import as_unicode, prints
|
from calibre import as_unicode, prints
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
FAKE_HOST, FAKE_PROTOCOL, __version__, in_develop_mode, is_running_from_develop,
|
FAKE_HOST, FAKE_PROTOCOL, __version__, in_develop_mode, is_running_from_develop,
|
||||||
isosx, iswindows
|
ismacos, iswindows
|
||||||
)
|
)
|
||||||
from calibre.ebooks.metadata.book.base import field_metadata
|
from calibre.ebooks.metadata.book.base import field_metadata
|
||||||
from calibre.ebooks.oeb.polish.utils import guess_type
|
from calibre.ebooks.oeb.polish.utils import guess_type
|
||||||
@ -204,7 +204,7 @@ def create_profile():
|
|||||||
ans = getattr(create_profile, 'ans', None)
|
ans = getattr(create_profile, 'ans', None)
|
||||||
if ans is None:
|
if ans is None:
|
||||||
ans = QWebEngineProfile(QApplication.instance())
|
ans = QWebEngineProfile(QApplication.instance())
|
||||||
osname = 'windows' if iswindows else ('macos' if isosx else 'linux')
|
osname = 'windows' if iswindows else ('macos' if ismacos else 'linux')
|
||||||
# DO NOT change the user agent as it is used to workaround
|
# DO NOT change the user agent as it is used to workaround
|
||||||
# Qt bugs see workaround_qt_bug() in ajax.pyj
|
# Qt bugs see workaround_qt_bug() in ajax.pyj
|
||||||
ua = 'calibre-viewer {} {}'.format(__version__, osname)
|
ua = 'calibre-viewer {} {}'.format(__version__, osname)
|
||||||
|
@ -14,7 +14,7 @@ from PyQt5.Qt import (QIcon, QFont, QLabel, QListWidget, QAction,
|
|||||||
QLineEdit, QComboBox, QPen, QGraphicsScene, QMenu, QStringListModel,
|
QLineEdit, QComboBox, QPen, QGraphicsScene, QMenu, QStringListModel,
|
||||||
QCompleter, QTimer, QRect, QGraphicsView, QPagedPaintDevice)
|
QCompleter, QTimer, QRect, QGraphicsView, QPagedPaintDevice)
|
||||||
|
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, ismacos
|
||||||
from calibre.gui2 import (error_dialog, pixmap_to_data, gprefs,
|
from calibre.gui2 import (error_dialog, pixmap_to_data, gprefs,
|
||||||
warning_dialog)
|
warning_dialog)
|
||||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||||
@ -1249,7 +1249,7 @@ class PaperSizes(QComboBox): # {{{
|
|||||||
from calibre.utils.icu import numeric_sort_key
|
from calibre.utils.icu import numeric_sort_key
|
||||||
if self.system_default_paper_size is None:
|
if self.system_default_paper_size is None:
|
||||||
PaperSizes.system_default_paper_size = 'a4'
|
PaperSizes.system_default_paper_size = 'a4'
|
||||||
if iswindows or isosx:
|
if iswindows or ismacos:
|
||||||
# On Linux, this can cause Qt to load the system cups plugin
|
# On Linux, this can cause Qt to load the system cups plugin
|
||||||
# which can crash: https://bugs.launchpad.net/calibre/+bug/1861741
|
# which can crash: https://bugs.launchpad.net/calibre/+bug/1861741
|
||||||
PaperSizes.system_default_paper_size = 'letter' if QPrinter().pageSize() == QPagedPaintDevice.Letter else 'a4'
|
PaperSizes.system_default_paper_size = 'letter' if QPrinter().pageSize() == QPagedPaintDevice.Letter else 'a4'
|
||||||
|
@ -20,7 +20,7 @@ from calibre import (
|
|||||||
as_unicode, force_unicode, isbytestring, prepare_string_for_xml,
|
as_unicode, force_unicode, isbytestring, prepare_string_for_xml,
|
||||||
replace_entities, strftime, xml_replace_entities
|
replace_entities, strftime, xml_replace_entities
|
||||||
)
|
)
|
||||||
from calibre.constants import cache_dir, isosx
|
from calibre.constants import cache_dir, ismacos
|
||||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||||
from calibre.customize.conversion import DummyReporter
|
from calibre.customize.conversion import DummyReporter
|
||||||
from calibre.customize.ui import output_profiles
|
from calibre.customize.ui import output_profiles
|
||||||
@ -706,7 +706,7 @@ class CatalogBuilder(object):
|
|||||||
c = item
|
c = item
|
||||||
|
|
||||||
ordnum, ordlen = collation_order(c)
|
ordnum, ordlen = collation_order(c)
|
||||||
if isosx and platform.mac_ver()[0] < '10.8':
|
if ismacos and platform.mac_ver()[0] < '10.8':
|
||||||
# Hackhackhackhackhack
|
# Hackhackhackhackhack
|
||||||
# icu returns bogus results with curly apostrophes, maybe others under OS X 10.6.x
|
# icu returns bogus results with curly apostrophes, maybe others under OS X 10.6.x
|
||||||
# When we see the magic combo of 0/-1 for ordnum/ordlen, special case the logic
|
# When we see the magic combo of 0/-1 for ordnum/ordlen, special case the logic
|
||||||
|
@ -9,7 +9,7 @@ import tempfile, os, atexit
|
|||||||
from polyglot.builtins import map, getenv
|
from polyglot.builtins import map, getenv
|
||||||
|
|
||||||
from calibre.constants import (__version__, __appname__, filesystem_encoding,
|
from calibre.constants import (__version__, __appname__, filesystem_encoding,
|
||||||
iswindows, get_windows_temp_path, isosx)
|
iswindows, get_windows_temp_path, ismacos)
|
||||||
|
|
||||||
|
|
||||||
def cleanup(path):
|
def cleanup(path):
|
||||||
@ -113,7 +113,7 @@ def base_dir():
|
|||||||
# unicode temp path instead. See
|
# unicode temp path instead. See
|
||||||
# https://bugs.launchpad.net/bugs/937389
|
# https://bugs.launchpad.net/bugs/937389
|
||||||
base = get_windows_temp_path()
|
base = get_windows_temp_path()
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
# Use the cache dir rather than the temp dir for temp files as Apple
|
# Use the cache dir rather than the temp dir for temp files as Apple
|
||||||
# thinks deleting unused temp files is a good idea. See note under
|
# thinks deleting unused temp files is a good idea. See note under
|
||||||
# _CS_DARWIN_USER_TEMP_DIR here
|
# _CS_DARWIN_USER_TEMP_DIR here
|
||||||
|
@ -8,7 +8,7 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
import os, sys, subprocess, signal, time, errno, socket, ssl
|
import os, sys, subprocess, signal, time, errno, socket, ssl
|
||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
|
|
||||||
from calibre.constants import islinux, iswindows, isosx
|
from calibre.constants import islinux, iswindows, ismacos
|
||||||
from calibre.srv.http_response import create_http_handler
|
from calibre.srv.http_response import create_http_handler
|
||||||
from calibre.srv.loop import ServerLoop
|
from calibre.srv.loop import ServerLoop
|
||||||
from calibre.srv.opts import Options
|
from calibre.srv.opts import Options
|
||||||
@ -161,7 +161,7 @@ elif iswindows:
|
|||||||
else:
|
else:
|
||||||
self.handle_modified({path})
|
self.handle_modified({path})
|
||||||
|
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
from fsevents import Observer, Stream
|
from fsevents import Observer, Stream
|
||||||
|
|
||||||
class Watcher(WatcherBase):
|
class Watcher(WatcherBase):
|
||||||
|
@ -9,7 +9,7 @@ import os, ctypes, errno, socket
|
|||||||
from io import DEFAULT_BUFFER_SIZE
|
from io import DEFAULT_BUFFER_SIZE
|
||||||
from select import select
|
from select import select
|
||||||
|
|
||||||
from calibre.constants import islinux, isosx
|
from calibre.constants import islinux, ismacos
|
||||||
from calibre.srv.utils import eintr_retry_call
|
from calibre.srv.utils import eintr_retry_call
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class SendfileInterrupted(Exception):
|
|||||||
|
|
||||||
sendfile_to_socket = sendfile_to_socket_async = None
|
sendfile_to_socket = sendfile_to_socket_async = None
|
||||||
|
|
||||||
if isosx:
|
if ismacos:
|
||||||
libc = ctypes.CDLL(None, use_errno=True)
|
libc = ctypes.CDLL(None, use_errno=True)
|
||||||
sendfile = ctypes.CFUNCTYPE(
|
sendfile = ctypes.CFUNCTYPE(
|
||||||
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int64, ctypes.POINTER(ctypes.c_int64), ctypes.c_void_p, ctypes.c_int, use_errno=True)(
|
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int64, ctypes.POINTER(ctypes.c_int64), ctypes.c_void_p, ctypes.c_int, use_errno=True)(
|
||||||
|
@ -9,7 +9,7 @@ import signal
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
from calibre.constants import is_running_from_develop, isosx, iswindows, plugins
|
from calibre.constants import is_running_from_develop, ismacos, iswindows, plugins
|
||||||
from calibre.db.delete_service import shutdown as shutdown_delete_service
|
from calibre.db.delete_service import shutdown as shutdown_delete_service
|
||||||
from calibre.db.legacy import LibraryDatabase
|
from calibre.db.legacy import LibraryDatabase
|
||||||
from calibre.srv.bonjour import BonJour
|
from calibre.srv.bonjour import BonJour
|
||||||
@ -129,7 +129,7 @@ libraries that the main calibre program knows about will be used.
|
|||||||
' URLs and export them.'
|
' URLs and export them.'
|
||||||
))
|
))
|
||||||
|
|
||||||
if not iswindows and not isosx:
|
if not iswindows and not ismacos:
|
||||||
# Does not work on macOS because if we fork() we cannot connect to Core
|
# Does not work on macOS because if we fork() we cannot connect to Core
|
||||||
# Serives which is needed by the QApplication() constructor, which in
|
# Serives which is needed by the QApplication() constructor, which in
|
||||||
# turn is needed by ensure_app()
|
# turn is needed by ensure_app()
|
||||||
|
@ -21,7 +21,7 @@ builtins.__dict__['__'] = lambda s: s
|
|||||||
builtins.__dict__['dynamic_property'] = lambda func: func(None)
|
builtins.__dict__['dynamic_property'] = lambda func: func(None)
|
||||||
|
|
||||||
|
|
||||||
from calibre.constants import iswindows, preferred_encoding, plugins, isosx, islinux, DEBUG, isfreebsd
|
from calibre.constants import iswindows, preferred_encoding, plugins, ismacos, islinux, DEBUG, isfreebsd
|
||||||
|
|
||||||
_run_once = False
|
_run_once = False
|
||||||
winutil = winutilerror = None
|
winutil = winutilerror = None
|
||||||
@ -100,7 +100,7 @@ if not _run_once:
|
|||||||
#
|
#
|
||||||
# Convert command line arguments to unicode
|
# Convert command line arguments to unicode
|
||||||
enc = preferred_encoding
|
enc = preferred_encoding
|
||||||
if isosx:
|
if ismacos:
|
||||||
enc = 'utf-8'
|
enc = 'utf-8'
|
||||||
for i in range(1, len(sys.argv)):
|
for i in range(1, len(sys.argv)):
|
||||||
if not isinstance(sys.argv[i], unicode_type):
|
if not isinstance(sys.argv[i], unicode_type):
|
||||||
@ -199,7 +199,7 @@ if not _run_once:
|
|||||||
bound_signal.connect(slot, **kw)
|
bound_signal.connect(slot, **kw)
|
||||||
builtins.__dict__['connect_lambda'] = connect_lambda
|
builtins.__dict__['connect_lambda'] = connect_lambda
|
||||||
|
|
||||||
if islinux or isosx or isfreebsd:
|
if islinux or ismacos or isfreebsd:
|
||||||
# Name all threads at the OS level created using the threading module, see
|
# Name all threads at the OS level created using the threading module, see
|
||||||
# http://bugs.python.org/issue15500
|
# http://bugs.python.org/issue15500
|
||||||
import threading
|
import threading
|
||||||
|
@ -12,7 +12,7 @@ Test a binary calibre build to ensure that all needed binary images/libraries ha
|
|||||||
|
|
||||||
import os, ctypes, sys, unittest, time
|
import os, ctypes, sys, unittest, time
|
||||||
|
|
||||||
from calibre.constants import plugins, iswindows, islinux, isosx, plugins_loc
|
from calibre.constants import plugins, iswindows, islinux, ismacos, plugins_loc
|
||||||
from polyglot.builtins import iteritems, map, unicode_type, getenv, native_string_type
|
from polyglot.builtins import iteritems, map, unicode_type, getenv, native_string_type
|
||||||
|
|
||||||
is_ci = os.environ.get('CI', '').lower() == 'true'
|
is_ci = os.environ.get('CI', '').lower() == 'true'
|
||||||
@ -100,7 +100,7 @@ class BuildTest(unittest.TestCase):
|
|||||||
if name in exclusions:
|
if name in exclusions:
|
||||||
if name in ('libusb', 'libmtp'):
|
if name in ('libusb', 'libmtp'):
|
||||||
# Just check that the DLL can be loaded
|
# Just check that the DLL can be loaded
|
||||||
ctypes.CDLL(os.path.join(plugins_loc, name + ('.dylib' if isosx else '.so')))
|
ctypes.CDLL(os.path.join(plugins_loc, name + ('.dylib' if ismacos else '.so')))
|
||||||
continue
|
continue
|
||||||
mod, err = plugins[name]
|
mod, err = plugins[name]
|
||||||
self.assertFalse(err or not mod, 'Failed to load plugin: ' + name + ' with error:\n' + err)
|
self.assertFalse(err or not mod, 'Failed to load plugin: ' + name + ' with error:\n' + err)
|
||||||
@ -128,7 +128,7 @@ class BuildTest(unittest.TestCase):
|
|||||||
large = b'x' * (100 * 1024 * 1024)
|
large = b'x' * (100 * 1024 * 1024)
|
||||||
msgpack_loads(msgpack_dumps(large))
|
msgpack_loads(msgpack_dumps(large))
|
||||||
|
|
||||||
@unittest.skipUnless(isosx, 'FSEvents only present on OS X')
|
@unittest.skipUnless(ismacos, 'FSEvents only present on OS X')
|
||||||
def test_fsevents(self):
|
def test_fsevents(self):
|
||||||
from fsevents import Observer, Stream
|
from fsevents import Observer, Stream
|
||||||
del Observer, Stream
|
del Observer, Stream
|
||||||
@ -235,7 +235,7 @@ class BuildTest(unittest.TestCase):
|
|||||||
p.printToPdf(print_callback)
|
p.printToPdf(print_callback)
|
||||||
QTimer.singleShot(5000, lambda: QApplication.instance().quit())
|
QTimer.singleShot(5000, lambda: QApplication.instance().quit())
|
||||||
QApplication.instance().exec_()
|
QApplication.instance().exec_()
|
||||||
test_flaky = isosx and not is_ci
|
test_flaky = ismacos and not is_ci
|
||||||
if not test_flaky:
|
if not test_flaky:
|
||||||
self.assertEqual(callback.result, 2, 'Simple JS computation failed')
|
self.assertEqual(callback.result, 2, 'Simple JS computation failed')
|
||||||
self.assertIn(b'Skia/PDF', bytes(print_callback.result), 'Print to PDF failed')
|
self.assertIn(b'Skia/PDF', bytes(print_callback.result), 'Print to PDF failed')
|
||||||
@ -334,7 +334,7 @@ class BuildTest(unittest.TestCase):
|
|||||||
def test_openssl(self):
|
def test_openssl(self):
|
||||||
import ssl
|
import ssl
|
||||||
ssl.PROTOCOL_TLSv1_2
|
ssl.PROTOCOL_TLSv1_2
|
||||||
if isosx:
|
if ismacos:
|
||||||
cafile = ssl.get_default_verify_paths().cafile
|
cafile = ssl.get_default_verify_paths().cafile
|
||||||
if not cafile or not cafile.endswith('/mozilla-ca-certs.pem') or not os.access(cafile, os.R_OK):
|
if not cafile or not cafile.endswith('/mozilla-ca-certs.pem') or not os.access(cafile, os.R_OK):
|
||||||
raise AssertionError('Mozilla CA certs not loaded')
|
raise AssertionError('Mozilla CA certs not loaded')
|
||||||
|
@ -11,7 +11,7 @@ from datetime import datetime, time as dtime, timedelta, MINYEAR, MAXYEAR
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.constants import iswindows, isosx, plugins, preferred_encoding
|
from calibre.constants import iswindows, ismacos, plugins, preferred_encoding
|
||||||
from calibre.utils.iso8601 import utc_tz, local_tz, UNDEFINED_DATE
|
from calibre.utils.iso8601 import utc_tz, local_tz, UNDEFINED_DATE
|
||||||
from calibre.utils.localization import lcdata
|
from calibre.utils.localization import lcdata
|
||||||
from polyglot.builtins import unicode_type, native_string_type
|
from polyglot.builtins import unicode_type, native_string_type
|
||||||
@ -31,7 +31,7 @@ if iswindows:
|
|||||||
except:
|
except:
|
||||||
parse_date_day_first = False
|
parse_date_day_first = False
|
||||||
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
try:
|
try:
|
||||||
date_fmt = plugins['usbobserver'][0].date_format()
|
date_fmt = plugins['usbobserver'][0].date_format()
|
||||||
parse_date_day_first = date_fmt.index('d') < date_fmt.index('M')
|
parse_date_day_first = date_fmt.index('d') < date_fmt.index('M')
|
||||||
|
@ -12,7 +12,7 @@ from math import ceil
|
|||||||
|
|
||||||
from calibre import force_unicode, isbytestring, prints, sanitize_file_name
|
from calibre import force_unicode, isbytestring, prints, sanitize_file_name
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
filesystem_encoding, iswindows, plugins, preferred_encoding, isosx
|
filesystem_encoding, iswindows, plugins, preferred_encoding, ismacos
|
||||||
)
|
)
|
||||||
from calibre.utils.localization import get_udc
|
from calibre.utils.localization import get_udc
|
||||||
from polyglot.builtins import iteritems, itervalues, unicode_type, range
|
from polyglot.builtins import iteritems, itervalues, unicode_type, range
|
||||||
@ -52,7 +52,7 @@ def shorten_component(s, by_what):
|
|||||||
def limit_component(x, limit=254):
|
def limit_component(x, limit=254):
|
||||||
# windows and macs use ytf-16 codepoints for length, linux uses arbitrary
|
# windows and macs use ytf-16 codepoints for length, linux uses arbitrary
|
||||||
# binary data, but we will assume utf-8
|
# binary data, but we will assume utf-8
|
||||||
filename_encoding_for_length = 'utf-16' if iswindows or isosx else 'utf-8'
|
filename_encoding_for_length = 'utf-16' if iswindows or ismacos else 'utf-8'
|
||||||
|
|
||||||
def encoded_length():
|
def encoded_length():
|
||||||
q = x if isinstance(x, bytes) else x.encode(filename_encoding_for_length)
|
q = x if isinstance(x, bytes) else x.encode(filename_encoding_for_length)
|
||||||
|
@ -11,7 +11,7 @@ from collections import defaultdict
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from calibre import walk, prints, as_unicode
|
from calibre import walk, prints, as_unicode
|
||||||
from calibre.constants import (config_dir, iswindows, isosx, plugins, DEBUG,
|
from calibre.constants import (config_dir, iswindows, ismacos, plugins, DEBUG,
|
||||||
isworker, filesystem_encoding)
|
isworker, filesystem_encoding)
|
||||||
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
@ -113,7 +113,7 @@ def font_dirs():
|
|||||||
path = os.path.join(path, r'Microsoft\Windows\Fonts')
|
path = os.path.join(path, r'Microsoft\Windows\Fonts')
|
||||||
paths.add(os.path.normcase(path))
|
paths.add(os.path.normcase(path))
|
||||||
return list(paths)
|
return list(paths)
|
||||||
if isosx:
|
if ismacos:
|
||||||
return [
|
return [
|
||||||
'/Library/Fonts',
|
'/Library/Fonts',
|
||||||
'/System/Library/Fonts',
|
'/System/Library/Fonts',
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import subprocess, re
|
import subprocess, re
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, ismacos
|
||||||
|
|
||||||
|
|
||||||
def get_address_of_default_gateway(family='AF_INET'):
|
def get_address_of_default_gateway(family='AF_INET'):
|
||||||
@ -56,7 +56,7 @@ if iswindows:
|
|||||||
get_default_route_src_address = get_default_route_src_address_api
|
get_default_route_src_address = get_default_route_src_address_api
|
||||||
|
|
||||||
|
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
|
|
||||||
def get_default_route_src_address():
|
def get_default_route_src_address():
|
||||||
# Use -inet6 for IPv6
|
# Use -inet6 for IPv6
|
||||||
|
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import subprocess, os, sys, time
|
import subprocess, os, sys, time
|
||||||
|
|
||||||
from calibre.constants import iswindows, isosx, isfrozen
|
from calibre.constants import iswindows, ismacos, isfrozen
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.ptempfile import PersistentTemporaryFile, base_dir
|
from calibre.ptempfile import PersistentTemporaryFile, base_dir
|
||||||
from calibre.utils.serialize import msgpack_dumps
|
from calibre.utils.serialize import msgpack_dumps
|
||||||
@ -56,7 +56,7 @@ class Worker(object):
|
|||||||
if iswindows:
|
if iswindows:
|
||||||
return os.path.join(os.path.dirname(sys.executable),
|
return os.path.join(os.path.dirname(sys.executable),
|
||||||
e+'.exe' if isfrozen else 'Scripts\\%s.exe'%e)
|
e+'.exe' if isfrozen else 'Scripts\\%s.exe'%e)
|
||||||
if isosx:
|
if ismacos:
|
||||||
return os.path.join(sys.executables_location, e)
|
return os.path.join(sys.executables_location, e)
|
||||||
|
|
||||||
if isfrozen:
|
if isfrozen:
|
||||||
@ -70,7 +70,7 @@ class Worker(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def gui_executable(self):
|
def gui_executable(self):
|
||||||
if isosx and not hasattr(sys, 'running_from_setup'):
|
if ismacos and not hasattr(sys, 'running_from_setup'):
|
||||||
if self.job_name == 'ebook-viewer':
|
if self.job_name == 'ebook-viewer':
|
||||||
base = os.path.dirname(sys.executables_location)
|
base = os.path.dirname(sys.executables_location)
|
||||||
return os.path.join(base, 'ebook-viewer.app/Contents/MacOS/', self.exe_name)
|
return os.path.join(base, 'ebook-viewer.app/Contents/MacOS/', self.exe_name)
|
||||||
|
@ -13,7 +13,7 @@ from contextlib import closing
|
|||||||
from zipimport import ZipImportError
|
from zipimport import ZipImportError
|
||||||
|
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import iswindows, isosx
|
from calibre.constants import iswindows, ismacos
|
||||||
from calibre.utils.ipc import eintr_retry_call
|
from calibre.utils.ipc import eintr_retry_call
|
||||||
from calibre.utils.serialize import msgpack_loads, pickle_dumps
|
from calibre.utils.serialize import msgpack_loads, pickle_dumps
|
||||||
from polyglot.queue import Queue
|
from polyglot.queue import Queue
|
||||||
@ -171,7 +171,7 @@ def main():
|
|||||||
# Close open file descriptors inherited from parent
|
# Close open file descriptors inherited from parent
|
||||||
# On Unix this is done by the subprocess module
|
# On Unix this is done by the subprocess module
|
||||||
os.closerange(3, 256)
|
os.closerange(3, 256)
|
||||||
if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ and 'CALIBRE_SIMPLE_WORKER' not in os.environ and '--pipe-worker' not in sys.argv:
|
if ismacos and 'CALIBRE_WORKER_ADDRESS' not in os.environ and 'CALIBRE_SIMPLE_WORKER' not in os.environ and '--pipe-worker' not in sys.argv:
|
||||||
# On some OS X computers launchd apparently tries to
|
# On some OS X computers launchd apparently tries to
|
||||||
# launch the last run process from the bundle
|
# launch the last run process from the bundle
|
||||||
# so launch the gui as usual
|
# so launch the gui as usual
|
||||||
|
@ -29,7 +29,7 @@ def available_translations():
|
|||||||
|
|
||||||
|
|
||||||
def get_system_locale():
|
def get_system_locale():
|
||||||
from calibre.constants import iswindows, isosx, plugins
|
from calibre.constants import iswindows, ismacos, plugins
|
||||||
lang = None
|
lang = None
|
||||||
if iswindows:
|
if iswindows:
|
||||||
try:
|
try:
|
||||||
@ -40,7 +40,7 @@ def get_system_locale():
|
|||||||
lang = None
|
lang = None
|
||||||
except:
|
except:
|
||||||
pass # Windows XP does not have the GetUserDefaultLocaleName fn
|
pass # Windows XP does not have the GetUserDefaultLocaleName fn
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
try:
|
try:
|
||||||
lang = plugins['usbobserver'][0].user_locale() or None
|
lang = plugins['usbobserver'][0].user_locale() or None
|
||||||
except:
|
except:
|
||||||
|
@ -11,7 +11,7 @@ import time
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
__appname__, fcntl, filesystem_encoding, islinux, isosx, iswindows, plugins
|
__appname__, fcntl, filesystem_encoding, islinux, ismacos, iswindows, plugins
|
||||||
)
|
)
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
from calibre.utils.shared_file import raise_winerror
|
from calibre.utils.shared_file import raise_winerror
|
||||||
@ -172,7 +172,7 @@ else:
|
|||||||
)
|
)
|
||||||
home = os.path.expanduser('~')
|
home = os.path.expanduser('~')
|
||||||
locs = ['/var/lock', home, tempfile.gettempdir()]
|
locs = ['/var/lock', home, tempfile.gettempdir()]
|
||||||
if isosx:
|
if ismacos:
|
||||||
locs.insert(0, '/Library/Caches')
|
locs.insert(0, '/Library/Caches')
|
||||||
for loc in locs:
|
for loc in locs:
|
||||||
if os.access(loc, os.W_OK | os.R_OK | os.X_OK):
|
if os.access(loc, os.W_OK | os.R_OK | os.X_OK):
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os, shutil, time, sys
|
import os, shutil, time, sys
|
||||||
|
|
||||||
from calibre import isbytestring
|
from calibre import isbytestring
|
||||||
from calibre.constants import (iswindows, isosx, plugins, filesystem_encoding,
|
from calibre.constants import (iswindows, ismacos, plugins, filesystem_encoding,
|
||||||
islinux)
|
islinux)
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ if iswindows:
|
|||||||
path = os.path.abspath(path) # Windows does not like recycling relative paths
|
path = os.path.abspath(path) # Windows does not like recycling relative paths
|
||||||
return delegate_recycle(path)
|
return delegate_recycle(path)
|
||||||
|
|
||||||
elif isosx:
|
elif ismacos:
|
||||||
u = plugins['cocoa'][0]
|
u = plugins['cocoa'][0]
|
||||||
if hasattr(u, 'send2trash'):
|
if hasattr(u, 'send2trash'):
|
||||||
def osx_recycle(path):
|
def osx_recycle(path):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user