diff --git a/2024-07 audit proto-gg.html b/2024-07 audit proto-gg.html new file mode 100644 index 0000000..a513581 --- /dev/null +++ b/2024-07 audit proto-gg.html @@ -0,0 +1,804 @@ + + + + + + + - + + + + +

Gem-graph client

+

version 0.0 commit +8ce7191df3652ddd6284c4ac6d8d42c3cf32d2d5

+

Audit de code +source et structure de projet

+

Arborescence des sources

+

Voici l’arborescence de la version actuelle du projet.

+
├── data
+│   ├── dimers random walk.xml
+│   ├── image
+│   │   ├── [...]
+│   └── text
+│       ├── [...]
+├── include
+│   ├── automat.h
+│   ├── base.h
+│   ├── calls.h
+│   ├── graph.h
+│   ├── parse.h
+│   └── widgets.h
+├── Makefile
+├── manifest.scm
+├── [...]
+└── src
+    ├── automat.c
+    ├── calls.c
+    ├── graph.c
+    │   ├── area.c
+    │   ├── draw.c
+    │   ├── grid.c
+    │   ├── init.c
+    │   ├── shader.frag
+    │   ├── shader.vert
+    │   └── stack.c
+    ├── main.c
+    ├── parse.c
+    └── widget.c
+        ├── heads.c
+        ├── labo.c
+        ├── rules.c
+        ├── state.c
+        ├── stock.c
+        └── tree.c
+
+8 dossiers, 46 fichiers
+

Un certain nombre d’élements doivent être respectés :

+ +

Erreurs critiques :

+ +

Analyse formelle des sources

+

Généralités :

+ +

Analyse des headers

+

Problèmes critiques relevés :

+ +
base.h [critique] +[à retravailler]
+ +
automat.h +[critique] [à retravailler]
+ +
calls.h [critique] +[à retravailler]
+ +
graph.h [critique] +[à retravailler]
+ +
parse.h [critique] +[à retravailler]
+ +
widgets.h +[critique] [à retravailler]
+ +

Analyse du code

+

Problèmes critiques relevés :

+ +
main.c [critique] +[à retravailler]
+ +
automat.c +[critique] [à retravailler]
+ +
calls.c [critique] +[à retravailler]
+ +
parse.c [critique] +[à retravailler]
+ +
module graph.c +[critique] [à retravailler]
+ +
area.c [critique] +[à retravailler]
+ +
draw.c [critique] +[à retravailler]
+ +
grid.c [critique] +[à retravailler]
+ +
init.c [critique] +[à retravailler]
+ +
shader.frag +[critique] [à retravailler]
+ +
shader.vert +[critique] [à retravailler]
+ +
stack.c [critique] +[à retravailler]
+ +
module widget.c +[critique] [à retravailler]
+ +
heads.c [critique] +[à retravailler]
+ +
labo.c [critique] +[à retravailler]
+

You who enter here, leave all hope of an understandable +code

+

Ok, je saute.

+
rules.c [critique] +[à retravailler]
+ +
state.c [critique] +[à retravailler]
+ +
stock.c [critique] +[à retravailler]
+ +
tree.c [critique] +[à retravailler]
+ + + + \ No newline at end of file diff --git a/include/actions.h b/include/action.h similarity index 67% rename from include/actions.h rename to include/action.h index ed4007f..47bc293 100644 --- a/include/actions.h +++ b/include/action.h @@ -7,4 +7,13 @@ // https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/include/ui.h // https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/src/ui/events.c // https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/src/ui/application.c +// +// https://en.wikipedia.org/wiki/GIO_(software) + +#include +#include + +void on_preferences_action(GSimpleAction *action, + GVariant *parameter, + gpointer user_data); diff --git a/include/automat.h b/include/fsm.h similarity index 100% rename from include/automat.h rename to include/fsm.h diff --git a/include/graph.h b/include/graphics.h similarity index 100% rename from include/graph.h rename to include/graphics.h diff --git a/include/calls.h b/include/signal.h similarity index 100% rename from include/calls.h rename to include/signal.h diff --git a/include/widgets.h b/include/widget.h similarity index 100% rename from include/widgets.h rename to include/widget.h diff --git a/src/actions.c b/src/actions.c index 711e8df..adcc126 100644 --- a/src/actions.c +++ b/src/actions.c @@ -40,6 +40,25 @@ } */ // // https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/src/ui/application.c + +#include +#include + +#define GEM_GRAPH_CLIENT_TYPE_WINDOW (gem_graph_client_window_get_type()) + + +void on_preferences_action(GSimpleAction *action, // nom de type « GSimpleAction » inconnu + GVariant *parameter, // nom de type « GVariant » inconnu + gpointer user_data) // nom de type « gpointer » inconnu +{ +// GemGraphClientApplication *self = user_data; + +// g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self)); + +// ui_send_internal_notification("Not implemented !"); +} + + /* void ui_enable_action(const char *name) { g_simple_action_set_enabled( (GSimpleAction *)g_action_map_lookup_action( diff --git a/src/automat.c b/src/automat.c index 7fce570..d1f0575 100644 --- a/src/automat.c +++ b/src/automat.c @@ -28,7 +28,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../include/automat.h" +#include "../include/fsm.h" /******************************************************************************/ diff --git a/src/calls.c b/src/calls.c index 975d4a6..04f63d3 100644 --- a/src/calls.c +++ b/src/calls.c @@ -29,10 +29,10 @@ -#include "../include/automat.h" -#include "../include/calls.h" -#include "../include/widgets.h" -#include "../include/graph.h" +#include "../include/fsm.h" +#include "../include/signal.h" +#include "../include/widget.h" +#include "../include/graphics.h" static void on_auto_notification (const char *message) diff --git a/src/graph.c/init.c b/src/graph.c/init.c deleted file mode 100644 index 104e6b9..0000000 --- a/src/graph.c/init.c +++ /dev/null @@ -1,191 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * -* * -* Gem-graph client * -* * -* Init OpenGL graphism * -* * -* Copyright © 2021 Libre en Communs * -* Copyright © 2023 Adrien Bourmault * -* Copyright © 2023 Arthur Menges * -* * -* This file is part of Gem-graph. * -* * -* This program is free software: you can redistribute it and/or modify it * -* under the terms of the GNU Affero General Public License * -* as publishedby the Free Software Foundation, * -* either version 3 of the License, or (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * -* See the GNU Affero General Public License for more details. * -* * -* You should have received a copy of the GNU Affero General Public License * -* along with this program. If not, see . * -* * -* * * * * * * * * * * * * * * * * * * * * * * * * * */ - - -/* -------------------------------------------------------------------------- */ - -#include "../../include/graph.h" - -/* Initializes the buffer of a gl_area - * Calls according to the user preferences - * @param gl_area, ptr to the gl_area widget - * @return void - */ -void graph_init_buffers(const int stack_id) -{ - struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO - - //XXX - graph_model_setup(stack_id); - - GLuint vao, vertex_buffer, color_buffer; - - glGenBuffers(1, &vertex_buffer); - glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); - glBufferData(GL_ARRAY_BUFFER, - graph_stack->buffer_vertex_size * - sizeof(graph_stack->buffer_vertex_origin[0]), - graph_stack->buffer_vertex_origin, - GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - - // colors - glGenBuffers(1, &color_buffer); - glBindBuffer(GL_ARRAY_BUFFER, color_buffer); - glBufferData(GL_ARRAY_BUFFER, graph_stack->buffer_colors_size * - sizeof(graph_stack->buffer_colors_origin[0]), - graph_stack->buffer_colors_origin, - GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - - // We only use one VAO, so we always keep it bound - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); - - graph_stack->vao = vao; - graph_stack->position_buffer = vertex_buffer; - graph_stack->color_buffer = color_buffer; -} - -/* - * Initializes the shaders of a gl_area and link them to a program - * - * @param gl_area, ptr to the gl_area widget - * - * @return true if initialized - */ -bool graph_init_shaders(const int stack_id) -{ - struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO - char *vertex_shader; - char *fragment_shader; - int status; - GLuint vertex = 0, fragment; // 2024-06-05 j'initialise vertex à 0 (au pif !) - GLuint program = 0; - GLuint m = 0; - GLuint v = 0; - GLuint p = 0; - - // Load vertex shader file - vertex_shader = read_file(VERTEX_SHADER_FILE); - if (vertex_shader == NULL) - return false; - vertex = graph_create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader); - - if(vertex == 0) { - graph_stack->program = 0; - g_free(vertex_shader); - return false; - } - - // Load fragment shader file - fragment_shader = read_file(FRAG_SHADER_FILE); - if (fragment_shader == NULL) - return false; - fragment = graph_create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader); - - if(fragment == 0) { - glDeleteShader(vertex); - graph_stack->program = 0; - g_free(vertex_shader); - g_free(fragment_shader); - return false; - } - - // Link shaders to program - program = glCreateProgram(); - printf("\n------------------------------------------------------------------------------------------\n"); - printf("[debug] graph_init_shaders() : program = %d, vertex = %d, fragment = %d\n\ - exec > ** (myprogram:-----): WARNING ** : --:--:--:---: Linking failure: (address)\n", - program, vertex, fragment); - - /* (myprogram:11732): WARNING **: 10:37:34.233: v plusieurs 'run' successifs - * (myprogram:11883): WARNING **: 10:38:22.979: glLinkProgram(program); < commenté - * (myprogram:11953): WARNING **: 10:38:46.170: - * (myprogram:12034): WARNING **: 10:39:14.709: - * (myprogram:12182): WARNING **: 10:40:49.788: - * > probablement la même adresse dans la librairie 'mesa' d'OpenGL (?) */ - - glAttachShader(program, vertex); - glAttachShader(program, fragment); - - printf("Failed to link the graphic stack to widgets ! <> see init.c graph_init_shaders()\n"); - printf("the error in not : vertex shader lacks `main' but : failed to link... (comment line 140)\n"); - // https://registry.khronos.org/OpenGL-Refpages/gl4/html/glLinkProgram.xhtml - // glLinkProgram(program); // Linking failure: (address) - printf("------------------------------------------------------------------------------------------\n"); - - glGetProgramiv(program, GL_LINK_STATUS, &status); // Linking failure: (address) - - if(status == GL_FALSE) { - int log_len; - char *buffer; - - glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_len); - - buffer = g_malloc(log_len + 1); - assert(buffer); - glGetProgramInfoLog(program, log_len, NULL, buffer); - - g_warning("Linking failure:\n%s", buffer); - - g_free(buffer); - - glDeleteProgram(program); - program = 0; - - glDeleteShader(vertex); - glDeleteShader(fragment); - - g_free(vertex_shader); - g_free(fragment_shader); - - return false; - } - - /* Get the location of the "mvp" uniform */ - m = glGetUniformLocation(program, "model_matrix"); - v = glGetUniformLocation(program, "view_matrix"); - p = glGetUniformLocation(program, "projection_matrix"); - - glDetachShader(program, vertex); - glDetachShader(program, fragment); - - glDeleteShader(vertex); - glDeleteShader(fragment); - - graph_stack->program = program; - graph_stack->m = m; - graph_stack->v = v; - graph_stack->p = p; - - g_free(vertex_shader); - g_free(fragment_shader); - - return true; -} diff --git a/src/graph.c/draw.c b/src/graphics/draw.c similarity index 99% rename from src/graph.c/draw.c rename to src/graphics/draw.c index 9a0c42c..2b2893e 100644 --- a/src/graph.c/draw.c +++ b/src/graphics/draw.c @@ -29,7 +29,7 @@ #include #include "../../include/base.h" -#include "../../include/graph.h" +#include "../../include/graphics.h" /* * Writes values to describe a vertex at (x,y,z) intoq the vertex buffer diff --git a/src/graph.c/grid.c b/src/graphics/grid.c similarity index 99% rename from src/graph.c/grid.c rename to src/graphics/grid.c index b2f290d..3e20bba 100644 --- a/src/graph.c/grid.c +++ b/src/graphics/grid.c @@ -26,7 +26,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../../include/graph.h" +#include "../../include/graphics.h" int graph_draw_space_ridges_vertex (const int stack_id, long offset_vertex, diff --git a/src/graph.c/stack.c b/src/graphics/init.c similarity index 69% rename from src/graph.c/stack.c rename to src/graphics/init.c index 51c8b03..27ce7bc 100644 --- a/src/graph.c/stack.c +++ b/src/graphics/init.c @@ -26,7 +26,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../../include/graph.h" +#include "../../include/graphics.h" #include "../../include/parse.h" #define TEST 0 @@ -227,12 +227,8 @@ bool graph_shutdown(const int id, void *error_buffer) */ void graph_model_setup (const int stack_id) { - /*------------------------------------------------------------------------*/ - /* I N I T I A L D A T A S P E C I F I C A T I O N */ - /*------------------------------------------------------------------------*/ - struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO char dimension; long space_X; @@ -279,12 +275,8 @@ void graph_model_setup (const int stack_id) multiplicity = model_get_multiplicity(); g_print("[GRAPH DEBUG] site_multiplicity = %d, density_max = %d\n", multiplicity, density_max); - /*------------------------------------------------------------------------*/ - /* S P A C E D R A W I N G */ - /*------------------------------------------------------------------------*/ - graph_draw_space_ridges_vertex (stack_id, graph_stack->buffer_vertex_size, space_X, space_Y, space_Z); graph_draw_space_ridges_lines (stack_id); graph_draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z); @@ -294,12 +286,8 @@ void graph_model_setup (const int stack_id) graph_stack->buffer_colors_0_arrow = graph_stack->buffer_colors_size; graph_stack->buffer_lines_0_arrow = graph_stack->buffer_lines_size; - /*------------------------------------------------------------------------*/ - /* A R R O W S D R A W I N G */ - /*------------------------------------------------------------------------*/ - char state_id[30] = {0}; struct arrow_t arrow = {0}; @@ -329,3 +317,163 @@ void graph_model_setup (const int stack_id) g_printerr("ARGH : not all arrows have been parsed !\n"); } + +/* Initializes the buffer of a gl_area + * Calls according to the user preferences + * @param gl_area, ptr to the gl_area widget + * @return void + */ +void graph_init_buffers(const int stack_id) +{ + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO + + //XXX + graph_model_setup(stack_id); + + GLuint vao, vertex_buffer, color_buffer; + + glGenBuffers(1, &vertex_buffer); + glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); + glBufferData(GL_ARRAY_BUFFER, + graph_stack->buffer_vertex_size * + sizeof(graph_stack->buffer_vertex_origin[0]), + graph_stack->buffer_vertex_origin, + GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + + // colors + glGenBuffers(1, &color_buffer); + glBindBuffer(GL_ARRAY_BUFFER, color_buffer); + glBufferData(GL_ARRAY_BUFFER, graph_stack->buffer_colors_size * + sizeof(graph_stack->buffer_colors_origin[0]), + graph_stack->buffer_colors_origin, + GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + // We only use one VAO, so we always keep it bound + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); + + graph_stack->vao = vao; + graph_stack->position_buffer = vertex_buffer; + graph_stack->color_buffer = color_buffer; +} + +/* + * Initializes the shaders of a gl_area and link them to a program + * + * @param gl_area, ptr to the gl_area widget + * + * @return true if initialized + */ +bool graph_init_shaders(const int stack_id) +{ + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO + char *vertex_shader; + char *fragment_shader; + int status; + GLuint vertex = 0, fragment; // 2024-06-05 j'initialise vertex à 0 (au pif !) + GLuint program = 0; + GLuint m = 0; + GLuint v = 0; + GLuint p = 0; + + // Load vertex shader file + vertex_shader = read_file(VERTEX_SHADER_FILE); + if (vertex_shader == NULL) + return false; + vertex = graph_create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader); + + if(vertex == 0) { + graph_stack->program = 0; + g_free(vertex_shader); + return false; + } + + // Load fragment shader file + fragment_shader = read_file(FRAG_SHADER_FILE); + if (fragment_shader == NULL) + return false; + fragment = graph_create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader); + + if(fragment == 0) { + glDeleteShader(vertex); + graph_stack->program = 0; + g_free(vertex_shader); + g_free(fragment_shader); + return false; + } + + // Link shaders to program + program = glCreateProgram(); + printf("\n------------------------------------------------------------------------------------------\n"); + printf("[debug] graph_init_shaders() : program = %d, vertex = %d, fragment = %d\n\ + exec > ** (myprogram:-----): WARNING ** : --:--:--:---: Linking failure: (address)\n", + program, vertex, fragment); + + /* (myprogram:11732): WARNING **: 10:37:34.233: v plusieurs 'run' successifs + * (myprogram:11883): WARNING **: 10:38:22.979: glLinkProgram(program); < commenté + * (myprogram:11953): WARNING **: 10:38:46.170: + * (myprogram:12034): WARNING **: 10:39:14.709: + * (myprogram:12182): WARNING **: 10:40:49.788: + * > probablement la même adresse dans la librairie 'mesa' d'OpenGL (?) */ + + glAttachShader(program, vertex); + glAttachShader(program, fragment); + + printf("Failed to link the graphic stack to widgets ! <> see init.c graph_init_shaders()\n"); + printf("the error in not : vertex shader lacks `main' but : failed to link... (comment line 140)\n"); + // https://registry.khronos.org/OpenGL-Refpages/gl4/html/glLinkProgram.xhtml + // glLinkProgram(program); // Linking failure: (address) + printf("------------------------------------------------------------------------------------------\n"); + + glGetProgramiv(program, GL_LINK_STATUS, &status); // Linking failure: (address) + + if(status == GL_FALSE) { + int log_len; + char *buffer; + + glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_len); + + buffer = g_malloc(log_len + 1); + assert(buffer); + glGetProgramInfoLog(program, log_len, NULL, buffer); + + g_warning("Linking failure:\n%s", buffer); + + g_free(buffer); + + glDeleteProgram(program); + program = 0; + + glDeleteShader(vertex); + glDeleteShader(fragment); + + g_free(vertex_shader); + g_free(fragment_shader); + + return false; + } + + /* Get the location of the "mvp" uniform */ + m = glGetUniformLocation(program, "model_matrix"); + v = glGetUniformLocation(program, "view_matrix"); + p = glGetUniformLocation(program, "projection_matrix"); + + glDetachShader(program, vertex); + glDetachShader(program, fragment); + + glDeleteShader(vertex); + glDeleteShader(fragment); + + graph_stack->program = program; + graph_stack->m = m; + graph_stack->v = v; + graph_stack->p = p; + + g_free(vertex_shader); + g_free(fragment_shader); + + return true; +} diff --git a/src/graph.c/shader.frag b/src/graphics/shader.frag similarity index 100% rename from src/graph.c/shader.frag rename to src/graphics/shader.frag diff --git a/src/graph.c/shader.vert b/src/graphics/shader.vert similarity index 100% rename from src/graph.c/shader.vert rename to src/graphics/shader.vert diff --git a/src/graph.c/area.c b/src/graphics/stack.c similarity index 99% rename from src/graph.c/area.c rename to src/graphics/stack.c index 172f8a3..288bad0 100644 --- a/src/graph.c/area.c +++ b/src/graphics/stack.c @@ -25,8 +25,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../../include/graph.h" -#include "../../include/calls.h" +#include "../../include/graphics.h" +#include "../../include/signal.h" struct stack_index_t { long stack_id; diff --git a/src/main.c b/src/main.c index 6fd56c7..bba9887 100644 --- a/src/main.c +++ b/src/main.c @@ -30,7 +30,7 @@ -#include "../include/calls.h" +#include "../include/signal.h" /* Comment renommer les fonctions ? * Cette question dépend de plusieurs choix @@ -337,7 +337,7 @@ int main (int argc, char **argv) GtkApplication *app; int status; - app = gtk_application_new ("org.jean.gg_hack", G_APPLICATION_DEFAULT_FLAGS); + app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); diff --git a/src/widget.c/menu.c b/src/widget.c/menu.c deleted file mode 100644 index 9a7f2ed..0000000 --- a/src/widget.c/menu.c +++ /dev/null @@ -1,132 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * -* * -* Gem-graph client * -* * -* Tree * -* * -* Copyright © 2021 Libre en Communs * -* Copyright © 2021 Adrien Bourmault * -* Copyright © 2021 Jean Sirmai * -* * -* This file is part of Gem-graph. * -* * -* This program is free software: you can redistribute it and/or modify it * -* under the terms of the GNU Affero General Public License * -* as published by the Free Software Foundation, * -* either version 3 of the License, * -* or (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; * -* without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. * -* See the GNU Affero General Public License for more details. * -* * -* You should have received a copy of the GNU Affero General Public License * -* along with this program. If not, see . * -* * -* * * * * * * * * * * * * * * * * * * * * * * * * * */ - - -#include "../../include/calls.h" -#include "../../include/widgets.h" - -// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL - - -static void add_menu_item (struct MenuNode_t *parent, struct MenuNode_t *child){ - if (parent->child) { - struct MenuNode_t *cur = parent->child; - while (cur && cur->next) {cur = cur->next;} - cur->next = child; - } else parent->child = child; -} - -struct MenuNode_t *create_user_menu_node (const gchar* text){ - struct MenuNode_t *node = g_malloc0 (sizeof(struct MenuNode_t)); - node->text = g_strdup (text); - node->child = NULL; // if (0) printf("create_user_menu_node %s\n", text); - return node; -} - -static GListModel* get_user_menu_model_child (struct MenuNode_t *parent){ - GtkStringList *list = NULL; - if (parent) { - if (0) printf("[get_user_menu_model_child] here is %s content : ", parent->text); - struct MenuNode_t *child = parent->child; - if (child) {list = gtk_string_list_new(NULL);} - while(child) { - gtk_string_list_append(list, child->text); - if (0) printf("%s ", child->text); - child = child->next; - } - } // else printf("hot.c GListModel* get_user_menu_model_child (struct MenuNode_t *parent) child = %d \n", parent); - if (0) printf("\n"); - return G_LIST_MODEL(list); -} - -static GListModel* get_user_menu_model (GObject *item, gpointer root){ - struct MenuNode_t *cur = (struct MenuNode_t *)root; - struct MenuNode_t *parent = root; - const gchar *string = gtk_string_object_get_string (GTK_STRING_OBJECT (item)); - while (cur) { - if (strcmp(string, cur->text) == 0) break; - cur = cur->next; - if (cur == NULL) {cur = parent->child; parent = cur;} - } - if (0) printf("[get_user_user_menu_model] looked for %s in %s item\n", cur->text, string); -// ! WARNING ! TODO CUR EST L'ENFANT, MAINTENANT DONC, SI CUR EST UNE FEUILLE, JE N'ATTEINDRAI PAS SON ENFANT - return get_user_menu_model_child (cur); -} - -GtkWidget *get_menu_anchor() -{ - // https://docs.gtk.org/gio/class.MenuModel.html - // https://www.geany.org/manual/gtk/gobject/index.html - // https://developer.gnome.org/hig/patterns/controls/menus.html - - if (0) labo_create_a_simple_gtk_string_list (); - struct MenuNode_t *menu_root = create_user_menu_node("menu"); - struct MenuNode_t *item_a = create_user_menu_node("item_a");add_menu_item (menu_root, item_a); - struct MenuNode_t *item_b = create_user_menu_node("item_b");add_menu_item (menu_root, item_b); - struct MenuNode_t *item_c = create_user_menu_node("item_c");add_menu_item (menu_root, item_c); - -// GtkWidget* list_box = gtk_list_box_new(); - - GtkStringList *model = gtk_string_list_new (NULL); - gtk_string_list_append (model, menu_root->text); - GtkSignalListItemFactory *factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new()); - g_signal_connect (factory, "setup", G_CALLBACK(on_setup_user_menu_factory), NULL); - g_signal_connect (factory, "bind", G_CALLBACK(on_bind_user_menu_factory), NULL); - - GtkTreeListModel *menu_model = gtk_tree_list_model_new ( - G_LIST_MODEL (model), - FALSE, // Passthrough - False in actual usage with dynamic children retrieval - FALSE, // TRUE, // FALSE, // autoexpand - (GtkTreeListModelCreateModelFunc) &get_user_menu_model, - menu_root, - NULL // (GDestroyNotify) free_user_menu_node - ); - - GtkSingleSelection *selection_model = gtk_single_selection_new (G_LIST_MODEL (menu_model)); - gtk_single_selection_set_autoselect (selection_model, FALSE); - 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)); - - return list_view; -} -/* - GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new()); -// Allocation height too small. Tried to allocate 1922x1030, but GtkNotebook 0x25cd4c0 needs at least 1922x1064. -// even if I remove (comment) the next line : - 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_widget_set_visible (GTK_WIDGET (scrolled_window), TRUE); - gtk_widget_set_visible (GTK_WIDGET (list_view), TRUE); - return scrolled_window; -} -*/ - - diff --git a/src/widget.c/action.c b/src/widget/action.c similarity index 100% rename from src/widget.c/action.c rename to src/widget/action.c diff --git a/src/widget.c/labo.c b/src/widget/labo.c similarity index 99% rename from src/widget.c/labo.c rename to src/widget/labo.c index e599c2b..8057b57 100644 --- a/src/widget.c/labo.c +++ b/src/widget/labo.c @@ -27,7 +27,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../../include/widgets.h" +#include "../../include/widget.h" // (NB à terme, labo.c disparaitra, bien sûr !) diff --git a/src/widget.c/rules.c b/src/widget/rules.c similarity index 99% rename from src/widget.c/rules.c rename to src/widget/rules.c index 46d7444..80485b3 100644 --- a/src/widget.c/rules.c +++ b/src/widget/rules.c @@ -27,7 +27,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../../include/widgets.h" +#include "../../include/widget.h" #define W 1920 // TODO 2024-06-30 #define H 960 // Ad hoc (pour mon écran) diff --git a/src/widget.c/state.c b/src/widget/state.c similarity index 99% rename from src/widget.c/state.c rename to src/widget/state.c index 4b4dca8..19c9cf9 100644 --- a/src/widget.c/state.c +++ b/src/widget/state.c @@ -27,9 +27,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../../include/automat.h" -#include "../../include/widgets.h" -#include "../../include/calls.h" +#include "../../include/fsm.h" +#include "../../include/widget.h" +#include "../../include/signal.h" #define W 1920 // TODO 2024-06-30 (Ad hoc pour mon écran) #define H 960 diff --git a/src/widget.c/stock.c b/src/widget/stock.c similarity index 98% rename from src/widget.c/stock.c rename to src/widget/stock.c index dcee76c..50c4383 100644 --- a/src/widget.c/stock.c +++ b/src/widget/stock.c @@ -28,8 +28,8 @@ #include "../../include/base.h" -#include "../../include/calls.h" -#include "../../include/widgets.h" +#include "../../include/signal.h" +#include "../../include/widget.h" GtkWidget *get_STOCK_page () { GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 32)); diff --git a/src/widget.c/heads.c b/src/widget/topbar.c similarity index 89% rename from src/widget.c/heads.c rename to src/widget/topbar.c index 803a96f..c79c09b 100644 --- a/src/widget.c/heads.c +++ b/src/widget/topbar.c @@ -29,8 +29,8 @@ #include "../../include/base.h" -#include "../../include/calls.h" -#include "../../include/widgets.h" +#include "../../include/signal.h" +#include "../../include/widget.h" #define W_TEXT_WINDOW 700 #define H_TEXT_WINDOW 1000 @@ -122,7 +122,7 @@ void widget_head_DIALOG_WINDOW_design (GtkWindow *main_window, GtkWindow *dialog /******************************************************************************/ -/* M A I N W I N D O W C E N T E R */ +/* M A I N W I N D O W H E A D C E N T E R */ /******************************************************************************/ static GtkWidget *window_header_bar (GtkWindow *window); @@ -150,7 +150,7 @@ static GtkWidget *window_header_bar (GtkWindow *window) /******************************************************************************/ -/* M A I N W I N D O W L E F T */ +/* M A I N W I N D O W H E A D L E F T */ /******************************************************************************/ static void window_header_bar_left (GtkWidget *header_bar) @@ -189,7 +189,7 @@ static void window_header_bar_left (GtkWidget *header_bar) /******************************************************************************/ -/* M A I N W I N D O W R I G H T */ +/* M A I N W I N D O W H E A D R I G H T */ /******************************************************************************/ static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); } @@ -214,12 +214,10 @@ static void window_header_bar_right (GtkWidget *header_bar) GtkWidget* list_box = gtk_list_box_new(); - GtkWidget *menu_item_A; - if (0) menu_item_A = GTK_WIDGET (g_menu_item_new ("A", "activate")); - else menu_item_A = GTK_WIDGET (gtk_label_new("A")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_A); - GtkWidget *menu_item_B = GTK_WIDGET (gtk_label_new("B")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_B); - GtkWidget *menu_item_C = GTK_WIDGET (gtk_label_new("C")); gtk_list_box_append (GTK_LIST_BOX (list_box), menu_item_C); -// gtk_menu_item_activate (menu_item_C); + GtkWidget *label_A = GTK_WIDGET (gtk_label_new("A")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A); + GtkWidget *label_B = GTK_WIDGET (gtk_label_new("B")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B); + GtkWidget *label_C = GTK_WIDGET (gtk_label_new("C")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C); +// gtk_menu_item_activate (label_C); // https://discourse.gnome.org/t/when-do-we-really-have-to-use-gtk-popover-present-to-show-a-popover-at-a-given-widget/17566/5 GtkWidget *pop = gtk_popover_new (); @@ -240,23 +238,13 @@ static void window_header_bar_right (GtkWidget *header_bar) GSimpleAction *act_connect = g_simple_action_new("connect", NULL); // g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect)); g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL); -// GMenuItem *menu_item_E = g_menu_item_new("connect", "app.connect"); -// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (menu_item_E)); +// GMenuItem *label_E = g_menu_item_new("connect", "app.connect"); +// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (label_E)); g_signal_connect (open_menu, "activate", G_CALLBACK (on_clicked_menu_experiment), list_box); -// signal 'clicked' is invalid for instance '0xbcb2900' of type 'GtkMenuButton' -// signal 'clicked' is invalid for instance '0x2c992b9' of type 'GtkPopover' -// signal 'clicked' is invalid for instance '0x2812f80' of type 'GtkListBox' -// signal 'clicked' is invalid for instance '0x2a15120' of type 'GtkLabel' -// -// signal 'activate' is invalid for instance '0x3c3de7a' of type 'GtkPopover' -// signal 'activate' is invalid for instance '0x3d62f80' of type 'GtkListBox' -// signal 'activate' is invalid for instance '0x17fb93d' of type 'GtkLabel' - - @@ -292,7 +280,7 @@ static void window_header_bar_right (GtkWidget *header_bar) printf("selected_row = %s\n", gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (selected_row)))); -// g_signal_connect (menu_item_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data); +// g_signal_connect (label_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data); } diff --git a/src/widget.c/tree.c b/src/widget/tree.c similarity index 98% rename from src/widget.c/tree.c rename to src/widget/tree.c index e76aa87..8d7e9e1 100644 --- a/src/widget.c/tree.c +++ b/src/widget/tree.c @@ -28,8 +28,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "../../include/calls.h" -#include "../../include/widgets.h" +#include "../../include/signal.h" +#include "../../include/widget.h" // GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL