After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 124297 - Need a custom TreeModel example
Need a custom TreeModel example
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: TreeView
2.2
Other Windows
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2003-10-10 15:07 UTC by Murray Cumming
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Feel free to simplify the GObject related stuff (7.04 KB, text/c-source)
2004-01-09 16:06 UTC, Christof Petig
Details
gtkmm_custom_treemodel2.cc (6.63 KB, text/plain)
2004-01-12 21:21 UTC, Murray Cumming
Details

Description Murray Cumming 2003-10-10 15:07:24 UTC
Some people have managed to implement custom Gtk::TreeModels, but they seem
to be using strange hacky techniques. It needs to register a GType, but
that should be similar to the custom cell renderer.
Comment 1 Christof Petig 2004-01-09 16:06:45 UTC
Created attachment 23167 [details]
Feel free to simplify the GObject related stuff
Comment 2 Murray Cumming 2004-01-12 21:20:34 UTC
So, the question is, why do need the awful C GClass stuff. Here
(gtkmm_custom_treemodel2.cc) is a version that is more like what we
would expect. Ignore the first warning. But it gives this bizarre warning:

(a.out:24508): GLib-GObject-WARNING **: cannot add interface type
`GtkTreeModel' to type `GObject', since type `GtkListStore' already
conforms to interface

But we don't mention ListStore anywhere in the example.
Comment 3 Murray Cumming 2004-01-12 21:21:18 UTC
Created attachment 23281 [details]
gtkmm_custom_treemodel2.cc
Comment 4 Murray Cumming 2004-01-12 22:10:49 UTC
I just checked in a fix to both branches that makes
gtkmm_custom_treemodel2.cc work. It properly implements the
Glib::Object default constructor so that it generates a custom
on-the-fly derived GType (derived from GObject) when you have already
called teh ObjectBase(typeid(MyCustomClass)) constructor.

So, now the nasty GType stuff is gone, and we just need to tidy this
example up (Separate files for each class. No method implementation in
a .h file.) and add some comments.
Comment 5 Murray Cumming 2004-01-14 10:54:59 UTC
I am working on a nicer example.
Comment 6 Murray Cumming 2004-01-16 14:24:21 UTC
Done. There's an ugly one in gtkmm 2.2 (The gtkmm2 cvs module) and a
prettier more-C++ one in gtkmm 2.4). The model has no children,
because I can't think of a way to manage memory of more complicated
user_data information in the GtkTreeIter. At the moment, I am just
shoving an int into the void* user_data.