how create model use variable
- From: Hariyanto <xhonghar gmail com>
- To: gtk-list gnome org
- Subject: how create model use variable
- Date: Fri, 9 Feb 2007 14:48:19 +0700
I create model in treeview like this :
GtkTreeModel *create_model_tw(gint ncol)
{
GtkListStore *model;
if (ncol == 2)
model = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING);
if (ncol == 3)
model = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING);
.
.
. until n col
return GTK_TREE_MODEL (model);
}
GtkTreeModel *fill_model_tw(GtkTreeModel *model, gint ncol)
{
gint i = 0;
GtkTreeIter iter;
if (ncol == 2)
{
for (i = 0; i < data_tw->>len; i++)
{
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
gtk_list_store_set (GTK_LIST_STORE(model), &iter,
1,
g_array_index (data_tw, ColPrefs, i).col1,
2,
g_array_index (data_tw, ColPrefs, i).col2,
-1);
}
}
if (ncol == 3)
.
.
.
return GTK_TREE_MODEL (model);
}
Is there another way to make it more simple?
thx
Hariyanto
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]