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. 4
      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);

4
src/window.cc

@ -103,8 +103,7 @@ 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));
@ -130,7 +129,6 @@ Window::Window() {
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