src/widget/main_window/design First visible window (with memory leaks)

To display this minimal window, three files and two functions must be
added simultaneously:

- include/widget/h
- src/manager.c
- src/main_window/design.c

main() now contains: g_signal_connect (on_windows_activation);
on_windows_activation () is in src/manager.c and calls
widget_main_window () which is in src/main_window/design.c

NB  The iconic image of E coli drawn by David S. Goodsell in 2009
is reproduced here with permission.

One goal of Gem-graph is to animate such static representations
i.e. use the best anatomy to try to achieve good physiology.
This commit is contained in:
Jean Sirmai 2024-11-12 16:51:02 +01:00
parent d82abfb462
commit 78ebd86cb5
Signed by: jean
GPG Key ID: FB3115C340E057E3
11 changed files with 200 additions and 26 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@ -1,7 +1,6 @@
/** /**
* @file * @file
* This file is part of Gem-graph; it is the client fsm (finite state machine) * FSM (Finite State Machine) header of the Gem-graph client.
* header.
* *
* @see readme.docs and this text below. * @see readme.docs and this text below.
* *
@ -110,7 +109,7 @@ enum fsm_enum_log_severity {
FATAL, /**< (or CRITICAL) an unrecoverable failure that prevents the whole FATAL, /**< (or CRITICAL) an unrecoverable failure that prevents the whole
application from doing any further useful work 🕳 */ application from doing any further useful work 🕳 */
ERROR, /**< an irremediable situation that hinders the execution of a ERROR, /**< an irremediable situation that hinders the execution of a
specific operation within the application 👀😮 */ specific operation within the application 👀😮! */
WARN, /**< something unexpected has occurred, but the application can WARN, /**< something unexpected has occurred, but the application can
continue to function normally for the time being 😅 */ continue to function normally for the time being 😅 */
INFO, /**< (or MESSAGE) a significant event occurs while the system is INFO, /**< (or MESSAGE) a significant event occurs while the system is

31
include/widget.h Normal file
View File

@ -0,0 +1,31 @@
/**
* @file
* Widgets hierarchy header of the Gem-graph client;
*
* @cond LICENSE
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
*
* 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 <http://www.gnu.org/licenses/>.
* @endcond
*/
#pragma once
#include <gtk-4.0/gtk/gtk.h>
void on_windows_activation (GtkApplication *app);
void widget_get_main_window (GtkWindow *main_window, GtkApplication *app);

View File

@ -1,7 +1,6 @@
/** /**
* @file * @file
* @brief This file is part of Gem-graph; it controls the client fsm * @brief Gem-graph client FSM controls.
* (Finite State Machine).
* *
* @details * @details
* *

View File

@ -1,7 +1,7 @@
/** /**
* @file * @file
* *
* This file is part of Gem-graph; it contains only auxiliary functions. * Gem-graph client auxiliary log functions container.
* *
* The log (or journal) stores chronologically the events during a session run. * The log (or journal) stores chronologically the events during a session run.
* *

View File

@ -1,6 +1,6 @@
/** /**
* @file * @file
* @brief This file is part of Gem-graph; fsm (Finite State Machine) log manager. * @brief FSM manager of the Gem-graph client log main structures and functions.
* *
* @details * @details
* The log (journal) is created, edited and published from here. * The log (journal) is created, edited and published from here.

View File

@ -1,11 +1,11 @@
/** /**
* @file * @file
* *
* This file is part of Gem-graph; * Gem-graph client log executive functions container.
* the log stores chronologically all the events during a run.
* *
* This file contains the executive functions needed to initialise the log, add * The log stores chronologically all the events occuring during an execution.
* events and publish everything. *
* The executive functions initialise the log, add events and publish everything.
* *
* The log presentation is: * The log presentation is:
* [date - rank - source file - source function - value] * [date - rank - source file - source function - value]
@ -81,7 +81,7 @@ void fsm_clear_log (fsm_log_struct *jj)
/** /**
* Adds a log unit (an event) to the list. * Adds a log unit (an event) to the log list.
* *
* *new_unit = malloc (sizeof (fsm_log_unit_struct)); * *new_unit = malloc (sizeof (fsm_log_unit_struct));
* *

View File

@ -1,6 +1,6 @@
/** /**
* @file * @file
* This file is part of Gem-graph; it contains only the main() function. * Main file of the Gem-graph client; contains only the main() function.
* *
* The main() function * The main() function
* - **initialise** * - **initialise**
@ -13,9 +13,6 @@
* before ending the program execution * before ending the program execution
* . * .
* *
* In this commit, it does not implement g_application_activate() and has no
* handlers connected to the 'activate' signal (which triggers an error message).
*
* The default values of the fsm initial state will be specified in: * The default values of the fsm initial state will be specified in:
* src/fsm/control(). They are user preferences. * src/fsm/control(). They are user preferences.
* *
@ -42,7 +39,8 @@
*/ */
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
#include "../include/fsm.h" // finite state machine (fsm) #include "../include/fsm.h"
#include "../include/widget.h"
/** /**
* @since 2024-04 * @since 2024-04
@ -74,11 +72,7 @@ int main (int argc, char **argv)
"| 👉️ windows creation requested"); "| 👉️ windows creation requested");
// g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL); // g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL);
// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL); g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
fsm_add_log (INFO, MAIN, "main",
"no g signal connect (activate)",
"| 🖐️ windows creation denied");
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);

View File

@ -1,8 +1,6 @@
/** /**
* @file * @file
* Gem-graph-client src/readme.docs file * Gem-graph-client quick documentation (NB see also the Manual)
*
* This file is part of Gem-graph.
* *
* @cond LICENSE * @cond LICENSE
* Copyright © 2021 Libre en Communs <contact@a-lec.org> * Copyright © 2021 Libre en Communs <contact@a-lec.org>

View File

@ -0,0 +1,59 @@
/**
* @file
* Gem-graph client Main Window designer.
*
* Initiates, designs and frees the Gem-graph client main window.
*
*
*
* @cond LICENSE
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
*
* 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 <http://www.gnu.org/licenses/>.
* @endcond
*/
#include "../../../include/widget.h"
#include "../../../include/fsm.h"
/**
* @brief Main Window design()
*
* @param *main_window
* @param *app
*/
void widget_get_main_window (GtkWindow *main_window,
GtkApplication *app)
{
fsm_add_log (INFO, TOPBAR, "widget/main_window/design",
"> main window", "has began");
GtkWidget *topbar = GTK_WIDGET (gtk_header_bar_new ());
char *title = "E coli (with permission from David S. Goodsell, 2009)";
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (topbar),
gtk_label_new (title));
gtk_window_set_child (main_window,
GTK_WIDGET (gtk_picture_new_for_filename
("./docs/showcase/E coli (Goodsell).png")));
fsm_add_log (INFO, TOPBAR, "widget/main_window/design",
"> main window", "has ended");
}

94
src/widget/manager.c Normal file
View File

@ -0,0 +1,94 @@
/**
* @file
* Gem-graph client Widgets general manager.
*
* Initiates, designs and frees all the Gem-graph client windows.
*
*
*
* @cond LICENSE
* Copyright © 2021 Libre en Communs <contact@a-lec.org>
* Copyright © 2021-2024 Adrien Bourmault <neox@a-lec.org>
* Copyright © 2021-2024 Jean Sirmai <jean@a-lec.org>
*
* 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 <http://www.gnu.org/licenses/>.
* @endcond
*/
#include "../../include/widget.h"
#include "../../include/fsm.h"
static GtkWindow *main_window;
/**
* @brief Main Window new(app) and present()
*
* NB > on_windows_activation() is in: widget/manager NOT in: src/signal
*
* @since 2024-06
*
* @callgraph
* @see widget_design_main_window()
* @see widget_design_dialog_window()
* @see widget_design_text_window()
* @see util_trigger_test()
* @see fsm_add_log()
*
* @callergraph
* @see main()
*
* @param *app
*/
void on_windows_activation (GtkApplication *app)
{
fsm_add_log (INFO, WIDGETS, "widget/manager", "windows activation()", "has began");
// on_windows_activation() is in: widget/manager NOT in: src/signal
// g_application_activate (G_APPLICATION (app)); < how ? > in main is
// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
main_window = GTK_WINDOW (gtk_application_window_new (app));
widget_get_main_window (main_window, app);
gtk_window_present (GTK_WINDOW (main_window));
// ------------------------------------------------------------------------
// For the breakdown between pages, see signal > switch_state_rules_data()
// NB The rules page consists of two half-pages in a GtkPaned widget :
// - on the left, widgets for controlling or editing all the rules.
// - on the right, widgets for controlling or editing the selected rule.
// The preferred 'First Page' (the page displayed when the window is opened)
// is selected in: widget/topbar/left window_design_topbar_left()
// until it is defined in the fsm (2024-09)
// ------------------------------------------------------------------------
// widget_design_main_window (main_window, app); // def: widget/...
// ------------------------------------------------------------------------
// WIP 2024-09
// https://github.com/ToshioCP/Gtk4-tutorial/blob/main/gfm/sec17.md
/*GtkApplication *app2 = GTK_APPLICATION (app);
GSimpleAction *act_b = g_simple_action_new ("do_b", NULL);
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (act_b));
g_signal_connect (act_b, "activate", G_CALLBACK (action_b), app2);*/
fsm_add_log (INFO, WIDGETS, "widget/manager", "windows activation()",
"has ended 🧐️ | 👉️ a new session can be launched");
}