WIP: the switch is in the callback, now (a first sketch, only)

This commit is contained in:
Jean Sirmai 2024-06-20 05:37:06 +02:00
parent e6871816a4
commit 6f463326f9
Signed by: jean
GPG Key ID: FB3115C340E057E3
4 changed files with 30 additions and 35 deletions

View File

@ -185,10 +185,24 @@ void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *btt_MODEL_RUN
} }
} }
void on_STATE_RULES_DATA_selection (GtkToggleButton *source, gpointer user_data) {
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data) {window_main_child (main_window, STATE); SWITCH_TO (STATE);} // g_print ("Toggle button [%s] is active: %s", gtk_button_get_label (GTK_BUTTON (source)), gtk_toggle_button_get_active (source) ? "Yes" : "No");
void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data) {window_main_child (main_window, RULES); SWITCH_TO (RULES);} int choice = 0;
void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data) {window_main_child (main_window, DATA); SWITCH_TO (DATA);} switch (choice) {
case (STATE): get_window_child_STATE (); break;
case (RULES): get_window_child_STATE (); break;
case (DATA): get_window_child_STATE (); break;
default : get_window_child_STATE ();
}
}
/*
GtkToggleButton *source
g_print ("Toggle button "%s" is active: %s",
gtk_button_get_label (GTK_BUTTON (source)),
gtk_toggle_button_get_active (source) ? "Yes" : "No");*/
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data) {get_window_child_STATE (main_window); SWITCH_TO (STATE);}
void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data) {get_window_child_STATE (main_window); SWITCH_TO (RULES);}
void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data) {get_window_child_STATE (main_window); SWITCH_TO (DATA);}
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);

View File

@ -24,4 +24,4 @@ void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data);
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data); void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data);
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data); void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data);
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data); void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data);
void on_STATE_RULES_DATA_selection (GtkToggleButton *source, gpointer user_data);

View File

@ -154,7 +154,7 @@ void window_main_child_bottom (GtkBox *page_box){
static void icons_for_fun (GtkHeaderBar *header_bar); static void icons_for_fun (GtkHeaderBar *header_bar);
void window_header_bar (GtkWindow *window, char *title){ void window_header_bar (GtkWindow *window, char *title) { // https://docs.gtk.org/gtk4/class.ToggleButton.html
GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ());
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
gtk_window_set_titlebar (window, header_bar); gtk_window_set_titlebar (window, header_bar);
@ -179,15 +179,15 @@ void window_header_bar (GtkWindow *window, char *title){
GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_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")); 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); g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_STATE_RULES_DATA_selection), NULL);
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_STATE), group_STATE_RULES_DATA);
GtkButton *btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules")); 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); g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_STATE_RULES_DATA_selection), NULL);
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_RULES), group_STATE_RULES_DATA);
GtkButton *btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis")); 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); g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_STATE_RULES_DATA_selection), NULL);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA); gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA);
gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE); gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE);
@ -202,39 +202,20 @@ void window_header_bar (GtkWindow *window, char *title){
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
} }
void window_main_child (GtkWindow *main_window, int selected_page){ GtkWidget *get_window_child_STATE () {
// in automaton.h : enum { INTER, STATE, RULES, DATA }
switch (selected_page) {
case (INTER) : //SWITCH_TO (INTER);
break;
case (STATE) :
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); 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 (get_OBJECTS_and_SITUATIONS()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); 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 (get_SPACE_VIEW_box()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
// window_main_child_bottom (page_box); if (!get_mode ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
// if (!get_mode ()) 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()));
// else gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
gtk_window_set_child (main_window, GTK_WIDGET (page_box));
//SWITCH_TO (STATE); //SWITCH_TO (STATE);
break; return GTK_WIDGET (page_box);
case (RULES) : gtk_window_set_child (main_window, GTK_WIDGET (get_rules_page_new()));
//SWITCH_TO (RULES);
break;
case (DATA) : gtk_window_set_child (main_window, GTK_WIDGET (get_measures_page_new()));
//SWITCH_TO (DATA);
break;
case (4) : gtk_window_set_child (main_window, GTK_WIDGET (get_results_page_new())); break;
case (5) : gtk_window_set_child (main_window, GTK_WIDGET (get_discuss_page_new())); break;
case (6) : gtk_window_set_child (main_window, GTK_WIDGET (get_help_page_new())); break;
default : gtk_window_set_child (main_window, GTK_WIDGET (get_SPACE_VIEW_box())); // + un "help message"
}
// printf ("%d\n", get_status());
} }
void main_window_design (GtkWindow *main_window){ void main_window_design (GtkWindow *main_window){
window_main_child (main_window, STATE); gtk_window_set_child (main_window, get_window_child_STATE ());
window_header_bar (main_window, window_header_bar (main_window,
"E coli (with permission from David S. Goodsell, 2009)"); "E coli (with permission from David S. Goodsell, 2009)");
gtk_window_present (GTK_WINDOW (main_window)); gtk_window_present (GTK_WINDOW (main_window));

View File

@ -35,5 +35,5 @@ void two_notebooks_in_two_panes (GtkWindow *window);
GtkWidget *get_selected_rules_vpaned_new(); GtkWidget *get_selected_rules_vpaned_new();
GtkFrame *get_frame_with_label(); GtkFrame *get_frame_with_label();
void window_main_child_bottom (GtkBox *page_box); void window_main_child_bottom (GtkBox *page_box);
void window_main_child (GtkWindow *main_window, int selected_page); //void window_main_child (GtkWindow *main_window, int selected_page);
GtkWidget *get_window_child_STATE ();