Re: Getting the TreeModelColumns from a Glade file
- From: Dominik Gabi <dkgispam gmail com>
- To: José Alburquerque <jaalburquerque cox net>
- Cc: gtkmm-list gnome org
- Subject: Re: Getting the TreeModelColumns from a Glade file
- Date: Tue, 15 Jun 2010 11:24:24 +0200
On 06/14/2010 02:46 AM, José Alburquerque wrote:
On Sat, 2010-06-12 at 06:40 +0200, Dominik Gabi wrote:
Hi,
I'd like to set and get the values of a Gtk::TreeStore that I've
instantiated in Glade. I'd like to do this the way it is done in the
gtkmm-tutorial (with the overloaded [] operator of the TreeRow).
If you can get the model using Gtk::Builder::get_object(), it should be
possible to get to a desired row by dereferencing an iterator of the
model (see Gtk::TreeModel::get_iter()[1] and the section on "Iterating
over Model Rows"[2] in the online book). You would have to define a
Gtk::TreeModelColumnRecord corresponding to the model so that something
like:
(*iter)[columns.a_column] = ...;
could be done.
[1]
http://library.gnome.org/devel/gtkmm/stable/classGtk_1_1TreeModel.html#aebaa795e4920ddc0ec5e39c9f4fbc660
[2]
http://library.gnome.org/devel/gtkmm-tutorial/stable/sec-iterating-over-model-rows.html
The
problem is that, I either generate the whole TreeView in the code (which
I'd like to avoid, if somehow possible) and specify the necessary
TreeModelColumns by hand, or I have to extract them somehow from what is
generated in Glade. Since the columns are not objects in Glade, I was
hoping I could access them using the model or the view... Unfortunately
I can't find anything in the documentation.
It should be possible to get the columns of the TreeView (created in
glade) using Gtk::TreeView::get_column().
Is there an easier way to manipulate a TreeRow or am I just missing
something here?
Unfortunately Gtk::TreeView::get_column() returns a TreeViewColumn
whereas Gtk::TreeRow::operator[] takes an TreeModelColumn as argument.
I've solved the problem with the following code which is not as nice as
the book solution but works fine for now.
enum {TITLE=0, URI, NEW, TYPE}; // Columns
template <class T>
void get_value(Gtk::TreeIter it, int column, T &result)
{
if (it)
it->get_value(column, result);
}
template <class T>
void set_value(Gtk::TreeIter it, int column, T &value)
{
if (it)
it->set_value(column, value);
}
Regards,
Dominik.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]