[Glade-users] How to add stuff to treeviews??
- From: darkeen at westnet.com.au (Jason Brisbane)
- Subject: [Glade-users] How to add stuff to treeviews??
- Date: Mon, 28 May 2007 22:09:36 +0800
Michael Ekstrand wrote:
On Fri, 2007-05-25 at 11:47 +0300, Felipe Balbi wrote:
After getting my treeview using glade_xml_get_widget() and inserting a
column with gtk_tree_view_insert_column()... how can I add data to the
treeview???
You don't add data to a tree view itself, you add it to the TreeModel
which is backing the treeview. So you need to create a GtkTreeModel of
some kind (usually either GtkListStore or GtkTreeStore), populate it,
and assign it to the tree view (with gtk_tree_view_set_model()).
See the following links for more details:
* http://scentric.net/tutorial/
* http://developer.gnome.org/doc/API/2.0/gtk/TreeWidget.html
- Michael
_______________________________________________
Glade-users maillist - Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users
Hello,
I too am trying to use a Treeview model view, etc.
I have created a list store before and that works fine.
Now I am creating a new program and want to create a Treeview with a
parent iter and 6 set child iter (ie you create a "new row" and the row
auto creates the 6 children underneath)
But I am having trouble doing ANYTHING with the treeview.
Cut/paste the example from the gtk 2.0 API simply fails to do anything.
I am left with a blank screen. inserting g_print shows that the code is
being called, but nothing is being displayed.
Since the gtk_tree_view is created in glade, I am simply doing a
lookup_widget on the treeview and adding columns to it (ie none exist)
and then populating the data.
My code, very stripped down (to remove possible errors) is:
void
on_harpmanager_show (GtkWidget *widget,
gpointer user_data)
{
GtkTreeStore *tree_store;
GtkTreeIter parent_iter, child_iter;
GtkWidget *view;
GtkCellRenderer *renderer;
GtkTreeSelection *selection;
GtkTreeViewColumn *col;
// CREATE THE TREE_VIEW and hook the row selection event into it!
view = lookup_widget(widget, "treeview_base");
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
gtk_tree_selection_set_select_function(selection, func_base_select,
NULL, NULL);
// CREATE COLUMN HEADERS
if (gtk_tree_view_get_column(GTK_TREE_VIEW(view), 0) == NULL)
{
// -- Column 1 --
col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, "CHARACTER NAME");
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, "text", 0);
}
}
With this I should get a simple treeview with column headings, but I get
nothing.
Adding the following also produces a blank screen.
tree_store = gtk_tree_store_new (1, G_TYPE_STRING);
gtk_tree_store_append (tree_store, &parent_iter, NULL);
gtk_tree_store_set (tree_store, &parent_iter, 0, "Darkeen", -1);
gtk_tree_store_append (tree_store, &parent_iter, &child_iter);
gtk_tree_store_set (tree_store, &child_iter, 0, "Profession", -1);
gtk_tree_store_append (tree_store, &parent_iter, &child_iter);
gtk_tree_store_set (tree_store, &child_iter, 0, "Race", -1);
gtk_tree_store_append (tree_store, &parent_iter, &child_iter);
gtk_tree_store_set (tree_store, &child_iter, 0, "Talents", -1);
gtk_tree_store_append (tree_store, &parent_iter, &child_iter);
gtk_tree_store_set (tree_store, &child_iter, 0, "Skills", -1);
gtk_tree_store_append (tree_store, &parent_iter, &child_iter);
gtk_tree_store_set (tree_store, &child_iter, 0, "Equipment", -1);
gtk_tree_view_set_model (GTK_TREE_VIEW(view), GTK_TREE_MODEL(tree_store));
g_object_unref (tree_store);
gtk_widget_show_all(widget);
HELP!
--
---
Regards,
Jason Brisbane
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]