From 722a55d3d2c6c937d9efb13b198283ee64e6ab17 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 2 Aug 2015 18:17:05 +0200 Subject: [PATCH] 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. --- src/entrybox.cc | 11 ++++++----- src/window.cc | 26 +++++++++++--------------- src/window.h | 1 + 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/entrybox.cc b/src/entrybox.cc index d221393..f207e56 100644 --- a/src/entrybox.cc +++ b/src/entrybox.cc @@ -37,6 +37,7 @@ EntryBox::Label::Label(std::functionset_focus_chain({&lower_box}); } void EntryBox::clear() { @@ -50,16 +51,16 @@ void EntryBox::clear() { void EntryBox::show() { std::vector focus_chain; 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); } 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) - upper_box.pack_start(toggle_button, Gtk::PACK_SHRINK); + lower_box.pack_start(toggle_button, Gtk::PACK_SHRINK); for(auto& label: labels) - lower_box.pack_start(label, Gtk::PACK_SHRINK); - upper_box.set_focus_chain(focus_chain); + upper_box.pack_start(label, Gtk::PACK_SHRINK); + lower_box.set_focus_chain(focus_chain); show_all(); if(entries.size()>0) { entries.begin()->grab_focus(); diff --git a/src/window.cc b/src/window.cc index 86395cd..35c6902 100644 --- a/src/window.cc +++ b/src/window.cc @@ -21,10 +21,10 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL) { create_menu(); box.pack_start(menu.get_widget(), Gtk::PACK_SHRINK); - box.pack_start(entry_box, Gtk::PACK_SHRINK); - - directory_and_notebook_panes.pack1(directories, true, true); - directory_and_notebook_panes.pack2(notebook); + directory_and_notebook_panes.pack1(directories, Gtk::SHRINK); + notebook_vbox.pack_start(notebook); + notebook_vbox.pack_end(entry_box, Gtk::PACK_SHRINK); + directory_and_notebook_panes.pack2(notebook_vbox, Gtk::SHRINK); directory_and_notebook_panes.set_position(120); vpaned.set_position(300); vpaned.pack1(directory_and_notebook_panes, true, false); @@ -42,12 +42,16 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL) { }; entry_box.signal_show().connect([this](){ - std::vector focus_chain; - focus_chain.emplace_back(&entry_box); - box.set_focus_chain(focus_chain); + box.set_focus_chain({&vpaned}); + vpaned.set_focus_chain({&directory_and_notebook_panes}); + directory_and_notebook_panes.set_focus_chain({¬ebook_vbox}); + notebook_vbox.set_focus_chain({&entry_box}); }); entry_box.signal_hide().connect([this](){ 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]() { if(notebook.get_current_page()!=-1) { @@ -456,14 +460,6 @@ void Window::search_and_replace_entry() { 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](){ if(notebook.get_current_page()!=-1) notebook.get_current_view()->replace_all(replace_entry_it->get_text()); diff --git a/src/window.h b/src/window.h index 8d51c9a..44c6afb 100644 --- a/src/window.h +++ b/src/window.h @@ -19,6 +19,7 @@ private: Gtk::Box box; Gtk::VPaned vpaned; Gtk::Paned directory_and_notebook_panes; + Gtk::VBox notebook_vbox; Gtk::VBox terminal_vbox; Gtk::HBox status_hbox; EntryBox entry_box;