I'm new at GUI development and I've been working on a project with gtk+ 3 for some days, but I'm stuck at this point.
My app contains two treeviews, the data in the rows is obtained from an sql query, by right clicking on a row a popup-menu appears, giving the option to set the data as "known", updating the database table.
The previous data now should belong in the other treeview, and so it does when the app is restarted, but I'm looking to do it in real time.
Is it possible to update/refresh the data in a treeview?
The model is obtained with the function:
static GtkTreeStore* create_and_fill(char* known)
{
GtkTreeStore* store;
GtkTreeIter iter;
GtkWidget* tree;
store = gtk_tree_store_new(2,G_TYPE_STRING,G_TYPE_STRING);
char source_mac[50] = {0};
char source_ip[50] = {0};
int num_fields;
char query[300] = {0};
sprintf(query, "select mac,ip from hosts where known=%s", known);
if(mysql_query(conn, query))
{
fprintf(stderr,"%s\n", mysql_error(conn));
}
res = mysql_store_result(conn);
num_fields = mysql_num_fields(res);
while((row = mysql_fetch_row(res)))
{
sprintf(source_mac,"%s", row[0]);
sprintf(source_ip,"%s", row[1]);
gtk_tree_store_append(store, &iter, NULL);
gtk_tree_store_set(store, &iter, MAC_ADDRESS, source_mac, IP_ADDRESS, source_ip,-1);
}
gtk_tree_store_append(store, &iter, NULL);
mysql_free_result(res);
return store;
}