Re: [gtkmm] Problem with Gdk::Pixbuf in Gtk::TreeView
- From: Martin Schulze <martin-ml hippogriff de>
- To: Simon Fuhrmann <NightSlayer gmx de>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] Problem with Gdk::Pixbuf in Gtk::TreeView
- Date: Wed, 3 Sep 2003 21:51:53 +0200
Am 2003.09.03 12:15 schrieb(en) Simon Fuhrmann:
Hi there!
I have problems settung up a Gtk::TreeView with a column that can
display a Glib::RefPtr<Gtk::Pixbuf>.
On execution of my code the following error message appears for each
row I insert into my Gtk::ListStore:
(simfm:2255): GLib-GObject-WARNING **: unable to set property `text'
of
type `gchararray' from value of type `GdkPixbuf'
This cryptic error message usually means that the a wrong CellRenderer
(probably CellRendererText) is set up for the column. (-> pixbufs
cannot be converted into text, of course).
Strange, because there is a template specialization of
generate_cellrenderer() (file treeviewcolumn.h) for
Glib::RefPtr<Gdk::Pixbuf>. Is your debugger stable enough so that
you can step into
this->tree_view.append_column ("Icon", this->column_set.icon);
until you reach generate_cellrenderer() ?
It would be better, of course, if someone else could fill us
in with his experience with pixbuf columns ...
The Gtk::TreeView is OK in my application but I miss the pixbufs.
Here is the class for the Gtk::TreeModelColumns (ColumnRecord):
----------8<----------
class cFileListColumns : public Gtk::TreeModel::ColumnRecord
{
public:
cFileListColumns (void)
{
add(this->icon); add(this->filename);
add(this->size); add(this->uid);
add(this->gid); add(this->inode);
add(this->blocks); add(this->hlink);
}
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
Gtk::TreeModelColumn<Glib::ustring> filename;
Gtk::TreeModelColumn<unsigned int> size;
Gtk::TreeModelColumn<unsigned int> uid;
Gtk::TreeModelColumn<unsigned int> gid;
Gtk::TreeModelColumn<unsigned int> inode;
Gtk::TreeModelColumn<unsigned int> blocks;
Gtk::TreeModelColumn<unsigned int> hlink;
};
----------8<----------
One of the columns has the Pixbuf, the "icon" column.
Here comes the code that creates the columns in the Gtk::TreeView
----------8<----------
void
cFileList::create_columns (void)
{
/* FIXME: This relation causes errors */
this->tree_view.append_column ("Icon", this->column_set.icon);
/* This works. */
this->tree_view.append_column ("Filename",
this->column_set.filename);
this->tree_view.append_column ("Size", this->column_set.size);
this->tree_view.append_column ("UID", this->column_set.uid);
this->tree_view.append_column ("GID", this->column_set.gid);
this->tree_view.append_column ("Blocks", this->column_set.blocks);
this->tree_view.append_column ("Hlink", this->column_set.hlink);
}
----------8<----------
I figured out that the problem has something to do with the relation
of
the Gtk::TreeView::Column and the Gtk::ModelViewColumn. Because the
error messages appear even if I omit filling a
Glib::RefPtr<Gdk::Pixbuf>
into the store. If I create the Gtk::TreeView::Column manually with a
Gtk::CellRendererPixbuf without that relation, I don't get this error
message (but no pixbufs aswell, of corse).
Try to append the manually created column and see if it works then.
Regards,
Martin
Finally the code that fills the store:
----------8<----------
void
cFileListStore::set_dir (boost::shared_ptr<cDir> dir)
{
this->directory = dir;
for (unsigned int i = 0; i < dir->get_count(); ++i)
{
boost::shared_ptr<cFile> file = (*dir)[i];
Gtk::TreeModel::Row row = *(this->store->append());
row[this->column_set.icon] = cIconBase::get_broken();
row[this->column_set.filename] = file->get_name ();
row[this->column_set.size] = file->get_size ();
row[this->column_set.uid] = file->get_uid ();
row[this->column_set.gid] = file->get_gid ();
row[this->column_set.inode] = file->get_inode ();
row[this->column_set.blocks] = file->get_blocks ();
row[this->column_set.hlink] = file->get_hlink_count ();
}
return;
}
----------8<----------
I'm absolutly sure that ``cIconBase::get_broken()'' returns a valid
Glib::RefPtr<Gdk::Pixbuf>. And like I said above, if I omit that line
the errors still appear.
I hope anyone can help, any sample code would be enough I think.
Thanks.
Regards,
--
Simon Fuhrmann | NightSlayer at gmx.de | http://www.dismember.de
All people talk about the real life, but where can I download it?
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]