Compare commits

...

7 Commits

Author SHA1 Message Date
Jean Sirmai b2bccc8da4
src/fsm/log/oper.c fsm_add_log_event() fixing a bug
The bug was caused by pointers to local variables sended to fsm_add_log().
malloc() are now realized in fsm_add_log_event().

+ cleaning (checking that the sentence "This file is part of Gem-graph."
is systematicaly added to legal mentions.)
2024-11-13 17:17:36 +01:00
Jean Sirmai faba304ba4
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.
2024-11-12 17:15:12 +01:00
Jean Sirmai dc74605850
docs/rtfm/intro writing + cleaning details in src/ 2024-11-11 23:44:02 +01:00
Jean Sirmai de9b28520a
rtfm/intro (writing the manual) + cleaning doc 2024-11-11 23:36:02 +01:00
Jean Sirmai 7b51248aa5
* modifies several names:
* - in fsm_trigger_log_init(), fsm_trigger_log_close() the word **trigger** is
 * replaced by **relay**
 * - fsm_log_struct_unit is replaced by: fsm_log_unit_struct
 *
 * docs/rtfm/intro (previously 'Once upon a time'... 🙃️) is also renamed and
 * extended.
 *
2024-11-11 16:39:47 +01:00
Jean Sirmai 74894b5253
rtfm/intro Manual Introduction - a first version.
The same text is presented in two formats: for an external text editor (.txt)
or with lines limited to 80 characters.

The links are prepared but not functionnal.
2024-11-10 19:55:24 +01:00
Jean Sirmai 4d97b5328e
src/fsm/control.c fsm_init() and fsm_close() can be now triggered from main().
These two functions (defined in control.c) initiate the log and print it just
before the end of the program.
It is now possible to send messages that reports the events occuring during a
session: the creation of the log, then of the application and their closure in
the reverse order.
As previously,there is no g signal connect (activate) and no window is created.
This triggers the same error message in the console.
What is new, in this commit, is that a first log is printed in the console.
2024-11-09 08:03:55 +01:00
16 changed files with 877 additions and 220 deletions

View File

@ -403,7 +403,7 @@ MARKDOWN_ID_STYLE = DOXYGEN
# globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES.
AUTOLINK_SUPPORT = YES
AUTOLINK_SUPPORT = NO
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should set this
@ -565,7 +565,7 @@ EXTRACT_PACKAGE = NO
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC = NO
EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
@ -573,7 +573,7 @@ EXTRACT_STATIC = NO
# for Java sources.
# The default value is: YES.
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_CLASSES = NO
# This flag is only useful for Objective-C code. If set to YES, local methods,
# which are defined in the implementation section but not in the interface are
@ -614,7 +614,7 @@ HIDE_UNDOC_MEMBERS = NO
# if EXTRACT_ALL is enabled.
# The default value is: NO.
HIDE_UNDOC_CLASSES = NO
HIDE_UNDOC_CLASSES = YES
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
# declarations. If set to NO, these declarations will be included in the

View File

@ -24,7 +24,8 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
This file gives you information on how best to use the doc and a few tips for
personalising it.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@ -42,7 +43,6 @@ Attention
*
* docstrings
* ----------
* Pour chaque fonction, quelles sont les infos prioritaires ?
*
* @brief
* @details
@ -55,54 +55,11 @@ Attention
* @param (liste des paramètres)
* @return
autres (à envisager) @see https://www.doxygen.nl/manual/commands.html
--------------------------------------------------------------------------------
git commit 2024-10-14 avant d'exécuter une commande sed
qui remplacera tous les commentaires 'fantômes':
/** phantom documentation used to test the functioning of doxygen */
/**< a_variable_name phantom documentation */
sed -i 's/phantom documentation used to test the functioning of doxygen/\n
* @brief \n * @details \n * @dir \n * @file \n * @date \n * @author \n
* @callgraph \n * @see \n * @callergraph \n * @see\n * @param \n * @return \n/'
./src/main.c < or any other file...
NB signal et journal n'ont pas été 'tagués' <<<<<<<<<<
--------------------------------------------------------------------------------
---------------------------------------------------------------------------
* TODO : valgrind bin/gem-graph-client
* sanitize
*
*
* TODO : actuellement, valgrind bin/gem-graph-client détecte :
*
* HEAP SUMMARY:
* in use at exit: 11,537,505 bytes in 42,285 blocks
* total heap usage: 483,548 allocs,
* 441,263 frees,
* 112,049,363 bytes allocated
* LEAK SUMMARY:
* definitely lost: 40,161 bytes in 79 blocks
* indirectly lost: 11,233 bytes in 489 blocks
* possibly lost: 7,879,639 bytes in 7,844 blocks
* still reachable: 3,412,408 bytes in 32,248 blocks
* suppressed: 0 bytes in 0 blocks
* Rerun with --leak-check=full to see details of leaked memory
*
* valgrind --leak-check=full > ERROR SUMMARY: 1572 errors from 680 contexts
* --track-origins=yes ERROR SUMMARY: 896 errors from 4 contexts
* --show-leak-kinds=all
*
* sanitize <<
*
*
* TODO des scripts devraient pouvoir recueillir ces informations
* pour produire automatiquement, à la demande, des listes comme celle qui suit.
* (voir le dossier 'scripts')
* > plutôt utiliser Doxygen.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

View File

@ -1,34 +0,0 @@
Welcome to Gem-graph !
Gem-graph lets you move or transform drawn objects and can be used in all cases where drawings, designs or patterns are useful. You can draw anything you like. You can make it move or transform as you like. It is your design and you decide how you want it to evolve! You can use it to make a game. You can use it to make an animated representation (a model) of a phenomenon that interests you. You can represent what you want simply or in more realistic detail. Simple parts and more detailed parts can coexist in the same design. You can watch what you have created evolve without interfering or guiding it towards what you want to achieve. You can observe it in detail, go back, start again, measure, compare and keep the results that interest you so that you can play them again.
However, a certain amount of effort may be required to achieve the desired results. A complicated model will require more work than a simpler one, but it is possible to start with something simple and develop it step by step. In any case, you must draw what you want to see and say how you want it to move. Gem-graph cannot do that for you. Gem-graph can only help you to draw up and develop your idea. However, it can give you powerful tools to do so. All this is possible because the drawings that gem-graph manipulates are made up of very simple elements, all similar, driven by simple rules that can therefore be processed automatically. The tools provided by gem-graph give you access to the power of the automaton it uses to draw and animate your drawings, and this manual is here to help you to learn how to master them.
One way of doing this is to reproduce a very simple example, such as when a word processing program asks you to write "Hello world". For gem-graph, the equivalent of "Hello world" will be to move a small line on your screen. Once you have done this simple example, you will know enough to quickly build and animate much more complex drawings that suit your desires. If you like learning this way, this example is explained (here). If you prefer to learn by reading what the commands you see on the screen are doing, they have been detailed (here). The table of contents goes from the simplest to the most complicated. How to set up a simple model, observe it and measure what it does, then transform it by changing what you see and how it reacts.
------------
Our "Hello world" is the simplest program that gem-graph can execute. It consists of a single short arrow, which moves in a straight line in a single direction. To do this, we first had to draw this little arrow and then make it move. The result is certainly not very exciting, but this example is enough to show how a drawing is made and how it is animated. One state and one rule are enough. The rule only says: if an arrow is drawn here, I erase it and redraw it on the next square. For the moment, you don't need to know in detail how the rule works (it's described here). All that gem-graph needs to know is written in the "Hello world" file (here). If you open this file, you'll find a description of the arrow (here) and its movement (here).
------------
To improve this model, it is possible to give the arrow the ability to move in two directions: forwards or backwards. To do this, we need to add a second rule. This second rule says: if an arrow is drawn here, I erase it and redraw it on the previous square. A random draw (described here) is also necessary to determine whether the first or second rule applies. With these two rules and the random draw, the arrow now sometimes goes forwards, sometimes backwards. We can call this second model a "random walk".
------------
The second model (the random walk) had one state (the arrow) and two rules (forward/backward). Now here's a model with two states and two rules: the pendulum. This time, the arrow can be drawn either tilted forwards or tilted backwards (these are the two possible states) and the two rules switch the drawn arrow from one state to the other or vice versa. In the file, the states are (here) and the rules (here). The pendulum does not change place, but alternates between left and right. Like the previous ones, the programme is slowed down so that you can see the movements.
------------
Once you know how to write a state and a rule, you can write thousands of them: they will always be combinations of the same elementary form. However, it is also possible to combine programs: for example, you can combine the reports and rules from the two previous models to create a new model that shows both phenomena simultaneously. Once again, in the file, the states are (here) and the rules (here).
------------
A final simple example shows how a single rule can be applied to a multitude of states. The rule is the same as for the first model: an arrow can only be moved one square forward, but this time you have to check that the square forward is free. If it isn't, the arrow won't move. And this time, the space contains a multitude of arrows that have been randomly placed all over the place (see details here).
When you open this model, you see a multitude of small lines, all similar, some vertical, some horizontal, placed on a grid. When you set the model in motion, you see these little lines moving from left to right if they are horizontal, and up and down if they are vertical (a second rule vas added to do that). Their number is constant. They don't change shape or direction. There seems to be no accident when they cross. Nothing else happens.
------------
These five examples give an initial idea of the diversity of possible models and the operations that can be performed on them.

163
docs/rtfm/intro 80 char Normal file
View File

@ -0,0 +1,163 @@
Welcome to Gem-graph !
Gem-graph lets you move and transform drawn objects using an automaton. It's an
ideal tool for describing the evolution of a situation through drawing. Would
you like to see your drawings evolve automatically to represent a phenomenon?
Gem-graph lets you transform your drawings as you wish. You can draw whatever
you want. It's your drawing and you decide how it evolves! You can use gem-graph
to make a game. You can use it to make a model of a phenomenon that interests you.
You can represent what you want simply or in more realistic detail.
Simple parts and more detailed parts can coexist in the same design. You can
watch what you have created evolve without interfering or guiding it towards what
you want to achieve. You can mix several drawings and animations. You can observe
them in detail, modify them, go back, start again, measure, compare and keep the
results that interest you so that you can play them again.
However, a certain amount of effort will be required to achieve this. A complicated
model will require more work than a simpler one, but it is possible to start with
something simple and develop it step by step. In any case, you must draw what you
want to see and say how you want it to be transformed. Gem-graph cannot do that
for you. Gem-graph can only help you to draw up and develop your idea. However,
it can give you powerful tools to do so. The strength of gem-graph - short for
'geometric graph' - lies in the fact that it deals only with very simple drawing
elements, all of which are similar, and that the rules it uses to manipulate these
elements are equally simple and similar. As a result, these rules can be combined
and processed automatically, no matter how many there are. The tools provided by
gem-graph give you access to the power of the automaton it uses to draw and animate
your drawings, and this manual is here to help you to learn how to master them.
One way of doing this is to reproduce a very simple example, such as when a word
processing program asks you to write "Hello world". For gem-graph, the equivalent
of "Hello world" will be to move a small line on your screen. Once you have done
this simple example, you will know enough to quickly build and animate much more
complex drawings that suit your desires. If you like learning this way, this
example is explained (here). If you prefer to learn by reading what the commands
you see on the screen are doing, they have been detailed (here). The table of
contents goes from the simplest to the most complicated. How to set up a simple
model, observe it and measure what it does, then transform it by changing what
you see and how it reacts.
------------
Our "Hello world" is the simplest program that gem-graph can execute. It consists
of a single short arrow, which moves in a straight line in a single direction.
To do this, we first had to draw this little arrow and then make it move. The
result is certainly not very exciting, but this example is enough to show how a
drawing is made and how it is animated. One state and one rule are enough. The
rule only says: if an arrow is drawn here, I erase it and redraw it on the next
square. For the moment, you don't need to know in detail how the rule works
(it's described here). All that gem-graph needs to know is written in the
"Hello world" file (here). If you open this file, you'll find a description of
the arrow (here) and its movement (there).
------------
To improve this model, it is possible to give the arrow the ability to move in
two directions: forwards or backwards. To do this, we need to add a second rule.
This second rule says: if an arrow is drawn here, I erase it and redraw it on the
previous square. A random draw (described here) is also necessary to determine
whether the first or second rule applies. With these two rules and the random
draw, the arrow now sometimes goes forwards, sometimes backwards. We can call
this second model a "random walk".
------------
The second model (the random walk) had one state (the arrow) and two rules
(forward/backward). Now here's a model with two states and two rules:
the "pendulum". This time, the arrow can be drawn either tilted forwards or tilted
backwards (these are the two possible states) and the two rules switch the drawn
arrow from one state to the other or vice versa. In the file, the states are (here)
and the rules (here). The pendulum does not change place, but alternates between
left and right. Like the previous ones, you can slow down the programme so that
you can observe the movements.
------------
Once you know how to write a state and a rule, you can write thousands of them:
they will always be combinations of the same elementary form. However, it is also
possible to combine programs: for example, you can combine the reports and rules
from the two previous models to create a new model that shows both phenomena
simultaneously. Once again, in the file, the states are (here) and the rules
(here).
------------
The next example shows how the same rule can be applied to a multitude of states.
The rule is the same as that used in the first model: an arrow can only be moved
one square forward, but this time you have to check that the square forward is
free. If it isn't, the arrow won't move. Once the rule has been modified in this
way (see how), it can be applied to a multitude of arrows distributed randomly in space
(see more details here).
When you set the model in motion, you will see all these small lines moving from
left to right. A single rule is responsible for all these movements.
For a small fee, we can apply the two rules of the 'random walk' model to all the
arrows distributed in this space, and they will then all behave in the same way,
sometimes moving forwards, sometimes backwards.
------------
In the next example, we first build a model similar to the previous one: a
multitude of arrows are randomly distributed in space, but this time they are
vertical and the movements are up and down instead of right and left. Then, we
add this model to the previous state and set the final model in motion. We see
then little lines moving from left to right or reverse if they are horizontal,
and up and down or reverse if they are vertical. Their number is constant. They
don't change shape or direction. There seems to be no accident when they cross.
Nothing else happens.
------------
The last example in this series, because it shows a multitude of diverse and
simultaneous movements, perhaps gives the impression of a more complex system.
It would be easy to make it even more complex, but it's much more interesting
to show how gem-graph can be used to analyse and control that complexity (here). At
this point, it's time to compare gem-graph to other classes of automata that do
quite similar things, and to look at what it can actually do and what its
limitations are.
------------
The main difference between gem-graph models and agent-based models is that
gem-graph deals with situations, not agents. In a situation where several agents
are interacting and each agent could apply a different rule, gem-graph considers
and processes the situation. Not the agents. Whatever the new situation that
results from his action, his decision-making process will have been simple and
straightforward. It will therefore be easy to modify and control. And the
diversity of possible new situations will be far greater than that offered by
agent-based models.
------------
The comparison between gem-graphs and cellular automata first comes up against
a question of vocabulary. What is commonly called a 'rule' in one and the other
is not the same thing. Gem-graphs and cellular automata have the same power:
anything that can be done by one can be done by the other, but their writing is
not the same (details of this comparison here).
------------
How can gem-graph be used to analyse and control the complexity of what it
represents and sets in motion? This chapter introduces the gem-graph mechanism.
------------
Gem-graph can reproduce the behavior of any cellular automata. Whatever the state
of the cellular automaton space at a given time (n), this state can be considered
as a gem-graph state and a rule can be written to transform it into the next
state (n+1).
The difference with the cellular automaton is that this rule is not generated by
a "micro-rule" applied cell by cell to the entire state (n). This rule must be
written by hand and its writing requires knowledge of state (n+1).
Writing all the rules that describe all the transformations that have occurred
when a cellular automaton describes a trajectory (a story) is certainly tedious,
but it is always possible. And the number of possible histories that gem-graph
rules can describe is limited only by the size of the space and the number of
symbols it contains.
If a set of "micro-rules", each applied cell by cell to the entire state (n) of
a cellular automaton, can produce all the possible states that the gem-graph can
describe, the two representations can be considered to be equivalent in power.

60
docs/rtfm/intro.txt Normal file
View File

@ -0,0 +1,60 @@
Welcome to Gem-graph !
Gem-graph lets you move and transform drawn objects using an automaton. It's an ideal tool for describing the evolution of a situation through drawing. Would you like to see your drawings evolve automatically to represent a phenomenon? Gem-graph lets you transform your drawings as you wish. You can draw whatever you want. It's your drawing and you decide how it evolves! You can use gem-graph to make a game. You can use it to make a model of a phenomenon that interests you. You can represent what you want simply or in more realistic detail. Simple parts and more detailed parts can coexist in the same design. You can watch what you have created evolve without interfering or guiding it towards what you want to achieve. You can mix several drawings and animations. You can observe them in detail, modify them, go back, start again, measure, compare and keep the results that interest you so that you can play them again.
However, a certain amount of effort will be required to achieve this. A complicated model will require more work than a simpler one, but it is possible to start with something simple and develop it step by step. In any case, you must draw what you want to see and say how you want it to be transformed. Gem-graph cannot do that for you. Gem-graph can only help you to draw up and develop your idea. However, it can give you powerful tools to do so. The strength of gem-graph - short for 'geometric graph' - lies in the fact that it deals only with very simple drawing elements, all of which are similar, and that the rules it uses to manipulate these elements are equally simple and similar. As a result, these rules can be combined and processed automatically, no matter how many there are. The tools provided by gem-graph give you access to the power of the automaton it uses to draw and animate your drawings, and this manual is here to help you to learn how to master them.
One way of doing this is to reproduce a very simple example, such as when a word processing program asks you to write "Hello world". For gem-graph, the equivalent of "Hello world" will be to move a small line on your screen. Once you have done this simple example, you will know enough to quickly build and animate much more complex drawings that suit your desires. If you like learning this way, this example is explained (here). If you prefer to learn by reading what the commands you see on the screen are doing, they have been detailed (here). The table of contents goes from the simplest to the most complicated. How to set up a simple model, observe it and measure what it does, then transform it by changing what you see and how it reacts.
------------
Our "Hello world" is the simplest program that gem-graph can execute. It consists of a single short arrow, which moves in a straight line in a single direction. To do this, we first had to draw this little arrow and then make it move. The result is certainly not very exciting, but this example is enough to show how a drawing is made and how it is animated. One state and one rule are enough. The rule only says: if an arrow is drawn here, I erase it and redraw it on the next square. For the moment, you don't need to know in detail how the rule works (it's described here). All that gem-graph needs to know is written in the "Hello world" file (here). If you open this file, you'll find a description of the arrow (here) and its movement (there).
------------
To improve this model, it is possible to give the arrow the ability to move in two directions: forwards or backwards. To do this, we need to add a second rule. This second rule says: if an arrow is drawn here, I erase it and redraw it on the previous square. A random draw (described here) is also necessary to determine whether the first or second rule applies. With these two rules and the random draw, the arrow now sometimes goes forwards, sometimes backwards. We can call this second model a "random walk".
------------
The second model (the random walk) had one state (the arrow) and two rules (forward/backward). Now here's a model with two states and two rules: the "pendulum". This time, the arrow can be drawn either tilted forwards or tilted backwards (these are the two possible states) and the two rules switch the drawn arrow from one state to the other or vice versa. In the file, the states are (here) and the rules (here). The pendulum does not change place, but alternates between left and right. Like the previous ones, you can slow down the programme so that you can observe the movements.
------------
Once you know how to write a state and a rule, you can write thousands of them: they will always be combinations of the same elementary form. However, it is also possible to combine programs: for example, you can combine the reports and rules from the two previous models to create a new model that shows both phenomena simultaneously. Once again, in the file, the states are (here) and the rules (here).
------------
The next example shows how the same rule can be applied to a multitude of states. The rule is the same as that used in the first model: an arrow can only be moved one square forward, but this time you have to check that the square forward is free. If it isn't, the arrow won't move. Once the rule has been modified in this way (see how), it can be applied to a multitude of arrows distributed randomly in space (see more details here).
When you set the model in motion, you will see all these small lines moving from left to right. A single rule is responsible for all these movements.
For a small fee, we can apply the two rules of the 'random walk' model to all the arrows distributed in this space, and they will then all behave in the same way, sometimes moving forwards, sometimes backwards.
------------
In the next example, we first, we build a model similar to the previous one: a multitude of arrows are randomly distributed in space, but this time they are vertical and the movements are up and down instead of right and left. Then, we add this model to the previous state and set the final model in motion. We see then little lines moving from left to right or reverse if they are horizontal, and up and down or reverse if they are vertical. Their number is constant. They don't change shape or direction. There seems to be no accident when they cross. Nothing else happens.
------------
The last example in this series, because it shows a multitude of diverse and simultaneous movements, perhaps gives the impression of a more complex system. It would be easy to make it even more complex, but it's much more interesting to show how gem-graph can be used to analyse and control that complexity. At this point, it's time to compare gem-graph to other classes of automata that do quite similar things, and to look at what it can actually do and what its limitations are.
------------
The main difference between gem-graph models and agent-based models is that gem-graph deals with situations, not agents. In a situation where several agents are interacting and each agent could apply a different rule, gem-graph considers and processes the situation. Not the agents. Whatever the new situation that results from his action, his decision-making process will have been simple and straightforward. It will therefore be easy to modify and control. And the diversity of possible new situations will be far greater than that offered by agent-based models.
------------
The comparison between gem-graphs and cellular automata first comes up against a question of vocabulary. What is commonly called a 'rule' in one and the other is not the same thing. Gem-graphs and cellular automata have the same power: anything that can be done by one can be done by the other, but their writing is not the same (details of this comparison here).
------------
How can gem-graph be used to analyse and control the complexity of what it represents and sets in motion? This chapter introduces the gem-graph mechanism.
------------
Gem-graph can reproduce the behavior of any cellular automata. Whatever the state of the cellular automaton space at a given time (n), this state can be considered as a gem-graph state and a rule can be written to transform it into the next state (n+1).
The difference with the cellular automaton is that this rule is not generated by a "micro-rule" applied cell by cell to the entire state (n). This rule must be written by hand and its writing requires knowledge of state (n+1).
Writing all the rules that describe all the transformations that have occurred when a cellular automaton describes a trajectory (a story) is certainly tedious, but it is always possible. And the number of possible histories that gem-graph rules can describe is limited only by the size of the space and the number of symbols it contains.
If a set of "micro-rules", each applied cell by cell to the entire state (n) of a cellular automaton, can produce all the possible states that the gem-graph can describe, the two representations can be considered to be equivalent in power.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@ -1,26 +1,23 @@
/**
* @file
* Fsm (finite state machine) header
* FSM (Finite State Machine) header of the Gem-graph client.
*
* This file is part of Gem-graph.
*
*
* This commit introduces the functions that the log needs.
* @see readme.docs and this text below.
*
* ---
*
* The two structures and the two enums listed below will stay in the fsm header.
* The two log structures and the two enums needed by the logs are defined in
* the fsm header.
*
* All functions are now in dedicated files.
* All log functions are in dedicated files.
*
* The most important function: fsm_add_log() is in the file:
* /src/fsm/log/manager.c
*
* This file contains the declaration of the log with the static attribute,
* This file contains the declaration of the log with the **static** attribute,
* which forces all the functions that read or write it to be in it.
* Forcing all functions that read or write to the log to be grouped together
* help to prevent uncontrolled operations.
* helps to prevent uncontrolled operations.
*
* All events sent to the log must pass through this function, which allows them
* to be filtered before being published in the log.
@ -70,6 +67,8 @@
*
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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>
@ -104,23 +103,23 @@
* https://en.wikipedia.org/wiki/Syslog
*
* All logs must contain at least one item from this enum and only one.
* This item can not be set to NULL.
* This item can NOT be set to NULL.
*
* @see fsm_add_log()
*/
enum fsm_enum_log_severity {
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
specific operation within the application */
specific operation within the application 👀😮! */
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
operating normally */
operating normally 📜👌 */
DEBUG, /**< a description of system states in sufficient detail to give
developers clues as to the cause of an error */
developers clues as to the cause of an error 🪳🧐 */
TRACE /**< provides a systematic overview of code execution but comes at
a cost in terms of performance */
a cost in terms of performance 🥱 */
};
/**
@ -176,27 +175,27 @@ enum fsm_enum_log_source {
//-----------------------------------------------------------------------------
/**
* Structure of a log unit.
* A log unit must include the followings:
*
* @callergraph
* @see fsm_log_struct
*/
typedef struct fsm_log_struct_unit
typedef struct fsm_log_unit_struct
{
long yy_dd_mm; /**< * date of the event reported in the log */
long usec; /**< * with microseconds precision */
const char *file_source; /**< * emitter file */
const char *function_source; /**< * emitter function */
const char *string_value; /**< * any event descriptors */
struct fsm_log_struct_unit *prev; /**< * chained list */
struct fsm_log_struct_unit *next; /**< * chained list */
char *file_source; /**< * emitter file */
char *function_source; /**< * emitter function */
char *string_value; /**< * any event descriptors */
struct fsm_log_unit_struct *prev; /**< * chained list */
struct fsm_log_unit_struct *next; /**< * chained list */
}
fsm_log_struct_unit;
fsm_log_unit_struct;
/**
* Two links towards the previous and the next unit are required to initialize
* and manage a double-chained list.
* Log is a double-chained list. Two links towards the previous and the next unit
* are required to initialize and manage it.
*
* @callgraph
* @see fsm_log_struct_unit
@ -211,8 +210,8 @@ typedef struct fsm_log_struct_unit
* @see fsm_remove_log()
*/
typedef struct {
fsm_log_struct_unit *first; /**< * required */
fsm_log_struct_unit *last; /**< * required */
fsm_log_unit_struct *first; /**< * required */
fsm_log_unit_struct *last; /**< * required */
}
fsm_log_struct;
@ -223,25 +222,31 @@ void fsm_publish_log (fsm_log_struct jj);
void fsm_clear_log (fsm_log_struct *jj);
void fsm_add_log_event (fsm_log_struct *jj,
const char *file_source,
const char *function_source,
const char *string_value);
char *file_source,
char *function_source,
char *string_value);
int fsm_get_log_length(fsm_log_struct jj);
void fsm_seek_log (fsm_log_struct jj,
long usec,
const char *file_source,
const char *function_source,
const char *string_value);
char *file_source,
char *function_source,
char *string_value);
long fsm_remove_log (fsm_log_struct *jj,
const char *file_source,
const char *function_source,
const char *string_value);
char *file_source,
char *function_source,
char *string_value);
void fsm_add_log (int severity,
int source,
const char *file_source,
const char *function_source,
const char *string_value);
char *file_source,
char *function_source,
char *string_value);
void fsm_relay_init_log();
void fsm_relay_close_log();
void fsm_init (char *initial_message_from_main);
void fsm_close (char *final_message_from_main);

33
include/widget.h Normal file
View File

@ -0,0 +1,33 @@
/**
* @file
* Widgets hierarchy header of the Gem-graph client;
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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);

196
src/fsm/control.c Normal file
View File

@ -0,0 +1,196 @@
/**
* @file
* @brief Gem-graph client FSM controls.
*
* @details
*
* The fsm control instance
* - **initialises** the log and the rest of the fsm when triggered by main()
* - **checks** all triggered operations and **allocates** them if they are valid
* - **closes** all the elements it opened before handing over to main()
* .
*
* ---
*
* The Finite State Machine (fsm) describes all the possible states of the
* Gem-graph client and all the transitions between them.
* It manages several kinds of exclusive states:
* - Run the model or edit it.
* - Select a single view of the model from all those possible.
* The different views show either the space, or the rule tree,
* or a single rule of interest, or measurements or results.
* NB an overview is possible, but it does not provide details.
* - Apply a selected measurement to the currently running model
* - Select some results for study or/and presentation.
* - Choose the user's preferred values for a set of parameters
* used to modify the appearance or behaviour of gem-graph.
*
* Each state of the fsm is a combination of each of these states.
*
* The current state of the fsm must be
* - saved at the end of a work session and
* - reread (available to the user) at the start of a new session.
*
* No state of the fsm should be defined in another module.
*
* No fsm transition should be executed in another module.
*
* The journal is created, edited and published from here.
*
* ---
*
* About code organization, see src/readme.dox
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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/fsm.h"
/**
* Initiates the four lists:
* 'measures', 'results', 'displayables results' and 'preferences'.
* The items selected in these lists contribute to define the current state of
* the fsm.
* The exact number and status of the structures of the fsm are still being
* assessed.
*
* @callergraph
* @see fsm_init()
*/
static void fsm_structures_init()
{
/**< will be introduced later on:
fsm_add_log (info, FSM, "fsm/dispatch", "measures list init()",
"measurement processes");
fsm_list_init_measures();
fsm_add_log (info, FSM, "fsm/dispatch", "results list init()",
"measurement results (gross)");
fsm_list_init_results();
fsm_add_log (info, FSM, "fsm/dispatch", "displayables list init()",
"displayable results");
fsm_list_init_displayables();
fsm_add_log (info, FSM, "fsm/dispatch", "preferences list init()",
"preferences");
fsm_list_init_preferences();
*/
}
/**
* Closes the four lists:
* 'measures', 'results', 'displayables results' and 'preferences'.
* The items selected in these lists contribute to define the current state of
* the fsm.
* The exact number and status of the structures of the fsm are still being
* assessed.
*
* @callergraph
* @see fsm_close()
*/
static void fsm_structures_close()
{
/**< ? */
}
/**
* @brief The first function called by main();
* initiates the journal and calls fsm_structures_init().
*
* Uses the relay function fsm_relay_init_log() in src/fsm/log/manager.c to
* reach the fsm_init_log().
*
* @since 2024-08
*
* @callergraph
* @see main()
*
* @callgraph
* @see fsm_relay_init_log()
* @see fsm_add_log()
* @see fsm_list_init_measures()
* @see fsm_list_init_results()
* @see fsm_list_init_displayables()
* @see fsm_list_init_preferences()
*
* @param *initial_info_from_main
*/
void fsm_init (char *initial_info_from_main)
{
fsm_relay_init_log();
fsm_add_log (INFO, MAIN, "main", initial_info_from_main,
"👋️ (☕️) Hi everybody ! Here is Gem-Graph.");
fsm_add_log (INFO, FSM, "fsm/control", "fsm initialisation", "has began ✍️");
fsm_structures_init();
fsm_add_log (INFO, FSM, "fsm/control", "fsm initialisation", "has ended 😇️");
}
/**
* @brief The last function called by main();
* closes all that was opened in reverse order.
*
* @details Ensures the fsm state is saved:
* - 'preferences'
* - 'model'
*
* Then closes the four lists:
* - 'measures',
* - 'results',
* - 'displayables results' and
* - 'preferences'
* .
*
* and closes the journal
*
* @since 2024-08
*
* @callergraph
* @see main()
*
* @callgraph
* @see fsm_structures_close()
* @see fsm_relay_close_log()
* @see fsm_add_log()
*
* @param *closing_info_from_main
*/
void fsm_close (char *closing_info_from_main)
{
fsm_add_log (INFO, FSM, "fsm/control", "fsm closing", "has began");
fsm_structures_close();
fsm_add_log (INFO, FSM, "fsm/control", "fsm closing", "has ended");
fsm_add_log (INFO, MAIN, "main", closing_info_from_main,
"👋️😄️ That'all folks !");
fsm_relay_close_log(); /**< fsm_clear_log(() can't be called from here
* because static fsm_log_struct gg_logs
* is in src/fsm/log/manager.c */
}

View File

@ -1,13 +1,16 @@
/**
* @file
*
* This file is part of Gem-graph. The log (or journal) stores chronologically
* the events during a session run (rules exec, mainly)
* Gem-graph client auxiliary log functions container.
*
* The log (or journal) stores chronologically the events during a session run.
*
* This file groups some functions that a typical list should implement but whose
* utility remains to evaluate in the case of a log list.
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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>
@ -32,8 +35,7 @@
#include "../../../include/fsm.h"
/**
* remove an event;
* the removal is a pop back
* Removes an event; the removal is a pop back
*
* @since 2024-09
*
@ -45,12 +47,12 @@
* @returns the removed event date microseconds
*/
long fsm_remove_log (fsm_log_struct *jj,
const char *file_source,
const char *function_source,
const char *string_value)
char *file_source,
char *function_source,
char *string_value)
{
long usec;
fsm_log_struct_unit *tmp = jj->last;
fsm_log_unit_struct *tmp = jj->last;
if (! tmp) return -1;
usec = tmp->usec;
jj->last = tmp->prev;
@ -63,7 +65,7 @@ long fsm_remove_log (fsm_log_struct *jj,
/**
* get log length
* Gets the log length
*
* @since 2024-09
*
@ -72,7 +74,7 @@ long fsm_remove_log (fsm_log_struct *jj,
*/
int fsm_get_log_length (fsm_log_struct jj)
{
fsm_log_struct_unit *a_unit = jj.first;
fsm_log_unit_struct *a_unit = jj.first;
int nb = 0;
while (a_unit)
{
@ -84,7 +86,7 @@ int fsm_get_log_length (fsm_log_struct jj)
/**
* seek for an event
* Seek for an event
*
* @since 2024-09
*
@ -96,11 +98,11 @@ int fsm_get_log_length (fsm_log_struct jj)
*/
void fsm_seek_log (fsm_log_struct jj,
long usec,
const char *file_source,
const char *function_source,
const char *string_value)
char *file_source,
char *function_source,
char *string_value)
{
fsm_log_struct_unit *a_unit = jj.first;
fsm_log_unit_struct *a_unit = jj.first;
int nb = 0;
while (a_unit)
{

View File

@ -1,16 +1,19 @@
/**
* @file
* @brief fsm (Finite State Machine) log manager
*
* This file is part of Gem-graph.
* @brief FSM manager of the Gem-graph client log main structures and functions.
*
* @details
* The log (journal) is created, edited and published from here.
* This file contains only (1) the static fsm_log_struct gg_logs
* and (2) the function fsm_add_log() that all calls must pass through to send a
* message to the log.
*
* This file contains only
* -# the static fsm_log_struct **gg_logs**
* -# the function fsm_add_log() that all calls must pass through to send a
* message to the log and
* -# the two relay functions that init and publish the log before closing it.
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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>
@ -38,34 +41,34 @@
*******************************************************************************/
/**
* The fsm_struct_journal (gg_logs) is a static instance in the file
* The fsm_struct_journal (gg_logs) is a **static** instance in the file
* /src/fsm/log/manager.c
* Therefore, all the functions that read or write it are in this file.
* This helps to avoid uncontrolled operations.
* Therefore, all the functions that read or write it must be in the same file.
*
* Limiting the access to gg_logs helps to avoid uncontrolled operations on it.
*/
static fsm_log_struct gg_logs;
/**
* @brief It is mandatory for any event to call this function to be published in
* the journal.
* @brief To be published in the log, all events must pass through this function,
* which enables filtering.
*
* @details The fsm_struct_journal (gg_logs) is a static instance in the file
* /src/fsm/log/manager.c
* Therefore, all the functions that read or write it will be in this file.
* This is to avoid uncontrolled operations on it.
* @details This function is both a relay and a filter.
*
* A message is send to the log for each documented event.
* - It is a relay because it must call fsm_add_log_event() and pass it **gg_logs**
* to write to the log. As gg_logs is a **static** instance, this call can only
* be made from the same file.
*
* If there are too many events, one or several filters can be applied
* here (and only here) before publication, to select only some events
* of interest (during debugging, for example).
* - It's more than just a relay, because one or more filters can be applied here
* (and only here) before publication to select only certain events.
* The interest of events can vary according to the type of session.
*
* These filters can operate on any the following five parameters:
* severity, source, file_source (text), function_source (text),
* string_value (text).
* - severity, - source, - file_source (text), - function_source (text),
* - string_value (text).
*
* They can be combined using any logical operators and parentheses.
* The filters can be combined using any logical operators and parentheses.
*
* @since 2024-08
*
@ -91,9 +94,9 @@ static fsm_log_struct gg_logs;
*/
void fsm_add_log (int severity,
int source,
const char *file_source,
const char *function_source,
const char *string_value)
char *file_source,
char *function_source,
char *string_value)
{
if
(
@ -102,3 +105,50 @@ void fsm_add_log (int severity,
)
fsm_add_log_event (&gg_logs, file_source, function_source, string_value);
}
/**
* Only a relay function: calls fsm_init_log(); nothing else.
*
* This call couldn't be written in another file because the fsm_log_struct
* **gg_logs** it transmits is **static** in src/fsm/log/manager.c
*
* Limiting the access to **gg_logs** helps to avoid uncontrolled operations on it.
*
* Functions which only relay should not send log.
*
* @since 2024-08
*
* @callergraph
* @see main()
*
*/
void fsm_relay_init_log()
{
fsm_init_log (&gg_logs);
}
/**
* Only a relay function: calls fsm_publish_log() and fsm_clear_log();
* nothing else.
*
* These calls couldn't be written in another file because the fsm_log_struct
* **gg_logs** they transmit is **static** in src/fsm/log/manager.c
*
* Limiting the access to **gg_logs** helps to avoid uncontrolled operations on it.
*
* Functions which only relay should not send log.
*
* @since 2024-08
*
* @callergraph
* @see main()
*
*/
void fsm_relay_close_log()
{
fsm_publish_log (gg_logs);
fsm_clear_log (&gg_logs);
}

View File

@ -1,12 +1,11 @@
/**
* @file
*
* This file is part of Gem-graph.
* Gem-graph client log executive functions container.
*
* The log (journal) stores chronologically the events during a session.
* The log stores chronologically all the events occuring during an execution.
*
* This file contains the executive functions needed to init the log, add an
* event and publish the log.
* The executive functions initialise the log, add events and publish everything.
*
* The log presentation is:
* [date - rank - source file - source function - value]
@ -15,6 +14,8 @@
* It will be printed in chronological order in a file.
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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>
@ -42,11 +43,14 @@
#include <glib.h>
#include "../../../include/fsm.h"
static int string_1_size = 40;
static int string_2_size = 40;
static int string_3_size = 40;
/**
* init the log: a double chained list
* Inits the log: a double chained list.
*
* first and last records are set to NULL
* First and last records are set to NULL
*
* @since 2024-09
*
@ -60,7 +64,7 @@ void fsm_init_log (fsm_log_struct *jj)
/**
* removes all the log content and free each unit
* Deletes all the contents of the log and frees each unit.
*
* @since 2024-09
*
@ -68,8 +72,8 @@ void fsm_init_log (fsm_log_struct *jj)
*/
void fsm_clear_log (fsm_log_struct *jj)
{
fsm_log_struct_unit *tmp;
fsm_log_struct_unit *a_unit = jj->first;
fsm_log_unit_struct *tmp;
fsm_log_unit_struct *a_unit = jj->first;
while(a_unit)
{
tmp = a_unit;
@ -82,9 +86,9 @@ void fsm_clear_log (fsm_log_struct *jj)
/**
* add an event
* Adds a log unit (an event) to the log list.
*
* *new_unit = malloc (sizeof(fsm_log_struct_unit));
* *new_unit = malloc (sizeof (fsm_log_unit_struct));
*
* warn: is never free (as new log units are never removed)
*
@ -96,25 +100,33 @@ void fsm_clear_log (fsm_log_struct *jj)
* @param *string_value
*/
void fsm_add_log_event (fsm_log_struct *jj,
const char *file_source,
const char *function_source,
const char *string_value)
char *file_source,
char *function_source,
char *string_value)
{
struct timeval tv;
gettimeofday (&tv, NULL);
fsm_log_struct_unit *new_unit = malloc (sizeof(fsm_log_struct_unit));
fsm_log_unit_struct *new_unit = malloc (sizeof(fsm_log_unit_struct));
if (! new_unit) exit (EXIT_FAILURE);
new_unit->yy_dd_mm = tv.tv_sec;
new_unit->usec = tv.tv_usec;
new_unit->file_source = file_source;
new_unit->function_source = function_source;
new_unit->string_value = string_value;
new_unit->file_source = malloc(string_1_size * sizeof(char));
new_unit->function_source = malloc(string_2_size * sizeof(char));
new_unit->string_value = malloc(string_3_size * sizeof(char));
strncpy (new_unit->file_source, file_source, string_1_size - 1);
strncpy (new_unit->function_source, function_source, string_2_size - 1);
strncpy (new_unit->string_value, string_value, string_3_size - 1);
new_unit->next = jj->first;
new_unit->prev = NULL;
if (jj->first) jj->first->prev = new_unit;
else jj->last = new_unit;
jj->first = new_unit;
}
@ -122,9 +134,10 @@ void fsm_add_log_event (fsm_log_struct *jj,
#define LOG_MAX_LENGTH 255 /**< arbitrary */
/**
* publish all the logs chronologically (using the g_lib function: g_message)
* Publishes all the logs chronologically (using the g_lib function: g_message)
*
* today, simply printed in the console; TODO: print in a file
* Today, simply printed in the console; TODO: print in a file
* NB string_3_size = 40 (this name can't be used for formatting in g_message()
*
* @since 2024-09
*
@ -132,19 +145,20 @@ void fsm_add_log_event (fsm_log_struct *jj,
*/
void fsm_publish_log (fsm_log_struct jj)
{
fsm_log_struct_unit *a_unit = jj.last;
fsm_log_unit_struct *a_unit = jj.last;
char buf [LOG_MAX_LENGTH];
int nb = 0;
while (a_unit)
{
strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm));
g_message ("%s + %-6ld %6d %-32s %-38s %-50s",
g_message ("%s + %-6ld %6d %-28s %-32s %-40s",
buf,
a_unit->usec,
nb,
a_unit->file_source,
a_unit->function_source,
a_unit->string_value);
free (a_unit->string_value);
a_unit = a_unit->prev;
nb ++;
}

View File

@ -1,11 +1,26 @@
/**
* @file
* Main file of the Gem-graph client; contains only the main() function.
*
* Gem-graph main file
* The main() function
* - **initialises**
* -# the log,
* -# the finite state machine (fsm),
* -# the application,
* -# the windows and
*
* This file is part of Gem-graph. It contains only the main() function.
* - **closes** all the elements it opened in reverse order
* before ending the program execution
* .
*
* The default values of the fsm initial state will be specified in:
* src/fsm/control(). They are user preferences.
*
* About code organization, see src/readme.dox
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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>
@ -23,39 +38,49 @@
* 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
*
* ---
*
* The main() function will **initialise** the log, the finite state machine (fsm),
* the application and the windows and **close** all the elements it opened
* before the end of 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:
* src/fsm/dispatch(). They are user preference and, in accordance, the overview
* page of the current model will be displayed as they specify it in:
* src/widget/main_window/designer/widget_design_main_window().
*
* About code organization, see src/readme.dox
*
* ---
*/
#include <gtk-4.0/gtk/gtk.h>
#include "../include/fsm.h"
#include "../include/widget.h"
/**
* @since 2024-04
*
* @callgraph
* @see fsm_trigger_log_init()
* @see fsm_init()
* @see fsm_close()
* @see fsm_trigger_log_close()
* @see fsm_add_log()
*
* @param argc
* @param **argv
* @return status, the program errorlevel
*/
int main (int argc, char **argv)
{
GtkApplication *app;
int status;
fsm_init ("first instruction / first log");
fsm_add_log (INFO, MAIN, "main", "*app = gtk_application_new()",
"| 👉️ trigger app initialization");
app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
//g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), NULL);
//g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), NULL);
fsm_add_log (INFO, MAIN, "main",
"g signal connect (activate)",
"| 👉️ windows creation requested");
// g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL);
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
fsm_add_log (INFO, MAIN, "main", "g_object unref (app)", "| 👌️ bye bye app !");
fsm_close("last instruction / last log");
return status;
}

View File

@ -1,10 +1,10 @@
/**
* @file
* Gem-graph-client src/readme.docs file
*
* This file is part of Gem-graph.
* Gem-graph-client quick documentation (NB see also the Manual)
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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>

View File

@ -0,0 +1,63 @@
/**
* @file
* Gem-graph client Main window designer.
*
* Initiates, designs and frees the Gem-graph client main window.
*
*
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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", "start of design");
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));
GtkWidget *e_coli = GTK_WIDGET (gtk_picture_new_for_filename
("./docs/showcase/E coli (Goodsell).png"));
gtk_window_set_child (main_window, e_coli);
// g_object_unref (e_coli);
fsm_add_log (INFO, TOPBAR, "widget/main_window/design",
"main window", "ready for presentation");
}

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

@ -0,0 +1,123 @@
/**
* @file
* Gem-graph client manager for all widgets.
*
* Initiates, designs and frees all the Gem-graph client windows.
*
*
*
* @cond LICENSE
* This file is part of Gem-graph.
*
* 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"
#include <stdio.h>
static GtkWindow *main_window;
/**
* @brief 1) creates a new main window 2) presents this window
*
* 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);
// https://docs.gtk.org/gobject/method.Object.unref.html
// https://www.cs.hunter.cuny.edu/~sweiss/course_materials/csci493.70/lecture_notes/GTK_memory_mngmt.pdf
// Objects are reference counted in GTK.
//GtkWidget * widget = gtk_fixed_new();
//g_object_ref(widget);
//g_object_ref_sink(widget); // remove floating reference, and own this object ourselves
//g_object_unref(widget);
//gtk_widget_destroy(widget);
main_window = GTK_WINDOW (gtk_application_window_new (app));
int window_int_id = gtk_application_window_get_id (GTK_APPLICATION_WINDOW (main_window));
char window_char_id[40];
sprintf(window_char_id, "%d", window_int_id);
//printf ("gtk_application_window_id = %s = %d\n", window_char_id, window_int_id);
fsm_add_log (INFO, WIDGETS, "widget/manager", "gtk_application_window_get_id",
window_char_id);//"sprintf(window_id,...) << fails. Why ?");
//printf ("gtk_application_window_get_id (main_window) = %d\n",
//gtk_application_window_get_id (GTK_APPLICATION_WINDOW (main_window)));
widget_get_main_window (main_window, app);
gtk_window_present (GTK_WINDOW (main_window));
// g_object_unref (main_window); TODO get the closing signal of the 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)
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// 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 starts");
}