it's not perfect but it'll do

This commit is contained in:
Lynne Megido 2020-09-04 02:08:31 +10:00
parent bc6d5b4fbb
commit a84e585d21
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

View file

@ -23,6 +23,7 @@ using System.Text.RegularExpressions;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Net;
using Gtk; using Gtk;
namespace Buypeeb { namespace Buypeeb {
@ -86,35 +87,20 @@ namespace Buypeeb {
this.RenderList(); this.RenderList();
this.itemTreeView.Model = this.items; this.itemTreeView.Model = this.items;
TreeCellDataFunc[] funcs = {
new TreeCellDataFunc(this.RenderColumnName),
new TreeCellDataFunc(this.RenderColumnPriceYen),
new TreeCellDataFunc(this.RenderColumnPriceAUD),
new TreeCellDataFunc(this.RenderColumnEnding)
};
for (int i = 0; i < this.itemTreeView.Columns.Length; i++) { for (int i = 0; i < this.itemTreeView.Columns.Length; i++) {
var c = this.itemTreeView.Columns[i]; var c = this.itemTreeView.Columns[i];
TreeCellDataFunc func;
//TODO: get rid of this awful if statement c.SetCellDataFunc(c.Cells[0], funcs[i]);
if (i == ItemColumns.Name) {
func = new TreeCellDataFunc(this.RenderColumnName);
}
else if (i == ItemColumns.PriceYen) {
func = new TreeCellDataFunc(this.RenderColumnPriceYen);
}
else if (i == ItemColumns.PriceAUD) {
func = new TreeCellDataFunc(this.RenderColumnPriceAUD);
}
else if (i == ItemColumns.Ending) {
func = new TreeCellDataFunc(this.RenderColumnEnding);
}
else {
Console.WriteLine($"unexpected value {i}!");
throw new IndexOutOfRangeException();
} }
c.SetCellDataFunc(c.Cells[0], func); this.UpdateItems();
}
foreach (object[] row in this.items) {
Console.WriteLine(row[0]);
}
DeleteEvent += Window_Shutdown; DeleteEvent += Window_Shutdown;
} }