Allow adding multiple books to running calibre

Allow adding multiple books to an already running calibre by passing
multiple file arguments to calibre.exe. Also change the .desktop file in
linux to indicate calibre can accept file arguments. Fixes #1207518 [Calibre is invisible in Ubuntu 13.04 "Open with" dialog](https://bugs.launchpad.net/calibre/+bug/1207518)
This commit is contained in:
Kovid Goyal 2013-08-02 07:21:27 +05:30
parent 8352b43e28
commit e5e2eae97f
3 changed files with 12 additions and 10 deletions

View File

@ -401,8 +401,9 @@ def communicate(opts, args):
shutdown_other(t)
else:
if len(args) > 1:
args[1] = os.path.abspath(args[1])
t.conn.send('launched:'+repr(args))
args[1:] = [os.path.abspath(x) if os.path.exists(x) else x for x in args[1:]]
import json
t.conn.send('launched:'+json.dumps(args))
t.conn.close()
raise SystemExit(0)

View File

@ -520,11 +520,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
except Empty:
return
if msg.startswith('launched:'):
argv = eval(msg[len('launched:'):])
if len(argv) > 1:
path = os.path.abspath(argv[1])
if os.access(path, os.R_OK):
self.iactions['Add Books'].add_filesystem_book(path)
import json
argv = json.loads(msg[len('launched:'):])
if isinstance(argv, (list, tuple)) and len(argv) > 1:
files = [os.path.abspath(p) for p in argv[1:] if not os.path.isdir(p) and os.access(p, os.R_OK)]
if files:
self.iactions['Add Books'].add_filesystem_book(files)
self.setWindowState(self.windowState() &
~Qt.WindowMinimized|Qt.WindowActive)
self.show_windows()

View File

@ -833,7 +833,7 @@ Name=LRF Viewer
GenericName=Viewer for LRF files
Comment=Viewer for LRF files (SONY ebook format files)
TryExec=lrfviewer
Exec=lrfviewer %F
Exec=lrfviewer %f
Icon=calibre-viewer
MimeType=application/x-sony-bbeb;
Categories=Graphics;Viewer;
@ -847,7 +847,7 @@ Name=E-book Viewer
GenericName=Viewer for E-books
Comment=Viewer for E-books in all the major formats
TryExec=ebook-viewer
Exec=ebook-viewer %F
Exec=ebook-viewer %f
Icon=calibre-viewer
Categories=Graphics;Viewer;
'''
@ -857,7 +857,7 @@ GUI = '''\
[Desktop Entry]
Version=1.0
Type=Application
Name=calibre
Name=calibre %F
GenericName=E-book library management
Comment=E-book library management: Convert, view, share, catalogue all your e-books
TryExec=calibre