void SetupFilterEntry(Alignment c, Table table, CheckButton cb) { Entry e = MiscHelpers.MakeFilterEntry(); e.Changed += delegate(object sender, EventArgs a) { UpdateSearchFilter(e, table, cb.Active); }; c.Add(e); c.ShowAll(); }
public EditDebaters() : base(Gtk.WindowType.Toplevel) { this.Build(); editDebatersSettings = AppSettings.I.EditDebaters; entryDebatersFilter = MiscHelpers.MakeFilterEntry(); entryDebatersFilter.Changed += OnEntryDebatersFilterChanged; cEntryFilter.Add(entryDebatersFilter); cEntryFilter.ShowAll(); InitTreeDebaters(); }
// TODO Currently, all the parsing functions simply swallow errors, // doing nothing if an error is encountered. It might me nicer to // give some feedback to the user. public EditDebaters() : base(WindowType.Toplevel) { columns = new Dictionary <string, ColumnInfo> { { "Name", new ColumnInfo { cellRendererType = CellRendererTextAdv.Type.Entry, get = e => new DebaterProperty <Name>( e.Name, (e1, name) => e1.Name = name, (e1, name) => e1.Name = name), parseAndSet = (e, name) => { OPDtabData.Name.Parse(name).Do(n => e.Name = n); } } }, { "Club", new ColumnInfo { cellRendererType = CellRendererTextAdv.Type.EntryWithCompletion, get = e => new DebaterProperty <Club>( e.Club, (e1, club) => e1.Club = club, (e1, club) => e1.Club = club), parseAndSet = (e, club) => { Club.Parse(club).Do(c => e.Club = c); } } }, { "Age", new ColumnInfo { cellRendererType = CellRendererTextAdv.Type.Entry, get = e => new DebaterProperty <uint>( e.Age, (e1, age) => e1.Age = age, (e1, age) => e1.Age = age), parseAndSet = (e, age) => { try { e.Age = uint.Parse(age); } catch (FormatException) {} } } }, { "Role", new ColumnInfo { cellRendererType = CellRendererTextAdv.Type.EntryWithCompletion, get = e => new DebaterProperty <Role>( e.Role, (e1, role) => e1.Role = role, (e1, role) => e1.Role = role), parseAndSet = (e, role) => { e.Role = OPDtabData.Role.Parse(role); } } }, { "BlackList", new ColumnInfo { cellRendererType = CellRendererTextAdv.Type.DebaterPattern, get = e => new DebaterProperty <DebaterPattern>( e.BlackList, (e1, bl) => e1.BlackList = bl, (_, __) => { throw new Exception( "Attempt to set BlackList property of RoundDebater."); }), parseAndSet = (e, bl) => e.BlackList = DebaterPattern.Parse(bl) } }, { "WhiteList", new ColumnInfo { cellRendererType = CellRendererTextAdv.Type.DebaterPattern, get = e => new DebaterProperty <DebaterPattern>( e.WhiteList, (e1, wl) => e1.WhiteList = wl, (_, __) => { throw new Exception( "Attempt to set WhiteList property of RoundDebater."); }), parseAndSet = (e, wl) => e.WhiteList = DebaterPattern.Parse(wl) } }, { "ExtraInfo", new ColumnInfo { cellRendererType = CellRendererTextAdv.Type.Entry, get = e => new DebaterProperty <string>( e.ExtraInfo, (e1, info) => e1.ExtraInfo = info, (_, __) => { throw new Exception( "Attempt to set ExtraInfo property of RoundDebater."); }), parseAndSet = (e, info) => e.ExtraInfo = info.Trim() } } }; Build(); editDebatersSettings = AppSettings.I.EditDebaters; entryDebatersFilter = MiscHelpers.MakeFilterEntry(); entryDebatersFilter.Changed += OnEntryDebatersFilterChanged; cEntryFilter.Add(entryDebatersFilter); cEntryFilter.ShowAll(); InitTreeDebaters(); }