Browse Source

Moved entrybox to bottom of notepad widget, this way the cursor does not change position on screen when entrybox gets shown. Also the entry fields gets closer to the text where the focus of the user is.

merge-requests/365/head
eidheim 10 years ago
parent
commit
722a55d3d2
  1. 11
      src/entrybox.cc
  2. 26
      src/window.cc
  3. 1
      src/window.h

11
src/entrybox.cc

@ -37,6 +37,7 @@ EntryBox::Label::Label(std::function<void(int state, const std::string& message)
EntryBox::EntryBox() : Gtk::Box(Gtk::ORIENTATION_VERTICAL), upper_box(Gtk::ORIENTATION_HORIZONTAL), lower_box(Gtk::ORIENTATION_HORIZONTAL) { EntryBox::EntryBox() : Gtk::Box(Gtk::ORIENTATION_VERTICAL), upper_box(Gtk::ORIENTATION_HORIZONTAL), lower_box(Gtk::ORIENTATION_HORIZONTAL) {
pack_start(upper_box, Gtk::PACK_SHRINK); pack_start(upper_box, Gtk::PACK_SHRINK);
pack_start(lower_box, Gtk::PACK_SHRINK); pack_start(lower_box, Gtk::PACK_SHRINK);
this->set_focus_chain({&lower_box});
} }
void EntryBox::clear() { void EntryBox::clear() {
@ -50,16 +51,16 @@ void EntryBox::clear() {
void EntryBox::show() { void EntryBox::show() {
std::vector<Gtk::Widget*> focus_chain; std::vector<Gtk::Widget*> focus_chain;
for(auto& entry: entries) { for(auto& entry: entries) {
upper_box.pack_start(entry, Gtk::PACK_SHRINK); lower_box.pack_start(entry, Gtk::PACK_SHRINK);
focus_chain.emplace_back(&entry); focus_chain.emplace_back(&entry);
} }
for(auto& button: buttons) for(auto& button: buttons)
upper_box.pack_start(button, Gtk::PACK_SHRINK); lower_box.pack_start(button, Gtk::PACK_SHRINK);
for(auto& toggle_button: toggle_buttons) for(auto& toggle_button: toggle_buttons)
upper_box.pack_start(toggle_button, Gtk::PACK_SHRINK); lower_box.pack_start(toggle_button, Gtk::PACK_SHRINK);
for(auto& label: labels) for(auto& label: labels)
lower_box.pack_start(label, Gtk::PACK_SHRINK); upper_box.pack_start(label, Gtk::PACK_SHRINK);
upper_box.set_focus_chain(focus_chain); lower_box.set_focus_chain(focus_chain);
show_all(); show_all();
if(entries.size()>0) { if(entries.size()>0) {
entries.begin()->grab_focus(); entries.begin()->grab_focus();

26
src/window.cc

@ -21,10 +21,10 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL) {
create_menu(); create_menu();
box.pack_start(menu.get_widget(), Gtk::PACK_SHRINK); box.pack_start(menu.get_widget(), Gtk::PACK_SHRINK);
box.pack_start(entry_box, Gtk::PACK_SHRINK); directory_and_notebook_panes.pack1(directories, Gtk::SHRINK);
notebook_vbox.pack_start(notebook);
directory_and_notebook_panes.pack1(directories, true, true); notebook_vbox.pack_end(entry_box, Gtk::PACK_SHRINK);
directory_and_notebook_panes.pack2(notebook); directory_and_notebook_panes.pack2(notebook_vbox, Gtk::SHRINK);
directory_and_notebook_panes.set_position(120); directory_and_notebook_panes.set_position(120);
vpaned.set_position(300); vpaned.set_position(300);
vpaned.pack1(directory_and_notebook_panes, true, false); vpaned.pack1(directory_and_notebook_panes, true, false);
@ -42,12 +42,16 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL) {
}; };
entry_box.signal_show().connect([this](){ entry_box.signal_show().connect([this](){
std::vector<Gtk::Widget*> focus_chain; box.set_focus_chain({&vpaned});
focus_chain.emplace_back(&entry_box); vpaned.set_focus_chain({&directory_and_notebook_panes});
box.set_focus_chain(focus_chain); directory_and_notebook_panes.set_focus_chain({&notebook_vbox});
notebook_vbox.set_focus_chain({&entry_box});
}); });
entry_box.signal_hide().connect([this](){ entry_box.signal_hide().connect([this](){
box.unset_focus_chain(); box.unset_focus_chain();
vpaned.unset_focus_chain();
directory_and_notebook_panes.unset_focus_chain();
notebook_vbox.unset_focus_chain();
}); });
entry_box.signal_hide().connect([this]() { entry_box.signal_hide().connect([this]() {
if(notebook.get_current_page()!=-1) { if(notebook.get_current_page()!=-1) {
@ -456,14 +460,6 @@ void Window::search_and_replace_entry() {
last_replace=replace_entry_it->get_text(); last_replace=replace_entry_it->get_text();
}); });
entry_box.buttons.emplace_back("Find", [this](){
if(notebook.get_current_page()!=-1)
notebook.get_current_view()->search_forward();
});
entry_box.buttons.emplace_back("Replace", [this, replace_entry_it](){
if(notebook.get_current_page()!=-1)
notebook.get_current_view()->replace_forward(replace_entry_it->get_text());
});
entry_box.buttons.emplace_back("Replace all", [this, replace_entry_it](){ entry_box.buttons.emplace_back("Replace all", [this, replace_entry_it](){
if(notebook.get_current_page()!=-1) if(notebook.get_current_page()!=-1)
notebook.get_current_view()->replace_all(replace_entry_it->get_text()); notebook.get_current_view()->replace_all(replace_entry_it->get_text());

1
src/window.h

@ -19,6 +19,7 @@ private:
Gtk::Box box; Gtk::Box box;
Gtk::VPaned vpaned; Gtk::VPaned vpaned;
Gtk::Paned directory_and_notebook_panes; Gtk::Paned directory_and_notebook_panes;
Gtk::VBox notebook_vbox;
Gtk::VBox terminal_vbox; Gtk::VBox terminal_vbox;
Gtk::HBox status_hbox; Gtk::HBox status_hbox;
EntryBox entry_box; EntryBox entry_box;

Loading…
Cancel
Save