c# - syncing a GTK iterTree with a list -
i have following problem, created tree model folowing arguments :
this.mods = sdvmmr.modlistmanagment.loadlist(modstore); // createing columns gtk.treeviewcolumn cbcolumn = new gtk.treeviewcolumn(); cbcolumn.title = "active"; gtk.cellrenderertext cbcell = new gtk.cellrenderertext(); cbcolumn.packstart(cbcell, true); gtk.treeviewcolumn namecolumn = new gtk.treeviewcolumn(); namecolumn.title = "name"; gtk.cellrenderertext modsnamecell = new gtk.cellrenderertext(); namecolumn.packstart(modsnamecell, true); gtk.treeviewcolumn authorcolumn = new gtk.treeviewcolumn(); authorcolumn.title = "author"; gtk.cellrenderertext authorcell = new gtk.cellrenderertext(); authorcolumn.packstart(authorcell, true); gtk.treeviewcolumn versioncolumn = new gtk.treeviewcolumn(); versioncolumn.title = "version"; gtk.cellrenderertext versioncell = new gtk.cellrenderertext(); versioncolumn.packstart(versioncell, true); // add columns treeview activemods.appendcolumn(cbcolumn); activemods.appendcolumn(namecolumn); activemods.appendcolumn(authorcolumn); activemods.appendcolumn(versioncolumn); namecolumn.addattribute(modsnamecell, "text", 1); authorcolumn.addattribute(authorcell, "text", 2); versioncolumn.addattribute(versioncell, "text",3); // column checkbox created gtk.cellrenderertoggle valuecb = new cellrenderertoggle(); cbcolumn.packstart(valuecb, true); activemods.model = modstore;
the in code used mods consists of internal definition: internal list mods = new list();
fore refrence here used modinfo:
public string name { get; set; } public string author { get; set; } public string version { get; set; } public string uniqueid { get; set; } public string minimumapiversion { get; set; } public string description { get; set; } public string entrydll { get; set;} public bool isactive { get; set; } public bool isxnb { get; set; } public string orgxnbpath { get; set; }
the function use looks like:
internal static void addtotree(modinfo mod, liststore modstore) { /*gtk.treeiter iter = modstore.appendvalues(mod.name); modstore.appendvalues(iter, "author", mod.author); modstore.appendvalues(iter, "version", mod.version); modstore.appendvalues(iter, "description", mod.description); modstore.appendvalues(iter, "is active", mod.isactive.tostring());*/ modstore.appendvalues(mod.isactive.tostring(),mod.name,mod.author,mod.version); }
but 1 doesnt accepts list entries. there way accept in memory list.
the model creation seems wrong. don't won't have list type of model items. want type list contains:
... new gtk.treestore(typeof(sdvmmr.modinfo));
.
assuming class sdvmmr.modinfo class properties have indicated, add items in list , populate model, should like:
foreach (modinfo mod in list<sdvmmr.modinfo>) { activemods.appendvalues (mod); }
you need customize cell data functions in order treeview know data from.
private void rendernamecell (gtk.treeviewcolumn column, gtk.cellrenderer cell, gtk.treemodel model, gtk.treeiter iter) { svdmmr.modinfo modinfo = (svdmmr.modinfo) model.getvalue (iter, 0); (cell gtk.cellrenderertext).text = modinfo.name; } private void rendervaluecell (gtk.treeviewcolumn column, gtk.cellrenderer cell, gtk.treemodel model, gtk.treeiter iter) { // didn't value lets use uniqueid svdmmr.modinfo modinfo = (svdmmr.modinfo) model.getvalue (iter, 0); (cell gtk.cellrenderertext).text = modinfo.uniqueid; }
these methods must setup on cell renderers:
namecolumn.setcelldatafunc (modsnamecell, new gtk.treecelldatafunc (rendernamecell)); valuecolumn.setcelldatafunc (modvaluecell, new gtk.treecelldatafunc (rendervaluecell));
your code incomplete , missing few hints answer may incomplete.
Comments
Post a Comment