From 0d312b7d3176bc151b46220af35ebb723cecab5e Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 22 Sep 2024 15:30:00 +0200 Subject: [PATCH] journal introduction of : 'REPEATED' (applied to conditions' list and tree) --- include/fsm.h | 6 ++++-- include/widget.h | 4 ++-- src/fsm/dispatch.c | 10 +++++----- src/fsm/prefer.c | 8 ++++---- src/main.c | 2 +- src/signal.c | 10 +++++----- src/widget/dispatch.c | 2 +- src/widget/one_rule/algebra/conditions.c | 25 +++++++++++++++++------- src/widget/state/top.c | 6 +++--- 9 files changed, 43 insertions(+), 30 deletions(-) diff --git a/include/fsm.h b/include/fsm.h index 1b06ff0..e4627a4 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, SPEW}; +enum severity {CRITICAL, ERROR, WARNING, INFO, MESSAGE, DEBUG, REPEATED, SPEW}; enum source { SOURCE, TARGET, JOURNAL, FSM, PREFER, @@ -72,7 +72,9 @@ enum source { SYNTH_PAGE, STATE_PAGE, RULES_PAGE, MEASURES_PAGE, RESULTS_PAGE, SYNTH_GLAREA, SYNTH_ALL_RESULTS, SYNTH_TIME_DEP_RESULTS, SYNTH_TIME_INDEP_RESULTS, STATE_TOP, STATE_BOTTOM, STATE_GLAREA, STATE_CAMERA, - RULE_GLAREA, RULE_CAMERA, RULES_TREE, RULES_COMPARE, RULES_USE, + RULE_GEOMETRY, RULE_GLAREA, RULE_CAMERA, + 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, WIDGET, BUTTON, SCROLL, GLAREA, TEXT, LABEL, TREE, SLIDER, EXPANDER, ENTRY, diff --git a/include/widget.h b/include/widget.h index 165e349..f208021 100644 --- a/include/widget.h +++ b/include/widget.h @@ -154,8 +154,8 @@ void *widget_get_sequence_control(); // bottom // call: prefer.c // def: widget / state / top.c -void widget_reset_all_situations_transparencies_to_value (int value); // top -void widget_set_object_transparency_to_value (int rank, int value); // top +void widget_reset_all_situations_transparencies_at_value (int value); // top +void widget_set_object_transparency_at_value (int rank, int value); // top int widget_get_object_transparency (int i); // top diff --git a/src/fsm/dispatch.c b/src/fsm/dispatch.c index f46bf26..d085edd 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -68,15 +68,15 @@ void fsm_journal_push (char *message, const char *string_value) fsm_journal_push_front (&gg_logs, concat (message, " ", string_value, NULL)); } - // CRITICAL ERROR WARNING INFO MESSAGE DEBUG SPEW 😄️ - // 0 1 2 3 4 5 6 -#define CRITICAL___ERROR____WARNING___INFO____MESSAGE___DEBUG ___SPEW____😄️ 0 + // 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 <= DEBUG - && source != TREE + severity != REPEATED + // && source != TREE /* && ( source == MAIN || source == FSM diff --git a/src/fsm/prefer.c b/src/fsm/prefer.c index 083e450..14fec00 100644 --- a/src/fsm/prefer.c +++ b/src/fsm/prefer.c @@ -77,20 +77,20 @@ void fsm_store_restore_reset (int choice, int value) "fsm/prefer store restore reset(): switch (STORE)", MESSAGE, PREFER, ""); for (int i = 0; i < n_objects; i++) { p [i] = widget_get_object_transparency (i); - widget_set_object_transparency_to_value (i, p [i]); + widget_set_object_transparency_at_value (i, p [i]); } break; case (RESTORE) : fsm_journal_event ( "fsm/prefer store restore reset(): switch (RESTORE)", MESSAGE, PREFER, ""); for (int i = 0; i < n_objects; i++) - widget_set_object_transparency_to_value (i, p [i]); + widget_set_object_transparency_at_value (i, p [i]); break; case (RESET) : fsm_journal_event ( "fsm/prefer store restore reset(): switch (RESET)", MESSAGE, PREFER, ""); for (int i = 0; i < n_objects; i++) - widget_set_object_transparency_to_value (i, value); // i * 4 // rand() % 127 + widget_set_object_transparency_at_value (i, value); // i * 4 // rand() % 127 break; default : fsm_journal_event ( @@ -113,7 +113,7 @@ void fsm_reset_all_situations_transparencies_at_value (int value) char string_value [12]; sprintf(string_value, " (%d)", value); strcat(str1, string_value); fsm_journal_event (str1, INFO, PREFER, string_value); // TODO reset_situations_to_value = value; - widget_reset_all_situations_transparencies_to_value (value); + widget_reset_all_situations_transparencies_at_value (value); } diff --git a/src/main.c b/src/main.c index 635e76e..9473c36 100644 --- a/src/main.c +++ b/src/main.c @@ -141,7 +141,7 @@ int main (int argc, char **argv) G_APPLICATION_DEFAULT_FLAGS); fsm_journal_event ("main \ - g signal connect (app <--> on_windows_startup)", INFO, MAIN, ""); + g signal connect (app <--> on_windows_startup & activate)", INFO, MAIN, "\n"); // ! WARNING ! 'on_windows_activation()' // and 'on_windows_startup()' are in: src/widget/dispatch.c // NOT in: src/signal.c diff --git a/src/signal.c b/src/signal.c index 3df8f3c..f8a3715 100644 --- a/src/signal.c +++ b/src/signal.c @@ -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()", - SPEW, EXPANDER, ""); + REPEATED, 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()", - DEBUG, TREE, text); + REPEATED, 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()", - SPEW, SLIDER_X, string_value); break; + REPEATED, SLIDER_X, string_value); break; case 1 : fsm_journal_event ("signal (axis) Y value changed()", - SPEW, SLIDER_Y, string_value); break; + REPEATED, SLIDER_Y, string_value); break; case 2 : fsm_journal_event ("signal (axis) Z value changed()", - SPEW, SLIDER_Z, string_value); break; + REPEATED, SLIDER_Z, string_value); break; } } diff --git a/src/widget/dispatch.c b/src/widget/dispatch.c index 40f836d..db2d82f 100644 --- a/src/widget/dispatch.c +++ b/src/widget/dispatch.c @@ -104,7 +104,7 @@ void on_windows_activation (GtkApplication *app) g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2);*/ fsm_journal_event ("widget/dispatch windows activation() has ended", - INFO, WIDGETS, ""); + INFO, WIDGETS, "\n"); } /******************************************************************************/ diff --git a/src/widget/one_rule/algebra/conditions.c b/src/widget/one_rule/algebra/conditions.c index a3fa413..da7eab5 100644 --- a/src/widget/one_rule/algebra/conditions.c +++ b/src/widget/one_rule/algebra/conditions.c @@ -25,6 +25,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "../../../../include/util.h" #include "../../../../include/fsm.h" #include "../../../../include/widget.h" #include "../../../../include/signal.h" @@ -39,15 +40,23 @@ 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 + 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; + for (int i = 0; i < 32; i++) { - char str1[40]; strcpy(str1, "if ( value ("); - char str2[5]; sprintf(str2, "%d, ", rand() % 10); strcat(str1, str2); - char str3[5]; sprintf(str3, "%d, ", rand() % 10); strcat(str1, str3); - char str4[5]; sprintf(str4, "%d, ", rand() % 10); strcat(str1, str4); - char str5[8]; sprintf(str5, "%d) == ", rand() % 10); strcat(str1, str5); - char str6[5]; sprintf(str6, "%d)", rand() % 10); strcat(str1, str6); - widget_set_item_text (list_box, str1, TRUE); + char str1[] = "if ( value ("; + char str2[5]; sprintf(str2, "%d, ", rand() % 10); + char str3[5]; sprintf(str3, "%d, ", rand() % 10); + 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); } GtkWidget *pop = gtk_popover_new (); gtk_popover_set_child (GTK_POPOVER (pop), scrolled_list_box); @@ -60,6 +69,8 @@ void *widget_get_btt_conditions_list() gtk_menu_button_set_always_show_arrow (conditions, TRUE); gtk_menu_button_set_popover (conditions, GTK_WIDGET (pop)); + fsm_journal_event ("conditions_list ", DEBUG, RULE_CONDITION, + concat ("clicked [", str_journal, "] = last of: ", str_nb, NULL)); return conditions; } diff --git a/src/widget/state/top.c b/src/widget/state/top.c index 350530f..6d12946 100644 --- a/src/widget/state/top.c +++ b/src/widget/state/top.c @@ -41,7 +41,7 @@ int widget_get_object_transparency (int rank) return gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (object_bar [rank])); } -void widget_set_object_transparency_to_value (int rank, int value) +void widget_set_object_transparency_at_value (int rank, int value) { gtk_adjustment_set_value (object_adjust [rank], value); } @@ -131,7 +131,7 @@ static void *get_objects_box() static GtkScrollbar *situation_bar [n_situations]; static GtkAdjustment *situation_adjust [n_situations]; -void widget_reset_all_situations_transparencies_to_value (int value) +void widget_reset_all_situations_transparencies_at_value (int value) { for (int i = 0; i < n_situations; i++) if (value > -1) @@ -169,7 +169,7 @@ static void *get_situations_box() gtk_box_append (situations_box, GTK_WIDGET (situation_bar [i])); } - widget_reset_all_situations_transparencies_to_value (-1); + widget_reset_all_situations_transparencies_at_value (-1); return situations_box; }