diff --git a/include/fsm.h b/include/fsm.h index 281a2d4..08cb114 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -46,25 +46,34 @@ typedef struct tool_list {int value; struct tool_list *suiv;} tool_list ; typedef struct data_list {int value; struct data_list *suiv;} data_list ; typedef struct disp_list {int value; struct disp_list *suiv;} disp_list ; -// --------------------------------------------------------------- WIP ------ +/******************************************************************************/ +/* J O U R N A L */ +/******************************************************************************/ + #define PRIORITY_0 0 #define PRIORITY_1 1 #define PRIORITY_2 2 #define PRIORITY_3 3 +#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 *first; unit *last;} journal; // structure d'accès au journal +// journal glogos; // gg_logs, should be, but 'glogos' is funny 2024-09-11 void fsm_journal_init (journal *jj, char *message); // initialise 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_push_front_from_fsm (char *message); // id from fsm/dispatch long fsm_journal_pop_back (journal *jj, char *message); // retire un évènement en fin de journal int fsm_journal_length (journal jj); // nombre d'évènements dans le journal void fsm_journal_seek (journal jj, long usec, char *message); // recherche un évènement dans le journal -void fsm_journal_view (journal jj, char *message); // affiche tout le journal -void fsm_journal_test(char *message); +void fsm_journal_publish (journal jj, char *message); // affiche tout le journal +void fsm_journal_test (char *message); + // --------------------------------------------------------------- WIP ------ // ref: sudo cat /var/log/messages -void fsm_journal_view_request (char *message); // def: fsm/dispatch call: widget/dispatch; +// journal fsm_get_journal(); // def: fsm/dispatch call: fsm/prefer/fsm_store_restore_reset() +void fsm_journal_publication_request (char *message); // def: fsm/dispatch call: widget/dispatch; void fsm_journal_widget_event (char *message, int priority); // def: fsm/dispatch call: widget/dispatch; // --------------------------------------------------------------- WIP ------ diff --git a/src/fsm/dispatch.c b/src/fsm/dispatch.c index babe884..15dc873 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -55,25 +55,30 @@ /* F S M I N I T */ /******************************************************************************/ // --------------------------------------------------------------- WIP ------ -journal glogos; // gg_logs, should be, but 'glogos' is funny 2024-09-11 +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); +} void fsm_init() { - fsm_journal_push_front (&glogos, " fsm > fsm_init() start"); + fsm_journal_push_front (&gologos, " fsm > fsm_init() start"); - fsm_measures_list_init(); fsm_journal_push_front (&glogos, " fsm > fsm_measures_list_init()"); - fsm_results_list_init(); fsm_journal_push_front (&glogos, " fsm > fsm_results_list_init()"); - fsm_displayable_list_init(); fsm_journal_push_front (&glogos, " fsm > fsm_displayable_list_init()"); - fsm_preferences_init(); fsm_journal_push_front (&glogos, " fsm > fsm_preferences_init()"); + 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 (&glogos, " fsm > fsm_init() end"); + fsm_journal_push_front (&gologos, " fsm > fsm_init() end"); } -void fsm_journal_view_request (char *message) {fsm_journal_view (glogos, message);} +void fsm_journal_publication_request (char *message) {fsm_journal_publish (gologos, message);} void fsm_journal_widget_event (char *message, int priority) { - if (priority > PRIORITY_0) - fsm_journal_push_front (&glogos, message); + if (priority > PRIORITY_0) // consider: >= instead 😄️ + fsm_journal_push_front (&gologos, message); } /******************************************************************************/ @@ -82,7 +87,15 @@ void fsm_journal_widget_event (char *message, int priority) static int preferences_have_been_modified = FALSE; -void fsm_set_preferences_state (bool value) {preferences_have_been_modified = value;} +void fsm_set_preferences_state (bool value) +{ + preferences_have_been_modified = value; + if (value) fsm_journal_push_front (&gologos, + " fsm > fsm_set_preferences_state() <> preferences modified = TRUE"); + else fsm_journal_push_front (&gologos, + " fsm > fsm_set_preferences_state() <> preferences modified = FALSE"); +} + bool fsm_get_preferences_state() {return preferences_have_been_modified;} // preferences_have_been_modified // and should be stored before closing the current session. TODO diff --git a/src/fsm/journal.c b/src/fsm/journal.c index 8fcfa09..254bafc 100644 --- a/src/fsm/journal.c +++ b/src/fsm/journal.c @@ -121,10 +121,10 @@ void fsm_journal_seek (journal jj, long usec, char *message) else printf ("> date (usec) %ld not found in journal\n", usec); } -void fsm_journal_view (journal jj, char *message) +void fsm_journal_publish (journal jj, char *message) { unit *a_unit = jj.last; - char buf[80]; + char buf [JOURNAL_DATE_MAX_LENGTH]; int nb = 0; while (a_unit) { @@ -135,6 +135,6 @@ void fsm_journal_view (journal jj, char *message) a_unit = a_unit->prev; nb ++; } - printf ("view journal (n = %d)\n", nb); + printf ("%s (n = %d)\n", message, nb); } diff --git a/src/fsm/prefer.c b/src/fsm/prefer.c index b2baea3..c7a7524 100644 --- a/src/fsm/prefer.c +++ b/src/fsm/prefer.c @@ -73,23 +73,28 @@ void fsm_store_restore_reset (int choice, int value) { switch (choice) { case (STORE) : - printf("Objects transparencies STORE (value = %3d) (see prefer.c)\n", value); + fsm_journal_push_front_from_fsm ( + "prefer > fsm_store_restore_reset() <> switch (STORE)"); for (int i = 0; i < n_objects; i++) { p [i] = widget_get_object_transparency (i); widget_set_object_transparency_to_value (i, p [i]); } break; case (RESTORE) : - printf("Objects transparencies RESTORE (value = %3d) (see prefer.c)\n", value); + fsm_journal_push_front_from_fsm ( + "prefer > fsm_store_restore_reset() <> switch (RESTORE)"); for (int i = 0; i < n_objects; i++) widget_set_object_transparency_to_value (i, p [i]); break; case (RESET) : - printf("Objects transparencies RESET (value = %3d) (see prefer.c)\n", value); + fsm_journal_push_front_from_fsm ( + "prefer > fsm_store_restore_reset() <> switch (RESET)"); for (int i = 0; i < n_objects; i++) widget_set_object_transparency_to_value (i, value); // i * 4 // rand() % 127 break; - default : printf("default in signal.switch_store_restore_reset()\n"); + default : + fsm_journal_push_front_from_fsm ( + "prefer > fsm_store_restore_reset() <> switch (default)"); } fsm_set_preferences_state (TRUE); @@ -104,7 +109,9 @@ static int reset_situations_to_value = -1; void fsm_reset_all_situations_transparencies_at_value (int value) { - printf("reset_all_situations_transparencies_at_value %3d (see prefer.c)\n", value); + char str1[140] = "prefer > fsm_reset_all_situations_transparencies_at_value() "; + 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 reset_situations_to_value = value; widget_reset_all_situations_transparencies_to_value (value); } @@ -115,23 +122,27 @@ void fsm_reset_all_situations_transparencies_at_value (int value) /* D I S P L A Y E D R E S U L T S */ /******************************************************************************/ -static void *list_displayables; +// static void *list_displayables; void fsm_add_displayable (char *displayable_name) { - printf("fsm_add_displayable %p <<< %s (see prefer.c)\n", - list_displayables, displayable_name); + fsm_journal_push_front_from_fsm ( + strcat("prefer > fsm_add_displayable() ", displayable_name)); // TODO } /******************************************************************************/ /* P R E F E R E N C E S */ /******************************************************************************/ -void fsm_preferences_init () {} -void fsm_displayable_list_init () {} -/* -void fsm_preferences_init () {printf("fsm/prefer |\ - src/fsm/prefer.c fsm_preferences_init()\n");} -void fsm_displayable_list_init () {printf("fsm/prefer |\ - src/fsm/prefer.c fsm_displayable_list_init()\n");} - */ +void fsm_preferences_init () +{ + fsm_journal_push_front_from_fsm ( + "prefer > fsm_preferences_init()"); +} + +void fsm_displayable_list_init () +{ + fsm_journal_push_front_from_fsm ( + "prefer > fsm_displayable_list_init()"); +} + diff --git a/src/main.c b/src/main.c index 0582b86..9727625 100644 --- a/src/main.c +++ b/src/main.c @@ -145,6 +145,8 @@ int main (int argc, char **argv) int status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); + fsm_journal_publication_request ("main > fsm_journal_view_request() That'all folks ! 👋️ 😄️"); + return status; } diff --git a/src/signal.c b/src/signal.c index 23639eb..2ef5794 100644 --- a/src/signal.c +++ b/src/signal.c @@ -349,8 +349,7 @@ void on_clicked_topbar_right_search (GtkWidget *btt_menu, gpointer list_box) { 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_view_request ("signal > fsm_journal_view_request()"); - // gtk_window_present (GTK_WINDOW (widget_get_dialog_window())); // NB it works only once. < TODO + // gtk_window_present (GTK_WINDOW (widget_get_dialog_window())); // NB works only once. < TODO } diff --git a/src/widget/state/top.c b/src/widget/state/top.c index 576405d..350530f 100644 --- a/src/widget/state/top.c +++ b/src/widget/state/top.c @@ -182,32 +182,30 @@ static void *get_situations_box() void *widget_get_graph_view_control() { - GtkWidget *scroll_objects = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_objects), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); + GtkWidget *scroll_objects = gtk_scrolled_window_new (); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_objects), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparency - gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_objects_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_objects), frame_objects); + GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparency + gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_objects_box())); + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_objects), frame_objects); - GtkWidget *scroll_situations = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_situations), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); + GtkWidget *scroll_situations = gtk_scrolled_window_new (); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_situations), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification - gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (get_situations_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_situations), frame_situations); + GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification + gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (get_situations_box())); + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_situations), frame_situations); - GtkWidget *objects_vs_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); - gtk_paned_set_start_child (GTK_PANED(objects_vs_situations_horizontal_pane), GTK_WIDGET (scroll_objects)); - gtk_paned_set_end_child (GTK_PANED(objects_vs_situations_horizontal_pane), GTK_WIDGET (scroll_situations)); - gtk_paned_set_position (GTK_PANED (objects_vs_situations_horizontal_pane), PARTITION_STATE_TOP); - gtk_paned_set_shrink_start_child (GTK_PANED (objects_vs_situations_horizontal_pane), FALSE); - gtk_paned_set_shrink_end_child (GTK_PANED (objects_vs_situations_horizontal_pane), FALSE); - gtk_widget_set_size_request (objects_vs_situations_horizontal_pane, 0, H_OBJECTS_SITUATIONS); // OK (required)) + GtkWidget *objects_vs_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); + gtk_paned_set_start_child (GTK_PANED(objects_vs_situations_horizontal_pane), GTK_WIDGET (scroll_objects)); + gtk_paned_set_end_child (GTK_PANED(objects_vs_situations_horizontal_pane), GTK_WIDGET (scroll_situations)); + gtk_paned_set_position (GTK_PANED (objects_vs_situations_horizontal_pane), PARTITION_STATE_TOP); + gtk_paned_set_shrink_start_child (GTK_PANED (objects_vs_situations_horizontal_pane), FALSE); + gtk_paned_set_shrink_end_child (GTK_PANED (objects_vs_situations_horizontal_pane), FALSE); + gtk_widget_set_size_request (objects_vs_situations_horizontal_pane, 0, H_OBJECTS_SITUATIONS); // OK (required)) - return objects_vs_situations_horizontal_pane; + return objects_vs_situations_horizontal_pane; } - - diff --git a/src/widget/topbar/dispatch.c b/src/widget/topbar/dispatch.c index ce573d7..95df913 100644 --- a/src/widget/topbar/dispatch.c +++ b/src/widget/topbar/dispatch.c @@ -49,11 +49,11 @@ void widget_design_main_window (GtkWindow *main_window, GtkApplication *app) static GtkWidget *window_topbar (GtkWindow *window) { - 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)); - gtk_window_set_titlebar (window, topbar); - return topbar; + 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)); + gtk_window_set_titlebar (window, topbar); + return topbar; } diff --git a/src/widget/topbar/right.c b/src/widget/topbar/right.c index a5a384b..53aa12e 100644 --- a/src/widget/topbar/right.c +++ b/src/widget/topbar/right.c @@ -43,6 +43,11 @@ static void display_widgets_at_the_right_side (GtkWidget *header_bar) { gpointer no_local_data = NULL; +// next line removes the "minimize,maximize,close" buttons from the topbar right +// https://docs.gtk.org/gtk4/method.HeaderBar.set_decoration_layout.html +// gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (topbar), ""); +// I wanted once to trigger the journal publication on: gtk_window_close (GtkWindow* window) + GtkButton *btt_go_home = GTK_BUTTON (gtk_button_new ()); gtk_button_set_icon_name (btt_go_home, "go-home-symbolic"); gtk_widget_error_bell (GTK_WIDGET (btt_go_home)); // << TODO est-ce possible ?