WIP: introducing a simple text renderer. (I)

This commit is contained in:
Jean Sirmai 2023-11-25 08:59:48 +01:00
parent e5b58345d3
commit 1f96af32fd
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 39 additions and 2 deletions

View File

@ -28,12 +28,49 @@
#include "../../include/base.h" #include "../../include/base.h"
#include "../../include/ui.h" #include "../../include/ui.h"
#include <gtk/gtk.h>
enum
{
COL_FIRST_NAME = 0,
COL_LAST_NAME,
NUM_COLS
} ;
GtkListStore *list_store; GtkListStore *list_store;
GtkTreeStore *tree_store; GtkTreeStore *tree_store;
GtkTreeIter iter, child; GtkTreeIter iter, child;
static void tree_c_printing_test(void); static void tree_c_printing_test(void);
static GtkTreeModel *
create_and_fill_model (void)
{
GtkTreeStore *treestore;
GtkTreeIter toplevel, child;
treestore = gtk_tree_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_STRING);
/* Append a top level row and leave it empty */
gtk_tree_store_append(treestore, &toplevel, NULL);
/* Append a second top level row, and fill it with some data */
gtk_tree_store_append(treestore, &toplevel, NULL);
gtk_tree_store_set(treestore, &toplevel,
COL_FIRST_NAME, "Joe",
COL_LAST_NAME, "Dalton",
-1);
/* Append a child to the second top level row, and fill in some data */
gtk_tree_store_append(treestore, &child, &toplevel);
gtk_tree_store_set(treestore, &child,
COL_FIRST_NAME, "Averell",
COL_LAST_NAME, "Dalton",
-1);
return GTK_TREE_MODEL(treestore);
}
/*********************************************************** /***********************************************************
* * * *
* Going through every row in a list store * * Going through every row in a list store *
@ -130,10 +167,10 @@ tree_c_test(void)
static void tree_c_printing_test(void) static void tree_c_printing_test(void)
{ {
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\
(https://en.wikibooks.org/wiki/GTK (modulo) 2B_By_Example/Tree_View/Columns_and_Renderer)\n\n\
cf. tuto : gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT); - (cf. line 69)\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\n\ creates a new list store with two columns.\n\n\
gtk_tree_store_new(1, G_TYPE_STRING); - (cf. line 108)\n\ gtk_tree_store_new(1, G_TYPE_STRING); - (cf. line 108)\n\