diff --git a/src/calibre/gui2/viewer/web_view.py b/src/calibre/gui2/viewer/web_view.py index 393c2f6f4e..7760100273 100644 --- a/src/calibre/gui2/viewer/web_view.py +++ b/src/calibre/gui2/viewer/web_view.py @@ -168,6 +168,7 @@ class ViewerBridge(Bridge): set_session_data = from_js(object, object) + create_view = to_js() start_book_load = to_js() @@ -308,15 +309,16 @@ class WebView(RestartingWebEngineView): return self._page.bridge def on_bridge_ready(self): + self.bridge.create_view(vprefs['session_data']) for func, args in iteritems(self.pending_bridge_ready_actions): getattr(self.bridge, func)(*args) def start_book_load(self, initial_cfi=None): key = (set_book_path.path,) if self.bridge.ready: - self.bridge.start_book_load(key, vprefs['session_data'], initial_cfi) + self.bridge.start_book_load(key, initial_cfi) else: - self.pending_bridge_ready_actions['start_book_load'] = key, vprefs['session_data'], initial_cfi + self.pending_bridge_ready_actions['start_book_load'] = key, initial_cfi def set_session_data(self, key, val): if key == '*' and val is None: diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 4a169f9f90..49230c3013 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -344,10 +344,13 @@ class View: if sd.get('max_text_width') or sd.get('max_text_height'): self.set_margins() + def show_loading_message(self, msg): + self.overlay.show_loading_message(msg) + def show_loading(self): title = self.book.metadata.title name = self.currently_showing.name - self.overlay.show_loading_message(_( + self.show_loading_message(_( 'Loading {name} from {title}, please wait...').format(name=name, title=title)) def hide_loading(self): diff --git a/src/pyj/viewer-main.pyj b/src/pyj/viewer-main.pyj index 1cb4aa18f3..2f92c694c8 100644 --- a/src/pyj/viewer-main.pyj +++ b/src/pyj/viewer-main.pyj @@ -22,9 +22,6 @@ from utils import encode_query_with_path from viewer.constants import FAKE_HOST, FAKE_PROTOCOL -def container_div(id): - return E.div(id=id, style='margin: 0; padding: 0; display: none') - runtime.is_standalone_viewer = True runtime.FAKE_HOST = FAKE_HOST runtime.FAKE_PROTOCOL = FAKE_PROTOCOL @@ -177,11 +174,14 @@ def create_session_data(prefs): @from_python -def start_book_load(key, prefs, initial_cfi): +def create_view(prefs): nonlocal view if view is None: create_session_data(prefs) view = View(document.getElementById('view')) + +@from_python +def start_book_load(key, initial_cfi): xhr = ajax('manifest', manifest_received.bind(None, key, initial_cfi), ok_code=0) xhr.responseType = 'json' xhr.send()