From dcbc47e7a4087f34d71afe35d4f45384133f1b73 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Tue, 11 Jun 2024 19:20:44 +0200 Subject: [PATCH] WIP: ... et ajoutons-lui des boutons --- callback.c | 21 +++++++++++++++------ callback.h | 5 +++-- dialog.c | 21 +++++++++++++++------ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/callback.c b/callback.c index b8a2fd5..61d8030 100644 --- a/callback.c +++ b/callback.c @@ -1,6 +1,7 @@ #include #include +#include "callback.h" #include "tree.h" #include "contain.h" #include "dialog.h" @@ -15,12 +16,6 @@ static GtkWindow *main_window, *dialog_window; -void on_dialog_window_activation (GtkApplication *app, gpointer no_user_data) -{ - dialog_window = GTK_WINDOW (gtk_application_window_new (app)); - dialog_window_design (main_window, dialog_window); -} - void on_main_window_activation (GtkApplication *app, gpointer no_user_data) { main_window = GTK_WINDOW (gtk_application_window_new (app)); @@ -28,6 +23,12 @@ void on_main_window_activation (GtkApplication *app, gpointer no_user_data) g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), main_window); } +void on_dialog_window_activation (GtkApplication *app, gpointer no_user_data) +{ + dialog_window = GTK_WINDOW (gtk_application_window_new (app)); + dialog_window_design (main_window, dialog_window); +} + void on_auto_notification (const char *message) { @@ -194,3 +195,11 @@ void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointe // gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe"); // gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret"); } + +void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { + printf("SAVE_CURRENT_MODEL_BEFORE_EDITING (callback.c - line 200)\n"); +} + +void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { + printf("DISCARD_CURRENT_MODEL_AND_START_EDITING (callback.c - line 204)\n"); +} diff --git a/callback.h b/callback.h index 47185f2..9621957 100644 --- a/callback.h +++ b/callback.h @@ -14,11 +14,12 @@ void on_glarea_unrealize (GtkWidget *widget); void on_axis_value_change (GtkAdjustment *adjustment, gpointer data); -void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, gpointer data); +void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec); void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data); 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); diff --git a/dialog.c b/dialog.c index 3687a05..3352c47 100644 --- a/dialog.c +++ b/dialog.c @@ -12,16 +12,25 @@ /* doc : see > on_dialog_window_activation (...) in callback.c */ void dialog_window_design (GtkWindow *main_window, GtkWindow *dialog_window){ - char *title = " Should I save the current model before editing ? "; + char *title = " Do I need to save the current model before modifying it? "; 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_window_set_titlebar (dialog_window, header_bar); - GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - GtkButton *click = GTK_BUTTON (gtk_button_new_with_label ("click me !")); - gtk_box_append (page_box, GTK_WIDGET (click)); - // gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - gtk_window_set_child (dialog_window, GTK_WIDGET (page_box)); + GtkBox *YES_NO_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 400)); +// gtk_box_layout_new (GTK_ORIENTATION_HORIZONTAL); +// gtk_box_layout_set_homogeneous (GTK_BOX (YES_NO_box), TRUE); +// gtk_box_set_baseline_position (YES_NO_box, GTK_BASELINE_POSITION_CENTER); + + 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); + gtk_box_append (YES_NO_box, GTK_WIDGET (click_yes)); + +// gtk_box_append (YES_NO_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); + 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); + gtk_box_append (YES_NO_box, GTK_WIDGET (click_no)); + gtk_window_set_child (dialog_window, GTK_WIDGET (YES_NO_box)); gtk_window_set_transient_for (GTK_WINDOW (dialog_window), GTK_WINDOW (main_window)); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog_window), TRUE);