diff --git a/include/fsm.h b/include/fsm.h index e4627a4..5c4db3d 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -62,7 +62,7 @@ typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ; * * * * * - J O U R N A L M E T A R U L E S - * * * */ -enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, REPEATED, SPEW}; +enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, REPETITIVE, SPEW}; enum source { SOURCE, TARGET, JOURNAL, FSM, PREFER, @@ -76,7 +76,7 @@ enum source { RULE_ALGEBRA, RULE_CONDITION, RULE_ASSIGN, RULE_ID, RULES_TREE, RULES_COMPARE, RULES_USE, MEASURES_TOOLS, MEASURES__ACTIVITY, MEASURES__DISPLAY, - TIME_DEP_RESULTS, TIME_INDEP_RESULTS, + RESULTS, TIME_DEP_RESULTS, TIME_INDEP_RESULTS, WIDGET, BUTTON, SCROLL, GLAREA, TEXT, LABEL, TREE, SLIDER, EXPANDER, ENTRY, SWITCH_STATE_RULES_DATA, SLIDER_X, SLIDER_Y, SLIDER_Z, @@ -89,33 +89,46 @@ enum value {VALUE}; // to use or not to use ... (plutôt non) typedef struct unit {long yy_dd_mm; long usec; - char *message; + const char *file_source; + const char *function_source; + const char *string_value; struct unit *prev; struct unit *next;} unit; // journal unit structure typedef struct {unit *first; unit *last;} journal; // journal unit access structure void fsm_journal_init (journal *jj); // init from main -void fsm_journal_push (char *message, - const char *string_value); // def: fsm/dispatch - // call: any call that does not have +void fsm_journal_push_front (const char *file_source, // add an évènement at the journal front + const char *function_source, // def: fsm/dispatch + const char *string_value); // call: any call that does not have // the log address -void fsm_journal_clear (journal *jj, char *message); // empty the journal -void fsm_journal_push_front (journal *jj, char *message); // add an évènement at the journal front -long fsm_journal_pop_back (journal *jj, char *message); // remove an évènement at the journal end +void fsm_journal_clear (journal *jj, + const char *file_source, + const char *function_source, + const char *string_value); // empty the journal +long fsm_journal_pop_back (journal *jj, + const char *file_source, + const char *function_source, + const char *string_value); // remove an évènement at the journal end int fsm_journal_length (journal jj); // journal length -void fsm_journal_seek (journal jj, long usec, char *message); // seek for an évènement in the journal +void fsm_journal_seek (journal jj, long usec, + const char *file_source, + const char *function_source, + const char *string_value); // seek for an évènement in the journal void fsm_journal_publish (journal jj); // display the journal -void fsm_journal_test (char *message); -// --------------------------------------------------------------- WIP ------ -// ref: sudo cat /var/log/messages +// ----------------------------------------------------------------------------- +// ref: sudo cat /var/log/messages // journal fsm_get_journal(); // def: fsm/dispatch call: fsm/prefer/fsm_store_restore_reset() void fsm_journal_publication_request (); // def: fsm/dispatch call: main; -void fsm_journal_event (char *message, int severity, int source, const char *value); +void fsm_journal_event (int severity, + int source, + const char *file_source, + const char *function_source, + const char *string_value); // def: fsm/dispatch call: widget/dispatch; -// --------------------------------------------------------------- WIP ------ +// ----------------------------------------------------------------------------- @@ -148,12 +161,6 @@ void fsm_add_displayable (char *displayable_name);// def: fsm/prefer; call: fs void fsm_reset_all_situations_transparencies_at_value (int value); // provisoire... // def: fsm/prefer; call: signal; - -void fsm_msg (int choice, int value, char *string, int sub_automaton); - // def: fsm/dispatch; call: fsm/dispatch; - // fsm/measure; - // fsm/result; - // --------------------------------------------------------------- WIP ------ // def: measure/tool_list call: measure/tool_list (about the following functions...) void fsm_tools_list_insert (tool_list **tl, int value); diff --git a/include/util.h b/include/util.h index 61891b1..45b995b 100644 --- a/include/util.h +++ b/include/util.h @@ -30,6 +30,8 @@ #include "../include/fsm.h" char *util_read_file (char *filename); +// Programmers using the strcat function can easily be recognized as lazy and reckless. +// (quoted from: The GNU C Library (glibc) manual - 5.5 Concatenating Strings) char *concat (const char *str, ...); typedef struct pile {int value; struct pile *prev;} pile; // structure d'un élément diff --git a/journal.c b/journal.c deleted file mode 100644 index 0fb766e..0000000 --- a/journal.c +++ /dev/null @@ -1,103 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * -* * -* Gem-graph client * -* * -* State machine / Measures * -* * -* Copyright © 2024 Libre en Communs * -* Copyright © 2024 Adrien Bourmault * -* Copyright © 2024 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 -#include -#include "../../../include/fsm.h" - -/******************************************************************************/ -/* A journal (a pile) stores chronologically the fsm events */ -/* during a session run (rules exec, mainly) */ -/* */ -/* A session starts when the main window opens and ends when it closes. */ -/******************************************************************************/ - - - -int fsm_journal_push (journal **jj, int vv) -{ - journal *element = malloc (sizeof(journal)); - if (!element) exit (EXIT_FAILURE); // Si l'allocation a échoué. - element->value = vv; - element->prev = *jj; - *jj = element; // Le pointeur pointe sur le dernier élément. - return vv; -} - -int fsm_journal_pop (journal **jj) -{ - int vv; - journal *tmp; - if (!*jj) return -1; // Retourne -1 si le journal est vide. - tmp = (*jj)->prev; - vv = (*jj)->value; - free (*jj); - *jj = tmp; // Le pointeur pointe sur le dernier élément. - return vv; // retourne la value retirée du journal. -} - - -void fsm_journal_clear (journal **jj) -{ - journal *tmp; - while (*jj) - { - tmp = (*jj)->prev; - free (*jj); - *jj = tmp; - } -} - -int fsm_journal_length (journal *jj) -{ - int n=0; - while (jj) - { - n++; - jj = jj->prev; - } - return n; -} - -void fsm_journal_view (journal *jj) -{ - printf ("view journal (n = %d)\n", fsm_journal_length (jj)); - while (jj) - { - printf ("> %d\n", jj->value); - jj = jj->prev; - } - puts ("------"); -} - -void fsm_journal_seek (journal *jj, int value) -{ - -} diff --git a/src/fsm/dispatch.c b/src/fsm/dispatch.c index d085edd..f9b0e4b 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -60,42 +60,28 @@ static journal gg_logs; void fsm_journal_publication_request () {fsm_journal_publish (gg_logs);} -void fsm_journal_push (char *message, const char *string_value) +// CRITICAL ERROR WARNING INFO MESSAGE DEBUG REPETITIVE SPEW +// 0 1 2 3 4 5 6 7 +void fsm_journal_event (int severity, + int source, + const char *file_source, + const char *function_source, + const char *string_value) { -// Programmers using the strcat function can easily be recognized as lazy and reckless. -// (quoted from: The GNU C Library (glibc) manual - 5.5 Concatenating Strings) + if (TRUE // just to find easily the line beginning the filter conditions 😄️ - fsm_journal_push_front (&gg_logs, concat (message, " ", string_value, NULL)); + && severity != REPETITIVE + || FALSE + // source != TREE + // source == FSM + // strcmp (value, "") + + && TRUE) // just to find easily the line ending the filter conditions 😄️ + // in case there are many ... + + fsm_journal_push_front (&gg_logs, file_source, function_source, string_value); } - // CRITICAL ERROR WARNING INFO MESSAGE DEBUG qq SPEW 😄️ - // 0 1 2 3 4 5 6 7 -#define CRITICAL___ERROR____WARNING___INFO____MESSAGE___DEBUG ___REPEATED___SPEW____😄️ 0 -void fsm_journal_event (char *message, int severity, int source, const char *value) -{ - if - ( - severity != REPEATED - // && source != TREE - /* && ( - source == MAIN - || source == FSM - || source == TOPBAR - || source == DIALOG_WINDOW - || source == MODAL_WINDOW - || source == TEXT_WINDOW - || source == TOPBAR_LEFT - || source == TOPBAR_RIGHT - || source == PREFER - ) - // && strcmp (value, "") - && source != SIGNAL */ - ) - - fsm_journal_push (message, value); // TODO push (message + value) -} -#define MAIN___DIALOG___MODAL___TOPBAR___SYNTH___RULES___MEASURES___RESULTS___😄️ 0 - /******************************************************************************/ /* F S M I N I T */ @@ -103,23 +89,23 @@ void fsm_journal_event (char *message, int severity, int source, const char *val void fsm_init (char *initial_message_from_main) { fsm_journal_init (&gg_logs); - fsm_journal_event (initial_message_from_main, MESSAGE, MAIN, ""); + fsm_journal_event (MESSAGE, MAIN, "main", initial_message_from_main, ""); - fsm_journal_event ("fsm/dispatch fsm initialisation has began", MESSAGE, FSM, ""); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation has began", ""); - fsm_journal_event ("fsm/dispatch measures list init()", MESSAGE, FSM, ""); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "measures list init()", ""); fsm_measures_list_init(); - fsm_journal_event ("fsm/dispatch results list init()", MESSAGE, FSM, ""); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "results list init()", ""); fsm_results_list_init(); - fsm_journal_event ("fsm/dispatch displayable list init()", MESSAGE, FSM, ""); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "displayable list init()", ""); fsm_displayable_list_init(); - fsm_journal_event ("fsm/dispatch preferences list init()", MESSAGE, FSM, ""); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "preferences list init()", ""); fsm_preferences_list_init(); - fsm_journal_event ("fsm/dispatch fsm initialisation has ended", MESSAGE, FSM, ""); + fsm_journal_event (MESSAGE, FSM, "fsm/dispatch", "fsm initialisation has ended", ""); } @@ -132,22 +118,27 @@ static int preferences_have_been_modified = FALSE; void fsm_set_preferences_modified (bool value) { - char str1[] = "fsm/dispatch preferences modified: value = "; - char str2[] = "TRUE or FALSE (TODO)"; //sprintf(str2, "%d", value); TODO - fsm_journal_event (str1, INFO, FSM, str2); + const char str_value; + if (value) str_value = "FALSE"; else str_value = "TRUE"; + fsm_journal_event (INFO, FSM, + "fsm/dispatch", + "preferences modified: value = ", + str_value); preferences_have_been_modified = value; } -bool fsm_get_preferences_state() {return preferences_have_been_modified;} + // preferences_have_been_modified // and should be stored before closing the current session. TODO +bool fsm_get_preferences_state() {return preferences_have_been_modified;} static int choice_EXEC_EDIT = EXEC; static int choice_STATE_RULES_DATA = SYNTH; // THE FIRST PAGE TO BE PRESENTED // SEE ALSO fsm/dispatch.c window_design_topbar_left() (the end) + int fsm_get_exec_edit() {return choice_EXEC_EDIT;} int fsm_get_state_rules_data() {return choice_STATE_RULES_DATA;} @@ -157,61 +148,26 @@ int fsm_get_state_rules_data() {return choice_STATE_RULES_DATA;} /* T R A N S I T I O N S */ /******************************************************************************/ +static char *tab_0 [] = { "EXEC", "EDIT" }; +static char *tab_1 [] = { "SYNTH", "STATE", "RULES", "DATA" }; + void fsm_set_exec_edit (int choice) { - if (choice_EXEC_EDIT != choice) { - fsm_journal_event ("fsm/dispatch set_exec_edit()", INFO, FSM, ""); // TODO print choice - choice_EXEC_EDIT = choice; - } + if (choice_EXEC_EDIT != choice) + { + fsm_journal_event (INFO, FSM, "fsm/dispatch", "set_exec_edit()", + concat (tab_0 [choice_EXEC_EDIT], " > ", tab_0 [choice], NULL)); + choice_EXEC_EDIT = choice; + } } void fsm_set_state_rules_data (int choice) { - if (choice_STATE_RULES_DATA != choice) { - fsm_journal_event ("fsm/dispatch set_state_rules_data()", INFO, FSM, ""); // TODO print choice - choice_STATE_RULES_DATA = choice; - } -} - - -/******************************************************************************/ -/* D E B U G G I N G */ -/******************************************************************************/ - -static char *tab_0 [] = { "EXEC", "EDIT" }; -static char *tab_1 [] = { "SYNTH", "STATE", "RULES", "DATA" }; - -void fsm_msg (int choice, int value, char *string, int sub_automaton) -{ - switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and - // sub_automaton 1 is STATE_RULES_DATA - // sub_automaton 2 is MEASURE - case (0) : - fsm_journal_event ("fsm/dispatch switch EXEC_EDIT (TODO)", INFO, FSM, ""); // TODO print choice - printf ("fsm/dispatch (message) |\ - switch %5s x %5s > %5s x %5s\n", - tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA], - tab_0 [choice], tab_1 [choice_STATE_RULES_DATA]); - break; - - case (1) : - fsm_journal_event ("fsm/dispatch switch STATE_RULES_DATA (TODO)", INFO, FSM, ""); // TODO print choice - printf ("fsm/dispatch (message) |\ - switch %5s x %5s > %5s x %5s\n", - tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA], - tab_0 [choice_EXEC_EDIT], tab_1 [choice]); - break; - - case (2) : // printf ("fsm/dispatch (message) | %s\n", string); - break; - - case (3) : // printf ("fsm/dispatch (message) | %2d\n", choice); - break; - - - default : printf ("default in fsm/dispatch.fsm_msg()\n"); - fsm_journal_event ("fsm/dispatch fsm_msg () default in switch (sub_automaton)", INFO, FSM, ""); + if (choice_STATE_RULES_DATA != choice) + { + fsm_journal_event (INFO, FSM, "fsm/dispatch", "set_state_rules_data()", + concat (tab_1 [choice_STATE_RULES_DATA], " > ", tab_1 [choice], NULL)); + choice_STATE_RULES_DATA = choice; } } - diff --git a/src/fsm/journal.c b/src/fsm/journal.c index 3b5a783..0b5c5c1 100644 --- a/src/fsm/journal.c +++ b/src/fsm/journal.c @@ -23,7 +23,7 @@ * along with this program. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include +//#include #include #include #include @@ -32,10 +32,19 @@ #include "../../include/fsm.h" /******************************************************************************/ -/* A journal stores chronologically the fsm events */ +/* A journal stores chronologically the events */ /* during a session run (rules exec, mainly) */ /******************************************************************************/ +/* 2024-09-22 + * What types of events should be reported ? (fsm, widgets, ... ) + * For what purpose ? + * What information must be collected and transmitted ? + * How do you name and classify this information ? + * How do you present it ? + * + * date clé (rank) fichier source fonction source +/- valeur */ + /* time_t current_time = time(NULL); @@ -52,7 +61,10 @@ void fsm_journal_init (journal *jj) jj->last = NULL; } -void fsm_journal_clear (journal *jj, char *message) +void fsm_journal_clear (journal *jj, + const char *file_source, + const char *function_source, + const char *string_value) { unit *tmp; unit *a_unit = jj->first; @@ -66,7 +78,10 @@ void fsm_journal_clear (journal *jj, char *message) jj->last = NULL; } -void fsm_journal_push_front (journal *jj, char *message) +void fsm_journal_push_front (journal *jj, + const char *file_source, + const char *function_source, + const char *string_value) { struct timeval tv; gettimeofday(&tv, NULL); @@ -74,7 +89,9 @@ void fsm_journal_push_front (journal *jj, char *message) if (! new_unit) exit (EXIT_FAILURE); new_unit->yy_dd_mm = tv.tv_sec; new_unit->usec = tv.tv_usec; - new_unit->message = message; + new_unit->file_source = file_source; + new_unit->function_source = function_source; + new_unit->string_value = string_value; new_unit->next = jj->first; new_unit->prev = NULL; if (jj->first) jj->first->prev = new_unit; @@ -82,7 +99,10 @@ void fsm_journal_push_front (journal *jj, char *message) jj->first = new_unit; } -long fsm_journal_pop_back (journal *jj, char *message) +long fsm_journal_pop_back (journal *jj, + const char *file_source, + const char *function_source, + const char *string_value) { long usec; unit *tmp = jj->last; @@ -108,7 +128,10 @@ int fsm_journal_length (journal jj) return nb; } -void fsm_journal_seek (journal jj, long usec, char *message) +void fsm_journal_seek (journal jj, long usec, + const char *file_source, + const char *function_source, + const char *string_value) { unit *a_unit = jj.first; int nb = 0; @@ -123,6 +146,7 @@ void fsm_journal_seek (journal jj, long usec, char *message) //------------------------------------------------------------------------------ + // ref: sudo cat /var/log/messages // Format time, "ddd yyyy-mm-dd hh:mm:ss zzz" "%Y-%m-%d %H:%M:%S" // https://www.man7.org/linux/man-pages/man3/strftime.3.html // https://en.cppreference.com/w/c/io/fprintf @@ -139,7 +163,13 @@ void fsm_journal_publish (journal jj) while (a_unit) { strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm)); - g_message ("%s + %6ld %6d %s", buf, a_unit->usec, nb, a_unit->message); + g_message ("%s + %-6ld %6d %-30s %-60s %-60s", + buf, + a_unit->usec, + nb, + a_unit->file_source, + a_unit->function_source, + a_unit->string_value); a_unit = a_unit->prev; nb ++; } diff --git a/src/fsm/measure/manage.c b/src/fsm/measure/manage.c index d203f4d..a3cb975 100644 --- a/src/fsm/measure/manage.c +++ b/src/fsm/measure/manage.c @@ -87,8 +87,17 @@ -void fsm_add_measure (char *measure_name) {fsm_msg (2, 0, measure_name, 2);} +void fsm_add_measure (char *measure_name) +{ + fsm_journal_event (DEBUG, + MEASURES_TOOLS, + "fsm/measure/manage/", + "fsm_add_measure()", + measure_name); +} + void fsm_measures_list_init() {if (0) fsm_tools_list_test();} + void fsm_rule_trig_measure (int rule_id, int object_id, int measure_id) {} diff --git a/src/fsm/result.c b/src/fsm/result.c index 02a9f51..a817dcb 100644 --- a/src/fsm/result.c +++ b/src/fsm/result.c @@ -70,6 +70,10 @@ void fsm_add_result (char *result_name) void fsm_results_list_init () { - fsm_msg (0,0, "src/fsm/result.c fsm_results_list_init()", 2); // sub_automaton 2 + fsm_journal_event (DEBUG, + RESULTS, + "fsm/", + "fsm_results_list_init()", + ""); } diff --git a/src/main.c b/src/main.c index 9473c36..42c1896 100644 --- a/src/main.c +++ b/src/main.c @@ -133,15 +133,13 @@ int main (int argc, char **argv) { // def: src/fsm/dispatch fsm = finite state machine - fsm_init ("main first instruction in main() & first log"); - - fsm_journal_event ( - "main *app = gtk_application_new ()", INFO, MAIN, ""); + fsm_init ("first instruction / first log"); + fsm_journal_event (INFO, MAIN, "main", "*app = gtk_application_new ()", ""); GtkApplication *app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); - fsm_journal_event ("main \ - g signal connect (app <--> on_windows_startup & activate)", INFO, MAIN, "\n"); + fsm_journal_event (INFO, MAIN, "main", + "g signal connect (app <--> on_windows_startup & activate)", "\n"); // ! WARNING ! 'on_windows_activation()' // and 'on_windows_startup()' are in: src/widget/dispatch.c // NOT in: src/signal.c @@ -149,10 +147,10 @@ int main (int argc, char **argv) g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); int status = g_application_run (G_APPLICATION (app), argc, argv); - fsm_journal_event ("main g_object unref (app)", INFO, MAIN, ""); + fsm_journal_event (INFO, MAIN, "main", "g_object unref (app)", ""); g_object_unref (app); - fsm_journal_event ("main That'all folks ! 👋️😄️",INFO, MAIN, ""); + fsm_journal_event (INFO, MAIN, "main", "That'all folks ! 👋️😄️", ""); fsm_journal_publication_request(); return status; diff --git a/src/signal.c b/src/signal.c index f8a3715..d5964ea 100644 --- a/src/signal.c +++ b/src/signal.c @@ -37,7 +37,7 @@ static void on_auto_notification (char *message) { // message = "-(any auto notification)-"; // test - fsm_journal_event ("signal (notif.) ", DEBUG, AUTO_NOTIFICATION, message); + fsm_journal_event (DEBUG, AUTO_NOTIFICATION, "signal", "auto_notification", message); /* Ignored (2024-06-06) because I don't know how to get "main_window" easily if (window->toast_revealer == NULL) { @@ -74,7 +74,7 @@ static void on_user_tree_expander_toggled (GtkExpander *expander, void on_setup_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data){ fsm_journal_event ("signal setup user tree factory()", - REPEATED, EXPANDER, ""); + REPETITIVE, EXPANDER, ""); GtkWidget* expander = gtk_expander_new (NULL); gtk_list_item_set_child (GTK_LIST_ITEM (object), expander); } @@ -104,7 +104,7 @@ void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, gtk_widget_set_margin_start (expander, gtk_tree_list_row_get_depth(row) * 20); fsm_journal_event ("signal (tree) bind user tree factory()", - REPEATED, TREE, text); + REPETITIVE, TREE, text); } @@ -204,11 +204,11 @@ void on_axis_value_change (GtkAdjustment *adjustment, gpointer data) char string_value [10]; sprintf(string_value, " (%d)", axis_value); switch (axis) { case 0 : fsm_journal_event ("signal (axis) X value changed()", - REPEATED, SLIDER_X, string_value); break; + REPETITIVE, SLIDER_X, string_value); break; case 1 : fsm_journal_event ("signal (axis) Y value changed()", - REPEATED, SLIDER_Y, string_value); break; + REPETITIVE, SLIDER_Y, string_value); break; case 2 : fsm_journal_event ("signal (axis) Z value changed()", - REPEATED, SLIDER_Z, string_value); break; + REPETITIVE, SLIDER_Z, string_value); break; } } @@ -284,9 +284,13 @@ void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) static void switch_state_rules_data() { int value = fsm_get_state_rules_data(); + /* + * pas sûr que ça ait un intérêt... en tout cas, pas comme ça ! + * char string_value [12]; sprintf(string_value, "%d", value); fsm_journal_event ("signal (switch) value = ", DEBUG, SWITCH_STATE_RULES_DATA, string_value); + */ switch (value) { case (SYNTH) : @@ -342,8 +346,9 @@ void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data) { const char *toggled_button_name = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button)); - fsm_journal_event ("signal (toggle) <-->", - INFO, BUTTON, toggled_button_name); + fsm_journal_event ("signal (toggle) --> [", INFO, BUTTON, + concat (toggled_button_name, + " ]", NULL)); int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button)); if ( ! strcmp (toggled_button_name, "synth")) fsm_set_state_rules_data (SYNTH); diff --git a/src/widget/dispatch.c b/src/widget/dispatch.c index db2d82f..2b8e7d4 100644 --- a/src/widget/dispatch.c +++ b/src/widget/dispatch.c @@ -61,13 +61,12 @@ void *widget_get_text_window() { return text_window; } void on_windows_startup (GtkApplication *app) // WIP 2024-09 { // NB on_windows_startup() is in: widget/dispatch NOT in: src/signal - fsm_journal_event ("widget/dispatch windows startup()", MESSAGE, WIDGETS, ""); + fsm_journal_event (MESSAGE, WIDGETS, "widget/dispatch", "windows startup()", ""); } void on_windows_activation (GtkApplication *app) { - fsm_journal_event ("widget/dispatch windows activation() has began", - INFO, WIDGETS, ""); + fsm_journal_event (INFO, WIDGETS, "widget/dispatch", "windows activation()", " has began"); // on_windows_activation() is in: widget/dispatch NOT in: src/signal // g_application_activate (G_APPLICATION (app)); < how ? > in main is @@ -103,8 +102,7 @@ void on_windows_activation (GtkApplication *app) g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b)); g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2);*/ - fsm_journal_event ("widget/dispatch windows activation() has ended", - INFO, WIDGETS, "\n"); + fsm_journal_event (INFO, WIDGETS, "widget/dispatch", "windows activation()", " has ended\n"); } /******************************************************************************/ diff --git a/src/widget/one_rule/algebra/conditions.c b/src/widget/one_rule/algebra/conditions.c index da7eab5..75654f9 100644 --- a/src/widget/one_rule/algebra/conditions.c +++ b/src/widget/one_rule/algebra/conditions.c @@ -40,11 +40,11 @@ void *widget_get_btt_conditions_list() gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled_list_box), list_box); gtk_widget_set_size_request (GTK_WIDGET (scrolled_list_box), LIST_W, LIST_H); - int conditions_nb = 32, // arbitrary TODO + int conditions_nb = 32, // arbitrary TODO link to the XML model nb_of_digits_used_to_write_the_conditions_nb_plus_one = 3; char str_nb [nb_of_digits_used_to_write_the_conditions_nb_plus_one]; sprintf(str_nb, "%d", conditions_nb); - char *str_journal; + char *one_condition; for (int i = 0; i < 32; i++) { @@ -54,9 +54,13 @@ void *widget_get_btt_conditions_list() char str4[5]; sprintf(str4, "%d, ", rand() % 10); char str5[8]; sprintf(str5, "%d) == ", rand() % 10); char str6[4]; sprintf(str6, "%d)", rand() % 10); - str_journal = concat (str1, str2, str3, str4, str5, str6, NULL); - widget_set_item_text (list_box, str_journal, TRUE); - fsm_journal_event ("conditions_list ", REPEATED, RULE_CONDITION, str_journal); + one_condition = concat (str1, str2, str3, str4, str5, str6, NULL); + widget_set_item_text (list_box, one_condition, TRUE); + fsm_journal_event (REPETITIVE, + RULE_CONDITION, + "widget/one_rule/algebra/conditions", + "conditions list ", + one_condition); } GtkWidget *pop = gtk_popover_new (); gtk_popover_set_child (GTK_POPOVER (pop), scrolled_list_box); @@ -68,9 +72,15 @@ void *widget_get_btt_conditions_list() gtk_menu_button_set_label (GTK_MENU_BUTTON (conditions), "conditions"); gtk_menu_button_set_always_show_arrow (conditions, TRUE); gtk_menu_button_set_popover (conditions, GTK_WIDGET (pop)); + // clicked (conditions, NULL); + + fsm_journal_event (DEBUG, + RULE_CONDITION, + "widget/one_rule/algebra/conditions", + "conditions_list ", + concat ("[", one_condition, "] = last of: ", str_nb, NULL) + ); - fsm_journal_event ("conditions_list ", DEBUG, RULE_CONDITION, - concat ("clicked [", str_journal, "] = last of: ", str_nb, NULL)); return conditions; } diff --git a/src/widget/topbar/dialog.c b/src/widget/topbar/dialog.c index a828828..063a666 100644 --- a/src/widget/topbar/dialog.c +++ b/src/widget/topbar/dialog.c @@ -36,7 +36,7 @@ void widget_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window) { - fsm_journal_event ("modal window design", INFO, MODAL_WINDOW, ""); + fsm_journal_event (INFO, MODAL_WINDOW, "widget/topbar/dialog", "modal window design", ""); char *title = " Save the current model before modifying it? "; GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); diff --git a/src/widget/topbar/dispatch.c b/src/widget/topbar/dispatch.c index 6bcad87..f597ef4 100644 --- a/src/widget/topbar/dispatch.c +++ b/src/widget/topbar/dispatch.c @@ -39,8 +39,7 @@ static GtkWidget *window_topbar (GtkWindow *window); void widget_design_main_window (GtkWindow *main_window, GtkApplication *app) { - fsm_journal_event ("main_window *topbar = window_topbar (main_window)", - INFO, TOPBAR, ""); + fsm_journal_event (INFO, TOPBAR, "widget/topbar/dispatch", "design (main window topbar)", ""); GtkWidget *topbar = window_topbar (main_window); window_design_topbar_left (topbar); window_design_topbar_right (topbar, app); @@ -51,8 +50,7 @@ void widget_design_main_window (GtkWindow *main_window, GtkApplication *app) static GtkWidget *window_topbar (GtkWindow *window) { - fsm_journal_event ("topbar *topbar = gtk_header_bar_new ()", - INFO, TOPBAR_CENTER, ""); + fsm_journal_event (INFO, TOPBAR_CENTER, "widget/topbar/dispatch", "topbar = gtk_header_bar_new()", ""); char *title = "E coli (with permission from David S. Goodsell, 2009)"; GtkWidget *topbar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (topbar), gtk_label_new (title)); diff --git a/src/widget/topbar/left.c b/src/widget/topbar/left.c index 1df4fa5..da65570 100644 --- a/src/widget/topbar/left.c +++ b/src/widget/topbar/left.c @@ -43,8 +43,8 @@ void *widget_get_btt_data () {return btt_DATA;} void window_design_topbar_left (GtkWidget *header_bar) { - fsm_journal_event ("topbar left g_signal_connect (EXEC / EDIT) + select a page", - INFO, TOPBAR_LEFT, ""); + fsm_journal_event (INFO, TOPBAR_LEFT, "widget/topbar/left", "design", + "(EXEC / EDIT) and (SYNTH / STATE / RULES / DATA)"); gpointer no_local_data = NULL; GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ()); diff --git a/src/widget/topbar/modal.c b/src/widget/topbar/modal.c index 52c3050..0a82359 100644 --- a/src/widget/topbar/modal.c +++ b/src/widget/topbar/modal.c @@ -35,14 +35,14 @@ void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window) { - fsm_journal_event ("text window design", INFO, TEXT_WINDOW, ""); + fsm_journal_event (INFO, TEXT_WINDOW, "widget/topbar/modal", "text window design", ""); char *title = " Learn more about Gem Graph. "; GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); gtk_window_set_titlebar (text_window, header_bar); GtkWidget *child = widget_get_text_from_address (widget_get_text_address_theory()); - child = widget_get_text_from_address (widget_get_text_address_practice()); + child = widget_get_text_from_address (widget_get_text_address_practice()); gtk_window_set_child (GTK_WINDOW (text_window), GTK_WIDGET (child)); gtk_widget_set_size_request (GTK_WIDGET (child), W_TEXT_WINDOW, H_TEXT_WINDOW); diff --git a/src/widget/topbar/right.c b/src/widget/topbar/right.c index b6f123f..4f56cee 100644 --- a/src/widget/topbar/right.c +++ b/src/widget/topbar/right.c @@ -93,8 +93,7 @@ static void connect(GApplication *app, gpointer *data) { puts("Connect menu item void window_design_topbar_right (GtkWidget *header_bar, GtkApplication *app) { - fsm_journal_event ("topbar right display_widgets (buttons, menus)", - INFO, TOPBAR_RIGHT, ""); + fsm_journal_event (INFO, TOPBAR_RIGHT, "widget/topbar/right", "design (buttons, menus)", ""); display_widgets_at_the_right_side (header_bar); GSimpleActionGroup *ga = g_simple_action_group_new (); diff --git a/src/widget/tree.c b/src/widget/tree.c index 373007a..230d461 100644 --- a/src/widget/tree.c +++ b/src/widget/tree.c @@ -24,6 +24,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "../../include/fsm.h" #include "../../include/signal.h" #include "../../include/widget.h" @@ -76,6 +77,8 @@ static GListModel *get_user_tree_model (GObject *item, gpointer root) // ! WARNING ! TODO CUR EST L'ENFANT, MAINTENANT // DONC, SI CUR EST UNE FEUILLE, JE N'ATTEINDRAI PAS SON ENFANT +// TODO: link the tree to the XML model + return get_user_tree_model_child (cur); } @@ -84,6 +87,8 @@ static GListModel *get_user_tree_model (GObject *item, gpointer root) void *widget_get_user_rules_tree () { + fsm_journal_event (DEBUG, RULES_TREE, "widget/tree", "get user rules tree", "[We, the people,]..."); + struct TreeNode_t *tree_root = widget_create_user_tree_node("We, the people,"); widget_let_us_create_a_complex_useless_and_expensive_tree (tree_root);