From bc5b03eaec647ba25edd7c24a88a1b9dace55a32 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 9 Jun 2024 15:55:36 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20machine=20=C3=A0=20=C3=A9tats=20en=20con?= =?UTF-8?q?struction=20(in=5Fdepth.c)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- callback.c | 56 ++++++++----------------------- contain.c | 4 +-- in_depth.c | 98 +++++++++++++++++++++++++++++++++++------------------- 3 files changed, 79 insertions(+), 79 deletions(-) diff --git a/callback.c b/callback.c index e3a7199..a52e36e 100644 --- a/callback.c +++ b/callback.c @@ -160,58 +160,30 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data) /******************************************************************************/ void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec) { - if (get_status()) { - gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "power-profile-balanced-rtl-symbolic"); - gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run "); - gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), TRUE); - set_status (0); - } else { - gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "document-edit-symbolic"); - gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "text-editor-symbolic"); // I hesitate - set_status (1); - // Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon) - // S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues - gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " off "); - gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), FALSE); - set_status (0); - } +// gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "power-profile-balanced-rtl-symbolic"); +// gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run "); +// gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), TRUE); + +// gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "document-edit-symbolic"); +// gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "text-editor-symbolic"); // I hesitate +// gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " off "); +// gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), FALSE); } void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data) { - if (get_status() && ! get_status()) { - gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run "); - set_status (0); - } else { - gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), "stop"); - set_status (1); - } +// gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run "); +// gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), "stop"); } -// in_depth.c : enum { STATE, RULES, MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE }; - void on_toggle_state_rules (GtkWidget *btt_toggle_state_rules, gpointer data) { - if (get_status()) { - gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "state"); - window_main_child (main_window, 0); // 0 = state page (see contain.c) - set_status (0); - } else { - gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "rules"); - window_main_child (main_window, 1); // 1 = rules page (see contain.c) - set_status (1); - } +// gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "state"); +// gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "rules"); } void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointer data) { - if (get_status()) { - gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe"); - window_main_child (main_window, 2); // 2 = measures page (see contain.c) - set_status (0); - } else { - gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret"); - window_main_child (main_window, 3); // 3 = observe page (see contain.c) - set_status (1); - } +// gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe"); +// gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret"); } diff --git a/contain.c b/contain.c index bcb36f3..db53237 100644 --- a/contain.c +++ b/contain.c @@ -148,8 +148,8 @@ GtkWidget *get_SPACE_EDIT_controls_box() { void window_main_child_bottom (GtkBox *page_box){ - if (! get_status ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box())); - else gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box())); + // gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box())); + // gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box())); } static void icons_for_fun (GtkHeaderBar *header_bar); diff --git a/in_depth.c b/in_depth.c index bf952f8..7932ed9 100644 --- a/in_depth.c +++ b/in_depth.c @@ -9,7 +9,7 @@ // (exec / edit) X (state / rules / measure) X (observ / interpret / read / write) -enum { +enum { // S T A T E S EXEC_STOP, EXEC_RUN, EXEC_STOP_EDIT_RULE, @@ -24,49 +24,77 @@ enum { CONFIGURE }; -static int status = EXEC_STOP; -int get_status () {return status;} +static int status = EXEC_STOP; // int get_status () {return status;} +enum { // T R A N S I T I O N S + EXEC_TO_RUN, + RUN_TO_EXEC, +}; /******************************************************************************/ /* T R A N S I T I O N S */ /******************************************************************************/ -void set_status (int prescribed) { - status = prescribed; if (0) printf ("status = %d\n", status); - - switch (status) { - case (0) : /* EXEC_STOP */ +void let_transition_be (int asked) { + switch (asked) { + case (0) : // EXEC_TO_RUN status = EXEC_RUN; break; - case (1) : /* EXEC_RUN */ + case (1) : // RUN_TO_EXEC + // Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon) + // S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues status = EXEC_STOP; break; - case (2) : /* EXEC_STOP_EDIT_STOP */ - status = EXEC_RUN_EDIT_RULE; - break; - case (3) : /* EXEC_RUN_EDIT_RULE */ - status = EXEC_STOP_EDIT_RULE; - break; - case (4) : /* EXEC_STOP_EDIT_MEASURE */ - status = EXEC_RUN_EDIT_MEASURE; - break; - case (5) : /* EXEC_RUN_EDIT_MEASURE */ - status = EXEC_STOP_EDIT_MEASURE; - break; - case (6) : /* EDIT_STATE */ - break; - case (7) : /* EDIT_RULE */ - break; - case (8) : /* OBSERVE */ - break; - case (9) : /* INTERPRET */ - break; - case (10) : /* HELP */ - break; - case (11) : /* CONFIGURE */ - break; - case (12) : /* OTHER */ - break; default : ; } } + + + + + + + + + +/* +void set_status (int prescribed) { + status = prescribed; if (0) printf ("status = %d\n", status); + + switch (status) { + case (0) : // EXEC_STOP + status = EXEC_RUN; + break; + case (1) : // EXEC_RUN + // Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon) + // S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues + status = EXEC_STOP; + break; + case (2) : // EXEC_STOP_EDIT_STOP + status = EXEC_RUN_EDIT_RULE; + break; + case (3) : // EXEC_RUN_EDIT_RULE + status = EXEC_STOP_EDIT_RULE; + break; + case (4) : // EXEC_STOP_EDIT_MEASURE + status = EXEC_RUN_EDIT_MEASURE; + break; + case (5) : // EXEC_RUN_EDIT_MEASURE + status = EXEC_STOP_EDIT_MEASURE; + break; + case (6) : // EDIT_STATE + break; + case (7) : // EDIT_RULE + break; + case (8) : // OBSERVE + break; + case (9) : // INTERPRET + break; + case (10) : // HELP + break; + case (11) : // CONFIGURE + break; + case (12) : // OTHER + break; + default : ; + } +} */