gtk combobox questions
- From: Anca Mitrica <ancamitrica yahoo com>
- To: gtkmm-list gnome org
- Subject: gtk combobox questions
- Date: Wed, 13 Jul 2005 07:40:18 -0700 (PDT)
Hello,
I am trying to attach a Gtk::ComboBox to a Gtk::Table,
in a dynamical way: the combobox list store is filled
with values read from different list<Glib::ustring>
(several if branches). The problem is that I receive a
segmentation fault each time I try to visualize the
combobox.
Here is the code :
DirWindow.h file:
..................
class DirWindow{
public:
.............
protected:
//define class for tree model for combobox
class ModelTree:public Gtk::TreeModel::ColumnRecord{
public:
ModelTree(){
add(colName);
}
Gtk::TreeModelColumn<Glib::ustring> colName;
};
private:
Glib::RefPtr<Gtk::ListStore> typelist;
Gtk::ComboBox *combo ;
.......................
};
DirWindow.cc file :
......................................
void DirWindow::on_Combo_Name_Type(){
Glib::ustring parname,partype,pardelim;
Glib::ustring ns = getComboNameActive();
Glib::ustring typesel = getComboTypeActive();
//oxLabel = new Gtk::Label("0x");
butAjouter->set_sensitive(true);
delete intable;
paramTableRowNumber = 1;
intable = new Gtk::Table(paramTableRowNumber,3,true);
intable->set_col_spacings(8);
intable->set_row_spacings(8);
if(typesel =="SES"){
for(parseIterator=seslist.begin();parseIterator !=
seslist.end();parseIterator++){
Glib::ustring elem = *parseIterator;
Glib::ustring name =
elem.substr(0,elem.find_first_of("<",0));
if((name == ns)||(name =="\t"+ns)){
//get all parameters for a directive in put thzm
into a list
tokenizeString(elem,"<");
//li = list containing all parameters of a
directive
for(p = li.begin();p != li.end();++p){
//p = a parameter with name type and delimiter
Glib::ustring parameter = *p;
tokenizeParameter(parameter);
for(unsigned int i = 0;i<vecteur.size();i++){
if(i == 0)
parname = vecteur[i];
else if(i == 1){
partype = vecteur[i];
}else if(i == 2){
pardelim = vecteur[i];
}
}
paramTableRowNumber++;
intable->resize(paramTableRowNumber,3);
intable->set_resize_mode(Gtk::RESIZE_IMMEDIATE);
newParameterName = new Gtk::Label(parname);
newParameterType = new
Gtk::Label(Glib::ustring("(")+partype+Glib::ustring(")"));
newParameterEntry = new Gtk::Entry();
combo = new Gtk::ComboBox();
typelist = Gtk::ListStore::create(columns);
combo->set_model(typelist);
for(parsetypeIterator =
hexlist.begin();parsetypeIterator!=hexlist.end();++parsetypeIterator){
Glib::ustring s = *parsetypeIterator;
Gtk::TreeModel::Row firstrow =
*(typelist->append());
firstrow[columns.colName] = s;
}
combo->pack_start(columns.colName);
combo->signal_changed().connect(sigc::mem_fun(*this,&DirWindow::on_Combo_Type_Enum));
combo->set_active(0);
intable->attach(*newParameterName,0,1,paramTableRowNumber-1,paramTableRowNumber,Gtk::EXPAND,Gtk::EXPAND,0,0);
if(partype == "ENUM_HEX"){
hb = new Gtk::HBox();
oxLabel = new Gtk::Label("0x");
hb->pack_start(*oxLabel,Gtk::PACK_SHRINK);
hb->pack_start(*newParameterEntry,Gtk::PACK_SHRINK);
intable->attach(*hb,1,2,paramTableRowNumber-1,paramTableRowNumber,Gtk::FILL,Gtk::FILL,0,0);
hb->show_all_children();
intable->attach(*combo,2,3,paramTableRowNumber-1,paramTableRowNumber);
}else{
intable->attach(*newParameterEntry,1,2,paramTableRowNumber-1,paramTableRowNumber,Gtk::FILL,Gtk::FILL,0,0);
intable->attach(*newParameterType,2,3,paramTableRowNumber-1,paramTableRowNumber,Gtk::FILL,Gtk::FILL,0,0);
} intable->queue_resize();
}
}
}
}
..............................................
The table also is updated dynamically.
Does anyone has an idea about what's wrong with my
code? Or what could generate a seg fault?
Thank you
Anca Mitrica
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]