PREMIER AUTOMATE OK : EXEC_EDIT X STATE_RULES_DATA
This commit is contained in:
parent
8012dd37fc
commit
3cbbeb2c3a
95
automaton.c
95
automaton.c
|
@ -11,49 +11,68 @@
|
|||
static int choice_EXEC_EDIT = EXEC;
|
||||
static int choice_STATE_RULES_DATA = STATE;
|
||||
|
||||
void set_EXEC_EDIT (int prescribed) {
|
||||
choice_EXEC_EDIT = prescribed;
|
||||
SWITCH_TO (choice_EXEC_EDIT, choice_STATE_RULES_DATA);
|
||||
}
|
||||
int get_EXEC_EDIT () {return choice_EXEC_EDIT;}
|
||||
|
||||
void set_STATE_RULES_DATA (int prescribed) {
|
||||
choice_STATE_RULES_DATA = prescribed;
|
||||
SWITCH_TO (choice_EXEC_EDIT, choice_STATE_RULES_DATA);
|
||||
}
|
||||
int get_STATE_RULES_DATA () {return choice_STATE_RULES_DATA;}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* T R A N S I T I O N S */
|
||||
/******************************************************************************/
|
||||
|
||||
void SWITCH_TO (int choice_EXEC_EDIT, int choice_STATE_RULES_DATA)
|
||||
{
|
||||
switch (choice_STATE_RULES_DATA) {
|
||||
void debug_printing (int prescribed, int sub_automaton);
|
||||
|
||||
case (STATE) :
|
||||
choice_STATE_RULES_DATA = STATE;
|
||||
if (choice_EXEC_EDIT ) choice_EXEC_EDIT = EXEC;
|
||||
else choice_EXEC_EDIT = EDIT;
|
||||
break;
|
||||
|
||||
case (RULES) :
|
||||
choice_STATE_RULES_DATA = RULES;
|
||||
if (choice_EXEC_EDIT ) choice_EXEC_EDIT = EXEC;
|
||||
else choice_EXEC_EDIT = EDIT;
|
||||
break;
|
||||
|
||||
case (DATA) :
|
||||
choice_STATE_RULES_DATA = DATA;
|
||||
if (choice_EXEC_EDIT ) choice_EXEC_EDIT = EXEC;
|
||||
else choice_EXEC_EDIT = EDIT;
|
||||
break;
|
||||
|
||||
default : printf("default in automaton.SWITCH_TO()\n");
|
||||
void set_EXEC_EDIT (int prescribed) {
|
||||
if (choice_EXEC_EDIT != prescribed) {
|
||||
debug_printing (prescribed, 0);
|
||||
choice_EXEC_EDIT = prescribed;
|
||||
}
|
||||
|
||||
printf("SWITCH_TO %d X %d (EXEC_EDIT X STATE_RULES_DATA)\n",
|
||||
choice_EXEC_EDIT,
|
||||
choice_STATE_RULES_DATA);
|
||||
}
|
||||
|
||||
void set_STATE_RULES_DATA (int prescribed) {
|
||||
if (choice_STATE_RULES_DATA != prescribed) {
|
||||
debug_printing (prescribed, 1);
|
||||
choice_STATE_RULES_DATA = prescribed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* G E T T E R S & D E B U G G E R S */
|
||||
/******************************************************************************/
|
||||
|
||||
int get_EXEC_EDIT () {return choice_EXEC_EDIT;}
|
||||
int get_STATE_RULES_DATA () {return choice_STATE_RULES_DATA;}
|
||||
|
||||
char *get_str_EXEC_EDIT (int value) {
|
||||
switch (value) {
|
||||
case (EXEC) : return "EXEC";
|
||||
case (EDIT) : return "EDIT";
|
||||
default : printf("default in automaton.get_EXEC_EDIT ()\n"); return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char *get_str_STATE_RULES_DATA (int value) {
|
||||
switch (value) {
|
||||
case (STATE) : return "STATE";
|
||||
case (RULES) : return "RULES";
|
||||
case (DATA) : return "DATA";
|
||||
default : printf("default in automaton.get_STATE_RULES_DATA ()\n"); return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void debug_printing (int prescribed, int sub_automaton) {
|
||||
switch (sub_automaton) {
|
||||
case (0) : printf("switch > %5s X %5s <> %5s X %5s\n",
|
||||
get_str_EXEC_EDIT (choice_EXEC_EDIT),
|
||||
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
|
||||
get_str_EXEC_EDIT (prescribed),
|
||||
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA));
|
||||
break;
|
||||
case (1) : printf("switch > %5s X %5s <> %5s X %5s\n",
|
||||
get_str_EXEC_EDIT (choice_EXEC_EDIT),
|
||||
get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA),
|
||||
get_str_EXEC_EDIT (choice_EXEC_EDIT),
|
||||
get_str_STATE_RULES_DATA (prescribed));
|
||||
break;
|
||||
default : printf("default in automaton.debug_printing()\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
10
automaton.h
10
automaton.h
|
@ -3,12 +3,14 @@
|
|||
|
||||
enum choice_EXEC_EDIT { EXEC, EDIT };
|
||||
enum choice_STATE_RULES_DATA { STATE, RULES, DATA };
|
||||
// MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
|
||||
// MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE }; ?
|
||||
|
||||
void set_EXEC_EDIT (int prescribed);
|
||||
int get_EXEC_EDIT ();
|
||||
|
||||
void set_STATE_RULES_DATA (int prescribed);
|
||||
|
||||
int get_EXEC_EDIT ();
|
||||
int get_STATE_RULES_DATA ();
|
||||
|
||||
void SWITCH_TO (int choice_EXEC_EDIT, int choice_STATE_RULES_DATA);
|
||||
char *get_str_EXEC_EDIT (int value);
|
||||
char *get_str_STATE_RULES_DATA (int value);
|
||||
|
||||
|
|
35
callback.c
35
callback.c
|
@ -163,58 +163,53 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* B U T T O N S */
|
||||
/******************************************************************************/
|
||||
|
||||
/*void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data) {
|
||||
if (strcmp (gtk_button_get_label (GTK_BUTTON (btt_MODEL_RUN_STOP)), " run "))
|
||||
gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " run ");
|
||||
else gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " stop ");}*/
|
||||
|
||||
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *window_child_STATE) { // *btt_MODEL_RUN_STOP) {
|
||||
if (get_EXEC_EDIT()) {
|
||||
void on_toggle_EXEC_EDIT
|
||||
(GtkWidget *btt_XOR_EXEC_EDIT, gpointer user_data) {
|
||||
if (get_EXEC_EDIT ()) {// (strcmp (get_str_EXEC_EDIT(0), "EXEC")) {
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "power-profile-balanced-rtl-symbolic");
|
||||
set_EXEC_EDIT (EXEC);
|
||||
} else {
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "preferences-system-symbolic");
|
||||
// gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "emblem-ok-symbolic"); // Transport Steam Engine !!
|
||||
// gtk_widget_set_sensitive (GTK_WIDGET (btt_MODEL_RUN_STOP), FALSE);
|
||||
// gtk_box_append (GTK_BOX (window_child_STATE), GTK_WIDGET (get_SPACE_EDIT_controls_box()));
|
||||
// gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "preferences-system-symbolic");
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "text-editor-symbolic");
|
||||
set_EXEC_EDIT (EDIT);
|
||||
}
|
||||
// gtk_window_present (GTK_WINDOW (main_window));
|
||||
}
|
||||
|
||||
void on_toggle_STATE_RULES_DATA (GtkWidget *toggled_button, gpointer user_data) {
|
||||
// https://docs.gtk.org/gtk4/class.ToggleButton.html < f..k ! bad code ++
|
||||
|
||||
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));
|
||||
|
||||
int is_state_active = ! strcmp (toggled_button_name, "state");
|
||||
int is_rules_active = ! strcmp (toggled_button_name, "rules");
|
||||
int is_data_active = ! strcmp (toggled_button_name, "data analysis");
|
||||
if (0 && is_active) printf ("> [%d] %d, %d, %d %14s\n",
|
||||
is_active, is_state_active, is_rules_active, is_data_active, toggled_button_name);
|
||||
if (! strcmp (toggled_button_name, "state")) set_STATE_RULES_DATA (STATE);
|
||||
if (! strcmp (toggled_button_name, "rules")) set_STATE_RULES_DATA (RULES);
|
||||
if (! strcmp (toggled_button_name, "data analysis")) set_STATE_RULES_DATA (DATA);
|
||||
|
||||
if (is_active) {
|
||||
if (is_state_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE()));
|
||||
else if (is_rules_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES()));
|
||||
else if (is_data_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA()));
|
||||
if (is_active)
|
||||
switch (get_STATE_RULES_DATA()) {
|
||||
case (STATE) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE())); break;
|
||||
case (RULES) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES())); break;
|
||||
case (DATA) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA())); break;
|
||||
default : printf("default in callback.on_toggle_STATE_RULES_DATA()\n");
|
||||
}
|
||||
}
|
||||
|
||||
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
|
||||
printf ("callback.c (line 201) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
|
||||
SWITCH_TO (EXEC, STATE);
|
||||
}
|
||||
|
||||
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
|
||||
gtk_window_close (GTK_WINDOW (data));
|
||||
printf ("callback.c (line 206) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
|
||||
SWITCH_TO (EXEC, RULES);
|
||||
}
|
||||
|
||||
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) {
|
||||
|
|
|
@ -14,7 +14,7 @@ void on_glarea_unrealize (GtkWidget *widget);
|
|||
|
||||
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
|
||||
|
||||
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *btt_MODEL_RUN_STOP);
|
||||
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, gpointer user_data);
|
||||
void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data);
|
||||
|
||||
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data);
|
||||
|
|
21
contain.c
21
contain.c
|
@ -136,7 +136,6 @@ GtkWidget *get_SPACE_VIEW_box(){
|
|||
GtkBox *middle_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
||||
gtk_box_append (middle_box, GTK_WIDGET (get_image_ALL_SPACE()));
|
||||
// ui_setup_glarea (0, GTK_WIDGET (middle_box));
|
||||
printf("in contain.c (line 138) > ui_setup_glarea (0, GTK_WIDGET (middle_box)); < commented 2024/06/27\n");
|
||||
|
||||
gtk_box_append (middle_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
|
||||
gtk_box_append (middle_box, GTK_WIDGET (right_box));
|
||||
|
@ -150,11 +149,6 @@ GtkWidget *get_SPACE_EDIT_controls_box() {
|
|||
}
|
||||
|
||||
|
||||
void window_main_child_bottom (GtkBox *page_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);
|
||||
|
||||
static GtkButton *btt_open_STATE;
|
||||
|
@ -181,14 +175,11 @@ void window_header_bar (GtkWindow *window, char *title){
|
|||
|
||||
gpointer no_local_data = NULL;
|
||||
|
||||
// GtkButton *btt_MODEL_RUN_STOP = GTK_BUTTON (gtk_button_new_with_label (" run "));
|
||||
// g_signal_connect (btt_MODEL_RUN_STOP, "clicked", G_CALLBACK (on_toggle_MODEL_RUN_STOP), no_local_data);
|
||||
|
||||
GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ());
|
||||
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic"); // https://thenounproject.com/icon/train-134324/
|
||||
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic");
|
||||
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "process-stop-symbolic");
|
||||
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "power-profile-balanced-rtl-symbolic");
|
||||
g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), get_window_child_STATE()); // btt_MODEL_RUN_STOP);
|
||||
g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), no_local_data);
|
||||
|
||||
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | "));
|
||||
|
||||
|
@ -207,7 +198,6 @@ void window_header_bar (GtkWindow *window, char *title){
|
|||
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA);
|
||||
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_XOR_EXEC_EDIT));
|
||||
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_MODEL_RUN_STOP)); // << pas ici ! TODO
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (any_Label));
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_STATE));
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_RULES));
|
||||
|
@ -216,13 +206,13 @@ void window_header_bar (GtkWindow *window, char *title){
|
|||
|
||||
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
|
||||
// https://iconduck.com/sets/carbon-icons < pas mal ...
|
||||
// https://thenounproject.com/icon/train-134324/
|
||||
// ma préférée : Transport Steam Engine Icon mais : [ process icon ] semble un bon choix...
|
||||
}
|
||||
|
||||
void main_window_design (GtkWindow *main_window){
|
||||
window_header_bar (main_window,
|
||||
"E coli (with permission from David S. Goodsell, 2009)");
|
||||
gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE()));
|
||||
gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE);
|
||||
gtk_window_present (GTK_WINDOW (main_window));
|
||||
}
|
||||
|
@ -240,17 +230,18 @@ void main_window_design (GtkWindow *main_window){
|
|||
|
||||
|
||||
GtkWidget *get_window_child_STATE() {
|
||||
if (0) printf("contain.get_window_child_STATE (line 235)\n");
|
||||
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
|
||||
gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS()));
|
||||
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
||||
gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box()));
|
||||
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
|
||||
gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
|
||||
//SWITCH_TO (STATE);
|
||||
return GTK_WIDGET (page_box);
|
||||
}
|
||||
|
||||
GtkWidget *get_window_child_RULES(){
|
||||
if (0) printf("contain.get_window_child_RULES (line 246)\n");
|
||||
GtkPaned *H_tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
|
||||
// GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre des règles");
|
||||
// GtkWidget *édition_de_la_règle_sélectionnée_n_1 = gtk_frame_new ("Inspection");
|
||||
|
@ -258,11 +249,11 @@ GtkWidget *get_window_child_RULES(){
|
|||
gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (get_selected_rules_vpaned_new()));
|
||||
gtk_paned_set_position (H_tree_vs_selected, 400); // WARNING : c'est une position "absolue"
|
||||
gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE);
|
||||
//SWITCH_TO (RULES);
|
||||
return GTK_WIDGET (H_tree_vs_selected);
|
||||
}
|
||||
|
||||
GtkWidget *get_window_child_DATA (){
|
||||
if (0) printf("contain.get_window_child_DATA (line 259)\n");
|
||||
GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 32));
|
||||
|
||||
GtkWidget* frame_rule_effect = gtk_frame_new ("rule effect\n-----------");
|
||||
|
|
|
@ -31,12 +31,11 @@ G_END_DECLS
|
|||
*/
|
||||
|
||||
void main_window_design (GtkWindow *main_window);
|
||||
void two_notebooks_in_two_panes (GtkWindow *window);
|
||||
GtkWidget *get_selected_rules_vpaned_new();
|
||||
GtkFrame *get_frame_with_label();
|
||||
void window_main_child_bottom (GtkBox *page_box);
|
||||
//void window_main_child (GtkWindow *main_window, int selected_page);
|
||||
void set_check_button_active (GtkButton *button, int active);
|
||||
void two_notebooks_in_two_panes (GtkWindow *window);
|
||||
|
||||
GtkFrame *get_frame_with_label();
|
||||
GtkWidget *get_selected_rules_vpaned_new();
|
||||
GtkWidget *get_TIME_EXEC_controls_box();
|
||||
GtkWidget *get_SPACE_EDIT_controls_box();
|
||||
GtkButton *get_GtkButton (char *btt_name);
|
||||
|
|
2
main.c
2
main.c
|
@ -20,5 +20,7 @@ int main (int argc, char **argv)
|
|||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
printf("in contain.get_SPACE_VIEW_box() (line 138) > ui_setup_glarea (0, GTK_WIDGET (middle_box)); < commented 2024/06/27 > TODO\n");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue