From 89bde1d284b1462948e36e3315dfcb98df540438 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Wed, 24 Jul 2024 23:07:14 +0200 Subject: [PATCH] WIP: using 'preferences' < first step --- include/fsm.h | 6 ++++++ include/prefer.h | 8 ++++++++ include/signal.h | 2 +- include/widget.h | 3 --- src/fsm.c | 44 +++++++++++++++++++++++--------------------- src/prefer.c | 13 ++++++++++++- 6 files changed, 50 insertions(+), 26 deletions(-) diff --git a/include/fsm.h b/include/fsm.h index 191e0c2..e964ae6 100644 --- a/include/fsm.h +++ b/include/fsm.h @@ -42,6 +42,12 @@ enum fsm_choice_EXEC_EDIT { EXEC, EDIT }; // xor enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor enum fsm_choice_STORE_RESTORE_RESET { STORE, RESTORE, RESET }; // xor + +#define n_objects 32 +#define n_situations 128 + + + int fsm_get_exec_edit (); int fsm_get_state_rules_data (); int fsm_get_store_restore_reset (); diff --git a/include/prefer.h b/include/prefer.h index 81c204d..fbb57b8 100644 --- a/include/prefer.h +++ b/include/prefer.h @@ -33,3 +33,11 @@ #include void print_sth(char *msg); + +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/include/signal.h b/include/signal.h index 25fb5f6..7f91e0e 100644 --- a/include/signal.h +++ b/include/signal.h @@ -80,7 +80,7 @@ void on_toggle_state_rules_data (GtkWidget *btt_STATE_RULES_DATA, gpointer user_ -/******************************************************************************/ +/*************n_objects*****************************************************************/ /* D I A L O G W I N D O W */ /******************************************************************************/ diff --git a/include/widget.h b/include/widget.h index 001ad42..99863bc 100644 --- a/include/widget.h +++ b/include/widget.h @@ -31,9 +31,6 @@ #pragma once #include -#define n_objects 32 -#define n_situations 128 - /******************************************************************************/ /* W I N D O W S */ /******************************************************************************/ diff --git a/src/fsm.c b/src/fsm.c index 67de22d..2cba883 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -50,36 +50,37 @@ int fsm_get_store_restore_reset () {return choice_STORE_RESTORE_RESET;} /* T R A N S I T I O N S */ /******************************************************************************/ -static void debug_printing (int value, int sub_automaton); +static void debug_printing (int choice, int value, int sub_automaton); -void fsm_set_exec_edit (int value) +void fsm_set_exec_edit (int choice) { - if (choice_EXEC_EDIT != value) { - debug_printing (value, 0); // EXEC_EDIT is sub_automaton 0 - choice_EXEC_EDIT = value; + if (choice_EXEC_EDIT != choice) { + debug_printing (choice, 0, 0); // EXEC_EDIT is sub_automaton 0 + choice_EXEC_EDIT = choice; } } -void fsm_set_state_rules_data (int value) +void fsm_set_state_rules_data (int choice) { - if (choice_STATE_RULES_DATA != value) { - debug_printing (value, 1); // STATE_RULES_DATA is sub_automaton 1 - choice_STATE_RULES_DATA = value; + if (choice_STATE_RULES_DATA != choice) { + debug_printing (choice, 0, 1); // STATE_RULES_DATA is sub_automaton 1 + choice_STATE_RULES_DATA = choice; } } -void fsm_set_store_restore_reset (int target, int value) +void fsm_set_store_restore_reset (int choice, int value) { - choice_STORE_RESTORE_RESET = target; + choice_STORE_RESTORE_RESET = choice; - switch (target) { - case (STORE) : break; - case (RESTORE) : break; - case (RESET) : break; + 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 (target, 2); // STORE_RESTORE_RESET is sub_automaton 2 + debug_printing (choice, value, 2); // STORE_RESTORE_RESET is sub_automaton 2 } @@ -90,7 +91,8 @@ static int choice_SITUATIONS_box_RESET_VALUE = -1; void fsm_reset_all_situations_transparencies_at_value (int value) { - debug_printing (value, 3); // SITUATIONS_box_RESTORE_VALUES is sub_automaton 4 + debug_printing (choice_SITUATIONS_box_RESET_VALUE, value, 3); + // SITUATIONS_box_RESTORE_VALUES is sub_automaton 3 choice_SITUATIONS_box_RESET_VALUE = value; widget_reset_all_situations_transparencies_to_value (value); } @@ -104,23 +106,23 @@ 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 value, int sub_automaton) +static void debug_printing (int choice, int value, int sub_automaton) { switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and // sub_automaton 1 is STATE_RULES_DATA case (0) : printf("switch %5s x %5s > %5s x %5s\n", tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA], - tab_0 [value], + tab_0 [choice], tab_1 [choice_STATE_RULES_DATA]); break; case (1) : printf("switch %5s x %5s > %5s x %5s\n", tab_0 [choice_EXEC_EDIT], tab_1 [choice_STATE_RULES_DATA], tab_0 [choice_EXEC_EDIT], - tab_1 [value]); + tab_1 [choice]); break; - case (2) : printf("fsm_set_store_restore_reset <> target = %s\n", + 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); diff --git a/src/prefer.c b/src/prefer.c index a0fefdf..9209a7d 100644 --- a/src/prefer.c +++ b/src/prefer.c @@ -33,4 +33,15 @@ #include "../include/signal.h" #include "../include/widget.h" -void print_sth(char *msg){printf("%s\n", msg);} +void print_sth(char *msg) {printf("%s\n", msg);} + +struct preferences *pref; + +void pref_store_objects_transparencies_values() +{ + printf("pref_store_objects_transparencies_values n_objects = %d\n", n_objects); + +} +void pref_restore_previous_objects_transparencies_values() {} +void pref_reset_objects_transparencies_values() {} +