Re: GtkTreeView isn't updating when GtkListStore appended and set



On Sat, 2014-01-04 at 23:46 -0600, Michael Cronenworth wrote:
On 01/04/2014 05:21 PM, Jordan H. wrote:
In Glade I've defined column "0" in the list store as a "gchararray"
cell. I even tried forcing the assignment of GtkListStore to GtkTreeView
(knowing full well I wouldn't need to) to no avail.

I don't get any errors, but the GtkTreeView doesn't reflect the changes
made to the GtkListStore. Any suggestions? Thanks in advance!

I haven't used Glade/GtkBuilder, but I'm not sure if it automatically assigns 
the ListStore column to the TreeView like you are thinking. You can make sure by 
calling a few functions.

gtk_tree_view_set_model( tree_view, GTK_TREE_MODEL( list_store ) );
gtk_tree_view_column_add_attribute( column, cell, "text", 0 );
// 0 being the column you want to assign to the column in the GtkTreeView

The treeview editor does indeed set these attributes for you and
GtkBuilder properly sets them up.

If you've declared the liststore with Glade before adding your cell
renderers then Glade should let you set the column by name, even
(Glade saves 'named' columns of the liststore in the form of xml
comments, even if columns names are not a part of the GtkTreeModel 
API). 

Jordan, can your provide some more information ?

For instance, are you certain that the treeview is not "updating"
at the time you append only ? or is it not showing any of the data
you added to the liststore "at all" ?

Can you also show us the Glade file in question so I can see if
it's indeed setup properly ?

Also, instead of using GtkBuilder API directly (and even worse,
needlessly keeping a GtkBuilder instance around for the life cycle
of your UI component), please consider using the composite templates
features introduced in GTK+ 3.10, it's a much cleaner way of using
GtkBuilder (but only available in 3.10 so that might still be an
issue for you)

See this file for a quick example of a dialog:
    https://git.gnome.org/browse/glade/tree/src/glade-preferences.c#n172

For more info on how composite templates work, see these posts:
Vala:http://blogs.gnome.org/tvb/2013/05/29/composite-templates-lands-in-vala/
C:http://blogs.gnome.org/tvb/2013/04/09/announcing-composite-widget-templates/

Cheers,
    -Tristan


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]