I would like to create a simple table in gtk with the following content:
| test name | 0 | 10 |
I simply want to create this, but gtk doesn't make this easy. I have made a GtkListStore which contains all the information I need, but apparently I need to create a GtkTreeViewColumn as well. I need to pass the values to gtk_tree_view_column_new_with_attributes, but the problem is that I don't know any attribute names and I can't find them anywhere. The only attribute I found was "text", but I pass unsigned integers as well. Could someone tell me what these attributes are, and how to create a simple table? (I read https://developer.gnome.org/gtk3/stable/TreeWidget.html btw)
enum { FILE_NAME = 0, FILE_OFFSET, FILE_SIZE };
GtkWidget* tree;
GtkListStore* store;
GtkTreeIter iter;
GtkCellRenderer* renderer;
GtkTreeViewColumn* column;
store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, FILE_NAME, "test name", FILE_OFFSET, 0,
FILE_SIZE, 10, -1);
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
g_object_unref (G_OBJECT (store));
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Name", renderer,
"text", FILE_NAME, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
With the posted code I get the following result:
| name ? |
| test name |