open file
This commit is contained in:
parent
906d48a04b
commit
a2b55bc24e
3 changed files with 21 additions and 1 deletions
|
@ -388,6 +388,16 @@ def cancelImport(data):
|
||||||
return {}
|
return {}
|
||||||
actions.register(cancelImport, cache=False)
|
actions.register(cancelImport, cache=False)
|
||||||
|
|
||||||
|
def openFile(data):
|
||||||
|
response = {}
|
||||||
|
item = models.Item.get(data['id'])
|
||||||
|
if item:
|
||||||
|
path = item.get_path()
|
||||||
|
if path:
|
||||||
|
utils.open_file(path)
|
||||||
|
return response
|
||||||
|
actions.register(openFile, cache=False)
|
||||||
|
|
||||||
def openFolder(data):
|
def openFolder(data):
|
||||||
response = {}
|
response = {}
|
||||||
item = models.Item.get(data['id'])
|
item = models.Item.get(data['id'])
|
||||||
|
|
10
oml/utils.py
10
oml/utils.py
|
@ -337,6 +337,16 @@ def makefolder(path):
|
||||||
os.makedirs(dirname)
|
os.makedirs(dirname)
|
||||||
|
|
||||||
|
|
||||||
|
def open_file(path=None):
|
||||||
|
cmd = []
|
||||||
|
if sys.platform == 'darwin':
|
||||||
|
cmd += ['open', path]
|
||||||
|
elif sys.platform.startswith('linux'):
|
||||||
|
cmd += ['xdg-open', path]
|
||||||
|
else:
|
||||||
|
logger.debug('unsupported platform %s', sys.platform)
|
||||||
|
subprocess.Popen(cmd, close_fds=True)
|
||||||
|
|
||||||
def open_folder(folder=None, path=None):
|
def open_folder(folder=None, path=None):
|
||||||
cmd = []
|
cmd = []
|
||||||
if path and not folder:
|
if path and not folder:
|
||||||
|
|
|
@ -283,7 +283,7 @@ oml.ui.infoView = function(externalData, isMixed) {
|
||||||
if (data_.id == 'read') {
|
if (data_.id == 'read') {
|
||||||
oml.UI.set({itemView: 'book'});
|
oml.UI.set({itemView: 'book'});
|
||||||
} else if (data_.id == 'open') {
|
} else if (data_.id == 'open') {
|
||||||
// ...
|
oml.api.openFile({id: oml.user.ui.item});
|
||||||
} else {
|
} else {
|
||||||
oml.api.openFolder({id: oml.user.ui.item});
|
oml.api.openFolder({id: oml.user.ui.item});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue