I write GTKMM applications using version 4.18 and I wish to programatically obtain the Gtk::Box that contains the Gtk::Label that forms the title for each column in a Gtk::ColumnView. I can see the structure of the Gtk::ColumnView via Gtk Inspector but cannot find a member function (or series of them) to fetch the Gtk::Box for a given column. I would like to specify the column via an integral number - ie 0 for the first column, etc. I have searched this forum as well as general internet searches but I cannot locate the answer.
I write GTKMM applications using version 4.18 and I wish to programatically obtain the Gtk::Box that contains the Gtk::Label that forms the title for each column in a Gtk::ColumnView. I can see the structure of the Gtk::ColumnView via Gtk Inspector but cannot find a member function (or series of them) to fetch the Gtk::Box for a given column. I would like to specify the column via an integral number - ie 0 for the first column, etc. I have searched this forum as well as general internet searches but I cannot locate the answer.
Share Improve this question asked Apr 1 at 4:33 SRBSRB 183 bronze badges1 Answer
Reset to default 0Found a useful post on the GNOME Discourse site which provided me with enough information to answer my own question. The following code will explain what needs to happen:
Gtk::ColumnView *matrix;
//
//Now we need to obtain the first child of the matrix column view and
//this is the row of headers. Given the header we then need to fetch
//the set of children (as the column view contains one or more titles)
//and from this we can fetch the underlying widget.
//
auto matrix_header = matrix->get_first_child();
assert(matrix_header);
//
//As the row of headers contains more than one widget - there is a
//widget for each title - we must obtain all of the children for the
//above row of headers.
//
auto matrix_header_vector = matrix_header->get_children();
assert(matrix_header_vector.size() > 0);
//
//Now we need to obtain the parent for the child that is in the row
//number column. As the row number column widget will be a Gtk::Label
//we need the parent which should be a Gtk::Box and it is from this
//that we obtain the sizing information.
//
auto header_widget = matrix_header_vector[0]->get_parent();
assert(header_widget);
type here