2

I am trying to use a spin button within my TreeView. It as added like this:

Gtk.TreeViewColumn adjustColumn = new Gtk.TreeViewColumn();
adjustColumn.Title = "";
Gtk.CellRendererSpin adjustCell = new Gtk.CellRendererSpin();
adjustCell.Digits = 0;
adjustCell.Adjustment = new Adjustment(0, 0, 99, 1, 99, 99);
adjustCell.Editable = true;
adjustCell.Visible = true;
adjustCell.Sensitive = true;
adjustCell.Mode = CellRendererMode.Editable;
adjustColumn.PackEnd(adjustCell, true);

adjustColumn.SetCellDataFunc(adjustCell, new Gtk.TreeCellDataFunc(RenderAdjuster));
treeView.AppendColumn(adjustColumn);

And inside the rendering function the following is done:

(cell as Gtk.CellRendererSpin).Width = 30;
(cell as Gtk.CellRendererSpin).Height = 20;
(cell as Gtk.CellRendererSpin).Text = "" + (cell as Gtk.CellRendererSpin).Adjustment.Value;

This does render the value, but the spin buttons are not visible! They only become visible once the user clicks the value. That is absolutely ridiculous, as there is no way the user will know that the cell is editable other than randomly clicking in it, especially since there are other values in the row that are not editable.

So my first question is, how can I make those spin buttons always visible?

Could this be done with a custom CellRenderer?

I would be thankful for an example of how to create my own, actually working, spin button cell renderer. Unfortunately, custom cell renderers are an undocumented mystery (as almost anything in gtk# ;) ). And all you can find to them are examples that draw Cairo rectangles, etc. themselves. There must be an easier way where can you simply put any widget into that renderer, and listen to clicks, etc. and simply render the widget when the cell is rendered.

An example for a custom CellRenderer that simply displays a button (that can listen to clicks) would also be fine as I could at least "fake" a SpinButton, by having three columns with a text, a "+"-Button and a "-"-Button.

gpoo
  • 8,408
  • 3
  • 38
  • 53
TheSHEEEP
  • 2,961
  • 2
  • 31
  • 57

0 Answers0