> Say I've got a class containing a list of values. For example, a > Palette class containing a list of colors (something like the > following incomplete class declaration): > > class Palette > { > public: > typedef std::vector<rgb_t> color_list_type; > // snipped other methods > color_list_type& colors(void); > > private: > color_list_type m_colors; > }; > > Now say I want to display these values in a treeview. One option is > obviously to copy all of the values from m_colors into a > Gtk::ListModel. But this has a rather large disadvantage in that when > I make some changes in the treeview (i.e. add a new item, re-order > items, remove items), I would need to copy these items out of the > listmodel into a Palette whenever I want to use this group of items as > a Palette type.
Maybe you should just store the Palette in the list model and use cell_data_func callbacks to show it in the treeview. > I'd rather just have the treeview display data directly from the > Palette class so that I don't need to copy / synchronize things back > and forth. So in order to display data directly from the Palette > class, I'd need to have Palette inherit from Gtk::TreeModel (i.e. > implement a custom TreeModel). There is an example in gtkmm CVS that > shows how to implement a custom TreeModel, but unfortunately I haven't > had much luck deciphering it (especially the GlueItem stuff). And > besides the example, the documentation on implementing custom > TreeModels is pretty sparse, Has anybody really done this before? I've done it in Glom, but the gtkmm example is simpler. > Does anybody know of other examples I could look at? Is there a > better way to solve this problem than implementing a custom TreeModel? > > What I think would be helpful is some guidance on what methods need to > be implemented / overridden and approximately what they're supposed to > do, etc. I'd be willing to put together a document like this (maybe > as a section in the tutorial) if I can get it figured out. Murray Cumming [EMAIL PROTECTED] www.murrayc.com www.openismus.com _______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list