GNOME Bugzilla – Bug 121615
Problems with Gdk::Pixbuf columns in Gtk::TreeView
Last modified: 2004-12-22 21:47:04 UTC
Hello! This bug was discussed in the gtkmm-mailing-list. A bugzilla post was requested. The Gtk::TreeView does not generate the correct default renderer for a Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> >. The default renderer causes errors on execution: (treev_test:568): GLib-GObject-WARNING **: unable to set property `text' of type `gchararray' from value of type `GdkPixbuf' I have prepared code, that should work but causes errors: --------8<-------- #include <gtkmm/liststore.h> #include <gtkmm/treeview.h> #include <gtkmm/window.h> #include <gtkmm/main.h> static char* simple_icon_xpm[] = { "10 10 2 1", " c None", ". c #000000", "..........", ". .", ". ...... .", ". . . .", ". . .. . .", ". . .. . .", ". . . .", ". ...... .", ". .", ".........." }; static Glib::RefPtr<Gdk::Pixbuf> pixbuf_icon; class cListColumns : public Gtk::TreeModel::ColumnRecord { public: Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon; Gtk::TreeModelColumn<Glib::ustring> name; cListColumns (void) { this->add(this->icon); this->add(this->name); } }; class cListWindow : public Gtk::Window { public: cListColumns column_set; Glib::RefPtr<Gtk::ListStore> store; Gtk::TreeView tree_view; cListWindow (void) { /* Fill store */ this->store = Gtk::ListStore::create (this->column_set); Gtk::TreeModel::Row row = *(this->store->append()); row[this->column_set.icon] = pixbuf_icon; row[this->column_set.name] = "Something"; row = *(this->store->append()); row[this->column_set.icon] = pixbuf_icon; row[this->column_set.name] = "Another row"; /* Create cols */ this->tree_view.set_model (this->store); /* This column causes errors. If I create the column * manually with * iconcolumn->set_renderer(*imagerenderer, this->column_set.icon); * the code works. */ this->tree_view.append_column("Icon", this->column_set.icon); /* This one works well. */ this->tree_view.append_column("Name", this->column_set.name); this->add(this->tree_view); this->show_all(); } }; int main (int argc, char* argv[]) { Gtk::Main gtk_kit(&argc, &argv); pixbuf_icon = Gdk::Pixbuf::create_from_xpm_data (simple_icon_xpm); cListWindow listwin; Gtk::Main::run(); return 0; } --------8<-------- Regards. -- Simon Fuhrmann | Nightslayer at gmx.de | http://www.dismember.de
Includes corrected: #include <gdkmm/pixbuf.h> #include <gtkmm/treemodel.h> #include <gtkmm/treemodelcolumn.h> #include <gtkmm/liststore.h> #include <gtkmm/treeview.h> #include <gtkmm/window.h> #include <gtkmm/main.h>
I use g++-3.2 (GCC) 3.2.3 20030415 (Debian prerelease) g++ (GCC) 3.3.1 20030626 (Debian prerelease) does not work with gtkmm-2.2. Information about my Debian gtkmm: Package: libgtkmm2.0-dev Priority: optional Section: libdevel Installed-Size: 8260 Maintainer: Bradley Bell <btb@debian.org> Architecture: i386 Source: gtkmm2.0 Version: 2.2.2-1 Replaces: libgtkmm1.3-dev Depends: libgtkmm2.0-1c102 (= 2.2.2-1), libgtk2.0-dev (>= 2.2.0), libsigc++-1.2-dev (>= 1.2.3-1) Suggests: libgtkmm2.0-doc Conflicts: libgtkmm1.3-dev Filename: pool/main/g/gtkmm2.0/libgtkmm2.0-dev_2.2.2-1_i386.deb Size: 1547086
You debian package must be outdated. The test code runs fine with gtkmm 2.2.5 (built with gcc 3.2.2): no error messages and the pixmaps are drawn correctly.
I notice that he is talking about "gcc 3.2.3 20030415 ", which I guess is newer than Martin's gcc 3.2.2. So I doubt that it's not outdated. Is this a very new gcc 3.2.x bug?
Simon, have you tried the newest GCC 3.3 in Debian, i.e. a CVS version of 3.3.2?
I only tried the two compilers mentioned above, these are g++ (GCC) 3.3.1 20030626 (Debian prerelease) and g++-3.2 (GCC) 3.2.3 20030415 (Debian prerelease) 3.3.1 is the newest package from Debian Sarge and I do not want to update to SID (Still in Dev), I've had a very bad experience with these extreme unstable packages. Maybe I'll try the CVS version 3.3.2 soon. As a temporary solution I use the following code to create the PixBuf-Column: Gtk::CellRendererPixbuf *imagerenderer = Gtk::manage(new Gtk::CellRendererPixbuf); Gtk::TreeViewColumn* iconcolumn = Gtk::manage(new Gtk::TreeViewColumn("Icon", *imagerenderer)); iconcolumn->set_renderer(*imagerenderer, this->column_set.icon); this->tree_view.append_column (*iconcolumn); Maybe the whole problem is related to my gtkmm-version 2.2.2-1, which is older than Martin's version 2.2.5?
> Maybe the whole problem is related to my gtkmm-version 2.2.2-1, which > is older than Martin's version 2.2.5? Very possibly. Always try the latest version (2.2.7 now) before submitting a bug.
Which means, I'd really like you to try the latest version.
Please reopen if this turns out to actually be a bug that still exists.
Alright.