diff --git a/src/notebook.cc b/src/notebook.cc index cb5729f..80d5a4d 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -66,8 +66,6 @@ Notebook::Notebook() : Gtk::HPaned(), notebooks(2) { } } last_index=-1; - if(on_switch_page) - on_switch_page(); }); notebook.signal_page_added().connect([this](Gtk::Widget* widget, guint) { auto hbox=dynamic_cast(widget); @@ -217,8 +215,8 @@ void Notebook::open(const boost::filesystem::path &file_path, size_t notebook_in current_view_pre_focused=nullptr; if(source_view!=current_view_focused) { current_view_focused=source_view; - if(on_switch_page) - on_switch_page(); + if(on_focus) + on_focus(source_view); } else current_view_focused=source_view; diff --git a/src/notebook.h b/src/notebook.h index c2f4170..413b64d 100644 --- a/src/notebook.h +++ b/src/notebook.h @@ -47,7 +47,7 @@ public: Gtk::Label info; Gtk::Label status; - std::function on_switch_page; + std::function on_focus; std::function on_close; private: size_t get_index(Source::View *view); diff --git a/src/window.cc b/src/window.cc index 916b68d..c1e825b 100644 --- a/src/window.cc +++ b/src/window.cc @@ -103,34 +103,32 @@ Window::Window() { view->grab_focus(); }); - Notebook::get().on_switch_page=[this] { - if(auto view=Notebook::get().get_current_view()) { - if(search_entry_shown && EntryBox::get().labels.size()>0) { - view->update_search_occurrences=[this](int number){ - EntryBox::get().labels.begin()->update(0, std::to_string(number)); - }; - view->search_highlight(last_search, case_sensitive_search, regex_search); - } + Notebook::get().on_focus=[this](Source::View *view) { + if(search_entry_shown && EntryBox::get().labels.size()>0) { + view->update_search_occurrences=[this](int number){ + EntryBox::get().labels.begin()->update(0, std::to_string(number)); + }; + view->search_highlight(last_search, case_sensitive_search, regex_search); + } - activate_menu_items(); - - Directories::get().select(view->file_path); - - if(view->full_reparse_needed) { - if(!view->full_reparse()) - Terminal::get().async_print("Error: failed to reparse "+view->file_path.string()+". Please reopen the file manually.\n", true); - } - else if(view->soft_reparse_needed) - view->soft_reparse(); - - view->set_status(view->status); - view->set_info(view->info); - + activate_menu_items(); + + Directories::get().select(view->file_path); + + if(view->full_reparse_needed) { + if(!view->full_reparse()) + Terminal::get().async_print("Error: failed to reparse "+view->file_path.string()+". Please reopen the file manually.\n", true); + } + else if(view->soft_reparse_needed) + view->soft_reparse(); + + view->set_status(view->status); + view->set_info(view->info); + #ifdef JUCI_ENABLE_DEBUG - if(Project::debugging) - Project::debug_update_stop(); + if(Project::debugging) + Project::debug_update_stop(); #endif - } }; Notebook::get().on_close=[](Source::View *view) { #ifdef JUCI_ENABLE_DEBUG