[Gtk-sharp-list] TreeView & Glade on win32 via .NET

Simon Guindon simon@nureality.ca
Fri, 18 Apr 2003 16:04:18 -0400


Ok first off, I would like to report glade-sharp on .NET on the win32
platform isn't working very well I don't think.  If your just loading a
glade file to show the GUI all is perfect and great.  But once you try and
use the [Glade.Widget] attribute to attach to widgets, thats where you come
into problems.  If you do it once your ok, but any more than more than 1
widget it crashes.

Now the TreeView problem I'm having.  I don't know if this is a bug or just
my total complete lack of GTK/GTK# knowledge but I can't for the life of me
get a icon from disk into a treeview.  Stock icons work, but from disk it
does not, but like I said, I could very well be doing something wrong.  Let
me paste the code:

store = new TreeStore((int)TypeFundamentals.TypeString,
(uint)Gdk.Pixbuf.GType, (int)TypeFundamentals.TypeString);
tvFriendsList.Model = this.store;

// let's build the first column
TreeViewColumn labelColumn = new TreeViewColumn();
labelColumn.Title = "Friends";

CellRenderer iconRenderer = new CellRendererPixbuf();
labelColumn.PackStart(iconRenderer, false);
labelColumn.AddAttribute(iconRenderer, "pixbuf", (int)ColumnId.Icon);

CellRenderer labelRenderer = new CellRendererText();
labelColumn.PackStart(labelRenderer, true);
labelColumn.AddAttribute(labelRenderer, "text", (int)ColumnId.Name);

tvFriendsList.AppendColumn(labelColumn);

// let's build the column that stores the JIDs
TreeViewColumn labelColumn2 = new TreeViewColumn();
labelColumn2.Title = "JID";

CellRenderer labelRenderer2 = new CellRendererText();
labelColumn2.PackStart(labelRenderer2, true);
labelColumn2.AddAttribute(labelRenderer2, "text", (int)ColumnId.JID);

// Now we add a node
TreeModel model;
TreeIter parent = TreeIter.Zero, iter;
TreeSelection selection = tvFriendsList.Selection;

if (null != selection && selection.GetSelected(out model, ref parent))
{
	store.Append(out iter, parent);
}
else
{
	store.Append(out iter);
}
store.SetValue(iter, (int)ColumnId.Icon, new Value(new
Gdk.Pixbuf("test.png")));
store.SetValue(iter, (int)ColumnId.Name, new Value("Simon"));
store.SetValue(iter, (int)ColumnId.JID, new Value("simon@wherever.com"));

I get these exceptions:

(<unknown>:25049): Gtk-WARNING **: gtktreestore.c:817: Unable to convert
from gchararray to GdkPixbuf
(<unknown>:25049): Gtk-WARNING **: gtktreestore.c:817: Unable to convert
from gchararray to GdkPixbuf
(<unknown>:25049): Gtk-WARNING **: gtktreestore.c:817: Unable to convert
from gchararray to GdkPixbuf
(<unknown>:25049): GLib-GObject-WARNING **: unable to set property `pixbuf'
of type `GdkPixbuf' from value of type `gchararray'
(<unknown>:25049): GLib-GObject-WARNING **: unable to set property `text' of
type `gchararray' from value of type `GdkPixbuf'

Basically this works if I modify the code to use "stock" icons.  Am I doing
something wrong or is this just a bug?

Any suggestions/comments would be great on both of these issues.
Thanks,
Simon

-----------------------------
Simon Guindon
Nureality Networks
www.nureality.ca