From 20adec4d783c73b2693414cc2883a3a045409ce5 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 12 Sep 2024 09:31:18 +0200 Subject: [PATCH] =?UTF-8?q?fsm=20journal=20prioris=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/fsm.h | 6 +++- src/fsm/dispatch.c | 18 ++++++----- src/signal.c | 73 +++++++++++++++++++++---------------------- src/util/draw/gl.c | 4 +-- src/widget/dispatch.c | 10 ++++-- 5 files changed, 62 insertions(+), 49 deletions(-) diff --git a/include/fsm.h b/include/fsm.h index 5f85135..281a2d4 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -47,6 +47,10 @@ 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 ------ +#define PRIORITY_0 0 +#define PRIORITY_1 1 +#define PRIORITY_2 2 +#define PRIORITY_3 3 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 @@ -61,7 +65,7 @@ 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; -void fsm_journal_widget_event (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 45eae32..babe884 100644 --- a/src/fsm/dispatch.c +++ b/src/fsm/dispatch.c @@ -59,18 +59,22 @@ journal glogos; // gg_logs, should be, but 'glogos' is funny 2024-09-11 void fsm_init() { - fsm_journal_push_front (&glogos, "fsm_init() start"); + fsm_journal_push_front (&glogos, " fsm > fsm_init() start"); - fsm_measures_list_init(); fsm_journal_push_front (&glogos, "fsm_measures_list_init()"); - fsm_results_list_init(); fsm_journal_push_front (&glogos, "fsm_results_list_init()"); - fsm_displayable_list_init(); fsm_journal_push_front (&glogos, "fsm_displayable_list_init()"); - fsm_preferences_init(); fsm_journal_push_front (&glogos, "fsm_preferences_init()"); + 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_journal_push_front (&glogos, "fsm_init() end"); + fsm_journal_push_front (&glogos, " fsm > fsm_init() end"); } void fsm_journal_view_request (char *message) {fsm_journal_view (glogos, message);} -void fsm_journal_widget_event (char *message) {fsm_journal_push_front (&glogos, message);} +void fsm_journal_widget_event (char *message, int priority) +{ + if (priority > PRIORITY_0) + fsm_journal_push_front (&glogos, message); +} /******************************************************************************/ /* S T A T E S */ diff --git a/src/signal.c b/src/signal.c index 39184c5..23639eb 100644 --- a/src/signal.c +++ b/src/signal.c @@ -36,7 +36,7 @@ static void on_auto_notification (const char *message) { - fsm_journal_widget_event ("signal > on_auto_notification()"); + fsm_journal_widget_event ("signal > on_auto_notification()", PRIORITY_1); /* Ignored (2024-06-06) because I don't know how to get "main_window" easily if (window->toast_revealer == NULL) { @@ -63,7 +63,7 @@ static void on_auto_notification (const char *message) static void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data) { - fsm_journal_widget_event ("signal > on_user_tree_expander_toggled()"); + fsm_journal_widget_event ("signal > on_user_tree_expander_toggled()", PRIORITY_1); GtkTreeListRow *row = GTK_TREE_LIST_ROW (user_data); gboolean is_expanded = gtk_tree_list_row_get_expanded (row); gtk_tree_list_row_set_expanded (row, ! is_expanded); @@ -74,7 +74,7 @@ void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data) { - fsm_journal_widget_event ("signal > on_bind_user_tree_factory()"); + fsm_journal_widget_event ("signal > on_bind_user_tree_factory()", PRIORITY_0); GtkListItem *list_item = GTK_LIST_ITEM (object); assert (list_item); @@ -98,10 +98,9 @@ void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, void on_setup_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data){ - fsm_journal_widget_event ("signal > on_setup_user_tree_factory()"); + fsm_journal_widget_event ("signal > on_setup_user_tree_factory()", PRIORITY_0); GtkWidget* expander = gtk_expander_new (NULL); gtk_list_item_set_child (GTK_LIST_ITEM (object), expander); - if (0) printf("[on_setup_user_tree_factory] here is an expander\n"); } @@ -112,7 +111,7 @@ void on_setup_user_tree_factory (GtkSignalListItemFactory *factory, gboolean on_glarea_render (GtkGLArea *area, GdkGLContext *context) { - fsm_journal_widget_event ("signal > on_glarea_render()"); + fsm_journal_widget_event ("signal > on_glarea_render()", PRIORITY_1); // Check if the widget is a glarea if(gtk_gl_area_get_error(area) != NULL) { on_auto_notification("An OpenGL error occured !"); @@ -131,7 +130,7 @@ gboolean on_glarea_render (GtkGLArea *area, /* We need to set up our state when we realize the GtkGLArea widget */ void on_glarea_realize (GtkWidget *widget) { - fsm_journal_widget_event ("signal > on_glarea_realize()"); + fsm_journal_widget_event ("signal > on_glarea_realize()", PRIORITY_1); GError *internal_error = NULL; // Make the GL context current to be able to call the GL API @@ -157,7 +156,7 @@ void on_glarea_realize (GtkWidget *widget) /* We should tear down the state when unrealizing */ void on_glarea_unrealize (GtkWidget *widget) { - fsm_journal_widget_event ("signal > on_glarea_unrealize()"); + fsm_journal_widget_event ("signal > on_glarea_unrealize()", PRIORITY_1); GError *internal_error = NULL; // Make the GL context current to be able to call the GL API @@ -180,7 +179,7 @@ void on_glarea_unrealize (GtkWidget *widget) void on_axis_value_change (GtkAdjustment *adjustment, gpointer data) { - fsm_journal_widget_event ("signal > on_axis_value_change()"); + fsm_journal_widget_event ("signal > on_axis_value_change()", PRIORITY_1); GtkWidget *slider = gtk_widget_get_parent(GTK_WIDGET(data)); GtkWidget *container_widget = gtk_widget_get_parent(GTK_WIDGET(slider)); @@ -208,7 +207,7 @@ void on_axis_value_change (GtkAdjustment *adjustment, gpointer data) void on_save_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { - fsm_journal_widget_event ("signal > on_save_current_model_before_editing()"); + fsm_journal_widget_event ("signal > on_save_current_model_before_editing()", PRIORITY_1); gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); printf ("signal.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); @@ -217,14 +216,14 @@ void on_save_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL, void on_discard_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { - fsm_journal_widget_event ("signal > on_discard_current_model_before_editing()"); + fsm_journal_widget_event ("signal > on_discard_current_model_before_editing()", PRIORITY_1); gtk_window_close (GTK_WINDOW (data)); } void on_write_current_model (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) { - fsm_journal_widget_event ("signal > on_write_current_model()"); + fsm_journal_widget_event ("signal > on_write_current_model()", PRIORITY_1); gtk_window_close (GTK_WINDOW (data)); printf ("signal.c - WRITE_CURRENT_MODEL\n"); } @@ -241,7 +240,7 @@ static void switch_state_rules_data(); void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) { - fsm_journal_widget_event ("signal > on_toggle_exec_edit()"); + fsm_journal_widget_event ("signal > on_toggle_exec_edit()", PRIORITY_1); 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), @@ -270,7 +269,7 @@ void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) static void switch_state_rules_data() { - fsm_journal_widget_event ("signal > switch_state_rules_data()"); + fsm_journal_widget_event ("signal > switch_state_rules_data()", PRIORITY_1); switch (fsm_get_state_rules_data()) { case (SYNTH) : @@ -322,7 +321,7 @@ static void switch_state_rules_data() // Les noms d'icônes sont utilisés pour deux fonctions distinctes... void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data) { - fsm_journal_widget_event ("signal > on_toggle_state_rules_data()"); + fsm_journal_widget_event ("signal > on_toggle_state_rules_data()", PRIORITY_1); const char *toggled_button_name = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button)); int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button)); @@ -340,7 +339,7 @@ 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 ----------- // void on_clicked_topbar_right_search (GtkWidget *btt_menu, gpointer list_box) { - fsm_journal_widget_event ("signal > on_clicked_topbar_right_search()"); + fsm_journal_widget_event ("signal > on_clicked_topbar_right_search()", PRIORITY_1); // next line presents the text_window and works only once.\n // It should present a menu.\n"); // TODO gtk_window_present (GTK_WINDOW (widget_get_text_window())); @@ -349,7 +348,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()"); + 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 } @@ -365,7 +364,7 @@ void on_clicked_topbar_right_home (GtkWidget *btt_reset, gpointer data) void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *scrollbar) { - fsm_journal_widget_event ("signal > on_updating_objects_transparencies()"); + fsm_journal_widget_event ("signal > on_updating_objects_transparencies()", PRIORITY_1); const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source)); int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (scrollbar)); @@ -378,7 +377,7 @@ void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *sc void on_resetting_XYZ_in_state_page () { - fsm_journal_widget_event ("signal > on_resetting_XYZ_in_state_page()"); + fsm_journal_widget_event ("signal > on_resetting_XYZ_in_state_page()", PRIORITY_1); widget_state_XYZ_reset_all(); } @@ -386,7 +385,7 @@ void on_resetting_XYZ_in_state_page () void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) { - fsm_journal_widget_event ("signal > on_situations_box_do_reset()"); + fsm_journal_widget_event ("signal > on_situations_box_do_reset()", PRIORITY_1); GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar); fsm_reset_all_situations_transparencies_at_value (gtk_adjustment_get_value (adj_situ)); } @@ -399,7 +398,7 @@ void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrol void on_clicked_topbar_right_measure (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_clicked_topbar_right_measure()"); + fsm_journal_widget_event ("signal > on_clicked_topbar_right_measure()", PRIORITY_1); // fsm_measures_sorted_list_do something (); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_get_measure_page())); @@ -407,98 +406,98 @@ void on_clicked_topbar_right_measure (GtkWidget *btt, gpointer data) void on_start_new_measure (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_start_new_measure()"); + fsm_journal_widget_event ("signal > on_start_new_measure()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_select_rules_first())); } void on_select_rules_first (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_select_rules_first()"); + fsm_journal_widget_event ("signal > on_select_rules_first()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_depends_on_one_or_two_events())); } void on_measure_depends_on_a_single_event (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_measure_depends_on_a_single_event()"); + fsm_journal_widget_event ("signal > on_measure_depends_on_a_single_event()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_depends_on_a_single_event())); } void on_measure_depends_on_two_events (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_measure_depends_on_two_events()"); + fsm_journal_widget_event ("signal > on_measure_depends_on_two_events()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_select_a_second_rules_set())); } void on_select_a_second_rules_set (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_select_a_second_rules_set()"); + fsm_journal_widget_event ("signal > on_select_a_second_rules_set()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_choose_an_event_type())); } void on_select_a_second_measurement (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_select_a_second_measurement()"); + fsm_journal_widget_event ("signal > on_select_a_second_measurement()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_correlate())); } void on_skip_this_step (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_skip_this_step()"); + fsm_journal_widget_event ("signal > on_skip_this_step()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_insert_in_measurements_list ())); } void on_something_else (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_something_else()"); + fsm_journal_widget_event ("signal > on_something_else()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_do_end_creation_of_measurement_process())); } void on_closing_page (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_closing_page()"); + fsm_journal_widget_event ("signal > on_closing_page()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_get_synth_page())); } void on_measure_single_event_occurences_nb (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_measure_single_event_occurences_nb()"); + fsm_journal_widget_event ("signal > on_measure_single_event_occurences_nb()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_event_occurences_nb())); } void on_measure_single_event_occurences_dates (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_measure_single_event_occurences_dates()"); + fsm_journal_widget_event ("signal > on_measure_single_event_occurences_dates()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_event_occurences_dates())); } void on_measure_single_event_occurences_situations (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_measure_single_event_occurences_situations()"); + fsm_journal_widget_event ("signal > on_measure_single_event_occurences_situations()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_event_occurences_situations())); } void on_measure_time_elapsed_between_two_events (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_measure_time_elapsed_between_two_events()"); + fsm_journal_widget_event ("signal > on_measure_time_elapsed_between_two_events()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_time_elapsed_between_two_events())); } void on_measure_third_event_occurences_in_between (GtkWidget *btt, gpointer data) { - fsm_journal_widget_event ("signal > on_measure_third_event_occurences_in_between()"); + fsm_journal_widget_event ("signal > on_measure_third_event_occurences_in_between()", PRIORITY_1); gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), GTK_WIDGET (widget_measure_third_event_occurences_in_between())); } @@ -510,12 +509,12 @@ void on_measure_third_event_occurences_in_between (GtkWidget *btt, gpointer data void on_entry_name_insert_after (GtkWidget *entry, gpointer data) { - fsm_journal_widget_event ("signal > on_entry_name_insert_after()"); + fsm_journal_widget_event ("signal > on_entry_name_insert_after()", PRIORITY_1); } void on_entry_name_delete_after (GtkWidget *entry, gpointer data) { - fsm_journal_widget_event ("signal > on_entry_name_delete_after()"); + fsm_journal_widget_event ("signal > on_entry_name_delete_after()", PRIORITY_1); } diff --git a/src/util/draw/gl.c b/src/util/draw/gl.c index 88ee2a0..b911b83 100644 --- a/src/util/draw/gl.c +++ b/src/util/draw/gl.c @@ -350,8 +350,8 @@ on_render_debug (GtkGLArea *area, GdkGLContext *context) } int width, height; - width = gtk_widget_get_allocated_width(GTK_WIDGET(area)); - height = gtk_widget_get_allocated_height(GTK_WIDGET(area)); + width = gtk_widget_get_width(GTK_WIDGET(area)); + height = gtk_widget_get_height(GTK_WIDGET(area)); g_message("GtkGLArea size: %d x %d", width, height); glViewport(0, 0, width, height); diff --git a/src/widget/dispatch.c b/src/widget/dispatch.c index 50a0e81..43f1356 100644 --- a/src/widget/dispatch.c +++ b/src/widget/dispatch.c @@ -60,12 +60,18 @@ static void action_b (GSimpleAction *action, void on_windows_startup (GtkApplication *app) // WIP 2024-09 { - fsm_journal_widget_event ("on_windows_startup_event() is in: widget/dispatch.c NOT in: src/signal.c"); + fsm_journal_widget_event ( + "widget > on_windows_startup()", + PRIORITY_1); + // on_windows_startup() is in: widget/dispatch.c NOT in: src/signal.c } void on_windows_activation (GtkApplication *app) { - fsm_journal_widget_event ("on_windows_activation() is in: widget/dispatch.c NOT in: src/signal.c"); + fsm_journal_widget_event ( + "widget > on_windows_activation()", + PRIORITY_1); + // on_windows_activation() is in: widget/dispatch.c NOT in: src/signal.c // g_application_activate (G_APPLICATION (app)); < how ? > in main.c is // g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);