I'm having trouble getting TreeView in GTK3 to properly wrap text.
I installed it like this:
Gtk::TreeViewColumn* pColumn = mTreeView.get_column(2);
static_cast<Gtk::CellRendererText *>(pColumn->get_first_cell())
->property_wrap_mode().set_value(Pango::WRAP_WORD_CHAR);
static_cast<Gtk::CellRendererText *>(pColumn->get_first_cell())
->property_wrap_width().set_value(200);
This works, the text is wrapped, but when I resize the window and make it larger, there is a lot of ugly white space above and below the cell with long text. GTK seems to reserve height for a cell based on packing width. Which doesn't make any sense to me.
I tried to get around the setup needed in signal_check_resize, with calculating the required width as follows:
Gtk::TreeViewColumn* pColumn = mTreeView.get_column(2);
auto width = this->get_allocated_width()
- mTreeView.get_column(0)->get_width()
- mTreeView.get_column(1)->get_width();
static_cast<Gtk::CellRendererText *>(pColumn->get_first_cell())
->property_wrap_width().set_value(width-100);
this->forceRecreateModel = true;
But that allows me to make the window bigger. It cannot be compressed after resizing.
The question is, how is this done correctly?
I am using gtk3.20.3-1 and gtkmm3.20.1-1 on Arch linux.
EDIT: fixed typo in title ...