WIP: cleaning, simplifying, organizing #include base.h

This commit is contained in:
Jean Sirmai 2024-06-05 10:15:12 +02:00
parent 37827eca73
commit 4d827bda0d
Signed by: jean
GPG Key ID: FB3115C340E057E3
24 changed files with 97 additions and 72 deletions

4
base.h
View File

@ -37,10 +37,10 @@
#include <glib-2.0/glib.h> #include <glib-2.0/glib.h>
//#define G_APPLICATION_DEFAULT_FLAGS 0 //#define G_APPLICATION_DEFAULT_FLAGS 0
enum { X_AXIS, Y_AXIS, Z_AXIS, N_AXIS }; // Graphical axis 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 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 struct arrow_t { uint load; uint site; uint x; uint y; uint z; }; // describes an arrow
static inline char *read_file(char *filename); 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 : /* I'm standing on Earth (or any spinning spheroid) and looking towards its North pole, then :
X - X = EAST - WEST = rouge - cyan X - X = EAST - WEST = rouge - cyan

3
callback.d Normal file
View File

@ -0,0 +1,3 @@
callback.o: callback.c tree.h \
/gnu/store/hsby4biv4wjywr7slvjf0ykk1xzf31xb-glib-2.78.0/include/glib-2.0/glib.h \
display.h contain.h texts.h in_depth.h

BIN
callback.o Normal file

Binary file not shown.

135
contain.c
View File

@ -150,6 +150,79 @@ GtkWidget *get_run_space_page_new(){
return GTK_WIDGET (page_box); return GTK_WIDGET (page_box);
} }
static void icons_for_fun (GtkHeaderBar *header_bar);
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));
// GtkWidget my_window_controls = *gtk_window_controls_new (GTK_PACK_END); // _START
// gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS(my_window_controls), NULL); // const char* layout);
GtkButton *run_stop_model_exec = GTK_BUTTON (gtk_toggle_button_new ());
gtk_button_set_icon_name (run_stop_model_exec, "system-shutdown-symbolic");
gtk_button_set_icon_name (run_stop_model_exec, "media-playback-pause-symbolic");
gtk_button_set_icon_name (run_stop_model_exec, "media-playback-start-symbolic");
g_signal_connect (run_stop_model_exec, "clicked", G_CALLBACK (ui_toggle_model_exec), NULL);
GtkButton *exec_xor_edit = GTK_BUTTON (gtk_toggle_button_new ());
// gtk_button_set_icon_name (exec_xor_edit, "system-run-symbolic");
// g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (ui_toggle_run_edit), NULL);
gtk_button_set_icon_name (exec_xor_edit, "document-edit-symbolic");
gtk_button_set_icon_name (exec_xor_edit, "text-editor-symbolic");
gtk_button_set_icon_name (exec_xor_edit, "system-run-symbolic");
g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (ui_toggle_exec_edit), run_stop_model_exec);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (exec_xor_edit));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (run_stop_model_exec));
gtk_window_set_titlebar (window, header_bar);
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
}
void two_notebooks_in_two_panes (GtkWindow *window) {
GtkNotebook *run_notebook = GTK_NOTEBOOK(gtk_notebook_new());
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(run_notebook), GTK_POS_TOP); // GTK_POS_LEFT
gtk_notebook_append_page (run_notebook, get_run_space_page_new(), gtk_label_new ("space"));
gtk_notebook_append_page (run_notebook, get_run_rules_page_new(), gtk_label_new ("rules"));
gtk_notebook_append_page (run_notebook, get_run_measures_page_new(),gtk_label_new ("measures"));
gtk_notebook_append_page (run_notebook, get_run_results_page_new(), gtk_label_new ("results"));
gtk_notebook_append_page (run_notebook, get_run_discuss_page_new(), gtk_label_new ("interpret"));
gtk_notebook_append_page (run_notebook, get_run_help_page_new(), gtk_label_new ("help"));
GtkNotebook *edit_notebook = GTK_NOTEBOOK(gtk_notebook_new());
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(edit_notebook), GTK_POS_TOP); // GTK_POS_RIGHT
gtk_notebook_append_page (edit_notebook, get_edit_space_page_new(), gtk_label_new ("space"));
gtk_notebook_append_page (edit_notebook, get_edit_rules_page_new(), gtk_label_new ("rules"));
gtk_notebook_append_page (edit_notebook, get_edit_measures_page_new(),gtk_label_new ("measures"));
gtk_notebook_append_page (edit_notebook, get_edit_results_page_new(), gtk_label_new ("results"));
gtk_notebook_append_page (edit_notebook, get_edit_discuss_page_new(), gtk_label_new ("interpret"));
gtk_notebook_append_page (edit_notebook, get_edit_help_page_new(), gtk_label_new ("help"));
GtkWidget *exec_xor_edit_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_size_request (exec_xor_edit_horizontal_pane, 0, 0);
gtk_paned_set_start_child (GTK_PANED(exec_xor_edit_horizontal_pane), GTK_WIDGET (run_notebook));
gtk_paned_set_end_child (GTK_PANED(exec_xor_edit_horizontal_pane), GTK_WIDGET (edit_notebook));
gtk_paned_set_position (GTK_PANED (exec_xor_edit_horizontal_pane), W_IMAGE + 350); // '350' : AD HOC
gtk_window_set_child (window, GTK_WIDGET(exec_xor_edit_horizontal_pane));
gtk_notebook_set_current_page (run_notebook, 0); // @see hot.c 2024-05-11 (line 68)
gtk_notebook_set_current_page (edit_notebook, 1); // @see hot.c 2024-05-11 (line 68)
}
static void icons_for_fun (GtkHeaderBar *header_bar) static void icons_for_fun (GtkHeaderBar *header_bar)
{ {
GtkButton *go_home = GTK_BUTTON (gtk_button_new ()); GtkButton *go_home = GTK_BUTTON (gtk_button_new ());
@ -220,65 +293,3 @@ static void icons_for_fun (GtkHeaderBar *header_bar)
gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic"); gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic");
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low)); gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low));
} }
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));
// GtkWidget my_window_controls = *gtk_window_controls_new (GTK_PACK_END); // _START
// gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS(my_window_controls), NULL); // const char* layout);
GtkButton *run_stop_model_exec = GTK_BUTTON (gtk_toggle_button_new ());
gtk_button_set_icon_name (run_stop_model_exec, "system-shutdown-symbolic");
gtk_button_set_icon_name (run_stop_model_exec, "media-playback-pause-symbolic");
gtk_button_set_icon_name (run_stop_model_exec, "media-playback-start-symbolic");
g_signal_connect (run_stop_model_exec, "clicked", G_CALLBACK (ui_toggle_model_exec), NULL);
GtkButton *exec_xor_edit = GTK_BUTTON (gtk_toggle_button_new ());
// gtk_button_set_icon_name (exec_xor_edit, "system-run-symbolic");
// g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (ui_toggle_run_edit), NULL);
gtk_button_set_icon_name (exec_xor_edit, "document-edit-symbolic");
gtk_button_set_icon_name (exec_xor_edit, "text-editor-symbolic");
gtk_button_set_icon_name (exec_xor_edit, "system-run-symbolic");
g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (ui_toggle_exec_edit), run_stop_model_exec);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (exec_xor_edit));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (run_stop_model_exec));
gtk_window_set_titlebar (window, header_bar);
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
}
void two_notebooks_in_two_panes (GtkWindow *window) {
GtkNotebook *run_notebook = GTK_NOTEBOOK(gtk_notebook_new());
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(run_notebook), GTK_POS_TOP); // GTK_POS_LEFT
gtk_notebook_append_page (run_notebook, get_run_space_page_new(), gtk_label_new ("space"));
gtk_notebook_append_page (run_notebook, get_run_rules_page_new(), gtk_label_new ("rules"));
gtk_notebook_append_page (run_notebook, get_run_measures_page_new(),gtk_label_new ("measures"));
gtk_notebook_append_page (run_notebook, get_run_results_page_new(), gtk_label_new ("results"));
gtk_notebook_append_page (run_notebook, get_run_discuss_page_new(), gtk_label_new ("interpret"));
gtk_notebook_append_page (run_notebook, get_run_help_page_new(), gtk_label_new ("help"));
GtkNotebook *edit_notebook = GTK_NOTEBOOK(gtk_notebook_new());
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(edit_notebook), GTK_POS_TOP); // GTK_POS_RIGHT
gtk_notebook_append_page (edit_notebook, get_edit_space_page_new(), gtk_label_new ("space"));
gtk_notebook_append_page (edit_notebook, get_edit_rules_page_new(), gtk_label_new ("rules"));
gtk_notebook_append_page (edit_notebook, get_edit_measures_page_new(),gtk_label_new ("measures"));
gtk_notebook_append_page (edit_notebook, get_edit_results_page_new(), gtk_label_new ("results"));
gtk_notebook_append_page (edit_notebook, get_edit_discuss_page_new(), gtk_label_new ("interpret"));
gtk_notebook_append_page (edit_notebook, get_edit_help_page_new(), gtk_label_new ("help"));
GtkWidget *exec_xor_edit_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_size_request (exec_xor_edit_horizontal_pane, 0, 0);
gtk_paned_set_start_child (GTK_PANED(exec_xor_edit_horizontal_pane), GTK_WIDGET (run_notebook));
gtk_paned_set_end_child (GTK_PANED(exec_xor_edit_horizontal_pane), GTK_WIDGET (edit_notebook));
gtk_paned_set_position (GTK_PANED (exec_xor_edit_horizontal_pane), W_IMAGE + 350); // '350' : AD HOC
gtk_window_set_child (window, GTK_WIDGET(exec_xor_edit_horizontal_pane));
gtk_notebook_set_current_page (run_notebook, 0); // @see hot.c 2024-05-11 (line 68)
gtk_notebook_set_current_page (edit_notebook, 1); // @see hot.c 2024-05-11 (line 68)
}

3
contain.d Normal file
View File

@ -0,0 +1,3 @@
contain.o: contain.c tree.h \
/gnu/store/hsby4biv4wjywr7slvjf0ykk1xzf31xb-glib-2.78.0/include/glib-2.0/glib.h \
display.h contain.h texts.h callback.h

BIN
contain.o Normal file

Binary file not shown.

3
display.d Normal file
View File

@ -0,0 +1,3 @@
display.o: display.c tree.h \
/gnu/store/hsby4biv4wjywr7slvjf0ykk1xzf31xb-glib-2.78.0/include/glib-2.0/glib.h \
display.h contain.h texts.h

BIN
display.o Normal file

Binary file not shown.

View File

@ -25,7 +25,6 @@
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
#include <glib-2.0/glib.h> #include <glib-2.0/glib.h>
#include "base.h"
#include "contain.h" #include "contain.h"
#include "graph_area.h" #include "graph_area.h"

6
graph_area.d Normal file
View File

@ -0,0 +1,6 @@
graph_area.o: graph_area.c \
/gnu/store/hsby4biv4wjywr7slvjf0ykk1xzf31xb-glib-2.78.0/include/glib-2.0/glib.h \
contain.h graph_area.h \
/gnu/store/0gxl8awg16qysdmxsflwnz0gyynrgs99-mesa-24.0.4/include/GL/glext.h \
/gnu/store/0gxl8awg16qysdmxsflwnz0gyynrgs99-mesa-24.0.4/include/KHR/khrplatform.h \
base.h

View File

@ -24,7 +24,6 @@
*/ */
#pragma once #pragma once
#include "base.h"
#include <unistd.h> #include <unistd.h>
#include <stdbool.h> #include <stdbool.h>
#include <epoxy/gl.h> #include <epoxy/gl.h>
@ -32,6 +31,8 @@
#include <GL/glext.h> #include <GL/glext.h>
#include <cglm/cglm.h> #include <cglm/cglm.h>
#include "base.h"
#define VERTEX_SHADER_FILE "src/graphics/shaders/shader.vert" #define VERTEX_SHADER_FILE "src/graphics/shaders/shader.vert"
#define FRAG_SHADER_FILE "src/graphics/shaders/shader.frag" #define FRAG_SHADER_FILE "src/graphics/shaders/shader.frag"
#define GL_TARGET_MAJOR_VERSION 0 #define GL_TARGET_MAJOR_VERSION 0

BIN
graph_area.o Normal file

Binary file not shown.

View File

@ -25,9 +25,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "base.h"
#include "contain.h" #include "contain.h"
//#include "parsing.h"
#include "graph_area.h" #include "graph_area.h"
#define TEST 0 #define TEST 0

1
in_depth.d Normal file
View File

@ -0,0 +1 @@
in_depth.o: in_depth.c callback.h

BIN
in_depth.o Normal file

Binary file not shown.

1
main.d Normal file
View File

@ -0,0 +1 @@
main.o: main.c callback.h

BIN
main.o Normal file

Binary file not shown.

BIN
myprogram Executable file

Binary file not shown.

View File

@ -33,8 +33,6 @@
#include <libxml/xmlreader.h> // http://xmlsoft.org/examples/#parse1.c #include <libxml/xmlreader.h> // http://xmlsoft.org/examples/#parse1.c
// https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/general.html // https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/general.html
#include "base.h"
#define READ_SITE 1 << 0 #define READ_SITE 1 << 0
#define READ_WEIGHT 1 << 1 #define READ_WEIGHT 1 << 1
#define READ_X 1 << 2 #define READ_X 1 << 2

View File

@ -25,8 +25,6 @@
#pragma once #pragma once
#include <unistd.h> #include <unistd.h>
#include "base.h"
bool model_init(const char *content, size_t length, const char *basename); bool model_init(const char *content, size_t length, const char *basename);
bool model_shutdown(void); bool model_shutdown(void);

1
texts.d Normal file
View File

@ -0,0 +1 @@
texts.o: texts.c

BIN
texts.o Normal file

Binary file not shown.

1
tree.d Normal file
View File

@ -0,0 +1 @@
tree.o: tree.c contain.h texts.h callback.h

BIN
tree.o Normal file

Binary file not shown.