// -*- C++ -*- // #ifndef ALGOBOX_H #define ALGOBOX_H class AlgoBox; #include #include #include class AlgoBox : public Gtk::VBox { Gtk::Label * label; Gtk::ComboBoxText cbt; public: AlgoBox(std::vector tabnames) { update_tablist(tabnames); label=new Gtk::Label("Haliho"); pack_start(*label); pack_start(cbt); show_all_children(); }; void update_tablist( std::vector< std::string > tl ) { std::string actname=cbt.get_active_text(); int prev_act=-1; cbt.clear(); int actptr=0; std::vector< std::string >::iterator emsi=tl.begin(); for(;emsi!=tl.end();emsi++) { if(actname==*emsi) { prev_act=actptr; } cbt.append_text(*emsi); actptr++; } if(prev_act!=-1) { cbt.set_active(prev_act); } else if(actptr>0) //so there is item in the list { cbt.set_active(0); } } }; #endif //ALGOBOX_H