Workaround broken file chooser dialog on Ubuntu that does not auto-insert the specified extension. Fixes #1275125 [Edit book: cannot create new empty book when extension is not specified in the file](https://bugs.launchpad.net/calibre/+bug/1275125)

This commit is contained in:
Kovid Goyal 2014-02-01 07:51:36 +05:30
parent 42b8155440
commit 3b1d24a907

View File

@ -156,10 +156,12 @@ class Boss(QObject):
return return
d = NewBook(self.gui) d = NewBook(self.gui)
if d.exec_() == d.Accepted: if d.exec_() == d.Accepted:
fmt = d.fmt fmt = d.fmt.lower()
path = choose_save_file(self.gui, 'edit-book-new-book', _('Choose file location'), path = choose_save_file(self.gui, 'edit-book-new-book', _('Choose file location'),
filters=[(fmt.upper(), (fmt,))], all_files=False) filters=[(fmt.upper(), (fmt,))], all_files=False)
if path is not None: if path is not None:
if not path.lower().endswith('.' + fmt):
path = path + '.' + fmt
from calibre.ebooks.oeb.polish.create import create_book from calibre.ebooks.oeb.polish.create import create_book
create_book(d.mi, path, fmt=fmt) create_book(d.mi, path, fmt=fmt)
self.open_book(path=path) self.open_book(path=path)