[gnote] Refactor search update to a separate method
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Refactor search update to a separate method
- Date: Sat, 2 Jan 2021 14:35:17 +0000 (UTC)
commit d73c04f1548246e6ffeff0af7345d7e96fdd76ff
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Jan 2 12:26:05 2021 +0200
Refactor search update to a separate method
src/recentchanges.cpp | 38 ++++++++++++++++++++++----------------
src/recentchanges.hpp | 1 +
2 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/src/recentchanges.cpp b/src/recentchanges.cpp
index 1ab2c8a2..d443005b 100644
--- a/src/recentchanges.cpp
+++ b/src/recentchanges.cpp
@@ -328,6 +328,27 @@ namespace gnote {
}
}
+ void NoteRecentChanges::update_search_bar(EmbeddableWidget & widget, bool perform_search)
+ {
+ SearchableItem *searchable_item = dynamic_cast<SearchableItem*>(&widget);
+ if(searchable_item) {
+ m_search_button.show();
+ if(searchable_item->supports_goto_result()) {
+ m_find_next_prev_box->show();
+ }
+ else {
+ m_find_next_prev_box->hide();
+ }
+ if(perform_search) {
+ searchable_item->perform_search(m_search_button.get_active() ? m_search_entry.get_text() : "");
+ }
+ }
+ else {
+ m_search_button.set_active(false);
+ m_search_button.hide();
+ }
+ }
+
void NoteRecentChanges::present_search()
{
EmbeddableWidget *current = currently_embedded();
@@ -727,22 +748,7 @@ namespace gnote {
m_all_notes_button->set_visible(!search);
m_new_note_button->set_visible(search);
dynamic_cast<Gtk::Image*>(m_window_actions_button->get_image())->property_icon_name() = search ?
MAIN_MENU_PRIMARY_ICON : MAIN_MENU_SECONDARY_ICON;
-
- try {
- SearchableItem & searchable_item = dynamic_cast<SearchableItem&>(widget);
- m_search_button.show();
- if(searchable_item.supports_goto_result()) {
- m_find_next_prev_box->show();
- }
- else {
- m_find_next_prev_box->hide();
- }
- searchable_item.perform_search(m_search_button.get_active() ? m_search_entry.get_text() : "");
- }
- catch(std::bad_cast &) {
- m_search_button.set_active(false);
- m_search_button.hide();
- }
+ update_search_bar(widget, true);
try {
HasEmbeddableToolbar & toolbar_provider = dynamic_cast<HasEmbeddableToolbar&>(widget);
diff --git a/src/recentchanges.hpp b/src/recentchanges.hpp
index 5d81f895..c84eb7e5 100644
--- a/src/recentchanges.hpp
+++ b/src/recentchanges.hpp
@@ -82,6 +82,7 @@ private:
void entry_changed_timeout();
Glib::ustring get_search_text();
void update_toolbar(EmbeddableWidget & widget);
+ void update_search_bar(EmbeddableWidget & widget, bool perform_search);
void on_all_notes_button_clicked();
void on_show_window_menu();
void on_search_button_toggled();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]