From 09a8064c1d0f064eff060d6c44a912b95ea6909a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 11 Nov 2013 17:54:51 +0530 Subject: [PATCH] ... --- src/calibre/gui2/tweak_book/boss.py | 8 ++++++-- src/calibre/gui2/tweak_book/editor/widget.py | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 85b3c492fe..098191c7f4 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -263,7 +263,8 @@ class Boss(QObject): ed = self.gui.central.current_editor if ed is not None: ed.mark_selected_text() - self.gui.central.search_panel.set_where('selected-text') + if ed.has_marked_text: + self.gui.central.search_panel.set_where('selected-text') def search(self, action, overrides=None): ' Run a search/replace ' @@ -286,6 +287,9 @@ class Boss(QObject): err = _('No file is being edited.') elif where == 'selected' and not searchable_names['selected']: err = _('No files are selected in the Files Browser') + elif where == 'selected-text' and not ed.has_marked_text: + err = _('No text is marked. First select some text, and then use' + ' The "Mark selected text" action in the Search menu to mark it.') if not err and not state['find']: err = _('No search query specified') if err: @@ -307,7 +311,7 @@ class Boss(QObject): else: pass # TODO: Find the first name with a match and open its editor else: - pass # selected text TODO: Implement this + pass # marked text TODO: Implement this def save_book(self): c = current_container() diff --git a/src/calibre/gui2/tweak_book/editor/widget.py b/src/calibre/gui2/tweak_book/editor/widget.py index 321a1095fe..e2960f35cb 100644 --- a/src/calibre/gui2/tweak_book/editor/widget.py +++ b/src/calibre/gui2/tweak_book/editor/widget.py @@ -70,6 +70,10 @@ class Editor(QMainWindow): def mark_selected_text(self): self.editor.mark_selected_text() + @property + def has_marked_text(self): + return self.editor.current_search_mark is not None + @dynamic_property def is_modified(self): def fget(self):