[Glade-users] HELP: treeview GTK GLADE "C"
- From: damon karuna uklinux net (Damon Chaplin)
- Subject: [Glade-users] HELP: treeview GTK GLADE "C"
- Date: Thu, 12 May 2005 11:07:47 +0100
On Wed, 2005-05-11 at 13:13 -0300, john wrote:
I am studing GTK on GLADE with C.
what i must do in the follow code do works:
const char *numbers[] = { "Zero", "One", "Two", "Three", "Four",
"Five" };
enum {
INT_COLUMN,
STRING_COLUMN,
N_COLUMNS
};
void
on_button1_clicked (GtkButton *button,
gpointer user_data)
{
GtkListStore *list;
GtkTreeIter iter;
GtkTreeView *view;
GtkTreeViewColumn *num_column, *word_column;
GtkCellRenderer *text_renderer;
gint i;
view = lookup_widget(GTK_WIDGET(button),"treeview1");
/* create a two-column list */
list = gtk_list_store_new(N_COLUMNS, G_TYPE_INT, G_TYPE_STRING);
/* put some data into the list */
for (i = 0; i < 5; i++)
{
gtk_list_store_append(list, &iter);
gtk_list_store_set(list, &iter,
INT_COLUMN, i,
STRING_COLUMN, numbers[i],
-1);
}
/* create tree view for the list */
view = g_object_new(GTK_TYPE_TREE_VIEW,
"model", list,
"rules-hint", TRUE,
"headers-clickable", TRUE,
"reorderable", TRUE,
"enable-search", TRUE,
"search-column", STRING_COLUMN,
NULL);
You don't need to create another GtkTreeView here. You already have one,
in the 'view' variable.
You just need to do gtk_tree_view_set_model(view, list) to set the
model.
Damon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]