- wxCHECK_MSG( m_list != NULL, FALSE, "invalid checklistbox" );
-
- GList *child = g_list_nth( m_list->children, index );
- if (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- GtkLabel *label = GTK_LABEL( bin->child );
-
- wxString str = label->label;
-
- return (str[1] == 'X');
- }
-
- wxFAIL_MSG("wrong checklistbox index");
- return FALSE;
+ //Create the checklist in our treeview and set up events for it
+ GtkCellRenderer* renderer =
+ gtk_cell_renderer_toggle_new();
+ GtkTreeViewColumn* column =
+ gtk_tree_view_column_new_with_attributes( "", renderer,
+ "active", 0,
+ NULL );
+ gtk_tree_view_column_set_fixed_width(column, 20);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_clickable(column, TRUE);
+
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (gtk_checklist_toggled),
+ this);
+
+ gtk_tree_view_append_column(m_treeview, column);
+}
+
+bool wxCheckListBox::IsChecked(unsigned int index) const
+{
+ wxCHECK_MSG( m_treeview != NULL, false, wxT("invalid checklistbox") );
+
+ GtkTreeIter iter;
+ gboolean res = gtk_tree_model_iter_nth_child(
+ GTK_TREE_MODEL(m_liststore),
+ &iter, NULL, //NULL = parent = get first
+ index
+ );
+ if(!res)
+ return false;
+
+ GValue value = {0, };
+ gtk_tree_model_get_value(GTK_TREE_MODEL(m_liststore),
+ &iter,
+ 0, //column
+ &value);
+
+ return g_value_get_boolean(&value) == TRUE ? true : false;