mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 02:12:36 +02:00
Fix open in Preview for macOS
This commit is contained in:
parent
babcd62071
commit
3f76211459
1 changed files with 25 additions and 26 deletions
|
@ -46,35 +46,34 @@ class GuiCommon(object):
|
|||
return QtGui.QIcon(path)
|
||||
|
||||
def open_pdf_viewer(self, filename):
|
||||
if self.global_common.settings.get("open_app") in self.pdf_viewers:
|
||||
if platform.system() == "Darwin":
|
||||
# Open in Preview
|
||||
args = ["open", "-a", "Preview.app", filename]
|
||||
if platform.system() == "Darwin":
|
||||
# Open in Preview
|
||||
args = ["open", "-a", "Preview.app", filename]
|
||||
|
||||
# Run
|
||||
args_str = " ".join(pipes.quote(s) for s in args)
|
||||
print(Fore.YELLOW + "> " + Fore.CYAN + args_str)
|
||||
subprocess.run(args)
|
||||
# Run
|
||||
args_str = " ".join(pipes.quote(s) for s in args)
|
||||
print(Fore.YELLOW + "> " + Fore.CYAN + args_str)
|
||||
subprocess.run(args)
|
||||
|
||||
elif platform.system() == "Linux":
|
||||
# Get the PDF reader command
|
||||
args = shlex.split(
|
||||
self.pdf_viewers[self.global_common.settings.get("open_app")]
|
||||
)
|
||||
# %f, %F, %u, and %U are filenames or URLS -- so replace with the file to open
|
||||
for i in range(len(args)):
|
||||
if (
|
||||
args[i] == "%f"
|
||||
or args[i] == "%F"
|
||||
or args[i] == "%u"
|
||||
or args[i] == "%U"
|
||||
):
|
||||
args[i] = filename
|
||||
elif platform.system() == "Linux":
|
||||
# Get the PDF reader command
|
||||
args = shlex.split(
|
||||
self.pdf_viewers[self.global_common.settings.get("open_app")]
|
||||
)
|
||||
# %f, %F, %u, and %U are filenames or URLS -- so replace with the file to open
|
||||
for i in range(len(args)):
|
||||
if (
|
||||
args[i] == "%f"
|
||||
or args[i] == "%F"
|
||||
or args[i] == "%u"
|
||||
or args[i] == "%U"
|
||||
):
|
||||
args[i] = filename
|
||||
|
||||
# Open as a background process
|
||||
args_str = " ".join(pipes.quote(s) for s in args)
|
||||
print(Fore.YELLOW + "> " + Fore.CYAN + args_str)
|
||||
subprocess.Popen(args)
|
||||
# Open as a background process
|
||||
args_str = " ".join(pipes.quote(s) for s in args)
|
||||
print(Fore.YELLOW + "> " + Fore.CYAN + args_str)
|
||||
subprocess.Popen(args)
|
||||
|
||||
def _find_pdf_viewers(self):
|
||||
pdf_viewers = {}
|
||||
|
|
Loading…
Reference in a new issue