fsm_journal_publication_request (char *message) {fsm_journal_publish (gologos, message);}

This commit is contained in:
Jean Sirmai 2024-09-13 09:38:07 +02:00
parent 20adec4d78
commit 0e925fe882
Signed by: jean
GPG Key ID: FB3115C340E057E3
9 changed files with 98 additions and 61 deletions

View File

@ -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_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 ------

View File

@ -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

View File

@ -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);
}

View File

@ -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()");
}

View File

@ -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;
}

View File

@ -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
}

View File

@ -209,5 +209,3 @@ void *widget_get_graph_view_control()
return objects_vs_situations_horizontal_pane;
}

View File

@ -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 ?