diff --git a/src/pyj/modals.pyj b/src/pyj/modals.pyj
index 2c9d14d455..b7b42e7847 100644
--- a/src/pyj/modals.pyj
+++ b/src/pyj/modals.pyj
@@ -174,8 +174,8 @@ def create_simple_dialog_markup(title, msg, details, icon, prefix, parent):
)
-def create_simple_dialog(title, msg, details, icon, prefix):
- show_modal(create_simple_dialog_markup.bind(None, title, msg, details, icon, prefix))
+def create_simple_dialog(title, msg, details, icon, prefix, on_close=None):
+ show_modal(create_simple_dialog_markup.bind(None, title, msg, details, icon, prefix), on_close=on_close)
def create_custom_dialog(title, content_generator_func):
@@ -245,11 +245,11 @@ def close_all_modals():
return modal_container.close_all_modals()
-def error_dialog(title, msg, details=None):
- create_simple_dialog(title, msg, details, 'bug', _('Error:'))
+def error_dialog(title, msg, details=None, on_close=None):
+ create_simple_dialog(title, msg, details, 'bug', _('Error:'), on_close)
-def warning_dialog(title, msg, details=None):
- create_simple_dialog(title, msg, details, 'warning', _('Warning:'))
+def warning_dialog(title, msg, details=None, on_close=None):
+ create_simple_dialog(title, msg, details, 'warning', _('Warning:'), on_close)
def progress_dialog(msg, on_close=None):
# Show a modal dialog with a progress bar and an optional close button.
diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj
index 20186d24ba..895146aaa2 100644
--- a/src/pyj/read_book/view.pyj
+++ b/src/pyj/read_book/view.pyj
@@ -325,13 +325,20 @@ class View:
def on_find_in_spine(self, data):
if data.searched_in_spine:
- warning_dialog(_('Not found'), _('The text: {} was not found in this book').format(html_escape(data.text)))
+ warning_dialog(
+ _('Not found'), _('The text: {} was not found in this book').format(html_escape(data.text)),
+ on_close=def():
+ self.search_overlay.show()
+ )
return
spine = self.book.manifest.spine
idx = spine.indexOf(self.currently_showing.name)
if idx < 0:
error_dialog(_('Missing file'), _(
- 'Could not search as the spine item {} is missing from the book').format(self.currently_showing.name))
+ 'Could not search as the spine item {} is missing from the book').format(self.currently_showing.name),
+ on_close=def():
+ self.search_overlay.show()
+ )
return
names = v'[]'
item_groups = [range(idx-1, -1, -1), range(spine.length-1, idx, -1)] if data.backwards else [range(idx + 1, spine.length), range(idx)]
@@ -611,7 +618,9 @@ class View:
idx = spine.indexOf(name)
if idx is -1:
error_dialog(_('Destination does not exist'), _(
- 'The file {} does not exist in this book').format(name))
+ 'The file {} does not exist in this book').format(name), on_close=def():
+ ui_operations.focus_iframe()
+ )
return False
self.show_name(name, initial_position={'type':'anchor', 'anchor':frag, 'replace_history':False})
return True