GTK+3 GtkCellRendererPixbuf: pixbuf vs. icon-name



Hi,

I would like to render either an icon or a pixbuf at the same place in
a TreeView. So, I tried to use a CellRendererPixbuf and either set the
pixbuf- or icon-name-property:

- Use a liststore with two columns, one for the pixbuf, one for the
  icon-name.
- Set only one of pixbuf or icon-name, and the other to None.

But in my tests, the pixbuf is always ignored, and either the icon-name-
image is shown or nothing.
Tested Python example:

--
from gi.repository import Gtk, GdkPixbuf

# create liststore with 2 columns
liststore = Gtk.ListStore(str, GdkPixbuf.Pixbuf)
treeview = Gtk.TreeView()
treeview.set_model(liststore)
renderer = Gtk.CellRendererPixbuf()
# set pixbuf- and icon-name-property of renderer
col = Gtk.TreeViewColumn("Image", renderer, pixbuf=1, icon_name=0)
treeview.append_column(col)

# poupulate liststore
icontheme = Gtk.IconTheme.get_default()
pixbuf = icontheme.load_icon("dialog-warning", 16, 0)
liststore.append(("dialog-error", None))
liststore.append((None,           pixbuf))
liststore.append(("dialog-error", pixbuf))

# show
w = Gtk.Window()
w.add(treeview)
w.show_all()
Gtk.main()
--

The documentation for GtkCellRendererPixbuf says:
- The "pixbuf" property: The pixbuf to render
- The "icon-name" property: The name of the themed icon to display. 
  This property only has an effect if not overridden by "stock_id" 
  or "pixbuf" properties.
So, the pixbuf-property should even override the icon-name-property.

In my example, I would expect "error, warning, warning" as images.
But instead, the pixbuf is completely ignored and I get "error, nothing, error".


Am I doing anything wrong?
Or is the documentation wrong?
Or do I have to only use pixmaps, and therefore create a pixmap from
every icon-name I want to use?


Thanks,
Roland


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