From 0487a15b656c58afc8a11a21f1da72912e862e1c Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 30 Jun 2024 11:53:03 +0200 Subject: [PATCH] WIP: cleaning (headers, licences, authors, formats,...) --- include/automaton.h | 16 ----- include/base.h | 111 +++++++++++++++++++---------- include/callback.h | 31 +++++++- include/contain.h | 48 +++++++------ src/automaton.c | 26 ++++++- src/callback.c | 167 +++++++++++++++++++++++++++++++++----------- src/contain.c | 2 +- src/main.c | 41 ++++++++--- 8 files changed, 318 insertions(+), 124 deletions(-) delete mode 100644 include/automaton.h diff --git a/include/automaton.h b/include/automaton.h deleted file mode 100644 index 48e5517..0000000 --- a/include/automaton.h +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -enum choice_EXEC_EDIT { EXEC, EDIT }; -enum choice_STATE_RULES_DATA { STATE, RULES, DATA }; - // MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE }; ? - -void set_EXEC_EDIT (int prescribed); -void set_STATE_RULES_DATA (int prescribed); - -int get_EXEC_EDIT (); -int get_STATE_RULES_DATA (); - -// char *get_str_EXEC_EDIT (int value); -// char *get_str_STATE_RULES_DATA (int value); - diff --git a/include/base.h b/include/base.h index 365d60f..e6d460b 100644 --- a/include/base.h +++ b/include/base.h @@ -1,26 +1,31 @@ -/* - * Gem-graph OpenGL experiments - * - * Desc: Base header - * - * Copyright (C) 2023 Arthur Menges - * Copyright (C) 2023 Adrien Bourmault - * - * This file is part of Gem-graph. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Base header * +* * +* Copyright © 2021 Libre en Communs * +* Copyright © 2023 Adrien Bourmault * +* Copyright © 2023 Arthur Menges * +* Copyright © 2024 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 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 . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + #pragma once #include @@ -35,24 +40,60 @@ #include #include #include -//#define G_APPLICATION_DEFAULT_FLAGS 0 +#include + +// #define G_APPLICATION_DEFAULT_FLAGS 0 < work TODO here ? + + + +/******************************************************************************/ +/* 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 + +void set_EXEC_EDIT (int prescribed); +void set_STATE_RULES_DATA (int prescribed); + +int get_EXEC_EDIT (); +int get_STATE_RULES_DATA (); + + + +/******************************************************************************/ +/* S P A C E S T R U C T U R E S */ +/******************************************************************************/ + +enum { X_AXIS, Y_AXIS, Z_AXIS, N_AXIS }; // < used by graph_area.h + +struct arrow_t { uint load; uint site; uint x; uint y; uint z; }; + + + +/******************************************************************************/ +/* U T I L I T I E S */ +/******************************************************************************/ -enum { X_AXIS, Y_AXIS, Z_AXIS, N_AXIS }; // < used by : graph_area.h -enum { HOME_MODE, RUN_MODE, EDIT_MODE, PRESENTATION_MODE, N_MODE }; // Gem-graph modes -struct arrow_t { uint load; uint site; uint x; uint y; uint z; }; // describes an arrow static inline char *read_file(char *filename); // < used by : init.c -/* I'm standing on Earth (or any spinning spheroid) and looking towards its North pole, then : - X - X = EAST - WEST = rouge - cyan - Y - Y = ZENITH - NADIR = vert - magenta (fuschia) - Z - Z = NORTH - SOUTH = bleu - jaune */ +/* + I'm standing on Earth (or any spinning spheroid), + looking towards its North pole. -#define EAST 0 // + x rouge + Then : + + X - X = EAST - WEST = red - cyan + Y - Y = ZENITH - NADIR = green - magenta (fuschia) + Z - Z = NORTH - SOUTH = blue - yellow +*/ + +#define EAST 0 // + x red #define WEST 1 // - x cyan -#define ZENITH 2 // + y vert +#define ZENITH 2 // + y green #define NADIR 3 // - y magenta -#define SOUTH 4 // + z bleu -#define NORTH 5 // - z jaune +#define SOUTH 4 // + z blue +#define NORTH 5 // - z yellow /* diff --git a/include/callback.h b/include/callback.h index 678c9ba..d0e37ab 100644 --- a/include/callback.h +++ b/include/callback.h @@ -1,9 +1,38 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Callbacks header * +* * +* Copyright © 2021 Libre en Communs * +* Copyright © 2023 Adrien Bourmault * +* Copyright © 2024 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 distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * +* See the GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with this program. If not, see . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + + + #include +// 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_auto_notification (const char *message); void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data); void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data); diff --git a/include/contain.h b/include/contain.h index 23364c8..b062930 100644 --- a/include/contain.h +++ b/include/contain.h @@ -1,11 +1,30 @@ -//******************************************************************************/ -/* */ -/* E coli by David S. Goodsell (2009) */ -/* --- */ -/* Let this freeze frame guide us towards the model */ -/* that alone can account for the phenomenon ! */ -/* */ -/******************************************************************************/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Widgets header * +* * +* Copyright © 2021 Libre en Communs * +* Copyright © 2023 Adrien Bourmault * +* Copyright © 2024 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 distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * +* See the GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with this program. If not, see . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include @@ -17,19 +36,6 @@ #define W_IMAGE_LOCAL W / 16 #define H_IMAGE_LOCAL H / 16 -/* -G_BEGIN_DECLS -#define MY_TYPE_WINDOW (my_window_get_type()) -G_DECLARE_FINAL_TYPE (MyWindow, my_window, MY, WINDOW, GtkApplicationWindow) -G_END_DECLS - -G_BEGIN_DECLS -#define MY_TYPE_APPLICATION (my_application_get_type()) -G_DECLARE_FINAL_TYPE (MyApplication, my_application, MY, APPLICATION, GtkApplication) -MyApplication *my_application_new (const char *application_id, GApplicationFlags flags); -G_END_DECLS -*/ - void main_window_design (GtkWindow *main_window); void set_check_button_active (GtkButton *button, int active); void two_notebooks_in_two_panes (GtkWindow *window); diff --git a/src/automaton.c b/src/automaton.c index 7248434..ebfa103 100644 --- a/src/automaton.c +++ b/src/automaton.c @@ -1,7 +1,31 @@ +//=-------------------------------------------------------------------------=// +// Main // +// // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2024 Jean Sirmai (jean@a-lec.org) // +// Copyright © 2024 Adrien Bourmault (neox@a-lec.org) // +// // +// This file is part of gem-graph. // +// // +// This program is free software: you can redistribute it and/or modify // +// it under the terms of the GNU Affero General Public License as // +// published by the Free Software Foundation, either version 3 of the // +// License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU Affero General Public License for more details. // +// // +// You should have received a copy of the GNU Affero General Public License // +// along with this program. If not, see . // +//=-------------------------------------------------------------------------=// + + #include #include +#include "../include/base.h" #include "../include/callback.h" -#include "../include/automaton.h" /******************************************************************************/ diff --git a/src/callback.c b/src/callback.c index 05b2c38..053e1fd 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1,3 +1,28 @@ +//----------------------------------------------------------------------------// +// // +// callback // +// // +// Copyright © 2021 Libre en Communs (contact@a-lec.org) // +// Copyright © 2024 Jean Sirmai (jean@a-lec.org) // +// Copyright © 2024 Adrien Bourmault (neox@a-lec.org) // +// // +// This file is part of gem-graph. // +// // +// This program is free software: you can redistribute it and/or modify // +// it under the terms of the GNU Affero General Public License as // +// published by the Free Software Foundation, either version 3 of the // +// License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU Affero General Public License for more details. // +// // +// You should have received a copy of the GNU Affero General Public License // +// along with this program. If not, see . // +//---------------------------------------------------------------------------// + + #include #include @@ -7,33 +32,42 @@ #include "../include/contain.h" #include "../include/dialog.h" #include "../include/texts.h" -#include "../include/automaton.h" +#include "../include/base.h" #include "../include/parsing.h" #include "../include/graph_area.h" + /******************************************************************************/ -/* W I N D O W S A C T I V A T I O N */ +/* W I N D O W S A C T I V A T I O N S */ /******************************************************************************/ static GtkWindow *main_window, *dialog_window; -void on_main_window_activation (GtkApplication *app, gpointer no_user_data) + +void on_main_window_activation (GtkApplication *app, + gpointer no_user_data) { main_window = GTK_WINDOW (gtk_application_window_new (app)); main_window_design (main_window); - g_signal_connect (app, "activate", G_CALLBACK (on_dialog_window_activation), main_window); + g_signal_connect (app, + "activate", + G_CALLBACK (on_dialog_window_activation), + main_window); } -void on_dialog_window_activation (GtkApplication *app, gpointer no_user_data) + +void on_dialog_window_activation (GtkApplication *app, + gpointer no_user_data) { dialog_window = GTK_WINDOW (gtk_application_window_new (app)); - dialog_window_design (main_window, dialog_window); + dialog_window_design (main_window, + dialog_window); } -void on_auto_notification (const char *message) +static void on_auto_notification (const char *message) { - /* Ignored (2024-06-06) because I don't know how to get "main_window" easily + /* Ignored (2024-06-06) because I don't know how to get "main_window" easily if (window->toast_revealer == NULL) { g_printerr("Can't find app->toast_overlay !\n"); @@ -51,32 +85,53 @@ void on_auto_notification (const char *message) g_printerr("%s\n", message); } + /******************************************************************************/ /* T R E E */ /******************************************************************************/ -void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data) + +void on_user_tree_expander_toggled (GtkExpander *expander, + gpointer user_data) { 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); + gboolean is_expanded = gtk_tree_list_row_get_expanded (row); + gtk_tree_list_row_set_expanded (row, + !is_expanded); } -void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data) + +void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, + GObject* object, + gpointer user_data) { - GtkListItem *list_item = GTK_LIST_ITEM (object); assert (list_item); - GtkTreeListRow *row = gtk_list_item_get_item (list_item); assert (row); // if (row != NULL) {...} ? - const gchar *text = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row))); + GtkListItem *list_item = GTK_LIST_ITEM (object); + assert (list_item); + + GtkTreeListRow *row = gtk_list_item_get_item (list_item); + assert (row); // if (row != NULL) {...} do something ? + + const gchar *text = gtk_string_object_get_string ( + GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row))); GtkWidget *expander = gtk_list_item_get_child (list_item); gtk_expander_set_label (GTK_EXPANDER (expander), text); - g_signal_handlers_disconnect_by_func(expander, G_CALLBACK (on_user_tree_expander_toggled), row); - g_signal_connect(expander, "activate", G_CALLBACK (on_user_tree_expander_toggled), row); - gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row) * 20); + g_signal_handlers_disconnect_by_func (expander, + G_CALLBACK (on_user_tree_expander_toggled), + row); + g_signal_connect (expander, + "activate", + G_CALLBACK (on_user_tree_expander_toggled), + row); + gtk_widget_set_margin_start (expander, + gtk_tree_list_row_get_depth(row) * 20); } + /******************************************************************************/ /* G L A R E A */ /******************************************************************************/ -gboolean on_glarea_render(GtkGLArea *area, GdkGLContext *context) + +gboolean on_glarea_render(GtkGLArea *area, + GdkGLContext *context) { // Check if the widget is a glarea if(gtk_gl_area_get_error(area) != NULL) { @@ -168,23 +223,42 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data) /******************************************************************************/ static void switch_STATE_RULES_DATA() { + switch (get_STATE_RULES_DATA()) { - case (STATE) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE())); break; - case (RULES) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES())); break; - case (DATA) : gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA())); break; - default : printf("default in callback.on_toggle_STATE_RULES_DATA()\n"); + + case (STATE) : + gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_STATE())); + break; + + case (RULES) : + gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_RULES())); + break; + + case (DATA) : + gtk_window_set_child (main_window, GTK_WIDGET (get_window_child_DATA())); + break; + + default : + printf("default in callback.on_toggle_STATE_RULES_DATA()\n"); } } void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data) { if (get_EXEC_EDIT ()) { - gtk_button_set_icon_name (GTK_BUTTON (toggled_button), "power-profile-balanced-rtl-symbolic"); + + gtk_button_set_icon_name (GTK_BUTTON (toggled_button), + "power-profile-balanced-rtl-symbolic"); set_EXEC_EDIT (EXEC); + } else { - gtk_button_set_icon_name (GTK_BUTTON (toggled_button), "text-editor-symbolic"); - // https://docs.gtk.org/gtk4/class.Window.html TODO - gtk_window_present (GTK_WINDOW (dialog_window)); + + gtk_button_set_icon_name (GTK_BUTTON (toggled_button), + "text-editor-symbolic"); + + // https://docs.gtk.org/gtk4/class.Window.html TODO 2024-06-30 + gtk_window_present (GTK_WINDOW (dialog_window)); // works once only ! + set_EXEC_EDIT (EDIT); } @@ -193,28 +267,43 @@ void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data) { void on_toggle_STATE_RULES_DATA (GtkWidget *toggled_button, gpointer user_data) { - const char *toggled_button_name = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button)); + const char *toggled_button_name + = gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button)); int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button)); - if (! strcmp (toggled_button_name, "state")) set_STATE_RULES_DATA (STATE); - if (! strcmp (toggled_button_name, "rules")) set_STATE_RULES_DATA (RULES); - if (! strcmp (toggled_button_name, "data analysis")) set_STATE_RULES_DATA (DATA); + if (! strcmp (toggled_button_name, "state")) { + set_STATE_RULES_DATA (STATE); + } - if (is_active) switch_STATE_RULES_DATA(); + if (! strcmp (toggled_button_name, "rules")) { + set_STATE_RULES_DATA (RULES); + } + + if (! strcmp (toggled_button_name, "data analysis")) { + set_STATE_RULES_DATA (DATA); + } + + if (is_active) { + switch_STATE_RULES_DATA(); + } } -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 201) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); +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 294) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); } -void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { +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 206) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n"); + printf ("callback.c (line 300) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n"); } -void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) { +void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, + gpointer data) { gtk_window_close (GTK_WINDOW (data)); - printf ("callback.c (line 211) - WRITE_CURRENT_MODEL\n"); + printf ("callback.c (line 306) - WRITE_CURRENT_MODEL\n"); } diff --git a/src/contain.c b/src/contain.c index e08b1d4..61e2abf 100644 --- a/src/contain.c +++ b/src/contain.c @@ -3,7 +3,7 @@ #include "../include/graph_area.h" #include "../include/callback.h" -#include "../include/automaton.h" +#include "../include/base.h" #include "../include/display.h" #include "../include/tree.h" #include "../include/texts.h" diff --git a/src/main.c b/src/main.c index 2502cbb..cb0f0cd 100644 --- a/src/main.c +++ b/src/main.c @@ -1,11 +1,31 @@ -/******************************************************************************/ -/* */ -/* E coli by David S. Goodsell (2009) */ -/* --- */ -/* Let this freeze frame guide us towards the model */ -/* that alone can account for the phenomenon ! */ -/* */ -/******************************************************************************/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Main * +* * +* Copyright © 2021 Libre en Communs * +* Copyright © 2023 Adrien Bourmault * +* Copyright © 2023 Arthur Menges * +* Copyright © 2024 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 distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * +* See the GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with this program. If not, see . * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include "../include/callback.h" @@ -14,13 +34,14 @@ int main (int argc, char **argv) GtkApplication *app; int status; - app = gtk_application_new ("org.jean.GTK4_GG_hack", G_APPLICATION_DEFAULT_FLAGS); + 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_dialog_window_activation), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); - printf("in contain.get_SPACE_VIEW_box() (line 138) > ui_setup_glarea (0, GTK_WIDGET (middle_box)); < commented 2024/06/27 > TODO\n"); + printf("\nTODO (2024-06-30) OpenGL see : contain.get_SPACE_VIEW_box()\ +\nline 138 > ui_setup_glarea (0, GTK_WIDGET (middle_box));\n\n"); return status; }