[Gtk-sharp-list] TreeCellDataFunc not getting pinged
aybiss
aaron at hardwarehookups.com.au
Wed Apr 11 18:51:35 EDT 2007
Adam Tauno Williams-2 wrote:
>
> It might be easier to just come up with a different demo; this is all
> intertwined quite a bit - http://code.google.com/p/consonance/
>
> Maybe this is enough....
>
Well, I now have this:
using System;
using Gtk;
using Gdk;
public class Task /* Bogus Task Object */
{
public Task() { }
public int ObjectId { get { return 1000; } }
public bool IsToDo { get { return true; } }
}
public class Test
{
private Label label = null;
private int counter = 0;
private bool configurationFailed = false;
private Gtk.Window wnd;
// Want to display a dialog, but can't.
public static void Main()
{
if (!GLib.Thread.Supported) GLib.Thread.Init();
Gdk.Threads.Init();
Application.Init();
Test t = new Test();
Gdk.Threads.Enter();
Application.Run();
Gdk.Threads.Leave();
}
public Test()
{
wnd = new Gtk.Window("Test");
wnd.Destroyed += new EventHandler(wnd_Destroyed);
Gtk.TreeViewColumn column;
Gtk.CellRendererText cell;
TreeView treeView;
TreeModelFilter filter;
ListStore taskStore;
taskStore = new ListStore(typeof(Task));
taskStore.AppendValues(new Task());
taskStore.AppendValues(new Task());
taskStore.AppendValues(new Task());
taskStore.AppendValues(new Task());
treeView = new TreeView();
filter = new TreeModelFilter(taskStore, null);
filter.VisibleFunc = new Gtk.TreeModelFilterVisibleFunc(ToDoFilter);
treeView.Model = filter;
column = new Gtk.TreeViewColumn();
column.Title = "Object Id";
cell = new Gtk.CellRendererText();
column.SetCellDataFunc(cell, new
Gtk.TreeCellDataFunc(RenderObjectId));
column.PackStart(cell, true);
treeView.AppendColumn(column);
wnd.Add(treeView);
wnd.ShowAll();
}
protected virtual void RenderObjectId(
Gtk.TreeViewColumn _column,
Gtk.CellRenderer _cell,
Gtk.TreeModel _model,
Gtk.TreeIter _iter)
{
Task task;
Console.WriteLine("RenderObjectId invoked");
task = (Task)_model.GetValue(_iter, 0);
(_cell as Gtk.CellRendererText).Text = task.ObjectId.ToString();
}
private bool ToDoFilter(Gtk.TreeModel _model, Gtk.TreeIter _iter)
{
Task task;
Console.WriteLine("Filtering task for ToDo list");
task = (Task)_model.GetValue(_iter, 0);
if (task == null) return false;
if (task.IsToDo) return true;
return false;
}
void wnd_Destroyed(object sender, EventArgs e)
{
Application.Quit();
}
}
And what I see is a list of empty cells.
--
View this message in context: http://www.nabble.com/TreeCellDataFunc-not-getting-pinged-tf3548034.html#a9950017
Sent from the Mono - Gtk# mailing list archive at Nabble.com.
More information about the Gtk-sharp-list
mailing list