diff --git a/callback.c b/callback.c index a52e36e..4720007 100644 --- a/callback.c +++ b/callback.c @@ -3,12 +3,13 @@ #include "tree.h" #include "contain.h" +#include "dialog.h" #include "texts.h" #include "in_depth.h" #include "parsing.h" #include "graph_area.h" -static GtkWindow *main_window; +static GtkWindow *main_window, *dialog_window; /******************************************************************************/ /* M A I N W I N D O W A C T I V A T I O N */ @@ -22,6 +23,18 @@ void on_main_window_activation (GtkApplication *self, gpointer user_data) gtk_window_present (GTK_WINDOW (main_window)); } +void on_dialog_window_activation (GtkApplication *self, gpointer user_data) +{ + dialog_window = GTK_WINDOW (gtk_application_window_new (self)); + dialog_window_child (dialog_window,0); // 0 is the state page (see contain.c) + dialog_window_header_bar (dialog_window, "dialog window"); +// gtk_window_set_modal (GTK_WINDOW (dialog_window), TRUE); + 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_present (GTK_WINDOW (dialog_window)); +} + void on_auto_notification (const char *message) { /* Ignored (2024-06-06) because I don't know how to get "main_window" easily diff --git a/callback.h b/callback.h index e0778ee..f6c2a43 100644 --- a/callback.h +++ b/callback.h @@ -2,6 +2,7 @@ void on_main_window_activation (GtkApplication *app, gpointer user_data); +void on_dialog_window_activation (GtkApplication *self, gpointer user_data); void on_auto_notification (const char *message); void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data); diff --git a/dialog.c b/dialog.c new file mode 100644 index 0000000..3c876d7 --- /dev/null +++ b/dialog.c @@ -0,0 +1,19 @@ +#include +#include + +#include "callback.h" +#include "in_depth.h" +#include "display.h" +#include "tree.h" +#include "texts.h" + +// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery + + +void dialog_window_child (GtkWindow *dialog_window, int selected_page){} + +void dialog_window_header_bar (GtkWindow *dialog_window, char *title){ + 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); +} diff --git a/dialog.h b/dialog.h new file mode 100644 index 0000000..9d8a58e --- /dev/null +++ b/dialog.h @@ -0,0 +1,5 @@ +#include + +void dialog_window_header_bar (GtkWindow *dialog_window, char *title); +void dialog_window_child (GtkWindow *dialog_window, int selected_page); + diff --git a/in_depth.c b/in_depth.c index 7932ed9..98499e0 100644 --- a/in_depth.c +++ b/in_depth.c @@ -10,16 +10,14 @@ // (exec / edit) X (state / rules / measure) X (observ / interpret / read / write) enum { // S T A T E S + INTER, EXEC_STOP, EXEC_RUN, - EXEC_STOP_EDIT_RULE, - EXEC_RUN_EDIT_RULE, - EXEC_STOP_EDIT_MEASURE, - EXEC_RUN_EDIT_MEASURE, EDIT_STATE, EDIT_RULE, + MEASURE, OBSERVE, - INTERPRET, + ANALYSE, HELP, CONFIGURE }; @@ -29,23 +27,35 @@ static int status = EXEC_STOP; // int get_status () {return status;} enum { // T R A N S I T I O N S EXEC_TO_RUN, RUN_TO_EXEC, + EXEC_TO_INTER, + INTER_TO_EDIT, + EDIT_TO_INTER, + INTER_TO_EXEC, }; /******************************************************************************/ /* T R A N S I T I O N S */ /******************************************************************************/ -void let_transition_be (int asked) { +void SWITCH_TO (int asked) { switch (asked) { case (0) : // EXEC_TO_RUN status = EXEC_RUN; break; case (1) : // RUN_TO_EXEC + status = EXEC_STOP; + break; + case (2) : // EXEC_TO_INTER + status = INTER; + break; + case (3) : // EDIT_TO_INTER // Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon) // S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues - status = EXEC_STOP; + status = INTER; break; default : ; } + +//q gtk_window_present (GTK_WINDOW (main_window)); } diff --git a/main.c b/main.c index 32ccfc3..bd2de6e 100644 --- a/main.c +++ b/main.c @@ -16,6 +16,7 @@ int main (int argc, char **argv) app = gtk_application_new ("org.jean.GTK4_GG_hack", G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), NULL); + g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app);