The model class is the data storage for your key/value pairs.
It contains two columns, both are of type
Gtk::TYPE_STRING
and can hold text and numbers.
The first is used for the keys, the values are stored in the
second column.
The class has several method that allow you to store data in the model: The classis set_array() takes an associative array of key/value pairs. Once set, you can use append_array() and prepend_array() to add new data after or before the current values. You also have the possibility to use insert_array() that takes the position as first, and the data array as second parameter.
Beside the *_array
methods, you can add
single key/value pairs by using
append() and prepend()
which take the key as first, and the value as second parameter.
insert() wants an additional position number
as first parameter, and key/value as second and third.
To delete data from the model, use remove_key(). After finishing your data manipulation, you can retrieve the full associative array of key/value pairs via get_array().
To obtain the key or value of a certain GtkTreeIter (that you got e.g. from the model by using get_iter()), use get_key() and get_text().