0

(All this In perspective of implementation of own TreeModel, not usage of existing one)

How do i make any use of Gtk::TreeModelColumn in C++ implementation of own TreeModel?

As far i understood, it serves the purpose of uniquely identifying types of columns, but how do i use it in this way in C++ domain?

Is there a way to somehow convert arbitrary GType (which is underlying gtk object inside of TreeModelColumn) to C++ type, so i be able to cast to it?

And if not - why it exists in gtkmm? What it's real purpose there?

Alexander Tumin
  • 1,561
  • 4
  • 22
  • 33

1 Answers1

2

How do i make any use of Gtk::TreeModelColumn in C++ implementation of own TreeModel?

I don't think you need to and I don't think it would make sense to.

Gtk::TreeModel::Column is for applications to use, when using any Gtk::TreeModel: http://developer.gnome.org/gtkmm-tutorial/unstable/sec-treeview-model.html.en#treeview-model-columns

Its purpose in the API is to avoid you (as an app developer) from having to remember column indices and column types, and to let you use its specific type to call overloaded methods, generally without worrying about how that works.

However, if you are trying to make a generic data model that has a create(TreeModelColumnRecord) like ListStore and TreeStore, that will give you those TreeModelColumn<>s. In that case, you can get the GTypes like gtkmm does, by calling types(): http://git.gnome.org/browse/gtkmm/tree/gtk/src/liststore.ccg#n26

And TreeModelColumn::ElementType can tell you the C++ type: http://git.gnome.org/browse/gtkmm/tree/gtk/gtkmm/treemodelcolumn.h#n131 But you'd really need some dynamic_cast<>ing to really switch on the C++ type. The decision about how to store things is entirely up to you. But if I was you, I'd just use ListStore or TreeStore if possible.

murrayc
  • 2,103
  • 4
  • 17
  • 32