void Dialog::addCombo (GtkWidget* vbox, const std::string& name, const std::string& registryKey, const ComboBoxValueList& valueList) { GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); gtk_widget_show(alignment); { // Create a new combo box GtkWidget* combo = gtk_combo_box_new_text(); // Add all the string values to the combo box for (ComboBoxValueList::const_iterator i = valueList.begin(); i != valueList.end(); i++) { // Add the current string value to the combo box gtk_combo_box_append_text(GTK_COMBO_BOX(combo), i->c_str()); } // Connect the registry key to the newly created combo box _registryConnector.connectGtkObject(GTK_OBJECT(combo), registryKey); // Add it to the container and make it visible gtk_widget_show(combo); gtk_container_add(GTK_CONTAINER(alignment), combo); } // Add the widget to the dialog row GtkTable* row = DialogRow_new(name, alignment); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); }
void PrefPage::appendCombo(const std::string& name, const std::string& registryKey, const ComboBoxValueList& valueList, bool storeValueNotIndex) { Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment(0.0, 0.5, 0.0, 0.0)); // Create a new combo box of the correct type using boost::shared_ptr; using namespace gtkutil; Gtk::ComboBoxText* combo = Gtk::manage(new Gtk::ComboBoxText); // Add all the string values to the combo box for (ComboBoxValueList::const_iterator i = valueList.begin(); i != valueList.end(); ++i) { combo->append_text(*i); } if (storeValueNotIndex) { // There is no property_active_text() apparently, so we have to connect // manually combo->set_active_text(_registryBuffer.get(registryKey)); combo->property_active().signal_changed().connect( sigc::bind( sigc::ptr_fun(setRegBufferValueFromActiveText), combo, registryKey, sigc::ref(_registryBuffer) ) ); _resetValuesSignal.connect( sigc::bind(sigc::ptr_fun(setActiveTextFromRegValue), combo, registryKey) ); } else { registry::bindPropertyToBufferedKey(combo->property_active(), registryKey, _registryBuffer, _resetValuesSignal); } // Add it to the container alignment->add(*combo); // Add the widget to the dialog row appendNamedWidget(name, *alignment); }