Pixbufs in ComboBox columns



I have a model that looks like this:

class ModelColumns: public Gtk::TreeModelColumnRecord {
  public:
    ModelColumns() {
      add(picture);
      add(name);
    }
    
    Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > picture;
    Gtk::TreeModelColumn<Glib::ustring> name;
  };

After doing "all the other stuff" like declaring an instance of the
ColumnRecord, creating a ListStore instance, loading the pixbufs (tested
the pixbufs in a Gtk::Image and they're fine), filling the model, etc.,
I'm adding the columns with just:
  pack_start(columns.picture);
  pack_start(columns.name);


But, I'm getting errors like below:

(process:23146): GLib-GObject-CRITICAL **: gtype.c:2215: initialization
assertion failed, use IA__g_type_init() prior to this function

(lt-pixbuf:23146): Gtk-WARNING **: gtkliststore.c:366: Invalid type
(null) passed to gtk_list_store_set_column_types


(lt-pixbuf:23146): GLib-GObject-WARNING **: gtype.c:3312: type id `0' is
invalid

(lt-pixbuf:23146): GLib-GObject-WARNING **: can't peek value table for
type `<invalid>' which is not currently referenced

(lt-pixbuf:23146): GLib-GObject-WARNING **: gvalue.c:96: cannot
initialize GValue with type `(null)', this type has no GTypeValueTable
implementation

(lt-pixbuf:23146): GLib-GObject-CRITICAL **: g_value_set_object:
assertion `G_VALUE_HOLDS_OBJECT (value)' failed

(lt-pixbuf:23146): Gtk-CRITICAL **: gtk_list_store_set_value: assertion
`G_IS_VALUE (value)' failed

(lt-pixbuf:23146): GLib-GObject-CRITICAL **: g_value_unset: assertion
`G_IS_VALUE (value)' failed

(lt-pixbuf:23146): GLib-GObject-WARNING **: gtype.c:3312: type id `0' is
invalid

(lt-pixbuf:23146): GLib-GObject-WARNING **: can't peek value table for
type `<invalid>' which is not currently referenced



Despite the errors, the string column renders properly.

I noticed there was a post a couple of years ago regarding displaying a
pixbuf in a TreeView that looked like:

/* Create renderer */
Gtk::CellRendererPixbuf *imagerenderer = 
    Gtk::manage(new Gtk::CellRendererPixbuf);

/* Create col */
Gtk::TreeViewColumn* iconcolumn = 
   Gtk::manage(new Gtk::TreeViewColumn("Icon", *imagerenderer));

/* Add renderer and Gtk::ModelViewColumn to the Gtk::TreeView::Column */
iconcolumn->set_renderer(*imagerenderer, columns.picture);

/* Add col to Gtk::TreeView */
this->tree_view.append_column (*iconcolumn);

But, the ComboBox interface doesn't have a method that accepts a
TreeViewColumn. Any suggestions or examples on how to approach putting a
pixbuf into a ComboBox column?




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