This commit is contained in:
Jean Sirmai 2024-06-17 11:48:20 +02:00
parent aa3c7bcc82
commit 31957b7835
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 89 additions and 35 deletions

View File

@ -13,8 +13,6 @@
* (state / rules / data) < VIEW
* X
* (measure / analyse / interpret)
* X
* (read / write)
*/
static int mode = RUN;
@ -30,24 +28,14 @@ int get_view () {return view;}
/* T R A N S I T I O N S */
/******************************************************************************/
void SWITCH_TO (int asked) {
switch (asked) {
case (INTER) :
view = INTER; printf ("SWITCH_TO INTER\n");
break;
case (STATE) : // BEGIN_TO_EXEC_STOP
view = STATE; printf ("SWITCH_TO STATE\n");
break;
case (RULES) : // EXEC_STOP_TO_RUN
view = RULES; printf ("SWITCH_TO RULES\n");
break;
case (DATA) : // EXEC_RUN_TO_STOP
view = DATA; printf ("SWITCH_TO DATA\n");
break;
void toggle_TO (int mode, int view) {
switch (view) {
case (INTER) : printf ("switch to INTER\n"); break;
case (STATE) : printf ("switch to STATE\n"); break;
case (RULES) : printf ("switch to RULES\n"); break;
case (DATA) : printf ("switch to DATA \n"); break;
default : ;
}
//q gtk_window_present (GTK_WINDOW (main_window));
}
@ -58,6 +46,31 @@ void SWITCH_TO (int asked) {
/*
enum { // S T A T E S
INTER,

View File

@ -10,8 +10,6 @@
* (state / rules / data) < VIEW
* X
* (measure / analyse / interpret) < DATA
* X
* (read / write) < R__W
*/
/******************************************************************************/
@ -24,4 +22,4 @@ enum mode { RUN, EDIT };
enum view { INTER, STATE, RULES, DATA };
// MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
void SWITCH_TO (int asked);
void toggle_TO (int mode, int view);

View File

@ -186,20 +186,34 @@ void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *btt_MODEL_RUN
}
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data) {window_main_child (main_window, STATE); SWITCH_TO (STATE);}
void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data) {window_main_child (main_window, RULES); SWITCH_TO (RULES);}
void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data) {window_main_child (main_window, DATA); SWITCH_TO (DATA);}
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data) {
g_print ("Toggle button %s is active: %s\n",
gtk_button_get_label (GTK_TOGGLE_BUTTON (btt_open_STATE)),
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_STATE)) ? "Yes" : "No");
}//{window_main_child (main_window, STATE); toggle_TO (RUN, STATE);}
void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data) {
g_print ("Toggle button %s is active: %s\n",
gtk_button_get_label (GTK_TOGGLE_BUTTON (btt_open_RULES)),
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_RULES)) ? "Yes" : "No");
}//{window_main_child (main_window, RULES); toggle_TO (RUN, RULES);}
void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data) {
g_print ("Toggle button %s is active: %s\n",
gtk_button_get_label (GTK_TOGGLE_BUTTON (btt_open_DATA)),
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_DATA)) ? "Yes" : "No");
}//{window_main_child (main_window, DATA); toggle_TO (RUN, DATA);}
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 (INTER);
toggle_TO (RUN, INTER);
}
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 (RULES);
toggle_TO (RUN, RULES);
}
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) {

View File

@ -17,6 +17,8 @@ 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_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data);
// https://docs.gtk.org/gtk4/class.ToggleButton.html
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data);
void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data);
void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data);

View File

@ -176,20 +176,29 @@ void window_header_bar (GtkWindow *window, char *title){
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (separe));
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | "));
GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_new ());
GtkButton *btt_open_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state"));
g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_open_STATE), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_STATE), group_STATE_RULES_DATA);
GtkButton *btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules"));
g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_open_RULES), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_RULES), group_STATE_RULES_DATA);
GtkButton *btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis"));
g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_open_DATA), no_local_data);
GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_new ());
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_STATE), group_STATE_RULES_DATA);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_RULES), group_STATE_RULES_DATA);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA);
int selected = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_STATE));
printf("%d\n", selected);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_STATE)))
g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_open_STATE), NULL);
else
g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_open_STATE), NULL);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_RULES)))
g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_open_RULES), NULL);
else
g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_open_RULES), NULL);
g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_open_DATA), no_local_data);
gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_XOR_EXEC_EDIT));
@ -202,6 +211,24 @@ void window_header_bar (GtkWindow *window, char *title){
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
}
static void output_state (GtkToggleButton *source, gpointer user_data) {
g_print ("Toggle button %s is active: %s\n",
gtk_button_get_label (GTK_BUTTON (source)),
gtk_toggle_button_get_active (source) ? "Yes" : "No");
}
static void make_toggles (void) {
GtkWidget *toggle1, *toggle2;
toggle1 = gtk_toggle_button_new_with_label ("Hi, Im toggle button one");
g_signal_connect (toggle1, "toggled", G_CALLBACK (output_state), NULL);
toggle2 = gtk_toggle_button_new_with_label ("Hi, Im toggle button two");
g_signal_connect (toggle2, "toggled", G_CALLBACK (output_state), NULL);
}
void window_main_child (GtkWindow *main_window, int selected_page){
/*
switch (selected_page) {