|
15 | 15 |
|
16 | 16 | import builtins |
17 | 17 | import os |
| 18 | +import subprocess |
| 19 | +import sys |
18 | 20 |
|
19 | 21 | import wx |
20 | 22 | import wx.lib.agw.aui as aui |
|
42 | 44 | from ..ui.tagdialogs import ViewAllTagsDialog |
43 | 45 | from ..utils import RideFSWatcherHandler |
44 | 46 | from ..widgets import RIDEDialog, ImageProvider, HtmlWindow |
| 47 | +from isbinary import is_binary_file |
45 | 48 |
|
46 | 49 | _ = wx.GetTranslation # To keep linter/code analyser happy |
47 | 50 | builtins.__dict__['_'] = wx.GetTranslation |
@@ -81,6 +84,17 @@ def get_menudata(): |
81 | 84 | help_3 + help_4 + help_6 + help_7) |
82 | 85 |
|
83 | 86 |
|
| 87 | +def start_external_app(file_path): |
| 88 | + if sys.platform.startswith('darwin'): # macOS |
| 89 | + subprocess.call(['open', file_path]) |
| 90 | + elif sys.platform.startswith('win32'): # Windows |
| 91 | + subprocess.call(['cmd', '/c', 'start', file_path], shell=True) |
| 92 | + elif sys.platform.startswith('linux'): # Linux |
| 93 | + subprocess.call(['xdg-open', file_path]) |
| 94 | + else: |
| 95 | + print('Unsupported OS') |
| 96 | + |
| 97 | + |
84 | 98 | class RideFrame(wx.Frame): |
85 | 99 |
|
86 | 100 | _menudata_nt = """[File] |
@@ -464,7 +478,10 @@ def on_open_file(self, event): |
464 | 478 | return |
465 | 479 | if self.open_suite(path): |
466 | 480 | return |
467 | | - customsourceeditor.main(path) |
| 481 | + if not is_binary_file(path): |
| 482 | + customsourceeditor.main(path) |
| 483 | + else: |
| 484 | + start_external_app(path) |
468 | 485 |
|
469 | 486 | def on_menu_open_file(self, event): |
470 | 487 | if not self.filemgr: |
|
0 commit comments