Browse Source

Notebook: focus in cleanup

merge-requests/365/head
eidheim 10 years ago
parent
commit
ee3b199301
  1. 6
      src/notebook.cc
  2. 2
      src/notebook.h
  3. 48
      src/window.cc

6
src/notebook.cc

@ -66,8 +66,6 @@ Notebook::Notebook() : Gtk::HPaned(), notebooks(2) {
} }
} }
last_index=-1; last_index=-1;
if(on_switch_page)
on_switch_page();
}); });
notebook.signal_page_added().connect([this](Gtk::Widget* widget, guint) { notebook.signal_page_added().connect([this](Gtk::Widget* widget, guint) {
auto hbox=dynamic_cast<Gtk::HBox*>(widget); auto hbox=dynamic_cast<Gtk::HBox*>(widget);
@ -217,8 +215,8 @@ void Notebook::open(const boost::filesystem::path &file_path, size_t notebook_in
current_view_pre_focused=nullptr; current_view_pre_focused=nullptr;
if(source_view!=current_view_focused) { if(source_view!=current_view_focused) {
current_view_focused=source_view; current_view_focused=source_view;
if(on_switch_page) if(on_focus)
on_switch_page(); on_focus(source_view);
} }
else else
current_view_focused=source_view; current_view_focused=source_view;

2
src/notebook.h

@ -47,7 +47,7 @@ public:
Gtk::Label info; Gtk::Label info;
Gtk::Label status; Gtk::Label status;
std::function<void()> on_switch_page; std::function<void(Source::View*)> on_focus;
std::function<void(Source::View*)> on_close; std::function<void(Source::View*)> on_close;
private: private:
size_t get_index(Source::View *view); size_t get_index(Source::View *view);

48
src/window.cc

@ -103,34 +103,32 @@ Window::Window() {
view->grab_focus(); view->grab_focus();
}); });
Notebook::get().on_switch_page=[this] { Notebook::get().on_focus=[this](Source::View *view) {
if(auto view=Notebook::get().get_current_view()) { if(search_entry_shown && EntryBox::get().labels.size()>0) {
if(search_entry_shown && EntryBox::get().labels.size()>0) { view->update_search_occurrences=[this](int number){
view->update_search_occurrences=[this](int number){ EntryBox::get().labels.begin()->update(0, std::to_string(number));
EntryBox::get().labels.begin()->update(0, std::to_string(number)); };
}; view->search_highlight(last_search, case_sensitive_search, regex_search);
view->search_highlight(last_search, case_sensitive_search, regex_search); }
}
activate_menu_items(); activate_menu_items();
Directories::get().select(view->file_path); Directories::get().select(view->file_path);
if(view->full_reparse_needed) { if(view->full_reparse_needed) {
if(!view->full_reparse()) if(!view->full_reparse())
Terminal::get().async_print("Error: failed to reparse "+view->file_path.string()+". Please reopen the file manually.\n", true); 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) else if(view->soft_reparse_needed)
view->soft_reparse(); view->soft_reparse();
view->set_status(view->status); view->set_status(view->status);
view->set_info(view->info); view->set_info(view->info);
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
if(Project::debugging) if(Project::debugging)
Project::debug_update_stop(); Project::debug_update_stop();
#endif #endif
}
}; };
Notebook::get().on_close=[](Source::View *view) { Notebook::get().on_close=[](Source::View *view) {
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG

Loading…
Cancel
Save