journal formatting, naming, cleaning

This commit is contained in:
Jean Sirmai 2024-09-16 16:23:45 +02:00
parent ba17b5c023
commit adeee11597
Signed by: jean
GPG Key ID: FB3115C340E057E3
7 changed files with 198 additions and 134 deletions

View File

@ -49,39 +49,52 @@ typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ;
/******************************************************************************/ /******************************************************************************/
/* J O U R N A L */ /* J O U R N A L */
/******************************************************************************/ /******************************************************************************/
// CRITICAL ERROR WARNING INFO MESSAGE DEBUG SPEW (see: fsm.h)
// 0 1 2 3 4 5 6 (fsm_journal_event)
#define CRITICAL 0 // THE HIGHER THE PRIORITY, THE LOWER THE INDEX
#define ERROR 1
#define WARNING 2
#define MESSAGE 3
#define INFO 4
#define DEBUG 5
#define SPEW 6 // THE_LOWER THE PRIORITY, THE HIGHER THE INDEX
#define PRIORITY_0 0
#define PRIORITY_1 1
#define PRIORITY_2 2
#define PRIORITY_3 3
#define JOURNAL_DATE_MAX_LENGTH 255 #define JOURNAL_DATE_MAX_LENGTH 255
typedef struct unit {long yy_dd_mm; long usec; char *message; struct unit *prev; struct unit *next;} unit; typedef struct unit {long yy_dd_mm;
typedef struct {unit *first; unit *last;} journal; // structure d'accès au journal long usec;
// journal glogos; // gg_logs, should be, but 'glogos' is funny 2024-09-11 char *message;
struct unit *prev;
struct unit *next;} unit; // journal unit structure
void fsm_journal_init (journal *jj, char *message); // initialise typedef struct {unit *first; unit *last;} journal; // journal unit access structure
void fsm_journal_clear (journal *jj, char *message); // vide tout le journal
void fsm_journal_push_front (journal *jj, char *message); // ajoute un évènement en début de journal void fsm_journal_init (journal *jj); // init from main
void fsm_journal_push_front_from_fsm (char *message); // id from fsm/dispatch void fsm_journal_push (char *message); // def: fsm/dispatch
long fsm_journal_pop_back (journal *jj, char *message); // retire un évènement en fin de journal // call: any call that does not have
int fsm_journal_length (journal jj); // nombre d'évènements dans le journal // the log address
void fsm_journal_seek (journal jj, long usec, char *message); // recherche un évènement dans le journal void fsm_journal_clear (journal *jj, char *message); // empty the journal
void fsm_journal_publish (journal jj); // affiche tout le 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
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_publish (journal jj); // display the journal
void fsm_journal_test (char *message); void fsm_journal_test (char *message);
// --------------------------------------------------------------- WIP ------ // --------------------------------------------------------------- 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() // 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_publication_request (); // def: fsm/dispatch call: main;
void fsm_journal_widget_event (char *message, int priority); // def: fsm/dispatch call: widget/dispatch; void fsm_journal_event (char *message, int priority); // def: fsm/dispatch call: widget/dispatch;
// --------------------------------------------------------------- WIP ------ // --------------------------------------------------------------- WIP ------
void fsm_init(); // def: fsm/dispatch; call: main; void fsm_init (char *message); // def: fsm/dispatch; call: main;
void fsm_engine_init(); // def: fsm/engine/engine; call main void fsm_engine_init(); // def: fsm/engine/engine; call main
void fsm_preferences_init(); // def: fsm/prefer; call: fsm/dispatch; void fsm_preferences_list_init(); // def: fsm/prefer; call: fsm/dispatch;
void fsm_measures_list_init(); // def: fsm/measure/manage.c; call: fsm/dispatch; void fsm_measures_list_init(); // def: fsm/measure/manage.c; call: fsm/dispatch;
void fsm_results_list_init(); // def: fsm/results; call: fsm/dispatch; void fsm_results_list_init(); // def: fsm/results; call: fsm/dispatch;
void fsm_displayable_list_init(); // def: fsm/prefer; call: fsm/dispatch; void fsm_displayable_list_init(); // def: fsm/prefer; call: fsm/dispatch;
@ -97,8 +110,8 @@ void fsm_set_state_rules_data (int value); // def: fsm/dispatch; call: signal;
void fsm_store_restore_reset (int choice, int value);// def: prefer; call: signal; void fsm_store_restore_reset (int choice, int value);// def: prefer; call: signal;
bool fsm_get_preferences_state(); // def: fsm/dispatch; call: - - - bool fsm_get_preferences_state(); // def: fsm/dispatch; call: - - -
void fsm_set_preferences_state (bool value); // def: fsm/dispatch; call: signal; void fsm_set_preferences_modified (bool value); // def: fsm/dispatch;
// fsm/prefer; // call: signal; fsm/prefer;
void fsm_add_measure (char *measure_name); // def: fsm/measure/manage.c; void fsm_add_measure (char *measure_name); // def: fsm/measure/manage.c;
// call: widget/measure/dispatch; // call: widget/measure/dispatch;

View File

@ -46,40 +46,57 @@
/* - saved at the end of a work session and */ /* - saved at the end of a work session and */
/* - reread (available) at the start of a new session. */ /* - reread (available) at the start of a new session. */
/* */ /* */
/* No state of the fsm should be defined in another module. */ /* No state of the fsm should be defined in another module. */
/* No fsm transition needs to be executed in another module. */ /* No fsm transition needs to be executed in another module. */
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/
/* J O U R N A L */
/******************************************************************************/
static journal gg_logs;
void fsm_journal_push (char *message) {fsm_journal_push_front (&gg_logs, message);}
void fsm_journal_publication_request () {fsm_journal_publish (gg_logs);}
#define CRITICAL___ERROR____WARNING___INFO____MESSAGE___DEBUG ___SPEW____😄 0
void fsm_journal_event (char *message, int priority)
{
// CRITICAL ERROR WARNING INFO MESSAGE DEBUG SPEW 😄️
// 0 1 2 3 4 5 6
if (priority < DEBUG) fsm_journal_push_front (&gg_logs, message);
}
#define _CRITICAL___ERROR____WARNING___INFO____MESSAGE___DEBUG ___SPEW____👋 0
/******************************************************************************/ /******************************************************************************/
/* F S M I N I T */ /* F S M I N I T */
/******************************************************************************/ /******************************************************************************/
// --------------------------------------------------------------- WIP ------ void fsm_init (char *initial_message_from_main)
static journal gologos; // gg_logs, should be, but 'gologos' is funny 2024-09-11
// journal fsm_get_journal() {return gologos;}
void fsm_journal_push_front_from_fsm (char *message)
{ {
fsm_journal_push_front (&gologos, message); fsm_journal_init (&gg_logs);
fsm_journal_push_front (&gg_logs, initial_message_from_main);
fsm_journal_push_front (&gg_logs, "fsm/dispatch initialisation fsm has began");
fsm_measures_list_init();
fsm_journal_push_front (&gg_logs, "fsm/dispatch measures list init()");
fsm_results_list_init();
fsm_journal_push_front (&gg_logs, "fsm/dispatch results list init()");
fsm_displayable_list_init();
fsm_journal_push_front (&gg_logs, "fsm/dispatch displayable list init()");
fsm_preferences_list_init();
fsm_journal_push_front (&gg_logs, "fsm/dispatch preferences list init()");
fsm_journal_push_front (&gg_logs, "fsm/dispatch initialisation fsm has ended");
} }
void fsm_init()
{
fsm_journal_push_front (&gologos, "fsm fsm_init() start");
fsm_measures_list_init(); fsm_journal_push_front (&gologos, "fsm fsm_measures_list_init()");
fsm_results_list_init(); fsm_journal_push_front (&gologos, "fsm fsm_results_list_init()");
fsm_displayable_list_init(); fsm_journal_push_front (&gologos, "fsm fsm_displayable_list_init()");
fsm_preferences_init(); fsm_journal_push_front (&gologos, "fsm fsm_preferences_init()");
fsm_journal_push_front (&gologos, "fsm fsm_init() end");
}
void fsm_journal_publication_request () {fsm_journal_publish (gologos);}
void fsm_journal_widget_event (char *message, int priority)
{
if (priority > PRIORITY_0) // consider: >= instead 😄️
fsm_journal_push_front (&gologos, message);
}
/******************************************************************************/ /******************************************************************************/
/* S T A T E S */ /* S T A T E S */
@ -87,13 +104,13 @@ void fsm_journal_widget_event (char *message, int priority)
static int preferences_have_been_modified = FALSE; static int preferences_have_been_modified = FALSE;
void fsm_set_preferences_state (bool value) void fsm_set_preferences_modified (bool value)
{ {
preferences_have_been_modified = value; preferences_have_been_modified = value;
if (value) fsm_journal_push_front (&gologos, if (value) fsm_journal_push_front (&gg_logs,
"fsm fsm_set_preferences_state() <> preferences modified = TRUE"); "fsm/dispatch fsm set preferences modified (TRUE)");
else fsm_journal_push_front (&gologos, else fsm_journal_push_front (&gg_logs,
"fsm fsm_set_preferences_state() <> preferences modified = FALSE"); "fsm/dispatch fsm set preferences modified (FALSE)");
} }
bool fsm_get_preferences_state() {return preferences_have_been_modified;} bool fsm_get_preferences_state() {return preferences_have_been_modified;}

View File

@ -47,7 +47,7 @@
*/ */
void fsm_journal_init (journal *jj, char *message) void fsm_journal_init (journal *jj)
{ {
jj->first = NULL; jj->first = NULL;
jj->last = NULL; jj->last = NULL;

View File

@ -73,31 +73,31 @@ void fsm_store_restore_reset (int choice, int value)
{ {
switch (choice) { switch (choice) {
case (STORE) : case (STORE) :
fsm_journal_push_front_from_fsm ( fsm_journal_push (
"prefer fsm_store_restore_reset() <> switch (STORE)"); "fsm/prefer fsm store restore reset(): switch (STORE)");
for (int i = 0; i < n_objects; i++) { for (int i = 0; i < n_objects; i++) {
p [i] = widget_get_object_transparency (i); p [i] = widget_get_object_transparency (i);
widget_set_object_transparency_to_value (i, p [i]); widget_set_object_transparency_to_value (i, p [i]);
} }
break; break;
case (RESTORE) : case (RESTORE) :
fsm_journal_push_front_from_fsm ( fsm_journal_push (
"prefer fsm_store_restore_reset() <> switch (RESTORE)"); "fsm/prefer fsm store restore reset(): switch (RESTORE)");
for (int i = 0; i < n_objects; i++) for (int i = 0; i < n_objects; i++)
widget_set_object_transparency_to_value (i, p [i]); widget_set_object_transparency_to_value (i, p [i]);
break; break;
case (RESET) : case (RESET) :
fsm_journal_push_front_from_fsm ( fsm_journal_push (
"prefer fsm_store_restore_reset() <> switch (RESET)"); "fsm/prefer fsm store restore reset(): switch (RESET)");
for (int i = 0; i < n_objects; i++) for (int i = 0; i < n_objects; i++)
widget_set_object_transparency_to_value (i, value); // i * 4 // rand() % 127 widget_set_object_transparency_to_value (i, value); // i * 4 // rand() % 127
break; break;
default : default :
fsm_journal_push_front_from_fsm ( fsm_journal_push (
"prefer fsm_store_restore_reset() <> switch (default)"); "fsm/prefer fsm store restore reset(): switch (default)");
} }
fsm_set_preferences_state (TRUE); fsm_set_preferences_modified (TRUE);
} }
@ -109,9 +109,9 @@ static int reset_situations_to_value = -1;
void fsm_reset_all_situations_transparencies_at_value (int value) void fsm_reset_all_situations_transparencies_at_value (int value)
{ {
char str1[140] = "prefer fsm_reset_all_situations_transparencies_at_value() "; char str1[140] = "fsm/prefer fsm reset all situations transparencies at value() ";
char str2[10]; sprintf(str2, "%d, ", value); strcat(str1, str2); char str2[10]; sprintf(str2, "%d, ", value); strcat(str1, str2);
fsm_journal_push_front_from_fsm ("prefer fsm_reset_all_situations_transparencies_at_value() << TODO (prefer)"); // TODO fsm_journal_push ("fsm/prefer fsm reset all situations transparencies at value() "); // TODO
reset_situations_to_value = value; reset_situations_to_value = value;
widget_reset_all_situations_transparencies_to_value (value); widget_reset_all_situations_transparencies_to_value (value);
} }
@ -126,23 +126,21 @@ void fsm_reset_all_situations_transparencies_at_value (int value)
void fsm_add_displayable (char *displayable_name) void fsm_add_displayable (char *displayable_name)
{ {
fsm_journal_push_front_from_fsm ( fsm_journal_push (
strcat("prefer fsm_add_displayable() ", displayable_name)); // TODO strcat("fsm/prefer fsm add displayable() ", displayable_name)); // TODO
} }
/******************************************************************************/ /******************************************************************************/
/* P R E F E R E N C E S */ /* P R E F E R E N C E S */
/******************************************************************************/ /******************************************************************************/
void fsm_preferences_init () void fsm_preferences_list_init ()
{ {
fsm_journal_push_front_from_fsm ( fsm_journal_push ("fsm/prefer fsm preferences init()");
"prefer fsm_preferences_init()");
} }
void fsm_displayable_list_init () void fsm_displayable_list_init ()
{ {
fsm_journal_push_front_from_fsm ( fsm_journal_push ("fsm/prefer fsm display init()");
"prefer fsm_displayable_list_init()");
} }

View File

@ -132,10 +132,14 @@
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
fsm_init (); // def: src/fsm/dispatch.c fsm = finite state machine // def: src/fsm/dispatch fsm = finite state machine
fsm_init ("main first instruction in main() & first log");
fsm_journal_push ("main *app = gtk_application_new ()");
GtkApplication *app = gtk_application_new ("org.gem-graph", GtkApplication *app = gtk_application_new ("org.gem-graph",
G_APPLICATION_DEFAULT_FLAGS); G_APPLICATION_DEFAULT_FLAGS);
fsm_journal_push ("main g_signal_connect (app <--> on_windows_startup)");
g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL); g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL);
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
// ! WARNING ! 'on_windows_activation()' // ! WARNING ! 'on_windows_activation()'
@ -144,8 +148,9 @@ int main (int argc, char **argv)
int status = g_application_run (G_APPLICATION (app), argc, argv); int status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app); g_object_unref (app);
fsm_journal_push ("main g_object_unref (app)");
fsm_journal_push_front_from_fsm ("main That'all folks ! 👋️😄️"); fsm_journal_push ("main That'all folks ! 👋️😄️");
fsm_journal_publication_request(); fsm_journal_publication_request();
return status; return status;

View File

@ -36,7 +36,7 @@
static void on_auto_notification (const char *message) static void on_auto_notification (const char *message)
{ {
fsm_journal_widget_event ("signal on_auto_notification()", PRIORITY_1); fsm_journal_event ("signal on auto notification()", INFO);
/* Ignored (2024-06-06) because I don't know how to get "main_window" easily /* Ignored (2024-06-06) because I don't know how to get "main_window" easily
if (window->toast_revealer == NULL) { if (window->toast_revealer == NULL) {
@ -53,6 +53,7 @@ static void on_auto_notification (const char *message)
gtk_revealer_set_reveal_child(window->toast_revealer, true); gtk_revealer_set_reveal_child(window->toast_revealer, true);
*/ */
g_printerr("%s\n", message); g_printerr("%s\n", message);
fsm_journal_event ("signal on auto notification()", DEBUG);
} }
@ -63,10 +64,11 @@ static void on_auto_notification (const char *message)
static void on_user_tree_expander_toggled (GtkExpander *expander, static void on_user_tree_expander_toggled (GtkExpander *expander,
gpointer user_data) gpointer user_data)
{ {
fsm_journal_widget_event ("signal on_user_tree_expander_toggled()", PRIORITY_1); fsm_journal_event ("signal on user tree expander toggled()", DEBUG);
GtkTreeListRow *row = GTK_TREE_LIST_ROW (user_data); GtkTreeListRow *row = GTK_TREE_LIST_ROW (user_data);
gboolean is_expanded = gtk_tree_list_row_get_expanded (row); gboolean is_expanded = gtk_tree_list_row_get_expanded (row);
gtk_tree_list_row_set_expanded (row, ! is_expanded); gtk_tree_list_row_set_expanded (row, ! is_expanded);
fsm_journal_event ("signal on user tree expander toggled()", SPEW);
} }
@ -74,7 +76,7 @@ void on_bind_user_tree_factory (GtkSignalListItemFactory *factory,
GObject* object, GObject* object,
gpointer user_data) gpointer user_data)
{ {
fsm_journal_widget_event ("signal on_bind_user_tree_factory()", PRIORITY_0); fsm_journal_event ("signal on bind user tree factory()", DEBUG);
GtkListItem *list_item = GTK_LIST_ITEM (object); GtkListItem *list_item = GTK_LIST_ITEM (object);
assert (list_item); assert (list_item);
@ -94,13 +96,15 @@ void on_bind_user_tree_factory (GtkSignalListItemFactory *factory,
row); row);
gtk_widget_set_margin_start (expander, gtk_widget_set_margin_start (expander,
gtk_tree_list_row_get_depth(row) * 20); gtk_tree_list_row_get_depth(row) * 20);
fsm_journal_event ("signal on bind user tree factory()", SPEW);
} }
void on_setup_user_tree_factory (GtkSignalListItemFactory *factory, void on_setup_user_tree_factory (GtkSignalListItemFactory *factory,
GObject* object, gpointer user_data){ GObject* object, gpointer user_data){
fsm_journal_widget_event ("signal on_setup_user_tree_factory()", PRIORITY_0); fsm_journal_event ("signal on setup user tree factory()", DEBUG);
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);
fsm_journal_event ("signal on setup user tree factory()", SPEW);
} }
@ -111,7 +115,7 @@ void on_setup_user_tree_factory (GtkSignalListItemFactory *factory,
gboolean on_glarea_render (GtkGLArea *area, gboolean on_glarea_render (GtkGLArea *area,
GdkGLContext *context) GdkGLContext *context)
{ {
fsm_journal_widget_event ("signal on_glarea_render()", PRIORITY_1); fsm_journal_event ("signal on glarea render()", SPEW);
// Check if the widget is a glarea // Check if the widget is a glarea
if(gtk_gl_area_get_error(area) != NULL) { if(gtk_gl_area_get_error(area) != NULL) {
on_auto_notification("An OpenGL error occured !"); on_auto_notification("An OpenGL error occured !");
@ -123,6 +127,7 @@ gboolean on_glarea_render (GtkGLArea *area,
return false; return false;
} }
fsm_journal_event ("signal on glarea render()", SPEW);
return true; return true;
} }
@ -130,7 +135,7 @@ gboolean on_glarea_render (GtkGLArea *area,
/* We need to set up our state when we realize the GtkGLArea widget */ /* We need to set up our state when we realize the GtkGLArea widget */
void on_glarea_realize (GtkWidget *widget) void on_glarea_realize (GtkWidget *widget)
{ {
fsm_journal_widget_event ("signal on_glarea_realize()", PRIORITY_1); fsm_journal_event ("signal on glarea realize()", DEBUG);
GError *internal_error = NULL; GError *internal_error = NULL;
// Make the GL context current to be able to call the GL API // Make the GL context current to be able to call the GL API
@ -151,12 +156,13 @@ void on_glarea_realize (GtkWidget *widget)
} }
gtk_gl_area_set_auto_render(GTK_GL_AREA(widget), true); gtk_gl_area_set_auto_render(GTK_GL_AREA(widget), true);
fsm_journal_event ("signal on glarea realize()", SPEW);
} }
/* We should tear down the state when unrealizing */ /* We should tear down the state when unrealizing */
void on_glarea_unrealize (GtkWidget *widget) void on_glarea_unrealize (GtkWidget *widget)
{ {
fsm_journal_widget_event ("signal on_glarea_unrealize()", PRIORITY_1); fsm_journal_event ("signal on glarea unrealize()", DEBUG);
GError *internal_error = NULL; GError *internal_error = NULL;
// Make the GL context current to be able to call the GL API // Make the GL context current to be able to call the GL API
@ -165,6 +171,7 @@ void on_glarea_unrealize (GtkWidget *widget)
// Check if the widget is a glarea // Check if the widget is a glarea
if(gtk_gl_area_get_error(GTK_GL_AREA(widget)) != NULL) { if(gtk_gl_area_get_error(GTK_GL_AREA(widget)) != NULL) {
on_auto_notification("An OpenGL error occured !"); on_auto_notification("An OpenGL error occured !");
fsm_journal_event ("signal on glarea unrealize()", SPEW);
return; return;
} }
@ -173,13 +180,15 @@ void on_glarea_unrealize (GtkWidget *widget)
internal_error) == false) { internal_error) == false) {
on_auto_notification( on_auto_notification(
"Failed to shutdown the graphic stack !"); "Failed to shutdown the graphic stack !");
fsm_journal_event ("signal on glarea unrealize()", SPEW);
return; return;
} }
fsm_journal_event ("signal on glarea unrealize()", SPEW);
} }
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data) void on_axis_value_change (GtkAdjustment *adjustment, gpointer data)
{ {
fsm_journal_widget_event ("signal on_axis_value_change()", PRIORITY_1); fsm_journal_event ("signal on axis value change()", DEBUG);
GtkWidget *slider = gtk_widget_get_parent(GTK_WIDGET(data)); GtkWidget *slider = gtk_widget_get_parent(GTK_WIDGET(data));
GtkWidget *container_widget = gtk_widget_get_parent(GTK_WIDGET(slider)); GtkWidget *container_widget = gtk_widget_get_parent(GTK_WIDGET(slider));
@ -207,25 +216,25 @@ void on_axis_value_change (GtkAdjustment *adjustment, gpointer data)
void on_save_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL, void on_save_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL,
gpointer data) gpointer data)
{ {
fsm_journal_widget_event ("signal on_save_current_model_before_editing()", PRIORITY_1); fsm_journal_event ("signal on save current model before editing()", INFO);
gtk_widget_set_sensitive (GTK_WIDGET (data), gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
TRUE); fsm_journal_event ("signal on save current model before editing()", DEBUG);
printf ("signal.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
} }
void on_discard_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL, void on_discard_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL,
gpointer data) gpointer data)
{ {
fsm_journal_widget_event ("signal on_discard_current_model_before_editing()", PRIORITY_1); fsm_journal_event ("signal on discard current model before editing()", INFO);
gtk_window_close (GTK_WINDOW (data)); gtk_window_close (GTK_WINDOW (data));
fsm_journal_event ("signal on discard current model before editing()", DEBUG);
} }
void on_write_current_model (GtkWidget *btt_WRITE_CURRENT_MODEL, void on_write_current_model (GtkWidget *btt_WRITE_CURRENT_MODEL,
gpointer data) gpointer data)
{ {
fsm_journal_widget_event ("signal on_write_current_model()", PRIORITY_1); fsm_journal_event ("signal on write current model()", INFO);
gtk_window_close (GTK_WINDOW (data)); gtk_window_close (GTK_WINDOW (data));
printf ("signal.c - WRITE_CURRENT_MODEL\n"); fsm_journal_event ("signal on write current model()", DEBUG);
} }
@ -240,7 +249,7 @@ static void switch_state_rules_data();
void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data)
{ {
fsm_journal_widget_event ("signal on_toggle_exec_edit()", PRIORITY_1); fsm_journal_event ("signal on toggle exec edit()", INFO);
if (fsm_get_exec_edit ()) { // TODO (or NOT ?) et si je ne suis pas sur la page SYNTH if (fsm_get_exec_edit ()) { // TODO (or NOT ?) et si je ne suis pas sur la page SYNTH
gtk_button_set_icon_name (GTK_BUTTON (toggled_button), gtk_button_set_icon_name (GTK_BUTTON (toggled_button),
@ -261,6 +270,7 @@ void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data)
} }
switch_state_rules_data(); switch_state_rules_data();
fsm_journal_event ("signal on toggle exec edit()", DEBUG);
} }
@ -269,18 +279,18 @@ void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data)
static void switch_state_rules_data() static void switch_state_rules_data()
{ {
fsm_journal_widget_event ("signal switch_state_rules_data()", PRIORITY_1); fsm_journal_event ("signal switch state rules data()", INFO);
switch (fsm_get_state_rules_data()) { switch (fsm_get_state_rules_data()) {
case (SYNTH) : case (SYNTH) :
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_synth_page())); GTK_WIDGET (widget_get_synth_page()));
break; break;
case (STATE) : case (STATE) :
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_state_page())); GTK_WIDGET (widget_get_state_page()));
break; break;
case (RULES) : case (RULES) :
/* The rules page consists of two half-pages in a GtkPaned widget : /* The rules page consists of two half-pages in a GtkPaned widget :
@ -304,16 +314,18 @@ static void switch_state_rules_data()
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_all_vs_selected_one)); GTK_WIDGET (widget_all_vs_selected_one));
break; break;
case (DATA) : case (DATA) :
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_data_page())); GTK_WIDGET (widget_get_data_page()));
break; break;
default : default :
printf("default in signal.on_toggle_state_rule_data()\n"); printf("default in signal.on_toggle_state_rule_data()\n");
} fsm_journal_event ("signal default in : switch state rules data()", DEBUG);
}
fsm_journal_event ("signal switch state rules data()", DEBUG);
} }
// TODO Il doit y avoir plus élégant,... ET SURTOUT MOINS DANGEREUX !!! // TODO Il doit y avoir plus élégant,... ET SURTOUT MOINS DANGEREUX !!!
@ -321,7 +333,7 @@ static void switch_state_rules_data()
// Les noms d'icônes sont utilisés pour deux fonctions distinctes... // Les noms d'icônes sont utilisés pour deux fonctions distinctes...
void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data) void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data)
{ {
fsm_journal_widget_event ("signal on_toggle_state_rules_data()", PRIORITY_1); fsm_journal_event ("signal on toggle state rules data()", INFO);
const char *toggled_button_name const char *toggled_button_name
= gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button)); = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button));
int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button)); int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button));
@ -332,6 +344,7 @@ void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data)
if ( ! strcmp (toggled_button_name, "results")) fsm_set_state_rules_data (DATA); if ( ! strcmp (toggled_button_name, "results")) fsm_set_state_rules_data (DATA);
if (is_active) switch_state_rules_data(); if (is_active) switch_state_rules_data();
fsm_journal_event ("signal on toggle state rules data()", DEBUG);
} }
@ -339,17 +352,19 @@ void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data)
// ------------ M E N U / S E A R C H / H O M E / E T C ----------- // // ------------ M E N U / S E A R C H / H O M E / E T C ----------- //
void on_clicked_topbar_right_search (GtkWidget *btt_menu, gpointer list_box) { void on_clicked_topbar_right_search (GtkWidget *btt_menu, gpointer list_box) {
fsm_journal_widget_event ("signal on_clicked_topbar_right_search()", PRIORITY_1); fsm_journal_event ("signal on clicked topbar right search()", INFO);
// next line presents the text_window and works only once.\n // next line presents the text_window and works only once.\n
// It should present a menu.\n"); // TODO // It should present a menu.\n"); // TODO
gtk_window_present (GTK_WINDOW (widget_get_text_window())); gtk_window_present (GTK_WINDOW (widget_get_text_window()));
fsm_journal_event ("signal on clicked topbar right search()", DEBUG);
} }
void on_clicked_topbar_right_home (GtkWidget *btt_reset, gpointer data) void on_clicked_topbar_right_home (GtkWidget *btt_reset, gpointer data)
{ {
fsm_journal_widget_event ("signal on_clicked_topbar_right_home()", PRIORITY_1); fsm_journal_event ("signal on clicked topbar right home()", INFO);
// gtk_window_present (GTK_WINDOW (widget_get_dialog_window())); // NB works only once. < TODO // gtk_window_present (GTK_WINDOW (widget_get_dialog_window())); // NB works only once. < TODO
fsm_journal_event ("signal on clicked topbar right home()", DEBUG);
} }
@ -363,7 +378,7 @@ void on_clicked_topbar_right_home (GtkWidget *btt_reset, gpointer data)
void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *scrollbar) void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *scrollbar)
{ {
fsm_journal_widget_event ("signal on_updating_objects_transparencies()", PRIORITY_1); fsm_journal_event ("signal on updating objects transparencies()", INFO);
const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source)); const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source));
int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (scrollbar)); int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (scrollbar));
@ -371,22 +386,25 @@ void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *sc
if ( ! strcmp (btt_name, "edit-undo-symbolic")) fsm_store_restore_reset (RESTORE, value); if ( ! strcmp (btt_name, "edit-undo-symbolic")) fsm_store_restore_reset (RESTORE, value);
if ( ! strcmp (btt_name, "view-refresh-symbolic")) fsm_store_restore_reset (RESET, value); if ( ! strcmp (btt_name, "view-refresh-symbolic")) fsm_store_restore_reset (RESET, value);
fsm_set_preferences_state (TRUE); // << à détailler TODO fsm_set_preferences_modified (TRUE); // << à détailler TODO
fsm_journal_event ("signal on updating objects transparencies()", DEBUG);
} }
void on_resetting_XYZ_in_state_page () void on_resetting_XYZ_in_state_page ()
{ {
fsm_journal_widget_event ("signal on_resetting_XYZ_in_state_page()", PRIORITY_1); fsm_journal_event ("signal on resetting XYZ in state page()", INFO);
widget_state_XYZ_reset_all(); widget_state_XYZ_reset_all();
fsm_journal_event ("signal on resetting XYZ in state page()", DEBUG);
} }
// -------------------------- S I T U A T I O N S ----------------------- // // -------------------------- S I T U A T I O N S ----------------------- //
void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{ {
fsm_journal_widget_event ("signal on_situations_box_do_reset()", PRIORITY_1); fsm_journal_event ("signal on_situations_box_do_reset()", INFO);
GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar); GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar);
fsm_reset_all_situations_transparencies_at_value (gtk_adjustment_get_value (adj_situ)); fsm_reset_all_situations_transparencies_at_value (gtk_adjustment_get_value (adj_situ));
fsm_journal_event ("signal on_situations_box_do_reset()", DEBUG);
} }
@ -397,108 +415,123 @@ void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrol
void on_clicked_topbar_right_measure (GtkWidget *btt, gpointer data) void on_clicked_topbar_right_measure (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_clicked_topbar_right_measure()", PRIORITY_1); fsm_journal_event ("signal on clicked topbar right measure()", INFO);
// fsm_measures_sorted_list_do something (); // fsm_measures_sorted_list_do something ();
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_measure_page())); GTK_WIDGET (widget_get_measure_page()));
fsm_journal_event ("signal on clicked topbar right measure()", DEBUG);
} }
void on_start_new_measure (GtkWidget *btt, gpointer data) void on_start_new_measure (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_start_new_measure()", PRIORITY_1); fsm_journal_event ("signal on start new measure()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_select_rules_first())); GTK_WIDGET (widget_measure_do_select_rules_first()));
fsm_journal_event ("signal on start new measure()", DEBUG);
} }
void on_select_rules_first (GtkWidget *btt, gpointer data) void on_select_rules_first (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_select_rules_first()", PRIORITY_1); fsm_journal_event ("signal on select rules first()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_depends_on_one_or_two_events())); GTK_WIDGET (widget_measure_do_depends_on_one_or_two_events()));
fsm_journal_event ("signal on select rules first()", DEBUG);
} }
void on_measure_depends_on_a_single_event (GtkWidget *btt, gpointer data) void on_measure_depends_on_a_single_event (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_measure_depends_on_a_single_event()", PRIORITY_1); fsm_journal_event ("signal on measure depends on a single event()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_depends_on_a_single_event())); GTK_WIDGET (widget_measure_do_depends_on_a_single_event()));
fsm_journal_event ("signal on measure depends on a single event()", DEBUG);
} }
void on_measure_depends_on_two_events (GtkWidget *btt, gpointer data) void on_measure_depends_on_two_events (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_measure_depends_on_two_events()", PRIORITY_1); fsm_journal_event ("signal on measure depends on two events()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_select_a_second_rules_set())); GTK_WIDGET (widget_measure_do_select_a_second_rules_set()));
fsm_journal_event ("signal on measure depends on two events()", DEBUG);
} }
void on_select_a_second_rules_set (GtkWidget *btt, gpointer data) void on_select_a_second_rules_set (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_select_a_second_rules_set()", PRIORITY_1); fsm_journal_event ("signal on select a second rules set()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_choose_an_event_type())); GTK_WIDGET (widget_measure_do_choose_an_event_type()));
fsm_journal_event ("signal on select a second rules set()", DEBUG);
} }
void on_select_a_second_measurement (GtkWidget *btt, gpointer data) void on_select_a_second_measurement (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_select_a_second_measurement()", PRIORITY_1); fsm_journal_event ("signal on_select_a_second_measurement()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_correlate())); GTK_WIDGET (widget_measure_do_correlate()));
fsm_journal_event ("signal on_select_a_second_measurement()", DEBUG);
} }
void on_skip_this_step (GtkWidget *btt, gpointer data) void on_skip_this_step (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_skip_this_step()", PRIORITY_1); fsm_journal_event ("signal on_skip_this_step()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_insert_in_measurements_list ())); GTK_WIDGET (widget_measure_do_insert_in_measurements_list ()));
fsm_journal_event ("signal on_skip_this_step()", DEBUG);
} }
void on_something_else (GtkWidget *btt, gpointer data) void on_something_else (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_something_else()", PRIORITY_1); fsm_journal_event ("signal on_something_else()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_do_end_creation_of_measurement_process())); GTK_WIDGET (widget_measure_do_end_creation_of_measurement_process()));
fsm_journal_event ("signal on_something_else()", DEBUG);
} }
void on_closing_page (GtkWidget *btt, gpointer data) void on_closing_page (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_closing_page()", PRIORITY_1); fsm_journal_event ("signal on_closing_page()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_synth_page())); GTK_WIDGET (widget_get_synth_page()));
fsm_journal_event ("signal on_closing_page()", DEBUG);
} }
void on_measure_single_event_occurences_nb (GtkWidget *btt, gpointer data) void on_measure_single_event_occurences_nb (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_measure_single_event_occurences_nb()", PRIORITY_1); fsm_journal_event ("signal on_measure_single_event_occurences_nb()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_event_occurences_nb())); GTK_WIDGET (widget_measure_event_occurences_nb()));
fsm_journal_event ("signal on_measure_single_event_occurences_nb()", DEBUG);
} }
void on_measure_single_event_occurences_dates (GtkWidget *btt, gpointer data) void on_measure_single_event_occurences_dates (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_measure_single_event_occurences_dates()", PRIORITY_1); fsm_journal_event ("signal on_measure_single_event_occurences_dates()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_event_occurences_dates())); GTK_WIDGET (widget_measure_event_occurences_dates()));
fsm_journal_event ("signal on_measure_single_event_occurences_dates()", DEBUG);
} }
void on_measure_single_event_occurences_situations (GtkWidget *btt, gpointer data) void on_measure_single_event_occurences_situations (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_measure_single_event_occurences_situations()", PRIORITY_1); fsm_journal_event ("signal on_measure_single_event_occurences_situations()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_event_occurences_situations())); GTK_WIDGET (widget_measure_event_occurences_situations()));
fsm_journal_event ("signal on_measure_single_event_occurences_situations()", DEBUG);
} }
void on_measure_time_elapsed_between_two_events (GtkWidget *btt, gpointer data) void on_measure_time_elapsed_between_two_events (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_measure_time_elapsed_between_two_events()", PRIORITY_1); fsm_journal_event ("signal on_measure_time_elapsed_between_two_events()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_time_elapsed_between_two_events())); GTK_WIDGET (widget_measure_time_elapsed_between_two_events()));
fsm_journal_event ("signal on_measure_time_elapsed_between_two_events()", DEBUG);
} }
void on_measure_third_event_occurences_in_between (GtkWidget *btt, gpointer data) void on_measure_third_event_occurences_in_between (GtkWidget *btt, gpointer data)
{ {
fsm_journal_widget_event ("signal on_measure_third_event_occurences_in_between()", PRIORITY_1); fsm_journal_event ("signal on_measure_third_event_occurences_in_between()", INFO);
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_measure_third_event_occurences_in_between())); GTK_WIDGET (widget_measure_third_event_occurences_in_between()));
fsm_journal_event ("signal on_measure_third_event_occurences_in_between()", DEBUG);
} }
@ -508,12 +541,12 @@ void on_measure_third_event_occurences_in_between (GtkWidget *btt, gpointer data
void on_entry_name_insert_after (GtkWidget *entry, gpointer data) void on_entry_name_insert_after (GtkWidget *entry, gpointer data)
{ {
fsm_journal_widget_event ("signal on_entry_name_insert_after()", PRIORITY_1); fsm_journal_event ("signal on_entry_name_insert_after()", INFO);
} }
void on_entry_name_delete_after (GtkWidget *entry, gpointer data) void on_entry_name_delete_after (GtkWidget *entry, gpointer data)
{ {
fsm_journal_widget_event ("signal on_entry_name_delete_after()", PRIORITY_1); fsm_journal_event ("signal on_entry_name_delete_after()", INFO);
} }

View File

@ -56,24 +56,20 @@ void *widget_get_text_window() { return text_window; }
static void action_b (GSimpleAction *action, static void action_b (GSimpleAction *action,
GVariant *parameter, GVariant *parameter,
GApplication *application) {printf ("action_b() in widget/dispatch.c\n");} GApplication *application) {printf ("action_b() in widget/dispatch\n");}
void on_windows_startup (GtkApplication *app) // WIP 2024-09 void on_windows_startup (GtkApplication *app) // WIP 2024-09
{ {
fsm_journal_widget_event ( fsm_journal_event ("widget/dispatch on_windows_startup()", INFO);
"widget on_windows_startup()", // on_windows_startup() is in: widget/dispatch NOT in: src/signal
PRIORITY_1);
// on_windows_startup() is in: widget/dispatch.c NOT in: src/signal.c
} }
void on_windows_activation (GtkApplication *app) void on_windows_activation (GtkApplication *app)
{ {
fsm_journal_widget_event ( fsm_journal_event ("widget/dispatch on_windows_activation() has began", INFO);
"widget on_windows_activation()",
PRIORITY_1);
// on_windows_activation() is in: widget/dispatch.c NOT in: src/signal.c // on_windows_activation() is in: widget/dispatch NOT in: src/signal
// g_application_activate (G_APPLICATION (app)); < how ? > in main.c is // g_application_activate (G_APPLICATION (app)); < how ? > in main is
// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); // g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
main_window = GTK_WINDOW (gtk_application_window_new (app)); main_window = GTK_WINDOW (gtk_application_window_new (app));
@ -95,16 +91,18 @@ void on_windows_activation (GtkApplication *app)
widget_design_dialog_window (main_window, dialog_window); widget_design_dialog_window (main_window, dialog_window);
widget_design_text_window (main_window, text_window); widget_design_text_window (main_window, text_window);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
util_trigger_test(); // then go to util/tests.c and change if (0) to if (1)... util_trigger_test(); // then go to util/tests and change if (0) to if (1)...
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// WIP 2024-09 // WIP 2024-09
// https://github.com/ToshioCP/Gtk4-tutorial/blob/main/gfm/sec17.md // https://github.com/ToshioCP/Gtk4-tutorial/blob/main/gfm/sec17.md
GtkApplication *app2 = GTK_APPLICATION (app); GtkApplication *app2 = GTK_APPLICATION (app);
GSimpleAction *act_b = g_simple_action_new ("do_b", NULL); GSimpleAction *act_b = g_simple_action_new ("do_b", NULL);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b)); g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b));
g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2); g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2);
fsm_journal_event ("widget/dispatch on_windows_activation() has ended", INFO);
} }
/******************************************************************************/ /******************************************************************************/