#include ONCE "window9.bi"

Function AddListViewColumn(iGadget As Long, sText As String, iPos As Long , iSubItem As long , iWidthColumn As long = 0 , iStyleColumnTEXT As Long = 0 , iStyleMask As Integer = 0) As long Export
	
	dim as  GtkTreeViewColumn ptr column
	
	dim as  GtkCellRenderer   ptr renderer
	
	dim as any ptr listview = GadgetID(iGadget)
	
	column = gtk_tree_view_column_new()
	
	if len(sText) then
		
		gtk_tree_view_column_set_title(column, strptr(sText))
		
	EndIf 
	
	Dim As Node Ptr fNode = tree_find_node(iGadget,pGlobalTypeWindow9->treeNumberGadgets)
	
	g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK (@EventColumnClickListViewGadgetSub), @(fNode->x))
	
	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED)
	
	gtk_tree_view_column_set_fixed_width (column, iWidthColumn)
	
	gtk_tree_view_column_set_resizable( column, 1)
	
	gtk_tree_view_column_set_clickable ( column, 1)  
	
	renderer = gtk_cell_renderer_pixbuf_new()
	
	gtk_tree_view_column_pack_start(column, renderer, FALSE)
	
	gtk_tree_view_column_set_attributes(column, renderer, "pixbuf", iSubItem*2, NULL)
	
	renderer = gtk_cell_renderer_text_new()
	
	gtk_tree_view_column_pack_start(column, renderer, TRUE)
	
	gtk_tree_view_column_set_attributes(column, renderer, "text", iSubItem*2+1 , NULL)	
	
	dim as integer iIndex = gtk_tree_view_insert_column (listview , column , iPos)
	
	g_object_set_data( cast(any ptr,column) , "IndexColumn" , cast(any ptr,iIndex-1))
	
	return iIndex
	
End Function