<signal name=clicked handler=ui_toggle_sidebar /> (line 36) < ?

This commit is contained in:
Jean Sirmai 2024-05-26 07:37:38 +02:00
parent b978bcfe20
commit a7d74c81c1
Signed by: jean
GPG Key ID: FB3115C340E057E3
12 changed files with 87 additions and 44 deletions

View File

@ -41,10 +41,15 @@ NTHREADS= $(shell nproc)
CC=gcc CC=gcc
WARNINGS= -Wall WARNINGS= -Wall
# applications should be compiled with the -Wl,--export-dynamic argument inside their compiler flags, < ?
# and linked against gmodule-export-2.0. < ? TODO
DEBUG= -ggdb -fno-omit-frame-pointer -fdiagnostics-color=always -fsanitize=bounds -fstack-check DEBUG= -ggdb -fno-omit-frame-pointer -fdiagnostics-color=always -fsanitize=bounds -fstack-check
#-fsanitize=address \ #-fsanitize=address \
#-fsanitize=pointer-compare -fsanitize=pointer-subtract \ #-fsanitize=pointer-compare -fsanitize=pointer-subtract \
#-fsanitize=leak -fsanitize=undefined -fsanitize=null -fsanitize=bounds #-fsanitize=leak -fsanitize=undefined -fsanitize=null -fsanitize=bounds
OPTIMIZE= -O3 OPTIMIZE= -O3
INCLUDE= $(shell pkg-config --cflags glib-2.0 libxml-2.0 gtk4) INCLUDE= $(shell pkg-config --cflags glib-2.0 libxml-2.0 gtk4)
LIBS= $(shell pkg-config --libs glib-2.0 libxml-2.0 gtk4) -lGL -lGLU -lm -lepoxy -lX11 -lGLEW LIBS= $(shell pkg-config --libs glib-2.0 libxml-2.0 gtk4) -lGL -lGLU -lm -lepoxy -lX11 -lGLEW

View File

@ -28,7 +28,7 @@
/* E coli by David S. Goodsell (2009) */ /* E coli by David S. Goodsell (2009) */
/* --- */ /* --- */
/* Knowing that only a dynamic model can explain this phenomenon, */ /* Knowing that only a dynamic model can explain this phenomenon, */
/* let's let this beautiful freeze frame be our guide. */ /* let this beautiful freeze frame be our guide. */
/* */ /* */
/******************************************************************************/ /******************************************************************************/
@ -58,11 +58,6 @@
#define W_IMAGE_LOCAL W / 16 #define W_IMAGE_LOCAL W / 16
#define H_IMAGE_LOCAL H / 16 #define H_IMAGE_LOCAL H / 16
//GtkWidget *get_selected_rules_vpaned_new();
//void activate (GtkApplication *app, gpointer user_data);
// Graphical axis // Graphical axis
enum enum
{ {

View File

@ -2,8 +2,8 @@
/* */ /* */
/* E coli by David S. Goodsell (2009) */ /* E coli by David S. Goodsell (2009) */
/* --- */ /* --- */
/* Knowing that only a dynamic model can explain this phenomenon, */ /* Knowing that only a dynamic model can explore this phenomenon, */
/* let's let this beautiful freeze frame be our guide. */ /* let this beautiful freeze frame be our guide. */
/* */ /* */
/******************************************************************************/ /******************************************************************************/

View File

@ -2,8 +2,8 @@
/* */ /* */
/* E coli by David S. Goodsell (2009) */ /* E coli by David S. Goodsell (2009) */
/* --- */ /* --- */
/* Let this freeze frame guide us towards the model */ /* Knowing that only a dynamic model can explain this phenomenon, */
/* that alone can account for the phenomenon ! */ /* let this beautiful freeze frame be our guide. */
/* */ /* */
/******************************************************************************/ /******************************************************************************/

View File

@ -3,7 +3,7 @@
/* E coli by David S. Goodsell (2009) */ /* E coli by David S. Goodsell (2009) */
/* --- */ /* --- */
/* Knowing that only a dynamic model can explain this phenomenon, */ /* Knowing that only a dynamic model can explain this phenomenon, */
/* let's let this beautiful freeze frame be our guide. */ /* let this beautiful freeze frame be our guide. */
/* */ /* */
/******************************************************************************/ /******************************************************************************/

View File

@ -130,6 +130,16 @@ void on_glarea_realize(GtkWidget *widget);
void on_glarea_unrealize(GtkWidget *widget); void on_glarea_unrealize(GtkWidget *widget);
void on_close_window(GtkWidget *widget); void on_close_window(GtkWidget *widget);
/*
* A GtkBuilder holds a reference to all objects that it has constructed
* and drops these references when it is finalized.
* This finalization can cause the destruction of non-widget objects or widgets
* which are not contained in a toplevel window.
* For toplevel windows constructed by a builder, it is the responsibility of the user
* to call gtk_window_destroy() to get rid of them and all the widgets they contain.
* https://docs.gtk.org/gtk4/class.Builder.html
*/
void gtk_window_destroy (GtkWindow* window); // (in application.c) TODO ?
// //
// Tree-related events // Tree-related events

View File

@ -28,7 +28,31 @@
#include "../include/base.h" #include "../include/base.h"
#include "../include/ui.h" #include "../include/ui.h"
/* ----------------------- DOCUMENTATION ---------------------------------- */
// https://docs.gtk.org/gio/class.Application.html
// https://docs.gtk.org/glib/main-loop.html
// https://developer.gnome.org/documentation/tutorials/main-contexts.html
// https://developer.gnome.org/documentation/tutorials/lists.html
// https://developer.gnome.org/documentation/tutorials/application.html
// https://developer.gnome.org/documentation/introduction.html
// https://docs.gtk.org/gtk3/getting_started.html < WARNING Gtk3
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* The main entry point for your application should only create a GtkApplication instance,
* set up the signal handlers, and then call g_application_run().
* When saving and Loading Window State, you will need a GSettings schema,
* to define the keys, the type of the values, and default value for each key.
* Once you have a schema, you can map window properties to the GSettings keys defined by that schema
* To use GAction you should be using GtkApplication.
* GSimpleAction has two interesting signals: activate and change-state.
* You can add a GAction to anything implementing the GActionMap interface, including GtkApplication.
* This is done with g_action_map_add_action() and g_action_map_add_action_entries().
* Pre- and post-condition assertions are implemented using g_return_if_fail() and g_return_val_if_fail().
*
* https://docs.gtk.org/gtk4/class.Builder.html
* https://developer.gnome.org/documentation/tutorials/widget-templates.html
*/
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

View File

@ -24,8 +24,8 @@
#include "../../include/ui.h" #include "../../include/ui.h"
#define COMMUTE 1 // 0 first design (2023) based on <gemgraph.ui> XML data #define COMMUTE 0 // 0 first design (2023) based on <gemgraph.ui> XML data
// 1 2024 May design, free of the XML encryption mechanism // 1 2024 May design, free of Builder & templates
/* Window actual presentation on screen */ /* Window actual presentation on screen */
static void gem_graph_client_application_activate (GApplication *app) static void gem_graph_client_application_activate (GApplication *app)
@ -41,16 +41,15 @@ static void gem_graph_client_application_activate (GApplication *app)
NULL)); NULL));
switch(COMMUTE) { // enum {...} in ui.h switch(COMMUTE) { // enum {...} in ui.h
case GG_2023: case GG_2023: // Launch with sidebar of gtk_notebook_append_pagef
// Launch with sidebar of gtk_notebook_append_pagef
ui_toggle_sidebar(); ui_toggle_sidebar();
ui_set_stack (HOME_MODE); ui_set_stack (HOME_MODE);
ui_debug_model_loading (window, "data/models/dimers random walk.xml"); ui_debug_model_loading (window, "data/models/dimers random walk.xml");
// XXX the window closes when a leaf expander is clicked (Erreur de segmentation) // XXX the window closes when a leaf expander is clicked (Erreur de segmentation)
break; break;
case GG_2024_05: case GG_2024_05: // see > in contain.c
// see > in contain.c
experimental_activate_00 (app, window); experimental_activate_00 (app, window);
// ui_debug_model_loading (window, "data/models/dimers random walk.xml");
break; break;
default: default:
break; break;
@ -127,7 +126,7 @@ void ui_send_notification(const char *message)
static void gem_graph_client_application_class_init (GemGraphClientApplicationClass *klass) static void gem_graph_client_application_class_init (GemGraphClientApplicationClass *klass)
{ {
GApplicationClass *app_class = G_APPLICATION_CLASS(klass); GApplicationClass *app_class = G_APPLICATION_CLASS(klass);
// app_class->activate = experimental_activate_00;// (app, window); < ?? XXX
app_class->activate = gem_graph_client_application_activate; app_class->activate = gem_graph_client_application_activate;
} }
@ -142,3 +141,5 @@ GemGraphClientApplication *gem_graph_client_application_new(
"flags", flags, "flags", flags,
NULL); NULL);
} }
void gtk_window_destroy (GtkWindow* window) {printf("gtk_window_destroy() < TODO");}

View File

@ -45,11 +45,11 @@ GtkWidget *get_edit_help_page_new(){
GtkWidget *get_run_measures_page_new(){ GtkWidget *get_run_measures_page_new(){
GtkWidget *measures_grid = gtk_grid_new(); GtkWidget *measures_grid = gtk_grid_new();
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("movements"), 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("movements"), 0, 0, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transports"), 1, 0, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transports"), 1, 0, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transformations"), 2, 0, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transformations"), 2, 0, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("objects"), 0, 1, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("objects"), 0, 1, 1, 1);
gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("situations"), 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("situations"), 1, 1, 1, 1);
return measures_grid; return measures_grid;
} }
@ -102,7 +102,7 @@ GtkWidget *get_selected_rules_vpaned_new(){
GtkBox *up_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); GtkBox *up_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMATE())); gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMATE()));
gtk_box_append (up_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL))); gtk_box_append (up_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMINE())); gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMINE()));
/* /*
GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
@ -112,7 +112,7 @@ GtkWidget *get_selected_rules_vpaned_new(){
*/ */
GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); GtkBox *bottom_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (bottom_box, GTK_WIDGET (get_image_ATP())); gtk_box_append (bottom_box, GTK_WIDGET (get_image_ATP()));
gtk_box_append (bottom_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL))); gtk_box_append (bottom_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
gtk_box_append (bottom_box, GTK_WIDGET (get_image_AMP())); gtk_box_append (bottom_box, GTK_WIDGET (get_image_AMP()));
gtk_paned_set_start_child (V_selected_1_vs_2, GTK_WIDGET (up_box)); gtk_paned_set_start_child (V_selected_1_vs_2, GTK_WIDGET (up_box));
@ -132,7 +132,7 @@ GtkWidget *get_selected_rules_vpaned_new(){
GtkWidget *get_run_space_top_box(){ GtkWidget *get_run_space_top_box(){
GtkBox *top_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); GtkBox *top_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (top_box, GTK_WIDGET (get_ELAPSED_TIME_ProgressBar())); gtk_box_append (top_box, GTK_WIDGET (get_ELAPSED_TIME_ProgressBar()));
gtk_box_append (top_box, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_VERTICAL))); gtk_box_append (top_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
gtk_box_append (top_box, GTK_WIDGET (get_RUN_STOP_box())); gtk_box_append (top_box, GTK_WIDGET (get_RUN_STOP_box()));
return GTK_WIDGET (top_box); return GTK_WIDGET (top_box);
} }
@ -180,8 +180,8 @@ void window_bar(GtkWindow *window, char *title){
void experimental_activate_00 (GtkApplication *app, GtkWindow *window) { void experimental_activate_00 (GtkApplication *app, GtkWindow *window) {
window_bar (window, "E coli (with permission from David S. Goodsell, 2009)"); window_bar (window, "E coli (with permission from David S. Goodsell, 2009)");
GtkNotebook *run_notebook = GTK_NOTEBOOK(gtk_notebook_new()); 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_set_tab_pos (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_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_rules_page_new(), gtk_label_new ("rules"));
@ -190,8 +190,8 @@ void experimental_activate_00 (GtkApplication *app, GtkWindow *window) {
gtk_notebook_append_page (run_notebook, get_run_discuss_page_new(), gtk_label_new ("interpret")); 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")); gtk_notebook_append_page (run_notebook, get_run_help_page_new(), gtk_label_new ("help"));
GtkNotebook *edit_notebook = GTK_NOTEBOOK(gtk_notebook_new()); 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_set_tab_pos (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_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_rules_page_new(), gtk_label_new ("rules"));
@ -202,10 +202,10 @@ void experimental_activate_00 (GtkApplication *app, GtkWindow *window) {
GtkWidget *run_xor_edit_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); GtkWidget *run_xor_edit_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_widget_set_size_request (run_xor_edit_horizontal_pane, 0, 0); gtk_widget_set_size_request (run_xor_edit_horizontal_pane, 0, 0);
gtk_paned_set_start_child (GTK_PANED(run_xor_edit_horizontal_pane), GTK_WIDGET (run_notebook)); gtk_paned_set_start_child (GTK_PANED (run_xor_edit_horizontal_pane), GTK_WIDGET (run_notebook));
gtk_paned_set_end_child (GTK_PANED(run_xor_edit_horizontal_pane), GTK_WIDGET (edit_notebook)); gtk_paned_set_end_child (GTK_PANED(run_xor_edit_horizontal_pane), GTK_WIDGET (edit_notebook));
gtk_paned_set_position (GTK_PANED (run_xor_edit_horizontal_pane), W_IMAGE + 350); // '350' : AD HOC gtk_paned_set_position (GTK_PANED (run_xor_edit_horizontal_pane), W_IMAGE + 350); // '350' : AD HOC
gtk_window_set_child (window, GTK_WIDGET(run_xor_edit_horizontal_pane)); gtk_window_set_child (window, GTK_WIDGET (run_xor_edit_horizontal_pane));
gtk_notebook_set_current_page (run_notebook, 1); // @see hot.c 2024-05-11 (line 68) gtk_notebook_set_current_page (run_notebook, 1); // @see hot.c 2024-05-11 (line 68)
gtk_notebook_set_current_page (edit_notebook, 1); // @see hot.c 2024-05-11 (line 68) gtk_notebook_set_current_page (edit_notebook, 1); // @see hot.c 2024-05-11 (line 68)

View File

@ -3,7 +3,7 @@
/* E coli by David S. Goodsell (2009) */ /* E coli by David S. Goodsell (2009) */
/* --- */ /* --- */
/* Knowing that only a dynamic model can explain this phenomenon, */ /* Knowing that only a dynamic model can explain this phenomenon, */
/* let's let this beautiful freeze frame be our guide. */ /* let this beautiful freeze frame be our guide. */
/* */ /* */
/******************************************************************************/ /******************************************************************************/
@ -25,6 +25,7 @@ GtkWidget *get_image_ALL_SPACE(){
image = gtk_image_new_from_file("data/image/aXoris.png"); image = gtk_image_new_from_file("data/image/aXoris.png");
image = gtk_picture_new_for_filename ("data/image/gg sketch.png"); image = gtk_picture_new_for_filename ("data/image/gg sketch.png");
image = gtk_picture_new_for_filename ("data/image/E coli (Goodsell).png"); image = gtk_picture_new_for_filename ("data/image/E coli (Goodsell).png");
// ui_setup_glarea (RUN_MODE, GTK_WIDGET(image)); < un essai...
gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE, H_IMAGE); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE, H_IMAGE);
return image; return image;
} }

View File

@ -33,7 +33,8 @@
<property name="icon-name">sidebar-show-symbolic</property> <property name="icon-name">sidebar-show-symbolic</property>
<property name="tooltip-text" translatable="yes">Display/hide sidebar</property> <property name="tooltip-text" translatable="yes">Display/hide sidebar</property>
<property name="action-name">app.togglesidebar</property> <property name="action-name">app.togglesidebar</property>
</object> <signal name="clicked" handler="ui_toggle_sidebar" />
</object>
</child> </child>
</object> </object>
</child> </child>

View File

@ -108,20 +108,26 @@ char* ui_tree_create_model_func (GObject *item, gpointer root)
return ui_tree_get_children_model (cur); return ui_tree_get_children_model (cur);
} }
static void print_widget_hierarchy(GtkWidget *widget){
assert(widget);
printf("[src/ui/views.ui_create_tree (GtkWidget *w)] widgets hiercharchy : %s > %s > %s > %s > %s > %s > %s > %s\n",\
gtk_widget_get_name (GTK_WIDGET (gtk_widget_get_root (widget))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (widget)))))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (widget))))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (widget)))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (widget))),\
gtk_widget_get_name (gtk_widget_get_parent (widget)),\
gtk_widget_get_name (widget),\
gtk_widget_get_name (gtk_widget_get_first_child (widget))
);
}
// Application activation callback // Application activation callback
void ui_create_tree (GtkWidget *target_widget) void ui_create_tree (GtkWidget *target_widget)
{ {
assert(target_widget); assert(target_widget);
printf("[src/ui/views.ui_create_tree (GtkWidget *w)] widgets hiercharchy : %s > %s > %s > %s > %s > %s > %s > %s\n",\ print_widget_hierarchy(target_widget);
gtk_widget_get_name (GTK_WIDGET (gtk_widget_get_root (target_widget))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (target_widget)))))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (target_widget))))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (gtk_widget_get_parent (target_widget)))),\
gtk_widget_get_name (gtk_widget_get_parent (gtk_widget_get_parent (target_widget))),\
gtk_widget_get_name (gtk_widget_get_parent (target_widget)),\
gtk_widget_get_name (target_widget),\
gtk_widget_get_name (gtk_widget_get_first_child (target_widget))
);
// We don't want to add another tree in another scrolled_window into the current GtkBox, so : // We don't want to add another tree in another scrolled_window into the current GtkBox, so :
if (gtk_widget_get_first_child (target_widget)) return; if (gtk_widget_get_first_child (target_widget)) return;