private void BuildColumns() { // Hidden expander column TreeViewColumn col = new TreeViewColumn(); col.Visible = false; AppendColumn(col); ExpanderColumn = col; source_column = new TreeViewColumn(); source_column.Sizing = TreeViewColumnSizing.Autosize; uint xpad = 2; // Special renderer for header rows; hidden for normal source rows header_renderer = new CellRendererText() { Xpad = xpad, Ypad = 4, Ellipsize = Pango.EllipsizeMode.End, Weight = (int)Pango.Weight.Bold, Variant = Pango.Variant.SmallCaps }; // Renderer for source rows; hidden for header rows source_renderer = new SourceRowRenderer(); source_renderer.Xpad = xpad; source_column.PackStart(header_renderer, true); source_column.SetCellDataFunc(header_renderer, new Gtk.CellLayoutDataFunc((layout, cell, model, iter) => { var type = (SourceModel.EntryType)model.GetValue(iter, (int)SourceModel.Columns.Type); header_renderer.Visible = type == SourceModel.EntryType.Group; source_renderer.Visible = type == SourceModel.EntryType.Source; if (type == SourceModel.EntryType.Group) { var source = model.GetValue(iter, (int)SourceModel.Columns.Source) as Source; header_renderer.Visible = true; header_renderer.Text = source.Name; } else { header_renderer.Visible = false; } })); int width, height; Gtk.Icon.SizeLookup(IconSize.Menu, out width, out height); source_renderer.RowHeight = RowHeight.Get(); source_renderer.RowHeight = height; source_renderer.Ypad = (uint)RowPadding.Get(); source_renderer.Ypad = 2; source_column.PackStart(source_renderer, true); source_column.SetCellDataFunc(source_renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler)); AppendColumn(source_column); HeadersVisible = false; }
private void BuildColumns() { // Hidden expander column TreeViewColumn col = new TreeViewColumn(); col.Visible = false; AppendColumn(col); ExpanderColumn = col; focus_column = new TreeViewColumn(); renderer = new SourceRowRenderer(); renderer.RowHeight = RowHeight.Get(); renderer.Padding = RowPadding.Get(); focus_column.PackStart(renderer, true); focus_column.SetCellDataFunc(renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler)); AppendColumn(focus_column); HeadersVisible = false; }
private void BuildColumns() { // Hidden expander column TreeViewColumn col = new TreeViewColumn(); col.Visible = false; AppendColumn(col); ExpanderColumn = col; source_column = new TreeViewColumn(); source_column.Sizing = TreeViewColumnSizing.Autosize; uint xpad = 2; // Special renderer for header rows; hidden for normal source rows header_renderer = new CellRendererText() { Xpad = xpad, Ypad = 4, Ellipsize = Pango.EllipsizeMode.End, Weight = (int)Pango.Weight.Bold, Variant = Pango.Variant.SmallCaps }; // Renderer for source rows; hidden for header rows source_renderer = new SourceRowRenderer(); source_renderer.Xpad = xpad; source_column.PackStart(header_renderer, true); source_column.SetCellDataFunc(header_renderer, new Gtk.CellLayoutDataFunc((layout, cell, model, iter) => { if (model == null) { throw new ArgumentNullException("model"); } // be paranoid about the values returned from model.GetValue(), they may be null or have unexpected types, see bgo#683359 var obj_type = model.GetValue(iter, (int)SourceModel.Columns.Type); if (obj_type == null || !(obj_type is SourceModel.EntryType)) { var source = model.GetValue(iter, (int)SourceModel.Columns.Source) as Source; var source_name = source == null ? "some source" : String.Format("source {0}", source.Name); Log.ErrorFormat( "SourceView of {0} could not render its source column because its type value returned {1} from the iter", source_name, obj_type == null ? "null" : String.Format("an instance of {0}", obj_type.GetType().FullName)); header_renderer.Visible = false; source_renderer.Visible = false; return; } var type = (SourceModel.EntryType)obj_type; header_renderer.Visible = type == SourceModel.EntryType.Group; source_renderer.Visible = type == SourceModel.EntryType.Source; if (type == SourceModel.EntryType.Group) { var source = (Source)model.GetValue(iter, (int)SourceModel.Columns.Source); header_renderer.Visible = true; header_renderer.Text = source.Name; } else { header_renderer.Visible = false; } })); int width, height; Gtk.Icon.SizeLookup(IconSize.Menu, out width, out height); source_renderer.RowHeight = RowHeight.Get(); source_renderer.RowHeight = height; source_renderer.Ypad = (uint)RowPadding.Get(); source_renderer.Ypad = 2; source_column.PackStart(source_renderer, true); source_column.SetCellDataFunc(source_renderer, new CellLayoutDataFunc(SourceRowRenderer.CellDataHandler)); AppendColumn(source_column); HeadersVisible = false; }