Set window title to title of book being read

This commit is contained in:
Kovid Goyal 2016-03-20 22:57:45 +05:30
parent 449511cd8e
commit 6b9debcea7
2 changed files with 7 additions and 1 deletions

View File

@ -53,13 +53,17 @@ class Boss:
divid = 'read-book-container' if mode is 'read_book' else 'book-list-container'
for x in ['book-list-container', 'read-book-container']:
document.getElementById(x).style.display = 'block' if x is divid else 'none'
self.update_window_title()
@property
def has_history(self):
return self.history_count > 0
def update_window_title(self):
if self.current_mode is 'book_list':
document.title = 'calibre :: ' + self.current_library_name
elif self.current_mode is 'read_book':
document.title = self.read_ui.current_metadata.title
def onerror(self, msg, script_url, line_number, column_number, error_object):
try:

View File

@ -4,6 +4,7 @@
from ajax import ajax, encode_query
from elementmaker import E
from gettext import gettext as _
from book_list.globals import get_boss
from modals import error_dialog
from utils import human_readable
from read_book.db import create_db
@ -97,6 +98,7 @@ class ReadUI:
self.current_book_id = book_id
metadata = metadata or self.interface_data.metadata[book_id]
self.current_metadata = metadata or {'title':_('Book id #') + book_id}
get_boss().update_window_title()
self.init_ui()
if type(self.db) is 'string':
self.show_error(_('Cannot read book'), self.db)