diff --git a/(notes) b/(notes) index 0c84cd0..d23ac99 100644 --- a/(notes) +++ b/(notes) @@ -1,3 +1,8 @@ + + + +================================================================================ + jean@Project:~/Gem-Graph/gem-graph-client [env] $ nano ~/.gitconfig jean@Project:~/Gem-Graph/gem-graph-client [env] $ git commit -as < pour signer jean@Project:~/Gem-Graph/gem-graph-client [env] $ git config --global alias.commit commit - diff --git a/include/callbacks.h b/include/callbacks.h index 8bac52c..563f1d9 100644 --- a/include/callbacks.h +++ b/include/callbacks.h @@ -33,9 +33,7 @@ // void on_auto_notification (const char *message); -void on_main_window_activation (GtkApplication *app, gpointer user_data); -void on_dialog_window_activation (GtkApplication *app, gpointer user_data); -void on_text_window_activation (GtkApplication *app, gpointer user_data); +void on_windows_activation (GtkApplication *app, gpointer user_data); void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, gpointer user_data); void on_toggle_STATE_RULES_DATA (GtkWidget *btt, gpointer user_data); diff --git a/include/widgets.h b/include/widgets.h index be11b28..3e1207d 100644 --- a/include/widgets.h +++ b/include/widgets.h @@ -31,6 +31,10 @@ #include +/******************************************************************************/ +/* W I N D O W S */ +/******************************************************************************/ + void set_main_window (GtkApplication *app); void set_dialog_window (GtkApplication *app); void set_text_window (GtkApplication *app); @@ -45,6 +49,11 @@ GtkWindow *get_main_window(); GtkWindow *get_dialog_window(); GtkWindow *get_text_window(); + +/******************************************************************************/ +/* W I D G E T S */ +/******************************************************************************/ + GtkButton *get_GtkButton (char *btt_name); GtkWidget *get_STATE_page(); @@ -53,12 +62,20 @@ GtkWidget *get_STOCK_page(); GtkWidget *get_STOCK_text (gchar *text_name); + +/******************************************************************************/ +/* T R E E */ +/******************************************************************************/ + struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;}; -void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child); struct TreeNode_t *create_user_tree_node (const gchar* text); + +void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child); void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root); + GtkScrolledWindow *get_user_rules_tree (); + /******************************************************************************/ /* I M A G E S */ /******************************************************************************/ @@ -81,15 +98,11 @@ gchar *get_text_address_ABOUT_COMMANDS (); gchar *get_text_address_ANY (); - - - /******************************************************************************/ /* L A B O */ /******************************************************************************/ -void icons_for_fun (GtkHeaderBar *header_bar); -void go_to_the_lab (GtkMenuButton* menu_button); +void learning_how_to_create_a_menu (GtkMenuButton* menu_button); diff --git a/src/callbacks.c b/src/callbacks.c index 2825b37..f99f445 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -1,31 +1,34 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Gem-graph client * +* Gem-graph client * * * -* Callbacks * +* Callbacks header * * * -* Copyright © 2021 Libre en Communs * -* Copyright © 2023 Adrien Bourmault * -* Copyright © 2024 Jean Sirmai * +* Copyright © 2021 Libre en Communs * +* Copyright © 2021 Adrien Bourmault * +* Copyright © 2021 Jean Sirmai * * * * This file is part of Gem-graph. * * * -* This program is free software: you can redistribute it and/or modify it * -* under the terms of the GNU Affero General Public License * -* as publishedby the Free Software Foundation, * -* either version 3 of the License, or (at your option) any later version. * +* 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. * +* 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 . * +* You should have received a copy of the GNU Affero General Public License * +* along with this program. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include "../include/callbacks.h" #include "../include/widgets.h" #include "../include/graph.h" @@ -57,61 +60,20 @@ static void on_auto_notification (const char *message) /* W I N D O W S */ /******************************************************************************/ -void on_main_window_activation (GtkApplication *app, +void on_windows_activation (GtkApplication *app, gpointer no_user_data) { set_main_window (app); widget_MAIN_WINDOW_design (get_main_window()); - g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), NULL); - g_signal_connect (app, "activate", G_CALLBACK (on_text_window_activation), NULL); -} - -void on_dialog_window_activation (GtkApplication *app, - gpointer no_user_data) -{ set_dialog_window (app); - widget_DIALOG_WINDOW_design (get_main_window(), - get_dialog_window()); -} + widget_DIALOG_WINDOW_design (get_main_window(), get_dialog_window()); - -void on_text_window_activation (GtkApplication *app, - gpointer no_user_data) -{ set_text_window (app); - widget_TEXT_WINDOW_design (get_main_window(), - get_text_window()); + widget_TEXT_WINDOW_design (get_main_window(), get_text_window()); } - -void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, - gpointer data) { - gtk_widget_set_sensitive (GTK_WIDGET (data), - TRUE); - printf ("callback.c (line 286) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); -} - -void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, - gpointer data) { - gtk_window_close (GTK_WINDOW (data)); - printf ("callback.c (line 292) - 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 (line 300) - WRITE_CURRENT_MODEL\n"); -} - -void on_clicked_HOME (GtkWidget *btt_reset, gpointer data) { - printf ("callback.on_clicked_HOME() button presents the dialog_window ( :- ) but it works only once.\n"); - gtk_window_present (GTK_WINDOW (get_dialog_window())); // works once only ! -} - - - /******************************************************************************/ /* T R E E */ /******************************************************************************/ @@ -122,7 +84,7 @@ void on_user_tree_expander_toggled (GtkExpander *expander, GtkTreeListRow *row = GTK_TREE_LIST_ROW (user_data); gboolean is_expanded = gtk_tree_list_row_get_expanded (row); gtk_tree_list_row_set_expanded (row, - !is_expanded); + ! is_expanded); } @@ -134,7 +96,7 @@ void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, assert (list_item); GtkTreeListRow *row = gtk_list_item_get_item (list_item); - assert (row); // if (row != NULL) {...} do something ? + assert (row); // if (row != NULL) {...} do something ? TODO Check ! const gchar *text = gtk_string_object_get_string ( GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row))); @@ -252,7 +214,35 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data) /******************************************************************************/ -/* S T A T E */ +/* D I A L O G W I D G E T S */ +/******************************************************************************/ + +void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, + gpointer data) +{ + gtk_widget_set_sensitive (GTK_WIDGET (data), + TRUE); + printf ("callback.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); +} + +void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, + gpointer data) +{ + gtk_window_close (GTK_WINDOW (data)); + printf ("callback.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"); +} + + + +/******************************************************************************/ +/* S T A T E W I D G E T */ /******************************************************************************/ static void switch_STATE_RULES_DATA() @@ -341,7 +331,9 @@ void on_OBJECTS_box_DO_RESET (GtkWidget *btt_reset, gpointer data) NB Cette valeur sera la valeur choisie au moyen du curseur situé à gauche du bouton 'RESET'\n\ et elle sera lue par l'un des sous-automates qui déterminent l'état de la page 'ÉTAT'\n\ et reportée dans le module 'automat'.\n"); - set_OBJECTS_box_RESET_VALUE (1); // utiliser gpointer data pour transmettre la valeur choisie TODO + // utiliser gpointer data pour transmettre la valeur choisie TODO + + set_OBJECTS_box_RESET_VALUE (1); } void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data) @@ -350,9 +342,26 @@ void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, gpointer data) } +/******************************************************************************/ +/* M A I N W I N D O W H E A D E R W I D E T S */ +/******************************************************************************/ + + +void on_clicked_MENU (GtkWidget *btt_reset, gpointer menu_button) +{ + printf ("callback.on_clicked_MENU() button presents the text_window\ + and works only once.\nIt should present a menu.\n"); // TODO + learning_how_to_create_a_menu (menu_button); +} + +void on_clicked_HOME (GtkWidget *btt_reset, gpointer data) +{ + printf ("callback.on_clicked_HOME() button presents the dialog_window\ + ( :- ) but it works only once.\n"); // TODO + gtk_window_present (GTK_WINDOW (get_dialog_window())); +} -void on_clicked_MENU (GtkWidget *btt_reset, gpointer menu_button) {go_to_the_lab (menu_button);} // GTK itself does not support event sounds, << A GREAT WAY TO DEBUG ! TODO diff --git a/src/main.c b/src/main.c index 7002012..7a43ff9 100644 --- a/src/main.c +++ b/src/main.c @@ -143,13 +143,25 @@ */ + +/* L I S T E D E S F I C H I E R S A R E N O M M E R */ + +/* Tous les callbacks sont dans le fichier 'src/callbacks.c' + * et leur nom commence par: 'on_' + * (aucun autre nom de fonction ne commence par 'on_'). + + * Tous les fonctions appelées par les fonctions callback() sont dans 'widgets' + * SAUF: (en cours - 2024-07-08 7h50) + */ + + int main (int argc, char **argv) { GtkApplication *app; int status; app = gtk_application_new ("org.jean.gg_hack", G_APPLICATION_DEFAULT_FLAGS); - g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), 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); @@ -157,3 +169,7 @@ int main (int argc, char **argv) return status; } + +// GTK itself does not support event sounds, << A GREAT WAY TO DEBUG ! TODO +// you have to use a loadable module like the one that comes with libcanberra. + diff --git a/src/widget.c/heads.c b/src/widget.c/heads.c index 2ddaece..758dbbf 100644 --- a/src/widget.c/heads.c +++ b/src/widget.c/heads.c @@ -42,19 +42,23 @@ GtkWindow *get_main_window() {return main_window;} GtkWindow *get_dialog_window() {return dialog_window;} GtkWindow *get_text_window() {return text_window;} -void set_main_window (GtkApplication *app) { +void set_main_window (GtkApplication *app) +{ main_window = GTK_WINDOW (gtk_application_window_new (app)); } -void set_dialog_window (GtkApplication *app) { +void set_dialog_window (GtkApplication *app) +{ dialog_window = GTK_WINDOW (gtk_application_window_new (app)); } -void set_text_window (GtkApplication *app) { +void set_text_window (GtkApplication *app) +{ text_window = GTK_WINDOW (gtk_application_window_new (app)); } -GtkButton *get_GtkButton (char *btt_name) { +GtkButton *get_GtkButton (char *btt_name) +{ if (strcmp (btt_name, "state")) return btt_STATE; if (strcmp (btt_name, "rules")) return btt_RULES; if (strcmp (btt_name, "data analysis")) return btt_DATA; @@ -63,7 +67,8 @@ GtkButton *get_GtkButton (char *btt_name) { //------------------------------------------------------------------------------ -void widget_TEXT_WINDOW_design (GtkWindow *main_window, GtkWindow *text_window){ +void widget_TEXT_WINDOW_design (GtkWindow *main_window, GtkWindow *text_window) +{ char *title = " Learn more about Gem Graph. "; GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); @@ -79,7 +84,8 @@ void widget_TEXT_WINDOW_design (GtkWindow *main_window, GtkWindow *text_window){ gtk_window_set_destroy_with_parent (GTK_WINDOW (text_window), TRUE); } -void widget_DIALOG_WINDOW_design (GtkWindow *main_window, GtkWindow *dialog_window){ +void widget_DIALOG_WINDOW_design (GtkWindow *main_window, GtkWindow *dialog_window) +{ char *title = " Save the current model before modifying it? "; GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); @@ -114,7 +120,8 @@ void widget_DIALOG_WINDOW_design (GtkWindow *main_window, GtkWindow *dialog_wind //------------------------------------------------------------------------------ -static void window_header_bar (GtkWindow *window, char *title){ +static void window_header_bar (GtkWindow *window, char *title) +{ GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title)); gtk_window_set_titlebar (window, header_bar); diff --git a/src/widget.c/labo.c b/src/widget.c/labo.c index 7662338..86583df 100644 --- a/src/widget.c/labo.c +++ b/src/widget.c/labo.c @@ -39,8 +39,9 @@ /* */ /* Potentially dangerous experiments underway! */ /* Sensitive individuals should be accompanied */ +/* _______ */ /* */ -/* <> You who enter here, leave all hope of an accomplished code <> */ +/* <> You who enter here, leave all hope of an understandable code <> */ /* _______ */ /* */ /* Y O U E N T E R H E R E A T Y O U R O W N R I S K ! */ @@ -55,13 +56,13 @@ -void go_to_the_lab (GtkMenuButton* menu_button) { // Je veux que ce bouton ouvre un menu. +void learning_how_to_create_a_menu (GtkMenuButton* menu_button) { // Je veux que ce bouton ouvre un menu. gtk_window_present (GTK_WINDOW (get_text_window())); char *array[] = {"one", "two", "three", "four", NULL}; GtkStringList *list = gtk_string_list_new ((const char * const *) array); - printf ("labo.go_to_the_lab () > list [3] = %s\n", gtk_string_list_get_string (list, 2)); + printf ("labo.learning_how_to_create_a_menu () > list [3] = %s\n", gtk_string_list_get_string (list, 2)); // https://docs.gtk.org/gtk4/class.ListView.html // https://toshiocp.github.io/Gtk4-tutorial/sec29.html diff --git a/src/widget.c/state.c b/src/widget.c/state.c index 4b5cd11..8933311 100644 --- a/src/widget.c/state.c +++ b/src/widget.c/state.c @@ -38,17 +38,19 @@ #define LOWER_COMPARTMENT_PARTITION 1300 /* L'image de l'état de l'espace (au centre) est entourée par trois panneaux: - * - CONTROL ou EDIT en bas qui permet de contrôler / choisir un état et / ou de l'éditer - * en mode EDIT, seuls les outils d'édition de l'état sont disponibles - * en mode EXEC, seuls les outils de déplacement dans la séquence sont disponibles - * - CAMERA à droite qui permet de choisir la position de la caméra - * - CONTRAST en haut qui 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 */ + * Si on les nomme selon leur fonction, + * + * - CONTROL ou EDIT en bas permet de contrôler / choisir un état et / ou de l'éditer + * en mode EDIT, seuls les outils d'édition de l'état sont disponibles + * en mode EXEC, seuls les outils de déplacement dans la séquence sont disponibles + * - CAMERA à droite permet de choisir la position de la caméra + * - 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 */ GtkBox *get_XYZ_box() { GtkBox *XYZ_labels_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); // spacing = 2 - GtkBox *XYZ_scrollbar_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2 + GtkBox *XYZ_scrollbar_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // GtkWidget *scale_X = gtk_scale_button_new (0, 360, 10, NULL); < à étudier // (double min, double max, double step, const char** icons) GtkAdjustment *X_adjust = gtk_adjustment_new (rand() % 100, 0, 380, 1, 0, 0); @@ -101,6 +103,7 @@ static GtkBox *get_OBJECTS_box() GtkWidget *btt_reset = gtk_check_button_new_with_label ("reset"); g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_OBJECTS_box_DO_RESET), NULL); gtk_box_append (objects_box, btt_reset); + // Je veux pouvoir remettre tous les curseurs à ZÉRO ou à UN. TODO // À ZÉRO ou à UN ou à n'importe quelle valeur intermédiaire (la même pour tous) // de façon à pouvoir mieux observer, par contraste, les structures qui m'intéressent @@ -234,13 +237,15 @@ static GtkWidget *get_SEQUENCE_CONTROL_box() /* g e t S T A T E p a g e */ /******************************************************************************/ -/* L'image de l'état de l'espace (au centre) est entourée par trois panneaux: (à renommer ?) - * - CONTROL ou EDIT en bas qui permet de contrôler / choisir un état et / ou de l'éditer - * en mode EDIT, seuls les outils d'édition de l'état sont disponibles - * en mode EXEC, seuls les outils de déplacement dans la séquence sont disponibles - * - CAMERA à droite qui permet de choisir la position de la caméra - * - CONTRAST en haut qui 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 */ +/* L'image de l'état de l'espace (au centre) est entourée par trois panneaux: + * Si on les nomme selon leur fonction, + * + * - CONTROL ou EDIT en bas permet de contrôler / choisir un état et / ou de l'éditer + * en mode EDIT, seuls les outils d'édition de l'état sont disponibles + * en mode EXEC, seuls les outils de déplacement dans la séquence sont disponibles + * - CAMERA à droite permet de choisir la position de la caméra + * - 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 *get_STATE_page() {