[Glade-users] HELP: treeview GTK GLADE "C"
- From: softfacil ligtaxi com br (john)
- Subject: [Glade-users] HELP: treeview GTK GLADE "C"
- Date: Wed, 11 May 2005 13:13:13 -0300
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);
/* create and initialize text renderer for cells */
text_renderer = gtk_cell_renderer_text_new();
/* create column views */
num_column = gtk_tree_view_column_new_with_attributes("Numeral",
text_renderer,
"text",
INT_COLUMN,
NULL);
g_object_set(num_column,
"resizable", TRUE,
"clickable", TRUE,
"reorderable", TRUE,
NULL);
word_column = gtk_tree_view_column_new_with_attributes("Word",
text_renderer,
"text",
STRING_COLUMN,
NULL);
g_object_set(word_column,
"resizable", TRUE,
"clickable", TRUE,
"reorderable", TRUE,
NULL);
/* insert columns into the view */
gtk_tree_view_append_column(view, num_column);
gtk_tree_view_append_column(view, word_column);
}
Thanks to the help.
<=================================================>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]