Handle missing title a bit better

This commit is contained in:
Kovid Goyal 2019-11-28 16:38:44 +05:30
parent 8db03fd0c8
commit 08674935c1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 6 additions and 3 deletions

View File

@ -444,7 +444,10 @@ class EbookViewer(MainWindow):
merge_annotations(parse_annotations(raw), amap)
def update_window_title(self):
title = self.current_book_data['metadata']['title']
try:
title = self.current_book_data['metadata']['title']
except Exception:
title = _('Unknown')
book_format = self.current_book_data['manifest']['book_format']
title = '{} [{}] — {}'.format(title, book_format, self.base_window_title)
self.setWindowTitle(title)

View File

@ -32,7 +32,7 @@ def create_open_book(container, book):
fname = entry.pathtoebook.replace(/\\/g, '/')
if '/' in fname:
fname = fname.rpartition('/')[-1]
items.push(create_item(entry.title, ui_operations.ask_for_open.bind(None, entry.pathtoebook), fname))
items.push(create_item(entry.title or _('Unknown'), ui_operations.ask_for_open.bind(None, entry.pathtoebook), fname))
create_item_list(c.lastChild, items)
c.appendChild(E.div(style='margin: 1rem'))

View File

@ -575,7 +575,7 @@ class View:
self.overlay.show_loading_message(msg)
def show_loading(self):
msg = _('Loading next section from <i>{title}</i>, please wait…').format(title=self.book.metadata.title)
msg = _('Loading next section from <i>{title}</i>, please wait…').format(title=self.book.metadata.title or _('Unknown'))
if self.show_loading_callback_timer is not None:
clearTimeout(self.show_loading_callback_timer)
self.show_loading_callback_timer = setTimeout(self.show_loading_message.bind(None, msg), 200)