Hello everyone,
I’m trying to create a ListView Widget and I have an issue. The widget is being created correctly but when I try to populate the ListStore using gtk_list_store_set_value() instruction even if the GValue structure is initialized and filled with the information I would like to use to populate the ListStore the rows in the listview remain empty.
This is the way I’m creating the widget :
Procedure.i New(ColumnNames.s)
*This.Private_Members = AllocateStructure(Private_Members)
*This\VirtualTable = ?START_METHODS
*This\ScrolledWindowID = gtk_scrolled_window_new_(#Null, #Null)
gtk_scrolled_window_set_shadow_type_(*This\ScrolledWindowID, #GTK_SHADOW_IN)
ColumnMax.l = CountString(ColumnNames, Chr(10))
*GTYPE = AllocateMemory((ColumnMax+1) * SizeOf(Integer))
FillMemory(*GTYPE, (ColumnMax+1) * SizeOf(Integer), #G_TYPE_STRING, #PB_Integer)
*ListStore = gtk_list_store_newv_(ColumnMax+1, *GTYPE)
FreeMemory(*GTYPE)
*This\ListViewID = gtk_tree_view_new_with_model_(*ListStore)
g_object_unref_(*ListStore)
gtk_container_add_(*This\ScrolledWindowID, *This\ListViewID)
; *Cursor = *GTYPE
For ColumnID = 0 To ColumnMax
*CellRenderer = gtk_cell_renderer_text_new_()
*TreeViewColumnID = gtk_tree_view_column_new_()
gtk_tree_view_column_add_attribute_(*TreeViewColumnID, *CellRenderer, "text", ColumnID)
gtk_tree_view_column_set_title_(*TreeViewColumnID, StringField(ColumnNames, ColumnID+1, Chr(10)))
gtk_tree_view_append_column_(*This\ListViewID, *TreeViewColumnID)
; Debug Str(PeekI(*Cursor)) + " vs #G_TYPE_STRING (" + Str(#G_TYPE_STRING) + ")"
; *Cursor + SizeOf(Integer)
Next
gtk_tree_view_set_grid_lines(*This\ListViewID, 3)
ProcedureReturn *This
EndProcedure
And this is the way I’m trying to populate the ListView :
Procedure AppendItem(*This.Private_Members, Definition.s)
Protected Iter.GtkTreeIter, Value.GValue
*ListStore = gtk_tree_view_get_model_(*This\ListViewID)
gtk_list_store_append_(*ListStore, @Iter)
If gtk_list_store_iter_is_valid_(*ListStore, @Iter)
ColumnMax.l = CountString(Definition, Chr(10))
For ColumnID = 0 To ColumnMax
CellValue.s = StringField(Definition, ColumnID+1, Chr(10))
g_value_init_(@Value, #G_TYPE_STRING)
g_value_set_string_(@Value, CellValue)
*ExtractedValue = g_value_get_string_(@Value)
If *ExtractedValue <> #Null
Debug CellValue + " vs " + PeekS(*ExtractedValue, -1, #PB_UTF8)
Else
Debug CellValue + " vs NUll Pointer"
EndIf
gtk_list_store_set_value(*ListStore, @Iter, ColumnID, @Value)
Next
EndIf
EndProcedure
Just for the record, the programming language I’m using is PureBasic and unfortunately as far as I know this compiler as no problem dealing C functions libraries as long as those functions don’t have a variable number of argument. So telling me that I should use the gtk_list_store_new () or gtk_list_store_set () function instead, you are not helping.
My guess is the function gtk_list_store_set_value() is broken but I’m not sure. Any help will be appreciated.
Best regards