WIP: Il faudra bien une fenêtre de dialogue pour sauvegarder...
This commit is contained in:
parent
bc5b03eaec
commit
5133d672fd
15
callback.c
15
callback.c
|
@ -3,12 +3,13 @@
|
||||||
|
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "contain.h"
|
#include "contain.h"
|
||||||
|
#include "dialog.h"
|
||||||
#include "texts.h"
|
#include "texts.h"
|
||||||
#include "in_depth.h"
|
#include "in_depth.h"
|
||||||
#include "parsing.h"
|
#include "parsing.h"
|
||||||
#include "graph_area.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 */
|
/* 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));
|
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)
|
void on_auto_notification (const char *message)
|
||||||
{
|
{
|
||||||
/* Ignored (2024-06-06) because I don't know how to get "main_window" easily
|
/* Ignored (2024-06-06) because I don't know how to get "main_window" easily
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
void on_main_window_activation (GtkApplication *app, gpointer user_data);
|
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_auto_notification (const char *message);
|
||||||
|
|
||||||
void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data);
|
void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
|
||||||
|
void dialog_window_header_bar (GtkWindow *dialog_window, char *title);
|
||||||
|
void dialog_window_child (GtkWindow *dialog_window, int selected_page);
|
||||||
|
|
24
in_depth.c
24
in_depth.c
|
@ -10,16 +10,14 @@
|
||||||
// (exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
// (exec / edit) X (state / rules / measure) X (observ / interpret / read / write)
|
||||||
|
|
||||||
enum { // S T A T E S
|
enum { // S T A T E S
|
||||||
|
INTER,
|
||||||
EXEC_STOP,
|
EXEC_STOP,
|
||||||
EXEC_RUN,
|
EXEC_RUN,
|
||||||
EXEC_STOP_EDIT_RULE,
|
|
||||||
EXEC_RUN_EDIT_RULE,
|
|
||||||
EXEC_STOP_EDIT_MEASURE,
|
|
||||||
EXEC_RUN_EDIT_MEASURE,
|
|
||||||
EDIT_STATE,
|
EDIT_STATE,
|
||||||
EDIT_RULE,
|
EDIT_RULE,
|
||||||
|
MEASURE,
|
||||||
OBSERVE,
|
OBSERVE,
|
||||||
INTERPRET,
|
ANALYSE,
|
||||||
HELP,
|
HELP,
|
||||||
CONFIGURE
|
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
|
enum { // T R A N S I T I O N S
|
||||||
EXEC_TO_RUN,
|
EXEC_TO_RUN,
|
||||||
RUN_TO_EXEC,
|
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 */
|
/* T R A N S I T I O N S */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
void let_transition_be (int asked) {
|
void SWITCH_TO (int asked) {
|
||||||
switch (asked) {
|
switch (asked) {
|
||||||
case (0) : // EXEC_TO_RUN
|
case (0) : // EXEC_TO_RUN
|
||||||
status = EXEC_RUN;
|
status = EXEC_RUN;
|
||||||
break;
|
break;
|
||||||
case (1) : // RUN_TO_EXEC
|
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)
|
// 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
|
// 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;
|
break;
|
||||||
default : ;
|
default : ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//q gtk_window_present (GTK_WINDOW (main_window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
1
main.c
1
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);
|
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_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);
|
status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||||
g_object_unref (app);
|
g_object_unref (app);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue