diff --git a/include/fsm.h b/include/fsm.h index e964ae6..379e3c6 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -30,7 +30,7 @@ #pragma once #include - +#include /******************************************************************************/ @@ -57,3 +57,6 @@ void fsm_set_state_rules_data (int value); void fsm_set_store_restore_reset (int target, int value); void fsm_reset_all_situations_transparencies_at_value (int value); +bool fsm_get_preferences_state (); +void fsm_set_preferences_state (bool value); + diff --git a/include/prefer.h b/include/prefer.h index fbb57b8..fc91618 100644 --- a/include/prefer.h +++ b/include/prefer.h @@ -32,12 +32,5 @@ #pragma once #include -void print_sth(char *msg); +void pref_set_store_restore_reset (int choice, int value); -struct preferences { - int id; -}; - -void pref_store_objects_transparencies_values (); -void pref_restore_previous_objects_transparencies_values (); -void pref_reset_objects_transparencies_values(); diff --git a/src/fsm.c b/src/fsm.c index 2cba883..66fafcb 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -27,6 +27,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include "../include/fsm.h" #include "../include/prefer.h" @@ -39,11 +40,13 @@ static int choice_EXEC_EDIT = EXEC; static int choice_STATE_RULES_DATA = STATE; -static int choice_STORE_RESTORE_RESET = STORE; +static int preferences = TRUE; int fsm_get_exec_edit () {return choice_EXEC_EDIT;} int fsm_get_state_rules_data () {return choice_STATE_RULES_DATA;} -int fsm_get_store_restore_reset () {return choice_STORE_RESTORE_RESET;} + +bool fsm_get_preferences_state () {return preferences;} +void fsm_set_preferences_state (bool value) {preferences = value;} /******************************************************************************/ @@ -52,6 +55,7 @@ int fsm_get_store_restore_reset () {return choice_STORE_RESTORE_RESET;} static void debug_printing (int choice, int value, int sub_automaton); + void fsm_set_exec_edit (int choice) { if (choice_EXEC_EDIT != choice) { @@ -68,25 +72,13 @@ void fsm_set_state_rules_data (int choice) } } -void fsm_set_store_restore_reset (int choice, int value) -{ - choice_STORE_RESTORE_RESET = choice; - switch (choice) { - case (STORE) : printf("STORE current values in MEM "); - pref_store_objects_transparencies_values (); break; - case (RESTORE) : printf("RESTORE values from MEM "); break; - case (RESET) : printf("RESET current values from [value] "); break; - default : printf("default in signal.switch_store_restore_reset()\n"); - } - - debug_printing (choice, value, 2); // STORE_RESTORE_RESET is sub_automaton 2 -} +// ------------------------- O B J E C T S ------------------------------// +// >> transferred to prefer.c // ---------------------- S I T U A T I O N S ---------------------------// - static int choice_SITUATIONS_box_RESET_VALUE = -1; void fsm_reset_all_situations_transparencies_at_value (int value) @@ -100,11 +92,10 @@ void fsm_reset_all_situations_transparencies_at_value (int value) /******************************************************************************/ /* D E B U G G E R S */ -/***************************************************************************ù***/ +/******************************************************************************/ static char *tab_0 [] = { "EXEC", "EDIT" }; static char *tab_1 [] = { "STATE", "RULES", "DATA" }; -static char *tab_2 [] = { "STORE", "RESTORE", "RESET" }; static void debug_printing (int choice, int value, int sub_automaton) { @@ -122,11 +113,8 @@ static void debug_printing (int choice, int value, int sub_automaton) tab_0 [choice_EXEC_EDIT], tab_1 [choice]); break; - case (2) : printf("fsm_set_store_restore_reset <> choice = %s\n", - tab_2 [choice_STORE_RESTORE_RESET]); - break; - case (3) : printf("fsm_reset_all_situations_transparencies_at_value : %3d\n", value); - break; + case (2) : printf("fsm_set_store_restore_reset >> prefer.c\n"); break; + case (3) : printf("fsm_reset_all_situations_transparencies_at_value : %3d\n", value); break; default : printf("default in automaton.debug_printing()\n"); } diff --git a/src/prefer.c b/src/prefer.c index 9209a7d..22df1e3 100644 --- a/src/prefer.c +++ b/src/prefer.c @@ -33,15 +33,24 @@ #include "../include/signal.h" #include "../include/widget.h" -void print_sth(char *msg) {printf("%s\n", msg);} +// static struct preferences *pref = NULL; +// size_t pref_size = 0; -struct preferences *pref; +struct preferences { + int id [n_objects]; +}; -void pref_store_objects_transparencies_values() +static int choice_STORE_RESTORE_RESET = STORE; + +void pref_set_store_restore_reset (int choice, int value) { - printf("pref_store_objects_transparencies_values n_objects = %d\n", n_objects); + choice_STORE_RESTORE_RESET = choice; + switch (choice) { + case (STORE) : printf("STORE current values in MEM [%d]\n", n_objects); break; + case (RESTORE) : printf("RESTORE values from MEM [%d]\n", n_objects); break; + case (RESET) : printf("RESET current values from [%d]\n", value); break; + default : printf("default in signal.switch_store_restore_reset()\n"); + } } -void pref_restore_previous_objects_transparencies_values() {} -void pref_reset_objects_transparencies_values() {} diff --git a/src/signal.c b/src/signal.c index 66f7132..8fe80bf 100644 --- a/src/signal.c +++ b/src/signal.c @@ -225,9 +225,39 @@ void on_write_current_model (GtkWidget *btt_WRITE_CURRENT_MODEL, /******************************************************************************/ -/* S T A T E W I D G E T */ +/* T O P B A R W I D G E T S */ /******************************************************************************/ +// ----------------------- E X E C / E D I T -------------------------- // + +static void switch_state_rules_data(); + +void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) +{ + if (fsm_get_exec_edit ()) { + + gtk_button_set_icon_name (GTK_BUTTON (toggled_button), + "power-profile-balanced-rtl-symbolic"); + fsm_set_exec_edit (EXEC); + + } else { + + gtk_button_set_icon_name (GTK_BUTTON (toggled_button), + "text-editor-symbolic"); + + // https://docs.gtk.org/gtk4/class.Window.html TODO 2024-06-30 + // gtk_window_present (GTK_WINDOW (widget_get_dialog_window())); // works once only ! + + fsm_set_exec_edit (EDIT); + } + + switch_state_rules_data(); +} + + + +// ------------------ S T A T E / R U L E S / D A T A --------------- // + static void switch_state_rules_data() { switch (fsm_get_state_rules_data()) { @@ -252,28 +282,6 @@ static void switch_state_rules_data() } } -void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data) -{ - if (fsm_get_exec_edit ()) { - - gtk_button_set_icon_name (GTK_BUTTON (toggled_button), - "power-profile-balanced-rtl-symbolic"); - fsm_set_exec_edit (EXEC); - - } else { - - gtk_button_set_icon_name (GTK_BUTTON (toggled_button), - "text-editor-symbolic"); - - // https://docs.gtk.org/gtk4/class.Window.html TODO 2024-06-30 - // gtk_window_present (GTK_WINDOW (widget_get_dialog_window())); // works once only ! - - fsm_set_exec_edit (EDIT); - } - - switch_state_rules_data(); -} - // TODO Il doit y avoir plus élégant,... void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data) { @@ -290,31 +298,7 @@ void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data) -// ---------------------------- O B J E C T S --------------------------- // - -void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *reset_scrollbar) -{ - const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source)); - int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (reset_scrollbar)); - - if ( ! strcmp (btt_name, "view-restore-symbolic")) fsm_set_store_restore_reset (STORE, value); - if ( ! strcmp (btt_name, "view-fullscreen-symbolic")) fsm_set_store_restore_reset (RESTORE, value); - if ( ! strcmp (btt_name, "view-refresh-symbolic")) fsm_set_store_restore_reset (RESET, value); -} - - -void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) -{ - GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar); - fsm_reset_all_situations_transparencies_at_value (gtk_adjustment_get_value (adj_situ)); -} - - - -/******************************************************************************/ -/* M A I N W I N D O W H E A D E R W I D G E T S */ -/******************************************************************************/ - +// ------------ M E N U / S E A R C H / H O M E / E T C ----------- // void on_clicked_search (GtkWidget *btt_menu, gpointer list_box) { // next line presents the text_window and works only once.\n @@ -322,6 +306,7 @@ void on_clicked_search (GtkWidget *btt_menu, gpointer list_box) { gtk_window_present (GTK_WINDOW (widget_get_text_window())); } + void on_clicked_home (GtkWidget *btt_reset, gpointer data) { printf ("signal.on_clicked_HOME() button presents the dialog_window\ @@ -331,7 +316,30 @@ void on_clicked_home (GtkWidget *btt_reset, gpointer data) + /******************************************************************************/ -/* M E N U */ +/* S T A T E W I D G E T S */ /******************************************************************************/ +// ---------------------------- O B J E C T S --------------------------- // + +void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *reset_scrollbar) +{ + const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source)); + int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (reset_scrollbar)); + + if ( ! strcmp (btt_name, "view-restore-symbolic")) pref_set_store_restore_reset (STORE, value); + if ( ! strcmp (btt_name, "view-fullscreen-symbolic")) pref_set_store_restore_reset (RESTORE, value); + if ( ! strcmp (btt_name, "view-refresh-symbolic")) pref_set_store_restore_reset (RESET, value); +} + + + +// -------------------------- S IT U A T I O N S ------------------------ // + +void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar) +{ + GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar); + fsm_reset_all_situations_transparencies_at_value (gtk_adjustment_get_value (adj_situ)); +} +