Initialise our dropdown at contruction and just repopulate it when the cardinfo callback is received

This commit is contained in:
Colin Guthrie 2009-03-02 20:36:44 +00:00
parent 3d5133064e
commit 1758320b6a
1 changed files with 5 additions and 7 deletions

View File

@ -490,6 +490,10 @@ CardWidget::CardWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
x->get_widget("profileList", profileList); x->get_widget("profileList", profileList);
x->get_widget("iconImage", iconImage); x->get_widget("iconImage", iconImage);
treeModel = Gtk::ListStore::create(profileModel);
profileList->set_model(treeModel);
profileList->pack_start(profileModel.desc);
profileList->signal_changed().connect( sigc::mem_fun(*this, &CardWidget::onProfileChange)); profileList->signal_changed().connect( sigc::mem_fun(*this, &CardWidget::onProfileChange));
} }
@ -505,10 +509,7 @@ void CardWidget::prepareMenu() {
int idx = 0; int idx = 0;
int active_idx = -1; int active_idx = -1;
//m_refTreeModel = Gtk::TreeStore::create(m_Columns); treeModel->clear();
treeModel = Gtk::ListStore::create(profileModel);
profileList->set_model(treeModel);
//Fill the ComboBox's Tree Model: //Fill the ComboBox's Tree Model:
for (std::map<Glib::ustring, Glib::ustring>::iterator i = profiles.begin(); i != profiles.end(); ++i) { for (std::map<Glib::ustring, Glib::ustring>::iterator i = profiles.begin(); i != profiles.end(); ++i) {
Gtk::TreeModel::Row row = *(treeModel->append()); Gtk::TreeModel::Row row = *(treeModel->append());
@ -519,9 +520,6 @@ void CardWidget::prepareMenu() {
idx++; idx++;
} }
//Add the model columns to the Combo (which is a kind of view),
//rendering them in the default way:
profileList->pack_start(profileModel.desc);
if (active_idx >= 0) if (active_idx >= 0)
profileList->set_active(active_idx); profileList->set_active(active_idx);
} }