From a9b48749562ecc54db4404dfe1e859f81d39ed05 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sat, 20 Jul 2024 16:38:31 +0200 Subject: [PATCH] introducing widget/init.c --- include/widget.h | 12 +++++----- src/main.c | 15 +++++++------ src/signal.c | 32 ++++++++++++--------------- src/widget/action.c | 0 src/widget/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ src/widget/state.c | 4 +++- src/widget/topbar.c | 25 +++------------------ 7 files changed, 88 insertions(+), 54 deletions(-) delete mode 100644 src/widget/action.c create mode 100644 src/widget/init.c diff --git a/include/widget.h b/include/widget.h index c8135b5..6015455 100644 --- a/include/widget.h +++ b/include/widget.h @@ -38,9 +38,9 @@ /* W I N D O W S */ /******************************************************************************/ -void widget_topbar_fix_main_window (GtkApplication *app); -void widget_topbar_fix_dialog_window (GtkApplication *app); -void widget_topbar_fix_text_window (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, @@ -48,9 +48,9 @@ void widget_topbar_design_dialog_window (GtkWindow *main_window, void widget_topbar_design_text_window (GtkWindow *main_window, GtkWindow *text_window); -void *widget_topbar_rec_main_window(); -GtkWindow *widget_topbar_rec_dialog_window(); -GtkWindow *widget_topbar_rec_text_window(); +void *widget_topbar_get_main_window(); +void *widget_topbar_get_dialog_window(); +void *widget_topbar_get_text_window(); /******************************************************************************/ diff --git a/src/main.c b/src/main.c index ddda3e8..b1b85a4 100644 --- a/src/main.c +++ b/src/main.c @@ -136,16 +136,17 @@ int main (int argc, char **argv) { - GtkApplication *app; - int status; + GtkApplication *app; + int status; - app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); - g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); + app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); - status = g_application_run (G_APPLICATION (app), argc, argv); - g_object_unref (app); + g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); - return status; + status = g_application_run (G_APPLICATION (app), argc, argv); + g_object_unref (app); + + return status; } diff --git a/src/signal.c b/src/signal.c index 1c44de4..d4a4cfe 100644 --- a/src/signal.c +++ b/src/signal.c @@ -57,23 +57,19 @@ static void on_auto_notification (const char *message) -/******************************************************************************/ -/* W I N D O W S */ -/******************************************************************************/ - void on_windows_activation (GtkApplication *app, gpointer no_user_data) { - widget_topbar_fix_main_window (app); - widget_topbar_design_main_window (GTK_WINDOW (widget_topbar_rec_main_window ())); + widget_create_main_window (app); + widget_topbar_design_main_window (GTK_WINDOW (widget_topbar_get_main_window ())); - widget_topbar_fix_dialog_window (app); - widget_topbar_design_dialog_window (GTK_WINDOW (widget_topbar_rec_main_window ()), - widget_topbar_rec_dialog_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_topbar_fix_text_window (app); - widget_topbar_design_text_window (GTK_WINDOW (widget_topbar_rec_main_window ()), - widget_topbar_rec_text_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())); } @@ -253,17 +249,17 @@ static void switch_STATE_RULES_DATA() switch (fsm_get_STATE_RULES_DATA()) { case (STATE) : - gtk_window_set_child (GTK_WINDOW (widget_topbar_rec_main_window ()), + gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()), GTK_WIDGET (widget_rec_state_page())); break; case (RULES) : - gtk_window_set_child (GTK_WINDOW (widget_topbar_rec_main_window ()), + gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()), GTK_WIDGET (widget_rec_rules_page())); break; case (DATA) : - gtk_window_set_child (GTK_WINDOW (widget_topbar_rec_main_window ()), + gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()), GTK_WIDGET (widget_rec_stock_page())); break; @@ -286,7 +282,7 @@ void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data) "text-editor-symbolic"); // https://docs.gtk.org/gtk4/class.Window.html TODO 2024-06-30 - // gtk_window_present (GTK_WINDOW (widget_topbar_rec_dialog_window())); // works once only ! + // gtk_window_present (GTK_WINDOW (widget_topbar_get_dialog_window())); // works once only ! fsm_set_EXEC_EDIT (EDIT); } @@ -398,14 +394,14 @@ void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data) void on_clicked_search (GtkWidget *btt_menu, gpointer list_box) { // next line presents the text_window and works only once.\nIt should present a menu.\n"); // TODO - gtk_window_present (GTK_WINDOW (widget_topbar_rec_text_window())); + gtk_window_present (GTK_WINDOW (widget_topbar_get_text_window())); } void on_clicked_HOME (GtkWidget *btt_reset, gpointer data) { printf ("callback.on_clicked_HOME() button presents the dialog_window\ ( :- ) but it works only once.\n"); // TODO - gtk_window_present (GTK_WINDOW (widget_topbar_rec_dialog_window())); + gtk_window_present (GTK_WINDOW (widget_topbar_get_dialog_window())); } diff --git a/src/widget/action.c b/src/widget/action.c deleted file mode 100644 index e69de29..0000000 diff --git a/src/widget/init.c b/src/widget/init.c new file mode 100644 index 0000000..ad70d2a --- /dev/null +++ b/src/widget/init.c @@ -0,0 +1,54 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Callbacks header * +* * +* Copyright © 2021 Libre en Communs * +* Copyright © 2021 Adrien Bourmault * +* Copyright © 2021 Jean Sirmai * +* * +* This file is part of Gem-graph. * +* * +* This program is free software: you can redistribute it and/or modify it * +* under the terms of the GNU Affero General Public License * +* as published by the Free Software Foundation, * +* either version 3 of the License, * +* or (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; * +* without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. * +* See the GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with this program. If not, see . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + + + +#include "../../include/widget.h" + + +/******************************************************************************/ +/* W I N D O W S */ +/******************************************************************************/ + +static GtkWindow *main_window, *dialog_window, *text_window; + +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_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 d94c654..43dd4db 100644 --- a/src/widget/state.c +++ b/src/widget/state.c @@ -35,7 +35,9 @@ #define LOWER_COMPARTMENT_PARTITION 1300 /* L'image de l'état de l'espace (au centre) est entourée par trois panneaux: - * Si on les nomme selon leur fonction, + * "haut", "milieu", "bas" + * + * ou encore, si l'on nomme ces panneaux selon leur fonction: * * - CONTROL ou EDIT en bas permet de contrôler / choisir un état et / ou de l'éditer * en mode EDIT, seuls les outils d'édition de l'état sont disponibles diff --git a/src/widget/topbar.c b/src/widget/topbar.c index 22ca2ac..7a9ff77 100644 --- a/src/widget/topbar.c +++ b/src/widget/topbar.c @@ -36,27 +36,8 @@ #define H_TEXT_WINDOW 1000 -/******************************************************************************/ -/* G E T + S E T A L L W I N D O W S */ -/******************************************************************************/ - -static GtkWindow *main_window, *dialog_window, *text_window; static GtkButton *btt_STATE, *btt_RULES, *btt_DATA; -void *widget_topbar_rec_main_window() { return main_window; } -GtkWindow *widget_topbar_rec_dialog_window() { return dialog_window; } -GtkWindow *widget_topbar_rec_text_window() { return text_window; } - -void widget_topbar_fix_main_window (GtkApplication *app) -{ main_window = GTK_WINDOW (gtk_application_window_new (app)); } - -void widget_topbar_fix_dialog_window (GtkApplication *app) -{ dialog_window = GTK_WINDOW (gtk_application_window_new (app)); } - -void widget_topbar_fix_text_window (GtkApplication *app) -{ text_window = GTK_WINDOW (gtk_application_window_new (app)); } - - /******************************************************************************/ /* T E X T W I N D O W */ @@ -122,7 +103,7 @@ void widget_topbar_design_dialog_window (GtkWindow *main_window, GtkWindow *dial /******************************************************************************/ -/* M A I N W I N D O W H E A D C E N T E R */ +/* M A I N W I N D O W T O P B A R ( C E N T E R ) */ /******************************************************************************/ static GtkWidget *window_header_bar (GtkWindow *window); @@ -151,7 +132,7 @@ static GtkWidget *window_header_bar (GtkWindow *window) /******************************************************************************/ -/* M A I N W I N D O W H E A D L E F T */ +/* M A I N W I N D O W T O P B A R ( L E F T ) */ /******************************************************************************/ static void window_header_bar_left (GtkWidget *header_bar) @@ -190,7 +171,7 @@ static void window_header_bar_left (GtkWidget *header_bar) /******************************************************************************/ -/* M A I N W I N D O W H E A D R I G H T */ +/* M A I N W I N D O W T O P B A R ( R I G H T ) */ /******************************************************************************/ static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); }