From 27a3f54851e46b109faa2eb1d7f6a9ff5962ae48 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 21 Jul 2024 11:35:00 +0200 Subject: [PATCH] main.c : g_signal_connect (app, activate, G_CALLBACK (on_windows_activation), NULL); << see init.c --- include/widget.h | 4 ---- src/main.c | 1 - src/signal.c | 17 ----------------- src/widget/init.c | 15 ++++----------- src/widget/state.c | 3 ++- src/widget/topbar.c | 2 ++ 6 files changed, 8 insertions(+), 34 deletions(-) diff --git a/include/widget.h b/include/widget.h index 4518ec1..24a4b17 100644 --- a/include/widget.h +++ b/include/widget.h @@ -40,10 +40,6 @@ void widget_create_windows (GtkApplication *app); -void widget_create_main_window (GtkApplication *app); -void widget_create_dialog_window (GtkApplication *app); -void widget_create_text_window (GtkApplication *app); - void widget_topbar_design_main_window (GtkWindow *main_window); void widget_topbar_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window); diff --git a/src/main.c b/src/main.c index 9e29db9..2c46181 100644 --- a/src/main.c +++ b/src/main.c @@ -146,7 +146,6 @@ int main (int argc, char **argv) app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); - if (0) widget_create_windows (app); // < Erreur de segmentation status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); diff --git a/src/signal.c b/src/signal.c index bc8739a..06ce91c 100644 --- a/src/signal.c +++ b/src/signal.c @@ -56,23 +56,6 @@ static void on_auto_notification (const char *message) } - -void on_windows_activation (GtkApplication *app, - gpointer no_user_data) -{ - widget_create_main_window (app); - widget_topbar_design_main_window (GTK_WINDOW (widget_topbar_get_main_window ())); - - widget_create_dialog_window (app); - widget_topbar_design_dialog_window (GTK_WINDOW (widget_topbar_get_main_window ()), - GTK_WINDOW (widget_topbar_get_dialog_window())); - - widget_create_text_window (app); - widget_topbar_design_text_window (GTK_WINDOW (widget_topbar_get_main_window ()), - GTK_WINDOW (widget_topbar_get_text_window())); -} - - /******************************************************************************/ /* T R E E */ /******************************************************************************/ diff --git a/src/widget/init.c b/src/widget/init.c index 512f78f..14beadf 100644 --- a/src/widget/init.c +++ b/src/widget/init.c @@ -42,8 +42,11 @@ void *widget_topbar_get_main_window() { return main_window; } void *widget_topbar_get_dialog_window() { return dialog_window; } void *widget_topbar_get_text_window() { return text_window; } -void widget_create_windows (GtkApplication *app) +void on_windows_activation (GtkApplication *app) { +// g_application_activate (G_APPLICATION (app)); < how ? > in main.c is +// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); + main_window = GTK_WINDOW (gtk_application_window_new (app)); dialog_window = GTK_WINDOW (gtk_application_window_new (app)); text_window = GTK_WINDOW (gtk_application_window_new (app)); @@ -53,13 +56,3 @@ void widget_create_windows (GtkApplication *app) widget_topbar_design_text_window (main_window, text_window); } -void widget_create_main_window (GtkApplication *app) -{ main_window = GTK_WINDOW (gtk_application_window_new (app)); } - -void widget_create_dialog_window (GtkApplication *app) -{ dialog_window = GTK_WINDOW (gtk_application_window_new (app)); } - -void widget_create_text_window (GtkApplication *app) -{ text_window = GTK_WINDOW (gtk_application_window_new (app)); } - - diff --git a/src/widget/state.c b/src/widget/state.c index dd954ce..a31bcca 100644 --- a/src/widget/state.c +++ b/src/widget/state.c @@ -67,7 +67,8 @@ static GtkBox *rec_XYZ_box() gtk_box_append (XYZ_scrollbar_box, scroll_Z); gtk_box_append (XYZ_scrollbar_box, GTK_WIDGET (gtk_label_new (" "))); // AD HOC (pour "centrer") - GtkWidget *btt_reset = gtk_toggle_button_new_with_label ("reset"); + GtkWidget *btt_reset = gtk_toggle_button_new (); + gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic"); gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new ("\nX Y Z"))); gtk_box_append (XYZ_labels_box, GTK_WIDGET (XYZ_scrollbar_box)); gtk_box_append (XYZ_labels_box, GTK_WIDGET (btt_reset)); diff --git a/src/widget/topbar.c b/src/widget/topbar.c index 7a9ff77..79d9429 100644 --- a/src/widget/topbar.c +++ b/src/widget/topbar.c @@ -110,6 +110,7 @@ static GtkWidget *window_header_bar (GtkWindow *window); static void window_header_bar_left (GtkWidget *header_bar); static void window_header_bar_right (GtkWidget *header_bar); + void widget_topbar_design_main_window (GtkWindow *main_window) { GtkWidget *header_bar = window_header_bar (main_window); @@ -120,6 +121,7 @@ void widget_topbar_design_main_window (GtkWindow *main_window) gtk_window_present (GTK_WINDOW (main_window)); } + static GtkWidget *window_header_bar (GtkWindow *window) { char *title = "E coli (with permission from David S. Goodsell, 2009)";