diff options
Diffstat (limited to 'src/InputDialog.cpp')
-rw-r--r-- | src/InputDialog.cpp | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/InputDialog.cpp b/src/InputDialog.cpp index 520bfa2..16c4d01 100644 --- a/src/InputDialog.cpp +++ b/src/InputDialog.cpp @@ -1,22 +1,37 @@ #include "../include/InputDialog.hpp" #include <gtkmm/label.h> +#include <gtkmm/grid.h> namespace dchat { - InputDialog::InputDialog(const char *title, const char *text, const char *acceptText, const char *cancelText) + InputDialog::InputDialog(const char *title, const std::vector<const char*> &texts, const char *acceptText, const char *cancelText) { set_title(title); Gtk::Box *box = get_content_area(); - Gtk::Label *label = Gtk::manage(new Gtk::Label(text)); - label->set_valign(Gtk::ALIGN_END); - label->set_halign(Gtk::ALIGN_CENTER); - box->pack_start(*label, true, true); + //box->set_halign(Gtk::ALIGN_CENTER); + //box->set_valign(Gtk::ALIGN_CENTER); + Gtk::Grid *grid = Gtk::manage(new Gtk::Grid()); + grid->set_halign(Gtk::ALIGN_CENTER); + grid->set_valign(Gtk::ALIGN_CENTER); + box->pack_start(*grid, true, true); + int i = 0; + for(const char *text : texts) + { + Gtk::Label *label = Gtk::manage(new Gtk::Label(text)); + label->set_valign(Gtk::ALIGN_END); + label->set_halign(Gtk::ALIGN_CENTER); + grid->attach(*label, 0, i, 1, 1); - entry.set_valign(Gtk::ALIGN_CENTER); - entry.set_halign(Gtk::ALIGN_CENTER); - entry.set_hexpand(true); - box->pack_end(entry, true, true); + Gtk::Entry *entry = Gtk::manage(new Gtk::Entry()); + entry->set_valign(Gtk::ALIGN_CENTER); + entry->set_halign(Gtk::ALIGN_CENTER); + entry->set_hexpand(true); + grid->attach(*entry, 0, i + 1, 2, 1); + entries.push_back(entry); + + i += 2; + } add_button(acceptText, Gtk::RESPONSE_ACCEPT); add_button(cancelText, Gtk::RESPONSE_CANCEL); @@ -24,9 +39,4 @@ namespace dchat set_size_request(300, 150); } - - Glib::ustring InputDialog::getInput() const - { - return entry.get_text(); - } }
\ No newline at end of file |