After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 121615 - Problems with Gdk::Pixbuf columns in Gtk::TreeView
Problems with Gdk::Pixbuf columns in Gtk::TreeView
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: TreeView
2.2
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2003-09-06 14:42 UTC by Simon Fuhrmann
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Simon Fuhrmann 2003-09-06 14:42:20 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
Comment 1 Simon Fuhrmann 2003-09-06 14:51:58 UTC
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>
Comment 2 Simon Fuhrmann 2003-09-06 14:58:26 UTC
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
Comment 3 Martin Schulze 2003-09-09 17:54:35 UTC
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.
Comment 4 Murray Cumming 2003-09-13 18:09:37 UTC
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?
Comment 5 Ole Laursen 2003-09-16 18:54:19 UTC
Simon, have you tried the newest GCC 3.3 in Debian, i.e. a CVS version
of 3.3.2?
Comment 6 Simon Fuhrmann 2003-09-17 16:27:24 UTC
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?
Comment 7 Murray Cumming 2003-09-17 16:34:39 UTC
> 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.
Comment 8 Murray Cumming 2003-09-18 15:35:23 UTC
Which means, I'd really like you to try the latest version.
Comment 9 Murray Cumming 2003-09-22 16:43:39 UTC
Please reopen if this turns out to actually be a bug that still exists.
Comment 10 Simon Fuhrmann 2003-09-22 18:16:37 UTC
Alright.