Browse Source

Made the entry boxes, for instance used in Find, larger

merge-requests/413/head
eidheim 3 years ago
parent
commit
9d902e2354
  1. 5
      src/entrybox.cpp
  2. 2
      src/entrybox.hpp
  3. 12
      src/window.cpp

5
src/entrybox.cpp

@ -2,9 +2,8 @@
std::unordered_map<std::string, std::vector<std::string>> EntryBox::entry_histories; std::unordered_map<std::string, std::vector<std::string>> EntryBox::entry_histories;
EntryBox::Entry::Entry(const std::string &content, std::function<void(const std::string &content)> on_activate_, unsigned width_chars) : Gtk::Entry(), on_activate(std::move(on_activate_)) { EntryBox::Entry::Entry(const std::string &content, std::function<void(const std::string &content)> on_activate_) : Gtk::Entry(), on_activate(std::move(on_activate_)) {
set_max_length(0); set_max_length(0);
set_width_chars(width_chars);
set_text(content); set_text(content);
last_content = content; last_content = content;
selected_history = -1; selected_history = -1;
@ -97,7 +96,7 @@ 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) {
lower_box.pack_start(entry, Gtk::PACK_SHRINK); lower_box.pack_start(entry, Gtk::PACK_EXPAND_WIDGET);
focus_chain.emplace_back(&entry); focus_chain.emplace_back(&entry);
} }
for(auto &button : buttons) for(auto &button : buttons)

2
src/entrybox.hpp

@ -10,7 +10,7 @@ class EntryBox : public Gtk::Box {
public: public:
class Entry : public Gtk::Entry { class Entry : public Gtk::Entry {
public: public:
Entry(const std::string &content = "", std::function<void(const std::string &content)> on_activate_ = nullptr, unsigned width_chars = -1); Entry(const std::string &content = "", std::function<void(const std::string &content)> on_activate_ = nullptr);
std::function<void(const std::string &content)> on_activate; std::function<void(const std::string &content)> on_activate;
private: private:

12
src/window.cpp

@ -1388,8 +1388,7 @@ void Window::set_menu_actions() {
run_arguments.second, [run_arguments_first = std::move(run_arguments.first)](const std::string &content) { run_arguments.second, [run_arguments_first = std::move(run_arguments.first)](const std::string &content) {
Project::run_arguments[run_arguments_first] = content; Project::run_arguments[run_arguments_first] = content;
EntryBox::get().hide(); EntryBox::get().hide();
}, });
50);
auto entry_it = EntryBox::get().entries.begin(); auto entry_it = EntryBox::get().entries.begin();
entry_it->set_placeholder_text("Run Arguments"); entry_it->set_placeholder_text("Run Arguments");
EntryBox::get().buttons.emplace_back("Set Run Arguments", [entry_it]() { EntryBox::get().buttons.emplace_back("Set Run Arguments", [entry_it]() {
@ -1459,8 +1458,7 @@ void Window::set_menu_actions() {
EntryBox::get().hide(); EntryBox::get().hide();
else else
EntryBox::get().entries.front().select_region(0, -1); EntryBox::get().entries.front().select_region(0, -1);
}, });
30);
auto entry_it = EntryBox::get().entries.begin(); auto entry_it = EntryBox::get().entries.begin();
entry_it->set_placeholder_text("Command"); entry_it->set_placeholder_text("Command");
EntryBox::get().buttons.emplace_back("Run Command", [entry_it]() { EntryBox::get().buttons.emplace_back("Run Command", [entry_it]() {
@ -1494,8 +1492,7 @@ void Window::set_menu_actions() {
run_arguments.second, [run_arguments_first = std::move(run_arguments.first)](const std::string &content) { run_arguments.second, [run_arguments_first = std::move(run_arguments.first)](const std::string &content) {
Project::debug_run_arguments[run_arguments_first].arguments = content; Project::debug_run_arguments[run_arguments_first].arguments = content;
EntryBox::get().hide(); EntryBox::get().hide();
}, });
50);
auto entry_it = EntryBox::get().entries.begin(); auto entry_it = EntryBox::get().entries.begin();
entry_it->set_placeholder_text("Debug Run Arguments"); entry_it->set_placeholder_text("Debug Run Arguments");
@ -1572,8 +1569,7 @@ void Window::set_menu_actions() {
last_run_debug_command = content; last_run_debug_command = content;
} }
EntryBox::get().hide(); EntryBox::get().hide();
}, });
30);
auto entry_it = EntryBox::get().entries.begin(); auto entry_it = EntryBox::get().entries.begin();
entry_it->set_placeholder_text("Debug Command"); entry_it->set_placeholder_text("Debug Command");
EntryBox::get().buttons.emplace_back("Run Debug Command", [entry_it]() { EntryBox::get().buttons.emplace_back("Run Debug Command", [entry_it]() {

Loading…
Cancel
Save