Hi,

Le 06/01/2014 17:26, Jordan H. a écrit :
> Attached is the Glade file. The GtkListStore ("liststore_button_list")
> is assigned the GtkTreeView ("treeview_button_order").

Looks like the attachment is missing.

> The GtkTreeView doesn't seem to reflect the changes made to the
> GtkListStore.

No idea if it could be this, but someone recently had a similar issue
because he's TreeView wasn't inside a ScrolledWindow, and GTK3 TreeView
has a resizing bug in this case (so the value where there but the view
was too small to show them).  So, is your TreeView in a ScrolledWindow,
or does it help?

> I iterated through the GtkListStore itself and found that
> values were being added.
> 
>     if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter)){
>         gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, 0,
> &test_value, -1);
>         g_debug(" - Value: \"%s\"", test_value);
>     }else{
>         g_warning("GtkTreeModel contains no elements!");
>     }
>     while (gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter)){
>         memset(test_value, 0, sizeof(gchararray));
>         gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, 0,
> test_value, -1);
>         g_debug(" - Value: \"%s\"", test_value);

Wow, I don't know what you are trying to do here with the memset() and
stuff.  "gchararray" in this context actually means "a C string",
`gchar*`.  Also, gtk_tree_model_get() *duplicates* the data, so you want
to free the memory afterwards.

        gchar *str;
        gtk_tree_model_get(model, &iter, 0, &str, -1);
        // ...
        g_free(str);


Not to duplicate code you also probably would rather implement iteration
like this:

        if (gtk_tree_model_get_iter_first(...)) {
                do {
                        ...
                } while (gtk_tree_model_iter_next(...));
        }

> I'm wondering if the mutilated strings is what's causing my problem. I'm
> expecting the values to be "Button 1", "Button 2", etc., and the button
> labels reflect this change (as expected).

This may be a reason if the data is actually wrong (I mean, if it's not
your fetching when printing that is), because GtkCellRendererText
requires UTF-8-encoded text.  But if this was the error, you'd see a lot
of warnings in the terminal.

I see 3 possibilities:

1) the tree model is not properly connected to the tree view;

2) you didn't add CellRenderers;

3) your tree view isn't packed in a ScrolledWindow and you experience
the above-mentioned bug.


Hope it helps.  Regards,
Colomban
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to