un p'tit clean et c'est Ok pour l'arbre. Comment gérer les données, maintenant ?

This commit is contained in:
Jean Sirmai 2024-05-22 08:10:52 +02:00
parent 62008e0248
commit 2f1112085a
Signed by: jean
GPG Key ID: FB3115C340E057E3
22 changed files with 17 additions and 422 deletions

1
cold.d
View File

@ -1 +0,0 @@
cold.o: cold.c texts.h

BIN
cold.o

Binary file not shown.

View File

@ -5,7 +5,6 @@
#include "display.h" #include "display.h"
#include "contain.h" #include "contain.h"
#include "texts.h" #include "texts.h"
#include "tree.h"
GtkWidget *get_edit_rules_page_new(){ GtkWidget *get_edit_rules_page_new(){

View File

@ -1,3 +0,0 @@
contain.o: contain.c hot.h warm.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib.h \
cold.h display.h contain.h texts.h tree.h

BIN
contain.o

Binary file not shown.

View File

@ -6,7 +6,6 @@
#include "display.h" #include "display.h"
#include "contain.h" #include "contain.h"
#include "texts.h" #include "texts.h"
#include "tree.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -265,7 +264,6 @@ GtkBox *get_experimental_box_new(){
GtkBox *get_rules_user_tree_new(){ GtkBox *get_rules_user_tree_new(){
GtkBox *tree_sketch_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); GtkBox *tree_sketch_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0));
gtk_box_append (tree_sketch_box, GTK_WIDGET (get_experimental_box_new())); gtk_box_append (tree_sketch_box, GTK_WIDGET (get_experimental_box_new()));
ui_create_tree (GTK_WIDGET (tree_sketch_box));
return tree_sketch_box; return tree_sketch_box;
} }

View File

@ -1,3 +0,0 @@
display.o: display.c hot.h warm.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib.h \
cold.h display.h contain.h texts.h tree.h

BIN
display.o

Binary file not shown.

70
hot.c
View File

@ -18,15 +18,10 @@ static struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;};
static struct TreeNode_t *create_tree_node (const gchar* text){ static struct TreeNode_t *create_tree_node (const gchar* text){
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t)); struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));
node->text = g_strdup(text); node->text = g_strdup(text);
node->child = NULL; // printf("create_tree_node %s\n", text); node->child = NULL; // if (0) printf("create_tree_node %s\n", text);
return node; return node;
} }
/*static void on_experimental_expander_toggled(GtkExpander *expander, gpointer user_data){
gtk_expander_set_expanded (expander, gtk_expander_get_expanded (expander));
printf("> %s\n", gtk_expander_get_label (user_data));
}*/
static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child){ static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child){
if (parent->child) { if (parent->child) {
struct TreeNode_t *cur = parent->child; struct TreeNode_t *cur = parent->child;
@ -54,30 +49,30 @@ static void on_experimental_tree_bind_factory (GtkSignalListItemFactory *factory
g_signal_connect(expander, "activate", G_CALLBACK(on_experimental_tree_expander_toggled), row); g_signal_connect(expander, "activate", G_CALLBACK(on_experimental_tree_expander_toggled), row);
gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row)*20); gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row)*20);
gboolean is_expanded = gtk_tree_list_row_get_expanded(row); gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
printf("[on_experimental_tree_bind_factory] row content is [%s] and expander is [%d]\n", text, is_expanded); if (0) printf("[on_experimental_tree_bind_factory] row content is [%s] and expander is [%d]\n", text, is_expanded);
} else printf("[on_experimental_tree_bind_factory] row == NULL\n"); } else if (0) printf("[on_experimental_tree_bind_factory] row == NULL\n");
} }
void on_experimental_tree_setup_factory (GtkSignalListItemFactory *factory, void on_experimental_tree_setup_factory (GtkSignalListItemFactory *factory,
GObject* object, gpointer user_data){ GObject* object, gpointer user_data){
GtkWidget* expander = gtk_expander_new (NULL); GtkWidget* expander = gtk_expander_new (NULL);
gtk_list_item_set_child (GTK_LIST_ITEM(object), expander); gtk_list_item_set_child (GTK_LIST_ITEM(object), expander);
printf("[on_experimental_tree_setup_factory] here is an expander\n"); if (0) printf("[on_experimental_tree_setup_factory] here is an expander\n");
} }
static GListModel* get_experimental_tree_model_child (struct TreeNode_t *parent){ static GListModel* get_experimental_tree_model_child (struct TreeNode_t *parent){
GtkStringList *list = NULL; GtkStringList *list = NULL;
if (parent) { if (parent) {
printf("[get_experimental_tree_model_child] here is %s content : ", parent->text); if (0) printf("[get_experimental_tree_model_child] here is %s content : ", parent->text);
struct TreeNode_t *child = parent->child; struct TreeNode_t *child = parent->child;
if (child) {list = gtk_string_list_new(NULL);} if (child) {list = gtk_string_list_new(NULL);}
while(child) { while(child) {
gtk_string_list_append(list, child->text); gtk_string_list_append(list, child->text);
printf("%s ", child->text); if (0) printf("%s ", child->text);
child = child->next; child = child->next;
} }
} }
printf("\n"); if (0) printf("\n");
return G_LIST_MODEL(list); return G_LIST_MODEL(list);
} }
@ -85,21 +80,19 @@ GListModel* create_experimental_tree_model (GObject *item, gpointer root){
struct TreeNode_t *cur = (struct TreeNode_t *)root; struct TreeNode_t *cur = (struct TreeNode_t *)root;
struct TreeNode_t *parent = root; struct TreeNode_t *parent = root;
const gchar *string = gtk_string_object_get_string (GTK_STRING_OBJECT(item)); const gchar *string = gtk_string_object_get_string (GTK_STRING_OBJECT(item));
printf(">>> %s\n",string);
while (cur) { while (cur) {
if (strcmp(string, cur->text) == 0) break; if (strcmp(string, cur->text) == 0) break;
cur = cur->next; cur = cur->next;
if (cur == NULL) {cur = parent->child; parent = cur;} if (cur == NULL) {cur = parent->child; parent = cur;}
} }
printf("[create_experimental_tree_model] looked for %s in %s item\n", cur->text, string); if (0) printf("[create_experimental_tree_model] looked for %s in %s item\n", cur->text, string);
return get_experimental_tree_model_child (cur); return get_experimental_tree_model_child (cur);
} }
void create_experimental_tree (GtkBox *experimental_box){ void create_experimental_tree (GtkBox *experimental_box){
GtkScrolledWindow *scrolled_window;
struct TreeNode_t *tree_root = create_tree_node("hello"); struct TreeNode_t *tree_root = create_tree_node("hello");
struct TreeNode_t *it_s_me = create_tree_node("it's me"); add_child_node(tree_root, it_s_me); struct TreeNode_t *it_s_me = create_tree_node("it's me"); add_child_node(tree_root, it_s_me);
struct TreeNode_t *remember = create_tree_node("remember"); add_child_node(it_s_me, remember); struct TreeNode_t *remember = create_tree_node("do you remember ?"); add_child_node(it_s_me, remember);
GtkStringList *model = gtk_string_list_new(NULL); GtkStringList *model = gtk_string_list_new(NULL);
gtk_string_list_append (model, tree_root->text); gtk_string_list_append (model, tree_root->text);
@ -107,9 +100,6 @@ void create_experimental_tree (GtkBox *experimental_box){
g_signal_connect (factory, "setup", G_CALLBACK(on_experimental_tree_setup_factory), NULL); g_signal_connect (factory, "setup", G_CALLBACK(on_experimental_tree_setup_factory), NULL);
g_signal_connect (factory, "bind", G_CALLBACK(on_experimental_tree_bind_factory), NULL); g_signal_connect (factory, "bind", G_CALLBACK(on_experimental_tree_bind_factory), NULL);
// GListModel *a_test = create_experimental_tree_model(G_OBJECT (model), tree_root);
printf("> %s > %s > %s\n", tree_root->text, it_s_me->text, remember->text);
GtkTreeListModel *tree_model = gtk_tree_list_model_new( GtkTreeListModel *tree_model = gtk_tree_list_model_new(
G_LIST_MODEL (model), G_LIST_MODEL (model),
FALSE, // Passthrough - False in actual usage with dynamic children retrieval FALSE, // Passthrough - False in actual usage with dynamic children retrieval
@ -122,39 +112,13 @@ void create_experimental_tree (GtkBox *experimental_box){
GtkSingleSelection *selection_model = gtk_single_selection_new (G_LIST_MODEL (tree_model)); GtkSingleSelection *selection_model = gtk_single_selection_new (G_LIST_MODEL (tree_model));
gtk_single_selection_set_autoselect (selection_model, FALSE); gtk_single_selection_set_autoselect (selection_model, FALSE);
gtk_single_selection_set_can_unselect (selection_model, TRUE); gtk_single_selection_set_can_unselect (selection_model, TRUE);
GtkWidget *list_view = gtk_list_view_new (GTK_SELECTION_MODEL (selection_model), GTK_LIST_ITEM_FACTORY (factory));
GtkWidget *list_view = gtk_list_view_new (GTK_SELECTION_MODEL (selection_model), GtkScrolledWindow *experimental_scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new());
GTK_LIST_ITEM_FACTORY (factory)); gtk_scrolled_window_set_child(experimental_scrolled_window, list_view);
gtk_scrolled_window_set_policy (experimental_scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new()); gtk_widget_set_vexpand(GTK_WIDGET(experimental_scrolled_window), TRUE);
gtk_scrolled_window_set_child(scrolled_window, list_view); assert(experimental_box);
gtk_box_append(GTK_BOX(experimental_box), GTK_WIDGET(experimental_scrolled_window));
gtk_scrolled_window_set_policy (scrolled_window, gtk_widget_set_visible(GTK_WIDGET(experimental_scrolled_window), TRUE);
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_set_vexpand(GTK_WIDGET(scrolled_window), TRUE);
gtk_box_append(GTK_BOX(experimental_box), GTK_WIDGET(scrolled_window));
gtk_widget_set_visible(GTK_WIDGET(scrolled_window), TRUE);
gtk_widget_set_visible(GTK_WIDGET(list_view), TRUE); gtk_widget_set_visible(GTK_WIDGET(list_view), TRUE);
// gtk_widget_set_visible(GTK_WIDGET(experimental_box), TRUE);
// gtk_widget_set_visible(GTK_WIDGET(list_view), TRUE);
} }
/*
[on_experimental_tree_setup_factory] here is an expander
[on_experimental_tree_bind_factory] row content is [hello] and expander is [0]
[on_tree_setup_factory] here is an expander
[on_tree_bind_factory] here is Root content and expander is 0
[ui_tree_create_model_func] looked for Root in Root item
[ui_tree_get_children_model] here is Root content : ATP ADP AMP
[on_tree_setup_factory] here is an expander
[on_tree_bind_factory] here is ATP content and expander is 0
[on_tree_setup_factory] here is an expander
[on_tree_bind_factory] here is ADP content and expander is 0
[on_tree_setup_factory] here is an expander
[on_tree_bind_factory] here is AMP content and expander is 0
*/

3
hot.d
View File

@ -1,3 +0,0 @@
hot.o: hot.c warm.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib.h \
cold.h display.h contain.h texts.h

BIN
hot.o

Binary file not shown.

89
main.d
View File

@ -1,89 +0,0 @@
main.o: main.c hot.h warm.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/galloca.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gtypes.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/lib/glib-2.0/include/glibconfig.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmacros.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gversionmacros.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/glib-visibility.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/garray.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gasyncqueue.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gthread.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gatomic.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/glib-typeof.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gerror.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gquark.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gutils.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gbacktrace.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gbase64.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gbitlock.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gbookmarkfile.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gdatetime.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gtimezone.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gbytes.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gcharset.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gchecksum.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gconvert.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gdataset.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gdate.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gdir.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/genviron.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gfileutils.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/ggettext.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/ghash.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/glist.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmem.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gnode.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/ghmac.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gchecksum.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/ghook.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/ghostutils.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/giochannel.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmain.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gpoll.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gslist.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gstring.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gunicode.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gstrfuncs.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gkeyfile.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmappedfile.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmarkup.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmessages.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gvariant.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gvarianttype.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/goption.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gpathbuf.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gpattern.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gprimes.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gqsort.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gqueue.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/grand.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/grcbox.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/grefcount.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/grefstring.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmem.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gmacros.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gregex.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gscanner.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gsequence.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gshell.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gslice.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gspawn.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gstringchunk.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gstrvbuilder.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gtestutils.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gthreadpool.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gtimer.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gtrashstack.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gtree.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/guri.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/guuid.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/gversion.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/deprecated/gallocator.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/deprecated/gcache.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/deprecated/gcompletion.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/deprecated/gmain.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/deprecated/grel.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/deprecated/gthread.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib/glib-autocleanups.h \
cold.h display.h contain.h

BIN
main.o

Binary file not shown.

BIN
myprogram

Binary file not shown.

View File

@ -1 +0,0 @@
texts.o: texts.c

BIN
texts.o

Binary file not shown.

252
tree.c
View File

@ -1,252 +0,0 @@
#include <stdio.h>
#include <gtk-4.0/gtk/gtk.h>
#include "hot.h"
#include "warm.h"
#include "cold.h"
#include "display.h"
#include "contain.h"
#include "texts.h"
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
// https://docs.gtk.org/gtk4/section-text-widget.html
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
// Simplified TreeNode structure for demonstration purposes
// --------------------------------------------------------
/*
* Tree-related signals
*/
void on_tree_expander_toggled(GtkExpander *expander, gpointer user_data)
{
// This is a conceptual callback for when an expander is toggled
GtkTreeListRow *row = GTK_TREE_LIST_ROW(user_data);
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
gtk_tree_list_row_set_expanded(row, !is_expanded);
}
void on_tree_setup_factory (GtkSignalListItemFactory *factory,
GObject* object,
gpointer user_data)
{
GtkWidget* expander = gtk_expander_new (NULL);
gtk_list_item_set_child (GTK_LIST_ITEM(object), expander);
printf("[on_tree_setup_factory] here is an expander\n");
}
void on_tree_bind_factory (GtkSignalListItemFactory *factory,
GObject* object,
gpointer user_data)
{
// GObject *item;
const gchar *text;
GtkTreeListRow *row;
GtkListItem *list_item;
GtkWidget *expander;
list_item= GTK_LIST_ITEM(object);
row = gtk_list_item_get_item(list_item);
if (row != NULL) {
text = gtk_string_object_get_string(GTK_STRING_OBJECT(gtk_tree_list_row_get_item(row)));
expander = gtk_list_item_get_child(list_item);
gtk_expander_set_label(GTK_EXPANDER(expander), text);
// Disconnect previous signal handlers to avoid stacking them
g_signal_handlers_disconnect_by_func(expander, G_CALLBACK(on_tree_expander_toggled), row);
// Connect the signal handler
g_signal_connect(expander, "activate", G_CALLBACK(on_tree_expander_toggled), row);
gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row)*20);
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
printf("[on_tree_bind_factory] here is %s content and expander is %d\n",
text,
is_expanded);
} else {
printf("[on_tree_bind_factory] here is NON content\n");
}
}
void on_tree_selection_changed (GtkSelectionModel* self, guint position,
guint n_items, gpointer user_data)
{
printf("[on_tree_selection_changed]\n");
}
struct TreeNode_t
{
gchar *text;
struct TreeNode_t *child;
struct TreeNode_t *next;
};
// Function to create a new TreeNode instance
static struct TreeNode_t *create_tree_node (const gchar* text)
{
struct TreeNode_t *node = g_malloc0 (sizeof(struct TreeNode_t));
node->text = g_strdup(text);
node->child = NULL;
return node;
}
// Function to add a child node to a parent node
static void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child)
{
struct TreeNode_t *cur;
if (parent->child) {
cur = parent->child;
while (cur && cur->next) {
cur = cur->next;
}
cur->next = child;
} else {
parent->child = child;
}
}
// Recursive function to free a TreeNode and its children
// attention: « free_tree_node » défini mais pas utilisé <<< TODO
static void free_tree_node (struct TreeNode_t *node)
{
struct TreeNode_t *cur;
struct TreeNode_t *tmp;
if (!node) return;
// free siblings
cur = node;
while (cur) {
tmp = cur->next;
g_free(cur);
cur = tmp;
}
// recursive free
free_tree_node(node->child);
g_free(node->text);
g_free(node);
}
// Function to simulate getting a GListModel of children for a given TreeNode
GListModel* ui_tree_get_children_model (struct TreeNode_t *parent)
{
struct TreeNode_t *child;
GtkStringList *list = NULL;
if (parent) {
printf("[ui_tree_get_children_model] here is %s content : ", parent->text);
child = parent->child;
if (child) {
list = gtk_string_list_new(NULL);
}
while(child) {
gtk_string_list_append(list, child->text);
printf("%s ", child->text);
child = child->next;
}
}
printf("\n");
return G_LIST_MODEL(list);
}
// GtkTreeListModelCreateModelFunc callback implementation
GListModel* ui_tree_create_model_func(GObject *item, gpointer root)
{
struct TreeNode_t *cur = (struct TreeNode_t *)root;
struct TreeNode_t *parent = NULL;
const gchar *string = gtk_string_object_get_string(GTK_STRING_OBJECT(item));
parent = root;
while (cur) {
if (strcmp(string, cur->text) == 0) {
break;
}
cur = cur->next;
if (cur == NULL) {
cur = parent->child;
parent = cur;
}
}
printf("[ui_tree_create_model_func] looked for %s in %s item\n",
cur->text,
string);
return ui_tree_get_children_model(cur);
}
// Application activation callback
void ui_create_tree (GtkWidget *target_widget)
{
GtkStringList *model;
GtkTreeListModel *tree_model;
GtkSignalListItemFactory *factory;
GtkSingleSelection *selection_model;
GtkWidget *list_view;
GtkScrolledWindow *scrolled_window;
assert(target_widget);
struct TreeNode_t *tree_root = create_tree_node("Root"); // AD HOC XXX & no free()
struct TreeNode_t *ATP = create_tree_node("ATP"); add_child_node(tree_root, ATP);
struct TreeNode_t *ADP = create_tree_node("ADP"); add_child_node(tree_root, ADP);
struct TreeNode_t *AMP = create_tree_node("AMP"); add_child_node(tree_root, AMP);
struct TreeNode_t *adenine = create_tree_node("adénine"); add_child_node(ATP, adenine);
struct TreeNode_t *ribose = create_tree_node("ribose"); add_child_node(adenine, ribose);
struct TreeNode_t *PO4H3_1 = create_tree_node("phosphate 1"); add_child_node(ribose, PO4H3_1);
struct TreeNode_t *PO4H3_2 = create_tree_node("phosphate 2"); add_child_node(PO4H3_1, PO4H3_2);
struct TreeNode_t *PO4H3_3 = create_tree_node("phosphate 3"); add_child_node(PO4H3_2, PO4H3_3);
model = gtk_string_list_new(NULL);
gtk_string_list_append(model, tree_root->text);
// Create and setup the list view and item factory
factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new ());
g_signal_connect (factory, "setup", G_CALLBACK(on_tree_setup_factory), NULL);
g_signal_connect (factory, "bind", G_CALLBACK(on_tree_bind_factory), NULL);
// Create a GtkTreeListModel
tree_model = gtk_tree_list_model_new(
G_LIST_MODEL(model),
FALSE, // Passthrough - False in actual usage with dynamic children retrieval
FALSE, // autoexpand
(GtkTreeListModelCreateModelFunc)ui_tree_create_model_func,
tree_root,
NULL //(GDestroyNotify)free_tree_node
);
selection_model = gtk_single_selection_new (
G_LIST_MODEL (tree_model));
gtk_single_selection_set_autoselect (selection_model, FALSE);
gtk_single_selection_set_can_unselect (selection_model, TRUE);
/* g_signal_connect (selection_model, "selection-changed", */
/* G_CALLBACK(on_tree_selection_changed), NULL); */
list_view = gtk_list_view_new (GTK_SELECTION_MODEL (selection_model),
GTK_LIST_ITEM_FACTORY (factory));
scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new());
gtk_scrolled_window_set_child(scrolled_window, list_view);
gtk_scrolled_window_set_policy (scrolled_window,
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_set_vexpand(GTK_WIDGET(scrolled_window), TRUE);
gtk_box_append(GTK_BOX(target_widget), GTK_WIDGET(scrolled_window));
gtk_widget_set_visible(GTK_WIDGET(scrolled_window), TRUE);
gtk_widget_set_visible(GTK_WIDGET(list_view), TRUE);
}

3
tree.d
View File

@ -1,3 +0,0 @@
tree.o: tree.c hot.h warm.h \
/gnu/store/fkmpkdav2zmz1k72989bdgpdrfac7rz1-glib-2.78.0/include/glib-2.0/glib.h \
cold.h display.h contain.h texts.h

10
tree.h
View File

@ -1,10 +0,0 @@
/******************************************************************************/
/* */
/* E coli by David S. Goodsell (2009) */
/* --- */
/* Let this freeze frame guide us towards the model */
/* that alone can account for the phenomenon ! */
/* */
/******************************************************************************/
void ui_create_tree (GtkWidget *target_widget);

BIN
tree.o

Binary file not shown.

1
warm.d
View File

@ -1 +0,0 @@
warm.o: warm.c cold.h display.h contain.h texts.h

BIN
warm.o

Binary file not shown.