[gtkmm] Re: Gtk::Combo
- From: Murray Cumming <murrayc usa net>
- To: ERDI Gergo <cactus cactus rulez org>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: [gtkmm] Re: Gtk::Combo
- Date: 07 Aug 2002 16:54:24 +0100
On Wed, 2002-08-07 at 16:33, ERDI Gergo wrote:
> On 7 Aug 2002, Murray Cumming wrote:
> > I'd like to be able to set an invisible key for each combo item, and
> > just get the key of the selected item. Is that what you mean?
>
> That would be good, but it's just one part of the puzzle.
> I have code like this in Guikachu:
>
> void ResourceCombo::remove_resource (Resource *res)
> {
> if (res->get_type () != type)
> return;
>
> update_block = true;
>
> Gtk::List::ItemList listitems = combo.get_list ()->items ();
> for (Gtk::List::ItemList::iterator i = listitems.begin ();
> i != listitems.end (); i++)
> {
> if ((*i)->get_user_data () == res)
> i = listitems.erase (i);
> }
>
> update_block = false;
> }
>
> So I access list items individually and add/remove them.
> The GTKmm 1.3 version now looks like this:
>
> // This sucks, but we have to rebuild the whole list because
> // there's no other API to change a combo's list
>
> std::set<Resource*> resource_list = manager->get_resources ();
> std::list<std::string> resource_id_list;
> resource_id_list.push_back ("");
> for (std::set<Resource*>::const_iterator i = resource_list.begin ();
> i != resource_list.end (); ++i)
> if ((*i)->get_type () == type)
> resource_id_list.push_back ((*i)->id);
>
> combo.set_popdown_strings (resource_id_list);
You could add methods that use GList* internally. I'd accept that API
change.
But you would need to turn off the DEPRECATED #defines (maybe just an
#undef) so that it builds, and I'd prefer it if you did that for just
one .cc file rather than the whole library.
--
Murray Cumming
murrayc usa net
www.murrayc.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]