From 7ca29d8396bfda356cb346999fa38298874aeda5 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 25 Jul 2015 12:50:55 +0200 Subject: [PATCH] Label with the number of search matches addes as well as case sensitive and regex toggle buttons. Some minor fixes too. --- juci/entrybox.cc | 30 +++++++-- juci/entrybox.h | 15 +++++ juci/notebook.cc | 169 ++++++++++++++++++++++++++++++----------------- juci/notebook.h | 5 ++ juci/source.cc | 18 +++-- juci/source.h | 3 +- 6 files changed, 166 insertions(+), 74 deletions(-) diff --git a/juci/entrybox.cc b/juci/entrybox.cc index ad714a0..5ce5e56 100644 --- a/juci/entrybox.cc +++ b/juci/entrybox.cc @@ -20,24 +20,44 @@ EntryBox::Button::Button(const std::string& label, std::function on_acti }); } -EntryBox::EntryBox() : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) {} +EntryBox::ToggleButton::ToggleButton(const std::string& label, std::function on_activate) : Gtk::ToggleButton(label), on_activate(on_activate) { + signal_clicked().connect([this](){ + if(this->on_activate) + this->on_activate(); + }); +} + +EntryBox::Label::Label(std::function update) : Gtk::Label(), update(update) { + if(this->update) + this->update(-1, ""); +} + +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(lower_box, Gtk::PACK_SHRINK); +} void EntryBox::clear() { hide(); entries.clear(); buttons.clear(); + toggle_buttons.clear(); + labels.clear(); } void EntryBox::show() { std::vector focus_chain; for(auto& entry: entries) { - pack_start(entry, Gtk::PACK_SHRINK); + upper_box.pack_start(entry, Gtk::PACK_SHRINK); focus_chain.emplace_back(&entry); } for(auto& button: buttons) - pack_start(button, Gtk::PACK_SHRINK); - - set_focus_chain(focus_chain); + upper_box.pack_start(button, Gtk::PACK_SHRINK); + for(auto& toggle_button: toggle_buttons) + upper_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); show_all(); if(entries.size()>0) { entries.begin()->grab_focus(); diff --git a/juci/entrybox.h b/juci/entrybox.h index 47acf70..06632e7 100644 --- a/juci/entrybox.h +++ b/juci/entrybox.h @@ -17,12 +17,27 @@ public: Button(const std::string& label, std::function on_activate=nullptr); std::function on_activate; }; + class ToggleButton : public Gtk::ToggleButton { + public: + ToggleButton(const std::string& label, std::function on_activate=nullptr); + std::function on_activate; + }; + class Label : public Gtk::Label { + public: + Label(std::function update=nullptr); + std::function update; + }; + public: EntryBox(); + Gtk::Box upper_box; + Gtk::Box lower_box; void clear(); void show(); std::list entries; std::list