From c8516d7c432fe81588810250279b7559fe39be4f Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Tue, 11 Jun 2024 22:49:42 +0200 Subject: [PATCH] using : gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE); --- callback.c | 13 +++++++++---- callback.h | 2 +- dialog.c | 15 ++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/callback.c b/callback.c index c58d11f..4298e14 100644 --- a/callback.c +++ b/callback.c @@ -197,13 +197,18 @@ void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointe } void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { - printf("callback.c (line 200) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); + gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); + printf ("callback.c (line 200) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); } void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { - printf("callback.c (line 204) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n"); + gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE); + printf ("callback.c (line 204) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n"); } -void on_WRITE_THE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) { - printf("callback.c (line 208) - WRITE_THE_CURRENT_MODEL\n"); +void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) { +// close_request (GTK_WINDOW (data)); < comment fermer la fenêtre ? TODO +// attention: déclaration implicite de la fonction « close_request » + printf ("callback.c (line 208) - WRITE_THE_CURRENT_MODEL\n"); } + diff --git a/callback.h b/callback.h index 72f86f1..7f0d3fc 100644 --- a/callback.h +++ b/callback.h @@ -20,7 +20,7 @@ void on_toggle_state_rules (GtkWidget *btt_toggle_state_rules, gpointer data); void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, 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_WRITE_THE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data); +void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data); diff --git a/dialog.c b/dialog.c index 53a3c2b..d7be7ee 100644 --- a/dialog.c +++ b/dialog.c @@ -23,17 +23,18 @@ void dialog_window_design (GtkWindow *main_window, GtkWindow *dialog_window){ // gtk_box_layout_set_homogeneous (GTK_BOX (YES_NO_box), TRUE); // gtk_box_set_baseline_position (YES_NO_box, GTK_BASELINE_POSITION_CENTER); + GtkButton *action_save_current_model = GTK_BUTTON (gtk_button_new_with_label ("SAVE THE CURRENT MODEL")); + gtk_widget_set_sensitive (GTK_WIDGET (action_save_current_model), FALSE); + g_signal_connect (action_save_current_model, "clicked", G_CALLBACK (on_WRITE_CURRENT_MODEL), dialog_window); + GtkButton *click_yes = GTK_BUTTON (gtk_button_new_with_label ("YES")); - g_signal_connect (click_yes, "clicked", G_CALLBACK (on_SAVE_CURRENT_MODEL_BEFORE_EDITING), NULL); + g_signal_connect (click_yes, "clicked", G_CALLBACK (on_SAVE_CURRENT_MODEL_BEFORE_EDITING), action_save_current_model); gtk_box_append (YES_NO_box, GTK_WIDGET (click_yes)); GtkButton *click_no = GTK_BUTTON (gtk_button_new_with_label ("NO")); - g_signal_connect (click_no, "clicked", G_CALLBACK (on_DISCARD_CURRENT_MODEL_AND_START_EDITING), NULL); + g_signal_connect (click_no, "clicked", G_CALLBACK (on_DISCARD_CURRENT_MODEL_AND_START_EDITING), action_save_current_model); gtk_box_append (YES_NO_box, GTK_WIDGET (click_no)); - GtkButton *action_save_current_model = GTK_BUTTON (gtk_button_new_with_label ("SAVE THE CURRENT MODEL")); - g_signal_connect (click_no, "clicked", G_CALLBACK (on_WRITE_THE_CURRENT_MODEL), NULL); - GtkBox *WINDOW_CHILD_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); gtk_box_append (WINDOW_CHILD_box, GTK_WIDGET (YES_NO_box)); gtk_box_append (WINDOW_CHILD_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); @@ -42,8 +43,8 @@ void dialog_window_design (GtkWindow *main_window, GtkWindow *dialog_window){ gtk_window_set_transient_for (GTK_WINDOW (dialog_window), GTK_WINDOW (main_window)); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog_window), TRUE); - // gtk_window_set_deletable (GTK_WINDOW (dialog_window), FALSE); // FALSE - // gtk_window_set_modal (GTK_WINDOW (dialog_window), TRUE); +// gtk_window_set_deletable (GTK_WINDOW (dialog_window), FALSE); // FALSE + gtk_window_set_modal (GTK_WINDOW (dialog_window), TRUE); gtk_window_present (GTK_WINDOW (dialog_window)); }