WIP: créons donc cette fenêtre de dialogue.

This commit is contained in:
Jean Sirmai 2024-06-11 16:39:40 +02:00
parent 5133d672fd
commit 2b18424169
Signed by: jean
GPG Key ID: FB3115C340E057E3
6 changed files with 40 additions and 28 deletions

View File

@ -9,43 +9,37 @@
#include "parsing.h" #include "parsing.h"
#include "graph_area.h" #include "graph_area.h"
/******************************************************************************/
/* W I N D O W S A C T I V A T I O N */
/******************************************************************************/
static GtkWindow *main_window, *dialog_window; static GtkWindow *main_window, *dialog_window;
/******************************************************************************/ void on_dialog_window_activation (GtkApplication *app, gpointer no_user_data)
/* M A I N W I N D O W A C T I V A T I O N */
/******************************************************************************/
void on_main_window_activation (GtkApplication *self, gpointer user_data)
{ {
main_window = GTK_WINDOW (gtk_application_window_new (self)); dialog_window = GTK_WINDOW (gtk_application_window_new (app));
window_main_child (main_window, 0); // 0 is the state page (see contain.c) dialog_window_design (main_window, dialog_window);
window_header_bar (main_window,
"E coli (with permission from David S. Goodsell, 2009)");
gtk_window_present (GTK_WINDOW (main_window));
} }
void on_dialog_window_activation (GtkApplication *self, gpointer user_data) void on_main_window_activation (GtkApplication *app, gpointer no_user_data)
{ {
dialog_window = GTK_WINDOW (gtk_application_window_new (self)); main_window = GTK_WINDOW (gtk_application_window_new (app));
dialog_window_child (dialog_window,0); // 0 is the state page (see contain.c) main_window_design (main_window);
dialog_window_header_bar (dialog_window, "dialog window"); g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), main_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
if (window->toast_revealer == NULL) { if (window->toast_revealer == NULL) {
g_printerr("Can't find self->toast_overlay !\n"); g_printerr("Can't find app->toast_overlay !\n");
return; return;
} }
if (window->toast_text == NULL) { if (window->toast_text == NULL) {
g_printerr("Can't find self->toast_overlay !\n"); g_printerr("Can't find app->toast_overlay !\n");
return; return;
} }

View File

@ -2,7 +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_dialog_window_activation (GtkApplication *app, 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);

View File

@ -209,6 +209,12 @@ void window_main_child (GtkWindow *main_window, int selected_page){
} }
} }
void main_window_design (GtkWindow *main_window){
window_main_child (main_window, 0); // 0 is the state page
window_header_bar (main_window,
"E coli (with permission from David S. Goodsell, 2009)");
gtk_window_present (GTK_WINDOW (main_window));
}

View File

@ -30,8 +30,7 @@ MyApplication *my_application_new (const char *application_id, GApplicationFlags
G_END_DECLS G_END_DECLS
*/ */
void window_header_bar (GtkWindow *window, char *title); void main_window_design (GtkWindow *main_window);
void window_main_child (GtkWindow *window, int selected_page);
void two_notebooks_in_two_panes (GtkWindow *window); void two_notebooks_in_two_panes (GtkWindow *window);
GtkWidget *get_selected_rules_vpaned_new(); GtkWidget *get_selected_rules_vpaned_new();
GtkFrame *get_frame_with_label(); GtkFrame *get_frame_with_label();

View File

@ -9,11 +9,25 @@
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery // https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
/* doc : see > on_dialog_window_activation (...) in callback.c */
void dialog_window_child (GtkWindow *dialog_window, int selected_page){} void dialog_window_design (GtkWindow *main_window, GtkWindow *dialog_window){
char *title = " Should I save the current model before editing ? ";
void dialog_window_header_bar (GtkWindow *dialog_window, char *title){
GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); 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_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
gtk_window_set_titlebar (dialog_window, header_bar); 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));
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_present (GTK_WINDOW (dialog_window));
} }

View File

@ -1,5 +1,4 @@
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
void dialog_window_header_bar (GtkWindow *dialog_window, char *title); void dialog_window_design (GtkWindow *main_window, GtkWindow *dialog_window);
void dialog_window_child (GtkWindow *dialog_window, int selected_page);