WIP: (micro) Three empty lines have been added to the model.

This commit is contained in:
Jean Sirmai 2023-11-24 17:57:44 +01:00
parent ea43778291
commit 96bb834615
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 42 additions and 2 deletions

View File

@ -118,7 +118,13 @@ void ui_send_internal_notification (const char *message);
void ui_close_internal_notification (void); void ui_close_internal_notification (void);
void ui_toggle_sidebar (); void ui_toggle_sidebar ();
/* -------------------------------------------------------------------------- */
// Tree primitives
void traverse_list_store (GtkListStore *liststore);
void onTreeViewRowActivated (GtkTreeView *view, GtkTreePath *path, void onTreeViewRowActivated (GtkTreeView *view, GtkTreePath *path,
GtkTreeViewColumn *col, gpointer userdata); GtkTreeViewColumn *col, gpointer userdata);
void tree_c_printing_test(void); void tree_c_printing_test(void);

View File

@ -29,7 +29,35 @@
#include "../../include/ui.h" #include "../../include/ui.h"
GtkListStore *list_store; GtkListStore *list_store;
GtkTreeIter iter;
/***********************************************************
* *
* Going through every row in a list store *
* *
***********************************************************/
void
traverse_list_store (GtkListStore *liststore)
{
GtkTreeIter iter;
gboolean valid;
g_return_if_fail ( liststore != NULL );
/* Get first row in list store */
valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(liststore), &iter);
while (valid)
{
/* ... do something with that row using the iter ... */
/* (Here column 0 of the list store is of type G_TYPE_STRING) */
gtk_list_store_set(liststore, &iter, 0, "Joe", -1);
/* Make iter point to the next row in the list store */
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(liststore), &iter);
}
}
/************************************************************* /*************************************************************
* * * *
* Converting a GtkTreePath into a GtkTreeIter * * Converting a GtkTreePath into a GtkTreeIter *
@ -68,11 +96,17 @@ tree_c_printing_test(void)
{ {
list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT); list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT);
/* Append empty rows to the list store. Iter will point to the new row */
gtk_list_store_append(list_store, &iter);
gtk_list_store_append(list_store, &iter);
gtk_list_store_append(list_store, &iter);
printf("tree_c_printing_test() \ printf("tree_c_printing_test() \
---------------------------------------------------------\n\n\ ---------------------------------------------------------\n\n\
(https://en.wikibooks.org/wiki/GTK (modulo) 2B_By_Example/Tree_View/Tree_Models)\n\n\ (https://en.wikibooks.org/wiki/GTK (modulo) 2B_By_Example/Tree_View/Tree_Models)\n\n\
cf. tuto : This creates a new list store with two columns.\n\ cf. tuto : gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT) - (cf. line 69)\n\
creates a new list store with two columns.\n\
Column 0 stores a string and column 1 stores an unsigned integer for each row.\n\ Column 0 stores a string and column 1 stores an unsigned integer for each row.\n\
At this point the model has no rows yet of course.\n"); Three empty lines have been added to the model - (cf. line 100).\n");
} }