Gtk::CellRendererPixbuf: unable to set property 'surface'


I'm trying to set a "surface" property onĀ Gtk::CellRendererPixbuf
and getting a gtk error:

"unable to set property 'surface' of type 'CairoSurface' from value of type

This is the code:


class GscMainWindowIconView : public Gtk::IconView {

    Gtk::CellRendererPixbuf cell_renderer_pixbuf;
    // ...

            this->pack_start(cell_renderer_pixbuf, false);
                    sigc::mem_fun(this, &GscMainWindowIconView::on_cell_data));

    void on_cell_data(const Gtk::TreeModel::const_iterator& iter)
            Gtk::TreeRow row = *iter;
            Glib::RefPtr<Gdk::Pixbuf> pixbuf = row[col_pixbuf];

            // I couldn't find the gtkmm version of gdk_cairo_surface_create_from_pixbuf(),
            // that's why I create the surface this way.
            Cairo::Format format = Cairo::FORMAT_ARGB32;
            if (pixbuf->get_n_channels() == 3) {
                    format = Cairo::FORMAT_RGB24;
        Cairo::RefPtr<Cairo::Surface> surface = get_window()->create_similar_image_surface(
                            format, pixbuf->get_width(), pixbuf->get_height(), get_scale_factor());

            // THIS IS THE PROBLEM



Note that if I change Cairo surface creation and property setting
to C-style, everything works (although I'm not sure whether the "surface"
variable leaks? The docs don't mention):

cairo_surface_t* surface = gdk_cairo_surface_create_from_pixbuf(
        pixbuf->gobj(), get_scale_factor(), get_window()->gobj());
g_object_set(G_OBJECT(cell_renderer_pixbuf.gobj()), "surface", surface, NULL);

This all comes from trying to port the code from this bug report:


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