Custom CellRenderer with custom property



Hello, I've searched the web for a few days now and am out of ideas...

What I'm trying to do is create a TriState cellrenderer (one of several renderers that are part of a column) that can render a value that can take 3 states (unchecked, checked, or grayed). This is represented as an integer in the data model. Here is the closest to what I can figure out:


Gtk::TreeView::Column *tvc = new Gtk::TreeView::Column("Test");
tvc->pack_start(renderer, false);
tvc->pack_start(columns.col_name);
tvc->add_attribute(renderer, "tristate", columns.col_state);

I get this when it tries to render the cells
(Tierra.exe:4892): GLib-GObject-WARNING **: g_object_get_property: object class
`gtkmm__GtkCellRenderer' has no property named `tristate'

I can figure out that it wouldn't know about my tristate property, but I can't figure out how to register it. I've tried to simply define a property like this in the TriStateCellRenderer class: Glib::Property<int> tristate; // instantiated as TriStateCellRenderer::TriStateCellRenderer : tristate(*this, "tristate");

However it gives me this error:
(Tierra.exe:4892): GLib-GObject-CRITICAL **: g_object_class_install_property: as
sertion `class->set_property != NULL' failed

I thought I was getting close, but as I go through the glib, glibmm, gtk, and gtkmm source I'm getting lost. I figure I'm missing some sort of callback that is called when the property is set, but I can't figure out how or where to set it. Obviously I'm doing something wrong. I can't believe I haven't found some example that doesn't do this. I've seen references to CustomCellRenderer (even in the gtkmm sources), but it seems to have been removed. Can someone point me to an example of a CellRenderer using properties. The built in renderers (e.g. CellRendererText) seem to be taking advantage of some property handling built into Gtk.

Am I close or way off?  Any suggestions?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]