TheDummyAssistant(openfluid::machine::SimulationBlob* SimBlob) : Gtk::Assistant(), mp_SimBlob(SimBlob), mp_TestUnitsColl(0), m_Applied(false) { set_title("Dummy assistant"); set_default_size(400, 300); set_modal(true); Gtk::Label* Label1 = Gtk::manage(new Gtk::Label( "I'm a Dummy assistant for tests")); append_page(*Label1); set_page_title(*Label1, "Page 1/2"); set_page_type(*Label1, Gtk::ASSISTANT_PAGE_INTRO); set_page_complete(*Label1, true); Gtk::Label* Label2 = Gtk::manage(new Gtk::Label()); if (!mp_SimBlob) { Label2->set_text("Nb of units in TestUnits class: no CoreRepository\n" "Nothing to do"); signal_apply().connect(sigc::mem_fun(*this, &Gtk::Assistant::hide)); } else { unsigned int Size = 0; mp_TestUnitsColl = mp_SimBlob->getCoreRepository().getUnits("TestUnits"); if (mp_TestUnitsColl) Size = mp_TestUnitsColl->getList()->size(); Label2->set_text(Glib::ustring::compose( "Nb of units in TestUnits class: %1\n" "Clicking ok will add a Unit of class \"TestUnits\"", Size)); signal_apply().connect( sigc::mem_fun(*this, &TheDummyAssistant::m_apply)); } append_page(*Label2); set_page_title(*Label2, "Page 2/2"); set_page_type(*Label2, Gtk::ASSISTANT_PAGE_CONFIRM); set_page_complete(*Label2, true); signal_cancel().connect(sigc::mem_fun(*this, &Gtk::Assistant::hide)); signal_close().connect(sigc::mem_fun(*this, &Gtk::Assistant::hide)); show_all_children(); }
GenericAssistant::GenericAssistant ( std::string assistantTitle, std::vector<std::string> assistantLabels, std::vector<std::string> assistantPlaceholders, bool assistantModalMode ) { set_title(assistantTitle); set_default_size (323, 200); set_modal(assistantModalMode); container = manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL,(2*assistantLabels.size())-1)); for (unsigned int i=0;i<assistantLabels.size();i++) { Gtk::Box * b = manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL,3)); Gtk::Label * l = manage(new Gtk::Label(assistantLabels.at(i))); b->add(*l); Gtk::AspectFrame * af = manage(new Gtk::AspectFrame()); b->add(*af); // entry and placeholder.... Gtk::Entry * e = manage(new Gtk::Entry()); e->set_placeholder_text(assistantPlaceholders.at(i).c_str()); b->add(*e); // record the entry's content Entry.push_back(e); // show_children b->show_all_children(); // add container->add(*b); if (assistantLabels.size()-1 != i) { Gtk::AspectFrame * af = manage(new Gtk::AspectFrame()); container->add(*af); } } container->show_all_children(); // set assistant pages and config it append_page(*container); set_page_complete(*container, true); set_page_type(*container, Gtk::ASSISTANT_PAGE_CONFIRM); show_all_children(); // close or cancel the assistant signal_cancel().connect ( sigc::mem_fun ( *this, &GenericAssistant::on_assistant_cancel ) ); signal_close().connect ( sigc::mem_fun ( *this, &GenericAssistant::on_assistant_close ) ); }