I am writing an application that uses C/C++ and Glade 3 for the GUI.
A part of the GUI, includes a multi-line TreeView
where each row represents a user.
On column two there is a CellRendererCombo
that represents product brands and on column three there is another CellRendererCombo
that represents the products.
What I am trying to do is: whenever I set the product brand (in column 2) for a user, I want the options of the products CellRendererCombo
(in column 3) to show only the products of that brand.
I tried updating the model with g_object_set
but that updates all CellRendererCombo
in the column.
In Glade:
GtkTreeModel
to the model of my TreeView
. Unfortunately GtkTreeModel
is not part of the drop-down list that Glade provides when you create a column, so I manually typed GtkTreemodel
to the type column.CellRendererCombo
that represents the products and defined as a model the column that I just created.In the source code:
When I load the data to the model of the TreeView
, I create for each row a new ListStore
and store a reference to it in the TreeView
model.
gtk_list_store_set (GTK_LIST_STORE(data->liststore_analysis), &iter, COLUMN_MODEL, GTK_LIST_STORE(data->liststore_products), -1);
When I change the value of the CellRendererCombo
that represents the brands, I update the rows in the model for the other CellRendererCombo
.
GtkListStore * list = GTK_LIST_STORE(data->liststore_products);
GtkTreeIter iter;
const char * openmoko[] = {"Neo 1973","Neo FreeRunner","Dash Express","3D7K","WikiReader"};
int i, openmokoModels = sizeof (openmoko) / sizeof (*openmoko);
for (i = 0; i < openmokoModels; i++){
gtk_list_store_append(list, &iter);
gtk_list_store_set(list, &iter, 0, openmoko[i], -1);
}
Thank you guys for your help! :)