mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Also open multiple paths when dropped onto running editor instance
This commit is contained in:
parent
4c0df1ba17
commit
b0e1d97af6
@ -118,6 +118,19 @@ def get_boss():
|
||||
return get_boss.boss
|
||||
|
||||
|
||||
def open_path_in_new_editor_instance(path: str):
|
||||
import subprocess
|
||||
|
||||
from calibre.gui2 import sanitize_env_vars
|
||||
with sanitize_env_vars():
|
||||
if ismacos:
|
||||
from calibre.utils.ipc.launch import macos_edit_book_bundle_path
|
||||
bundle = os.path.dirname(os.path.dirname(macos_edit_book_bundle_path().rstrip('/')))
|
||||
subprocess.Popen(['open', '-n', '-a', bundle, path])
|
||||
else:
|
||||
subprocess.Popen([sys.executable, path])
|
||||
|
||||
|
||||
class Boss(QObject):
|
||||
|
||||
handle_completion_result_signal = pyqtSignal(object)
|
||||
@ -316,7 +329,10 @@ class Boss(QObject):
|
||||
if isinstance(path, (list, tuple)) and path:
|
||||
# Can happen from an file_event_hook on OS X when drag and dropping
|
||||
# onto the icon in the dock or using open -a
|
||||
path = path[-1]
|
||||
extra_paths = path[1:]
|
||||
path = path[0]
|
||||
for x in extra_paths:
|
||||
open_path_in_new_editor_instance(x)
|
||||
if not self._check_before_open():
|
||||
return
|
||||
if not hasattr(path, 'rpartition'):
|
||||
|
@ -8,7 +8,7 @@ import time
|
||||
|
||||
from qt.core import QIcon
|
||||
|
||||
from calibre.constants import EDITOR_APP_UID, islinux, ismacos
|
||||
from calibre.constants import EDITOR_APP_UID, islinux
|
||||
from calibre.ebooks.oeb.polish.check.css import shutdown as shutdown_css_check_pool
|
||||
from calibre.gui2 import Application, decouple, set_gui_prefs, setup_gui_option_parser
|
||||
from calibre.ptempfile import reset_base_dir
|
||||
@ -38,19 +38,6 @@ def gui_main(path=None, notify=None):
|
||||
_run(['ebook-edit', path], notify=notify)
|
||||
|
||||
|
||||
def open_path_in_new_editor_instance(path: str):
|
||||
import subprocess
|
||||
|
||||
from calibre.gui2 import sanitize_env_vars
|
||||
with sanitize_env_vars():
|
||||
if ismacos:
|
||||
from calibre.utils.ipc.launch import macos_edit_book_bundle_path
|
||||
bundle = os.path.dirname(os.path.dirname(macos_edit_book_bundle_path().rstrip('/')))
|
||||
subprocess.Popen(['open', '-n', '-a', bundle, path])
|
||||
else:
|
||||
subprocess.Popen([sys.executable, path])
|
||||
|
||||
|
||||
def _run(args, notify=None):
|
||||
from calibre.utils.webengine import setup_fake_protocol
|
||||
# Ensure we can continue to function if GUI is closed
|
||||
@ -84,6 +71,7 @@ def _run(args, notify=None):
|
||||
paths = app.get_pending_file_open_events()
|
||||
if paths:
|
||||
if len(paths) > 1:
|
||||
from .boss import open_path_in_new_editor_instance
|
||||
for path in paths[1:]:
|
||||
try:
|
||||
open_path_in_new_editor_instance(path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user