Re: [gtk2] clist - treeview
- From: Olaf Frączyk <olaf cbk poznan pl>
- To: Andreas Volz <andreas brachttal net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: [gtk2] clist - treeview
- Date: 02 Dec 2002 14:30:53 +0100
On Mon, 2002-12-02 at 14:53, Andreas Volz wrote:
Hi,
where is the difference between "gtk_tree_view_new_with_model" and
"gtk_clist_new_with_titles"? They seems to look the same. Glade knows
only the treeview.
I couldn't find examples for the treeview. Could I use clist with gtk2
if I want to create a data-table? Or is there an example how to add data
to an treeview?
Hi,
1. Yes you can use CList, but this is deprecated. BTW, if you are going
to put a lot of data I would stay with gtk1. I have tried gtk2 with both
clist and tree, and it is just too slow (the rendering is slower by
factor 10 or 20) comparing to gtk-1 clist, this is probably because of
pango.
2. Here is an example:
static int Add_Eqt_List(struct MainWindow *Window)
{
glong i;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
GtkTreeIter iter;
Window->EqtListStore=gtk_list_store_new (8, G_TYPE_LONG, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING
, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, -1);
/* Here we should get all values to put to this List form SQL Database
*/
for(i=0;i<5000;i++)
{
gtk_list_store_append(Window->EqtListStore,&iter);
gtk_list_store_set(Window->EqtListStore,&iter,0,i,-1);
gtk_list_store_set(Window->EqtListStore,&iter,1,"kkk",-1);
gtk_list_store_set(Window->EqtListStore,&iter,2,"kkk",-1);
gtk_list_store_set(Window->EqtListStore,&iter,3,"kkk",-1);
gtk_list_store_set(Window->EqtListStore,&iter,4,"kkk",-1);
gtk_list_store_set(Window->EqtListStore,&iter,5,"kkk",-1);
gtk_list_store_set(Window->EqtListStore,&iter,6,"FAILED",-1);
gtk_list_store_set(Window->EqtListStore,&iter,7,"Ĺ?Ä?czka",-1);
}
Window->EqtTreeView=gtk_tree_view_new_with_model (GTK_TREE_MODEL
(Window->EqtListStore));
Window->EqtListScrolledWindow=gtk_scrolled_window_new(NULL,NULL);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("Id",renderer,"text",0,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_min_width(column,20);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("Name",renderer,"text",1,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_min_width(column,50);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("City",renderer,"text",2,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_min_width(column,50);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("Site",renderer,"text",3,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_min_width(column,50);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("Type",renderer,"text",4,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_min_width(column,100);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("bb",renderer,"text",5,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_min_width(column,20);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("aa",renderer,"text",6,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_fixed_width(column,20);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
renderer=gtk_cell_renderer_text_new ();
column=gtk_tree_view_column_new_with_attributes
("Status",renderer,"text",7,NULL);
gtk_tree_view_column_set_resizable(column,TRUE);
gtk_tree_view_column_set_min_width(column,60);
gtk_tree_view_append_column (GTK_TREE_VIEW (Window->EqtTreeView),
column);
gtk_container_add(GTK_CONTAINER(Window->EqtListScrolledWindow),
Window->EqtTreeView);
//gtk_fixed_put(GTK_FIXED(Window->FixedContainer), Window->EqtTreeView,
8, 16);
gtk_fixed_put(GTK_FIXED(Window->FixedContainer),
Window->EqtListScrolledWindow, 8, 16);
gtk_widget_set_usize(Window->EqtListScrolledWindow,488,224);
gtk_widget_show(Window->EqtListScrolledWindow);
gtk_widget_show(Window->EqtTreeView);
return(0);
}
Regards,
Olaf
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]