on_toggle_STATE_RULES_DATA is OK <> to clean (merge ccb5f51 ?)

This commit is contained in:
Jean Sirmai 2024-06-24 23:09:22 +02:00
parent ccb5f5177b
commit b05510e482
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 15 additions and 16 deletions

View File

@ -219,21 +219,20 @@ void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data) {
void on_toggle_STATE_RULES_DATA (GtkWidget *btt, gpointer user_data) { void on_toggle_STATE_RULES_DATA (GtkWidget *btt, gpointer user_data) {
// https://docs.gtk.org/gtk4/class.ToggleButton.html < f..k ! bad code ++ // https://docs.gtk.org/gtk4/class.ToggleButton.html < f..k ! bad code ++
// g_print ("Toggle button [%s] is active: %s\n", gtk_button_get_label (GTK_BUTTON (source)), gtk_toggle_button_get_active (source) ? "Yes" : "No");
char *source = ""; const char *btt_name = gtk_check_button_get_label (GTK_CHECK_BUTTON (btt));
if (0) printf("gtk_check_button_get_active > %d, %d, %d < from callback : on_toggle_STATE_RULES_DATA()\n",\ int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (btt));
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton (source))),
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton (source))),
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton (source))));
int is_state_active = ! strcmp (btt_name, "state");
int is_rules_active = ! strcmp (btt_name, "rules");
int is_data_active = ! strcmp (btt_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, btt_name);
int choice = 0; if (is_active) {
switch (choice) { if (is_state_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE()));
case (STATE): get_GtkButton ("state"); break; // get_window_child_STATE (); else if (is_rules_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES()));
case (RULES): get_GtkButton ("rules"); break; // get_window_child_RULES (); break; else if (is_data_active) gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA()));
case (DATA): get_GtkButton ("data analysis"); break; // get_window_child_DATA (); break;
default : get_GtkButton ("state"); break; // get_window_child_STATE ();
} }
} }

View File

@ -197,17 +197,17 @@ 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 ());
btt_open_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state")); 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_open_STATE), no_local_data);
g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
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);
btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules")); 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_open_RULES), no_local_data);
g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_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_RULES), group_STATE_RULES_DATA);
btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis")); 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_open_DATA), no_local_data);
g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
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);
@ -217,7 +217,7 @@ void window_header_bar (GtkWindow *window, char *title){
gtk_check_button_get_label (GTK_CHECK_BUTTON (btt_open_RULES)), gtk_check_button_get_label (GTK_CHECK_BUTTON (btt_open_RULES)),
gtk_check_button_get_label (GTK_CHECK_BUTTON (btt_open_DATA))); gtk_check_button_get_label (GTK_CHECK_BUTTON (btt_open_DATA)));
if (1) printf("gtk_check_button_get_active > before = %d, %d, %d\n",\ if (0) printf("gtk_check_button_get_active > before = %d, %d, %d\n",\
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("state"))), gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("state"))),
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("rules"))), gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("rules"))),
gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("data analysis")))); gtk_check_button_get_active (GTK_CHECK_BUTTON (get_GtkButton ("data analysis"))));