C L E A N ++ From there, I will work only in: fsm, widget, signal

This commit is contained in:
Jean Sirmai 2024-07-21 23:17:01 +02:00
parent b63ab7d93b
commit 11bcd85d68
Signed by: jean
GPG Key ID: FB3115C340E057E3
11 changed files with 83 additions and 89 deletions

View File

@ -37,8 +37,8 @@
/* S T A T E M A C H I N E */
/******************************************************************************/
enum choice_EXEC_EDIT { EXEC, EDIT }; // xor
enum choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor
enum fsm_choice_EXEC_EDIT { EXEC, EDIT }; // xor
enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor
int fsm_get_exec_edit ();
int fsm_get_state_rules_data ();

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Callbacks header *
* Signals header *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *

View File

@ -53,24 +53,23 @@ void *widget_get_text_window();
/* W I D G E T S */
/******************************************************************************/
GtkWidget *widget_rec_state_page();
GtkWidget *widget_rec_rules_page();
GtkWidget *widget_rec_stock_page();
void *widget_get_state_page();
void *widget_get_rules_page();
void *widget_get_stock_page();
void reset_all_objects_transparencies_to_value (int value);
void reset_all_situations_transparencies_to_value (int value);
void widget_reset_all_objects_transparencies_to_value (int value);
void widget_reset_all_situations_transparencies_to_value (int value);
GtkWidget *widget_rec_stock_text (gchar *text_name);
void *widget_get_stock_text (gchar *text_name);
/******************************************************************************/
/* M E N U */
/******************************************************************************/
struct MenuNode_t {gchar *text; struct MenuNode_t *child, *next;};
struct MenuNode_t *widget_create_user_menu_node (const gchar* text);
//struct MenuNode_t {gchar *text; struct MenuNode_t *child, *next;};
//struct MenuNode_t *widget_create_user_menu_node (const gchar* text);
GtkWidget *widget_rec_menu_anchor();
/******************************************************************************/
@ -81,37 +80,37 @@ struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;};
struct TreeNode_t *widget_create_user_tree_node (const gchar* text);
void widget_add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child);
void labo_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root);
GtkScrolledWindow *widget_rec_user_rules_tree ();
void *widget_get_user_rules_tree ();
/******************************************************************************/
/* I M A G E S */
/******************************************************************************/
// images are in : data / image /
// images are in : data / image /
// functions are in : widget / stock.c
GtkWidget *widget_rec_image_E_coli();
GtkWidget *widget_rec_image_GLUTAMATE();
GtkWidget *widget_rec_image_GLUTAMINE();
GtkWidget *widget_rec_image_ATP();
GtkWidget *widget_rec_image_AMP();
void *widget_get_image_E_coli();
void *widget_get_image_glutamate();
void *widget_get_image_glutamine();
void *widget_get_image_ATP();
void *widget_get_image_AMP();
/******************************************************************************/
/* T E X T S */
/******************************************************************************/
// texts are in : data / text /
// texts are in : data / text /
// functions are in : widget / stock.c
gchar *widget_rec_text_address_theory ();
gchar *widget_rec_text_address_about_commands ();
gchar *widget_rec_text_address_any ();
char *widget_get_text_address_theory ();
char *widget_get_text_address_about_commands ();
char *widget_get_text_address_any ();
/******************************************************************************/
/* L A B O */
/******************************************************************************/
void learning_how_to_create_a_menu (GtkMenuButton* menu_button);
void labo_create_a_simple_gtk_string_list ();
void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root);

View File

@ -73,7 +73,7 @@ void fsm_reset_all_objects_transparencies_at_value (int value)
debug_printing (value, 2); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
reset_all_objects_transparencies_to_value (value);
widget_reset_all_objects_transparencies_to_value (value);
}
void fsm_reset_all_situations_transparencies_at_value (int value)
@ -84,7 +84,7 @@ void fsm_reset_all_situations_transparencies_at_value (int value)
debug_printing (value, 3); // SITUATIONS_box_RESET_VALUE is sub_automaton 3
choice_SITUATIONS_box_RESET_VALUE = value;
reset_all_situations_transparencies_to_value (value);
widget_reset_all_situations_transparencies_to_value (value);
}
void fsm_set_situations_box_reset_value (int value)

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Callbacks header *
* Signals *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
@ -204,21 +204,21 @@ void on_save_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL,
{
gtk_widget_set_sensitive (GTK_WIDGET (data),
TRUE);
printf ("callback.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
printf ("signal.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
}
void on_discard_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL,
gpointer data)
{
gtk_window_close (GTK_WINDOW (data));
printf ("callback.c - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
printf ("signal.c - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
}
void on_write_current_model (GtkWidget *btt_WRITE_CURRENT_MODEL,
gpointer data)
{
gtk_window_close (GTK_WINDOW (data));
printf ("callback.c - WRITE_CURRENT_MODEL\n");
printf ("signal.c - WRITE_CURRENT_MODEL\n");
}
@ -233,21 +233,21 @@ static void switch_state_rules_data()
case (STATE) :
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_rec_state_page()));
GTK_WIDGET (widget_get_state_page()));
break;
case (RULES) :
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_rec_rules_page()));
GTK_WIDGET (widget_get_rules_page()));
break;
case (DATA) :
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_rec_stock_page()));
GTK_WIDGET (widget_get_stock_page()));
break;
default :
printf("default in callback.on_toggle_state_rule_data()\n");
printf("default in signal.on_toggle_state_rule_data()\n");
}
}
@ -273,6 +273,7 @@ void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data)
switch_state_rules_data();
}
// TODO Il doit y avoir plus élégant,...
void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data)
{
const char *toggled_button_name
@ -321,7 +322,7 @@ void on_clicked_search (GtkWidget *btt_menu, gpointer list_box) {
void on_clicked_home (GtkWidget *btt_reset, gpointer data)
{
printf ("callback.on_clicked_HOME() button presents the dialog_window\
printf ("signal.on_clicked_HOME() button presents the dialog_window\
( :- ) but it works only once.\n"); // TODO
gtk_window_present (GTK_WINDOW (widget_get_dialog_window()));
}
@ -355,14 +356,14 @@ void on_clicked_home (GtkWidget *btt_reset, gpointer data)
/******************************************************************************/
void on_clicked_menu_experiment (GtkWidget *btt_menu, gpointer list_box) {
printf ("callback.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
printf ("signal.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
// gpointer list_box = gtk_popover_get_child (GTK_POPOVER (pop));
/*
if (gtk_list_box_get_row_at_index (list_box, 3))
printf ("callback.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
else printf ("callback.on_clicked_MENU() button > in list_box are the three buttons : %s, %s, %s\n\
printf ("signal.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
else printf ("signal.on_clicked_MENU() button > in list_box are the three buttons : %s, %s, %s\n\
and now : how to display these three buttons (and make use of them) ? 2024-07-13 (20h)\n",\
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (gtk_list_box_get_row_at_index (list_box, 0)))),
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (gtk_list_box_get_row_at_index (list_box, 1)))),

View File

@ -68,20 +68,11 @@
/* C O N T A I N E R S */
/******************************************************************************/
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
// https://iconduck.com/sets/adwaita-icon-theme
// https://iconduck.com/sets/carbon-icons
// https://docs.gtk.org/gtk4/section-text-widget.html
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// https://docs.gtk.org/gtk4/class.TextView.html
// https://docs.gtk.org/gtk4/class.TextBuffer.html
// https://docs.gtk.org/gtk3/method.TextIter.get_text.html
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
void labo_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) {
void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) {
struct TreeNode_t *a = widget_create_user_tree_node("We, the people");widget_add_child_node(tree_root, a);
struct TreeNode_t *b = widget_create_user_tree_node("in Order to"); widget_add_child_node(tree_root, b);
struct TreeNode_t *c = widget_create_user_tree_node("do establish"); widget_add_child_node(tree_root, c);
@ -113,14 +104,6 @@ void labo_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t
struct TreeNode_t *cc = widget_create_user_tree_node("access"); widget_add_child_node(c, cc);
}
void labo_create_a_simple_gtk_string_list () {
char *array[] = {"one", "two", "three", "four", NULL};
GtkStringList *list = gtk_string_list_new ((const char * const *) array);
for (int i = 0; i < 4; i++)
printf ("in labo.a_simple_gtk_string_list() > list [%d + 1] = %s\n",\
i,
gtk_string_list_get_string (list, i));
}
/*
"rule effect"
@ -162,6 +145,16 @@ void labo_create_a_simple_gtk_string_list () {
*/
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
// https://iconduck.com/sets/adwaita-icon-theme
// https://iconduck.com/sets/carbon-icons
// https://docs.gtk.org/gtk4/section-text-widget.html
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// https://docs.gtk.org/gtk4/class.TextView.html
// https://docs.gtk.org/gtk4/class.TextBuffer.html
// https://docs.gtk.org/gtk3/method.TextIter.get_text.html
/* https://iconduck.com/sets/adwaita-icon-theme
https://iconduck.com/sets/carbon-icons < pas mal ...

View File

@ -40,14 +40,14 @@ static GtkWidget *rec_selected_rules_vpaned_new() {
gtk_paned_set_shrink_end_child (EXEC_CONTROLS_pane, FALSE);
GtkBox *up_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (up_box, GTK_WIDGET (widget_rec_image_GLUTAMATE()));
gtk_box_append (up_box, GTK_WIDGET (widget_get_image_glutamate()));
gtk_box_append (up_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
gtk_box_append (up_box, GTK_WIDGET (widget_rec_image_GLUTAMINE()));
gtk_box_append (up_box, GTK_WIDGET (widget_get_image_glutamine()));
GtkBox *bottom_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (bottom_box, GTK_WIDGET (widget_rec_image_ATP()));
gtk_box_append (bottom_box, GTK_WIDGET (widget_get_image_ATP()));
gtk_box_append (bottom_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
gtk_box_append (bottom_box, GTK_WIDGET (widget_rec_image_AMP()));
gtk_box_append (bottom_box, GTK_WIDGET (widget_get_image_AMP()));
gtk_paned_set_start_child (EXEC_CONTROLS_pane, GTK_WIDGET (up_box));
gtk_paned_set_end_child (EXEC_CONTROLS_pane, GTK_WIDGET (bottom_box));
@ -58,13 +58,13 @@ static GtkWidget *rec_selected_rules_vpaned_new() {
static GtkBox *rec_rules_comparator_new(){
GtkBox *comparator = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_widget_set_size_request (GTK_WIDGET (comparator), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_ATP()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_ATP()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_AMP()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_AMP()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_GLUTAMATE()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_glutamate()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_GLUTAMINE()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_glutamine()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/histidine.png")));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
@ -80,8 +80,8 @@ static GtkWidget *rec_rules_tree_hpaned_new(){
// GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre");
// GtkWidget *comparaison_des_règles_sélectionnées = gtk_frame_new ("Sélection");
gtk_paned_set_start_child (H_tree_vs_comparison, GTK_WIDGET (widget_rec_user_rules_tree()));
// GTK_SCROLLED_WINDOW
gtk_paned_set_start_child (H_tree_vs_comparison, GTK_WIDGET (widget_get_user_rules_tree()));
gtk_paned_set_end_child (H_tree_vs_comparison, GTK_WIDGET (rec_rules_comparator_new()));
gtk_paned_set_position (H_tree_vs_comparison, 300);
gtk_paned_set_wide_handle (H_tree_vs_comparison, TRUE);
@ -91,7 +91,7 @@ static GtkWidget *rec_rules_tree_hpaned_new(){
return GTK_WIDGET (H_tree_vs_comparison);
}
GtkWidget *widget_rec_rules_page() {
void *widget_get_rules_page() {
GtkPaned *H_tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL));
// GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre des règles");
// GtkWidget *édition_de_la_règle_sélectionnée_n_1 = gtk_frame_new ("Inspection");

View File

@ -91,7 +91,7 @@ static GtkBox *rec_ZOOM_box()
static GtkScrollbar *object_bar [n_objects];
static GtkAdjustment *object_adjust [n_objects];
void reset_all_objects_transparencies_to_value (int value)
void widget_reset_all_objects_transparencies_to_value (int value)
{
for (int i = 0; i < n_objects; i++)
if (value > -1)
@ -127,7 +127,7 @@ static GtkBox *rec_OBJECTS_box()
gtk_box_append (objects_box, GTK_WIDGET (object_bar [i]));
}
reset_all_objects_transparencies_to_value (-1);
widget_reset_all_objects_transparencies_to_value (-1);
return objects_box;
}
@ -135,7 +135,7 @@ static GtkBox *rec_OBJECTS_box()
static GtkScrollbar *situation_bar [n_situations];
static GtkAdjustment *situation_adjust [n_situations];
void reset_all_situations_transparencies_to_value (int value)
void widget_reset_all_situations_transparencies_to_value (int value)
{
for (int i = 0; i < n_situations; i++)
if (value > -1)
@ -173,7 +173,7 @@ static GtkBox *rec_SITUATIONS_box()
gtk_box_append (situations_box, GTK_WIDGET (situation_bar [i]));
}
reset_all_situations_transparencies_to_value (-1);
widget_reset_all_situations_transparencies_to_value (-1);
return situations_box;
}
@ -219,7 +219,7 @@ static GtkWidget *rec_SPACE_VIEW_box()
GtkBox *central_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
// TODO
gtk_box_append (central_box, GTK_WIDGET (widget_rec_image_E_coli()));
gtk_box_append (central_box, GTK_WIDGET (widget_get_image_E_coli()));
// ui_setup_glarea (0, GTK_WIDGET (central_box));
gtk_box_append (central_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
@ -270,7 +270,7 @@ static GtkWidget *rec_SEQUENCE_CONTROL_box()
* - CONTRAST en haut permet de modifier un à un les contrastes des objets et des situations
* afin de mieux mettre en évidence l'objet ou le phénomène d'intérêt */
GtkWidget *widget_rec_state_page()
void *widget_get_state_page()
{
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (page_box, GTK_WIDGET (rec_OBJECTS_and_SITUATIONS()));

View File

@ -31,7 +31,7 @@
#include "../../include/signal.h"
#include "../../include/widget.h"
GtkWidget *widget_rec_stock_page () {
void *widget_get_stock_page () {
GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 32));
GtkWidget* frame_rule_effect = gtk_frame_new ("rule effect");
@ -64,7 +64,7 @@ GtkWidget *widget_rec_stock_page () {
return GTK_WIDGET (data_box);
}
GtkWidget *widget_rec_stock_text (gchar *text_address) {
void *widget_get_stock_text (gchar *text_address) {
GtkWidget *view = gtk_text_view_new ();
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, read_file (text_address), -1);
@ -85,15 +85,15 @@ GtkWidget *widget_rec_stock_text (gchar *text_address) {
/* T E X T S */
/******************************************************************************/
gchar *widget_rec_text_address_theory () {
char *widget_get_text_address_theory () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/théorie.txt";
}
gchar *widget_rec_text_address_about_commands () {
char *widget_get_text_address_about_commands () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/about_commands.txt";
}
gchar *widget_rec_text_address_any () {
char *widget_get_text_address_any () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/any.txt";
}
@ -103,31 +103,31 @@ gchar *widget_rec_text_address_any () {
/* I M A G E S */
/******************************************************************************/
GtkWidget *widget_rec_image_E_coli(){
void *widget_get_image_E_coli(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/E coli by D Goodsell.png");
return image;
}
GtkWidget *widget_rec_image_GLUTAMATE(){
void *widget_get_image_glutamate(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamate.png");
return image;
}
GtkWidget *widget_rec_image_GLUTAMINE(){
void *widget_get_image_glutamine(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamine.png");
return image;
}
GtkWidget *widget_rec_image_ATP(){
void *widget_get_image_ATP(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/ATP.png");
return image;
}
GtkWidget *widget_rec_image_AMP(){
void *widget_get_image_AMP(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/AMP.png");
return image;

View File

@ -50,8 +50,8 @@ void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window)
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
gtk_window_set_titlebar (text_window, header_bar);
GtkWidget *child = widget_rec_stock_text (widget_rec_text_address_theory());
child = widget_rec_stock_text (widget_rec_text_address_about_commands());
GtkWidget *child = widget_get_stock_text (widget_get_text_address_theory());
child = widget_get_stock_text (widget_get_text_address_about_commands());
gtk_window_set_child (GTK_WINDOW (text_window), GTK_WIDGET (child));
gtk_widget_set_size_request (GTK_WIDGET (child), W_TEXT_WINDOW, H_TEXT_WINDOW);
@ -289,3 +289,4 @@ static void window_header_bar_right (GtkWidget *header_bar)
// gtk_button_set_icon_name (search, "preferences-desktop-appearance-symbolic");
// gtk_button_set_icon_name (search, "applications-utilities-symbolic");

View File

@ -83,10 +83,10 @@ static GListModel *get_user_tree_model (GObject *item, gpointer root)
return get_user_tree_model_child (cur);
}
GtkScrolledWindow *widget_rec_user_rules_tree ()
void *widget_get_user_rules_tree ()
{
struct TreeNode_t *tree_root = widget_create_user_tree_node("root");
labo_let_us_create_a_complex_useless_and_expensive_tree (tree_root);
widget_let_us_create_a_complex_useless_and_expensive_tree (tree_root);
GtkStringList *model = gtk_string_list_new(NULL);
gtk_string_list_append (model, tree_root->text);