diff --git a/include/widgets.h b/include/widgets.h index 18e7350..f66c917 100644 --- a/include/widgets.h +++ b/include/widgets.h @@ -33,18 +33,18 @@ void set_main_window (GtkApplication *app); void set_dialog_window (GtkApplication *app); -void main_window_design (GtkWindow *main_window); -void dialog_window_design (GtkWindow *main_window, - GtkWindow *dialog_window); +void widget_MAIN_WINDOW_design (GtkWindow *main_window); +void widget_DIALOG_WINDOW_design (GtkWindow *main_window, + GtkWindow *dialog_window); GtkWindow *get_main_window(); GtkWindow *get_dialog_window(); GtkButton *get_GtkButton (char *btt_name); -GtkWidget *get_window_child_STATE(); -GtkWidget *get_window_child_RULES(); -GtkWidget *get_window_child_DATA(); +GtkWidget *widget_get_STATE_page(); +GtkWidget *widget_get_RULES_page(); +GtkWidget *widget_get_STOCK_page(); //-------------------------------------------------------- @@ -59,6 +59,7 @@ GtkWidget *get_rules_page_new(); GtkWidget *get_text_view(); //GtkWidget *get_image_ALL_SPACE(); +/* GtkWidget *get_image_GLUTAMATE(); GtkWidget *get_image_GLUTAMINE(); GtkWidget *get_image_HISTIDINE(); @@ -67,17 +68,17 @@ GtkWidget *get_image_PHENYLALANINE(); GtkWidget *get_image_DOPAMINE(); GtkWidget *get_image_ATP(); GtkWidget *get_image_AMP(); - +*/ GtkFrame *get_frame_with_label(); GtkProgressBar *get_ELAPSED_TIME_ProgressBar(); //GtkBox *get_RUN_STOP_box(); -GtkBox *get_ZOOM_box(); -GtkBox *get_edit_TOOL_box(); -GtkBox *get_XYZ_box(); -GtkBox *get_rules_user_tree_new(); -GtkBox *get_ELAPSED_TIME_box(); +//GtkBox *get_ZOOM_box(); +//GtkBox *get_edit_TOOL_box(); +//GtkBox *get_XYZ_box(); +//GtkBox *get_rules_user_tree_new(); +//GtkBox *get_ELAPSED_TIME_box(); struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;}; void add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child); diff --git a/src/callbacks.c b/src/callbacks.c index 6a8d8c3..504746d 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -39,7 +39,7 @@ void on_main_window_activation (GtkApplication *app, gpointer no_user_data) { set_main_window (app); - main_window_design (get_main_window()); + widget_MAIN_WINDOW_design (get_main_window()); } @@ -47,10 +47,8 @@ void on_dialog_window_activation (GtkApplication *app, gpointer no_user_data) { set_dialog_window (app); - dialog_window_design (get_main_window(), - get_dialog_window()); - - if (0) gtk_window_present (GTK_WINDOW (get_dialog_window())); + widget_DIALOG_WINDOW_design (get_main_window(), + get_dialog_window()); } @@ -223,15 +221,18 @@ static void switch_STATE_RULES_DATA() { switch (get_STATE_RULES_DATA()) { case (STATE) : - gtk_window_set_child (get_main_window(), GTK_WIDGET (get_window_child_STATE())); + gtk_window_set_child (get_main_window(), + GTK_WIDGET (widget_get_STATE_page())); break; case (RULES) : - gtk_window_set_child (get_main_window(), GTK_WIDGET (get_window_child_RULES())); + gtk_window_set_child (get_main_window(), + GTK_WIDGET (widget_get_RULES_page())); break; case (DATA) : - gtk_window_set_child (get_main_window(), GTK_WIDGET (get_window_child_DATA())); + gtk_window_set_child (get_main_window(), + GTK_WIDGET (widget_get_STOCK_page())); break; default : diff --git a/src/graph.c/draw.c b/src/graph.c/draw.c index 6fb32dc..9a0c42c 100644 --- a/src/graph.c/draw.c +++ b/src/graph.c/draw.c @@ -47,7 +47,7 @@ void graph_draw_vertex (const int stack_id, //g_printerr("stack_id is %d\n", stack_id); //g_printerr("graphic_stack is at %p\n", graphic_stack); //g_printerr("graphic_stack[stack_id] is at %p\n", graphic_stack + stack_id); - volatile struct graph_stack_t *graph_stack = &graph_stack[stack_id]; + volatile struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO //g_printerr("Currently stack->buffer_vertex_origin @ %p\n", stack->buffer_vertex_origin); @@ -77,7 +77,7 @@ void graph_draw_color (const int stack_id, GLfloat g, GLfloat b) { - struct graph_stack_t *graph_stack = &graph_stack[stack_id]; + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO graph_stack->buffer_colors_origin = g_realloc (graph_stack->buffer_colors_origin, (graph_stack->buffer_colors_size + 3) * sizeof(GLfloat)); @@ -102,7 +102,7 @@ void graph_draw_line (const int stack_id, GLuint a, GLuint b) { - struct graph_stack_t *stack = &graph_stack[stack_id]; + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO graph_stack->buffer_lines_origin = g_realloc (graph_stack->buffer_lines_origin, (graph_stack->buffer_lines_size + 2) * sizeof(GLuint)); diff --git a/src/graph.c/init.c b/src/graph.c/init.c index 526f735..104e6b9 100644 --- a/src/graph.c/init.c +++ b/src/graph.c/init.c @@ -37,7 +37,7 @@ */ void graph_init_buffers(const int stack_id) { - struct graph_stack_t *graph_stack = &graph_stack[stack_id]; + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO //XXX graph_model_setup(stack_id); @@ -81,7 +81,7 @@ void graph_init_buffers(const int stack_id) */ bool graph_init_shaders(const int stack_id) { - struct graph_stack_t *graph_stack = &graph_stack[stack_id]; + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO char *vertex_shader; char *fragment_shader; int status; diff --git a/src/graph.c/stack.c b/src/graph.c/stack.c index c3767cd..51c8b03 100644 --- a/src/graph.c/stack.c +++ b/src/graph.c/stack.c @@ -108,12 +108,12 @@ static void graph_debug_callback(GLenum source, GLenum type, GLuint id, int graph_init(void *error_buffer) { int cur_id = 0; - struct graph_stack_t *graph_stack; + struct graph_stack_t *graph_stack = NULL; g_printerr("[debug] graph_init()\n"); if (graph_stack == NULL) { - graph_stack = g_malloc0(sizeof(struct graph_stack_t)); + graph_stack = g_malloc0 (sizeof(struct graph_stack_t)); graph_stack_size = 1; g_printerr("[debug] graph_init(): init graph_stack @ %p\n", graph_stack); } else { @@ -122,12 +122,12 @@ int graph_init(void *error_buffer) // We get the last free slot registered cur_id = free_stack_slot[free_stack_slot_size-1]; // Unregister it (ofc) - free_stack_slot = g_realloc(free_stack_slot, + free_stack_slot = g_realloc (free_stack_slot, free_stack_slot_size-- * sizeof(int)); } else { cur_id = graph_stack_size; - graph_stack = g_realloc(graph_stack, + graph_stack = g_realloc (graph_stack, ++graph_stack_size * sizeof(struct graph_stack_t)); } @@ -168,7 +168,7 @@ int graph_init(void *error_buffer) */ bool graph_shutdown(const int id, void *error_buffer) { - struct graph_stack_t *graph_stack; + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO if (id >= graph_stack_size || graph_stack_size == 0 || @@ -233,7 +233,7 @@ void graph_model_setup (const int stack_id) /*------------------------------------------------------------------------*/ - struct graph_stack_t *graph_stack = &graph_stack[stack_id]; + struct graph_stack_t *graph_stack = NULL; // *graph_stack = &graph_stack[stack_id]; TODO char dimension; long space_X; long space_Y; diff --git a/src/widget.c/dialog.c b/src/widget.c/dialog.c deleted file mode 100644 index e5f0589..0000000 --- a/src/widget.c/dialog.c +++ /dev/null @@ -1,64 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * -* * -* Gem-graph client * -* * -* Dialog window * -* * -* Copyright © 2021 Libre en Communs * -* 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/callbacks.h" - -void 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)); - gtk_window_set_titlebar (dialog_window, header_bar); - - GtkWidget *dialog_window_grid = gtk_grid_new (); - - const char *txt = " SAVE CURRENT MODEL "; - GtkButton *action_save_current_model = GTK_BUTTON (gtk_button_new_with_label (txt)); - gtk_widget_set_sensitive (GTK_WIDGET (action_save_current_model), FALSE); - g_signal_connect (action_save_current_model, "clicked", - G_CALLBACK (on_WRITE_CURRENT_MODEL), dialog_window); - - GtkButton *click_yes = GTK_BUTTON (gtk_button_new_with_label ("YES")); - g_signal_connect (click_yes, "clicked", - G_CALLBACK (on_SAVE_CURRENT_MODEL_BEFORE_EDITING), action_save_current_model); - - GtkButton *click_no = GTK_BUTTON (gtk_button_new_with_label ("NO")); - g_signal_connect (click_no, "clicked", - G_CALLBACK (on_DISCARD_CURRENT_MODEL_AND_START_EDITING), dialog_window); - - gtk_grid_attach (GTK_GRID (dialog_window_grid), GTK_WIDGET (click_yes), 0, 0, 1, 1) ; - gtk_grid_attach (GTK_GRID (dialog_window_grid), GTK_WIDGET (click_no), 1, 0, 1, 1) ; - gtk_grid_attach (GTK_GRID (dialog_window_grid), GTK_WIDGET (action_save_current_model), 0, 2, 2, 1) ; - gtk_window_set_child (GTK_WINDOW (dialog_window), GTK_WIDGET (dialog_window_grid)); - - gtk_window_set_transient_for (GTK_WINDOW (dialog_window), GTK_WINDOW (main_window)); - gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog_window), TRUE); - gtk_window_set_deletable (GTK_WINDOW (dialog_window), FALSE); // FALSE - gtk_window_set_modal (GTK_WINDOW (dialog_window), TRUE); -// gtk_window_present (GTK_WINDOW (dialog_window)); see button... -} - - diff --git a/src/widget.c/heads.c b/src/widget.c/heads.c new file mode 100644 index 0000000..88d41e1 --- /dev/null +++ b/src/widget.c/heads.c @@ -0,0 +1,145 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Main * +* * +* 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 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/base.h" +#include "../../include/callbacks.h" +#include "../../include/widgets.h" + +static GtkWindow *main_window, *dialog_window; +static GtkButton *btt_open_STATE, *btt_open_RULES, *btt_open_DATA; + +GtkWindow *get_main_window() {return main_window;} +GtkWindow *get_dialog_window() {return dialog_window;} + +void set_main_window (GtkApplication *app) { + main_window = GTK_WINDOW (gtk_application_window_new (app)); +} + +void set_dialog_window (GtkApplication *app) { + dialog_window = GTK_WINDOW (gtk_application_window_new (app)); +} + +//------------------------------------------------------------------------------ + +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)); + gtk_window_set_titlebar (dialog_window, header_bar); + + GtkWidget *dialog_window_grid = gtk_grid_new (); + + const char *txt = " SAVE CURRENT MODEL "; + GtkButton *action_save_current_model = GTK_BUTTON (gtk_button_new_with_label (txt)); + gtk_widget_set_sensitive (GTK_WIDGET (action_save_current_model), FALSE); + g_signal_connect (action_save_current_model, "clicked", + G_CALLBACK (on_WRITE_CURRENT_MODEL), dialog_window); + + GtkButton *click_yes = GTK_BUTTON (gtk_button_new_with_label ("YES")); + g_signal_connect (click_yes, "clicked", + G_CALLBACK (on_SAVE_CURRENT_MODEL_BEFORE_EDITING), action_save_current_model); + + GtkButton *click_no = GTK_BUTTON (gtk_button_new_with_label ("NO")); + g_signal_connect (click_no, "clicked", + G_CALLBACK (on_DISCARD_CURRENT_MODEL_AND_START_EDITING), dialog_window); + + gtk_grid_attach (GTK_GRID (dialog_window_grid), GTK_WIDGET (click_yes), 0, 0, 1, 1) ; + gtk_grid_attach (GTK_GRID (dialog_window_grid), GTK_WIDGET (click_no), 1, 0, 1, 1) ; + gtk_grid_attach (GTK_GRID (dialog_window_grid), GTK_WIDGET (action_save_current_model), 0, 2, 2, 1) ; + gtk_window_set_child (GTK_WINDOW (dialog_window), GTK_WIDGET (dialog_window_grid)); + + gtk_window_set_transient_for (GTK_WINDOW (dialog_window), GTK_WINDOW (main_window)); + gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog_window), TRUE); + gtk_window_set_deletable (GTK_WINDOW (dialog_window), FALSE); // FALSE + gtk_window_set_modal (GTK_WINDOW (dialog_window), TRUE); +} + +//------------------------------------------------------------------------------ + +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); + + gpointer no_local_data = NULL; + + GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ()); + gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic"); + gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "power-profile-balanced-rtl-symbolic"); + g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), no_local_data); + + GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | ")); + + GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_new ()); + + btt_open_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state")); + g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); + gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_STATE), group_STATE_RULES_DATA); + + btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules")); + g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); + gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_RULES), group_STATE_RULES_DATA); + + btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis")); + g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); + gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA); + + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_XOR_EXEC_EDIT)); + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (any_Label)); + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_STATE)); + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_RULES)); + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_DATA)); + + // https://iconduck.com/sets/adwaita-icon-theme https://iconduck.com/sets/carbon-icons + + GtkButton *go_home = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (go_home, "go-home-symbolic"); + gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (go_home)); + + GtkButton *search = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (search, "user-trash-symbolic"); + gtk_button_set_icon_name (search, "emblem-documents-symbolic"); + gtk_button_set_icon_name (search, "preferences-desktop-appearance-symbolic"); + gtk_button_set_icon_name (search, "applications-utilities-symbolic"); + gtk_button_set_icon_name (search, "folder-saved-search-symbolic"); + gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (search)); + + GtkButton *open_menu = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (open_menu, "open-menu-symbolic"); + gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu)); +} + +void widget_MAIN_WINDOW_design (GtkWindow *main_window){ + window_header_bar (main_window, + "E coli (with permission from David S. Goodsell, 2009)"); + gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE); + gtk_window_present (GTK_WINDOW (main_window)); +} + diff --git a/src/widget.c/labo b/src/widget.c/labo new file mode 100644 index 0000000..a7b2808 --- /dev/null +++ b/src/widget.c/labo @@ -0,0 +1,123 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Widgets header * +* * +* Copyright © 2021 Libre en Communs * +* 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 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/widgets.h" + +// 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 + + +GtkButton *get_GtkButton (char *btt_name) { + if (strcmp (btt_name, "state")) return btt_open_STATE; + if (strcmp (btt_name, "rules")) return btt_open_RULES; + if (strcmp (btt_name, "data analysis")) return btt_open_DATA; + return NULL; +} + + +GtkFrame *get_frame_with_label() { // EN ATTENDANT DE SAVOIR UTILISER : GtkTextTagTable , GtkTextBuffer + GtkFrame *space_specif = GTK_FRAME(gtk_frame_new ("Space (run / edit) specifications")); + GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (get_space_run_edit_specif())); + gtk_frame_set_child (GTK_FRAME (space_specif), GTK_WIDGET (any_Label)); + return space_specif; +} + +GtkWidget *get_edit_rules_page_new() { + GtkPaned *hpaned = 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 = gtk_frame_new ("Édition de la règle sélectionnée"); + + gtk_paned_set_start_child (hpaned, GTK_WIDGET (arbre_des_règles)); + gtk_paned_set_end_child (hpaned, GTK_WIDGET (édition_de_la_règle_sélectionnée)); + // gtk_widget_set_size_request (GTK_WIDGET (hpaned), W, H); + gtk_paned_set_wide_handle (hpaned, TRUE); + + return GTK_WIDGET (hpaned); +} + +GtkWidget *get_edit_measures_page_new() { + GtkWidget *measures_grid = gtk_grid_new(); + return measures_grid; +} + +GtkWidget *get_edit_results_page_new() { + GtkWidget *xxx_grid = gtk_grid_new(); + return xxx_grid; +} + +GtkWidget *get_edit_discuss_page_new() { + GtkWidget *xxx_grid = gtk_grid_new(); + return xxx_grid; +} + +GtkWidget *get_edit_help_page_new() { + GtkWidget *edit_help_grid = gtk_grid_new(); + gtk_grid_attach (GTK_GRID(edit_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1); + return edit_help_grid; +} + +GtkWidget *get_measures_page_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 ("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 ("objects"), 0, 1, 1, 1); + gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("situations"), 1, 1, 1, 1); + return measures_grid; +} + +GtkWidget *get_results_page_new() { + GtkWidget *results_grid = gtk_grid_new(); + gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Repartitions"), 0, 0, 1, 1); + gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Correlations"), 0, 1, 1, 1); + gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Evolutions"), 0, 2, 1, 1); + return results_grid; +} + +GtkWidget *get_discuss_page_new() { + GtkWidget *discuss_grid = gtk_grid_new(); + gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Interpretations"), 0, 0, 1, 1); + gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Discussions"), 0, 1, 1, 1); + return discuss_grid; +} + +GtkWidget *get_help_page_new() { + GtkWidget *run_help_grid = gtk_grid_new(); + gtk_grid_attach (GTK_GRID(run_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1); + return run_help_grid; +} + + + + + + + diff --git a/src/widget.c/wdgt_lab_II.c b/src/widget.c/rules.c similarity index 73% rename from src/widget.c/wdgt_lab_II.c rename to src/widget.c/rules.c index 8824b16..198c15f 100644 --- a/src/widget.c/wdgt_lab_II.c +++ b/src/widget.c/rules.c @@ -42,96 +42,51 @@ //------------------------------------------------------------------------------ -static GtkWidget *get_image_ALL_SPACE(){ - GtkWidget *image; - // forget > GTK_WIDGET(get_scrolled_gl_area()); - // Use GtkImage if you want to display a fixed-size icon - // and GtkPicture if you want to display a (maybe) scaled picture. - image = gtk_image_new_from_file("/home/jean/Gem-Graph/gem-graph-client/data/image/aXoris.png"); - image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/gg sketch.png"); - image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/E coli (Goodsell) 2.png"); - gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE, H_IMAGE); - return image; -} - -GtkWidget *get_image_GLUTAMATE(){ +static GtkWidget *get_image_GLUTAMATE(){ GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamate.png"); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return image; } -GtkWidget *get_image_GLUTAMINE(){ +static GtkWidget *get_image_GLUTAMINE(){ GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamine.png"); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return image; } -GtkWidget *get_image_HISTIDINE(){ +static GtkWidget *get_image_HISTIDINE(){ GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/histidine.png"); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return image; } -GtkWidget *get_image_HISTAMINE(){ - GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/histamine.png"); - gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); - return image; -} - -GtkWidget *get_image_PHENYLALANINE(){ +static GtkWidget *get_image_PHENYLALANINE(){ GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/phénylalanine.png"); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return image; } -GtkWidget *get_image_DOPAMINE(){ +static GtkWidget *get_image_DOPAMINE(){ GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/dopamine.png"); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return image; } -GtkWidget *get_image_ATP(){ +static GtkWidget *get_image_ATP(){ GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/ATP.png"); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return image; } -GtkWidget *get_image_AMP(){ +static GtkWidget *get_image_AMP(){ GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/AMP.png"); gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); return image; } -GtkWidget *get_user_tree(){ - GtkWidget *image = gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/arbre utilisateur.png"); - gtk_widget_set_size_request (GTK_WIDGET (image), W_IMAGE_LOCAL, H_IMAGE_LOCAL); - return image; -} - //------------------------------------------------------------------------------ -// TODO cliquer sur "RUN" --> affiche "STOP" (et inversement) -static GtkWidget *get_scroll_speed(){ - GtkAdjustment *speed_adjust = gtk_adjustment_new (100, 0, 100, 1, 0, 0); - GtkWidget *scroll_speed = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, speed_adjust); - gtk_widget_set_size_request (GTK_WIDGET (scroll_speed), 120, 2); - return scroll_speed; -} - -static GtkBox *get_UNDO_SPEED_box(){ - GtkBox *SPEED_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); - gtk_box_append (SPEED_box, GTK_WIDGET(gtk_label_new ("< UNDO <\n"))); - gtk_box_append (SPEED_box, get_scroll_speed()); - return SPEED_box; -} - -static GtkBox *get_DO_SPEED_box(){ - GtkBox *SPEED_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); - gtk_box_append (SPEED_box, GTK_WIDGET(gtk_label_new ("> DO >\n"))); - gtk_box_append (SPEED_box, get_scroll_speed()); - return SPEED_box; -} - +/* static GtkBox *get_RUN_STOP_box_lab(){ GtkBox *RUN_STOP_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20)); gtk_box_append (RUN_STOP_box, GTK_WIDGET (get_UNDO_SPEED_box())); @@ -140,17 +95,9 @@ static GtkBox *get_RUN_STOP_box_lab(){ gtk_box_append (RUN_STOP_box, GTK_WIDGET(gtk_label_new (" R U N\n S T O P"))); return RUN_STOP_box; } -//------------------------------------------------------------------------------ +*/ -GtkBox *get_ZOOM_box(){ - GtkBox *ZOOM_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkWidget *ZOOM_Label = GTK_WIDGET (gtk_label_new (\ - "\n TOOLS\n ---\n zoom\n ---\n space\n struct.\n\ - ---\n arrows\n struct.\n ---\n orient\n state\n in space\n")); - gtk_widget_set_size_request (GTK_WIDGET (ZOOM_box), 10, 80); - gtk_box_append (ZOOM_box, ZOOM_Label); - return ZOOM_box; -} +//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ @@ -164,116 +111,27 @@ GtkBox *get_edit_TOOL_box(){ //------------------------------------------------------------------------------ -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 = 2q - // 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); - GtkAdjustment *Y_adjust = gtk_adjustment_new (rand() % 200, 0, 380, 1, 0, 0); - GtkAdjustment *Z_adjust = gtk_adjustment_new (rand() % 300, 0, 380, 1, 0, 0); - GtkWidget *scroll_X = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, X_adjust); - GtkWidget *scroll_Y = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Y_adjust); - GtkWidget *scroll_Z = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Z_adjust); - gtk_widget_set_size_request (GTK_WIDGET (scroll_X), 1, 500); +GtkWidget *get_selected_rules_vpaned_new() { + GtkPaned *EXEC_CONTROLS_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL)); - gtk_box_append (XYZ_scrollbar_box, GTK_WIDGET (gtk_label_new (" "))); // AD HOC (pour "centrer") - gtk_box_append (XYZ_scrollbar_box, scroll_X); - gtk_box_append (XYZ_scrollbar_box, scroll_Y); - gtk_box_append (XYZ_scrollbar_box, scroll_Z); - gtk_box_append (XYZ_scrollbar_box, GTK_WIDGET (gtk_label_new (" "))); // AD HOC (pour "centrer") - // - gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new ("\nX Y Z"))); - gtk_box_append (XYZ_labels_box, GTK_WIDGET (XYZ_scrollbar_box)); - gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new (""))); - return XYZ_labels_box; + 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 (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); + gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMINE())); + + 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 (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); + gtk_box_append (bottom_box, GTK_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)); + + return GTK_WIDGET (EXEC_CONTROLS_pane); } //------------------------------------------------------------------------------ -GtkProgressBar *get_ELAPSED_TIME_ProgressBar(){ // To rename : DO - UNDO - REDO ? - GtkProgressBar *buffer = GTK_PROGRESS_BAR (gtk_progress_bar_new ()); - gtk_progress_bar_set_text (buffer,\ - "\n<--- [buffer] (simulation extensive time) --->\n\ - supports DO - UNDO - REDO functions\n"); - gtk_progress_bar_set_show_text (buffer, TRUE); - gtk_widget_set_size_request (GTK_WIDGET (buffer), W - 740, 0); - return buffer; -} - -static GtkWidget *get_TIME_EXEC_controls_box_lab() { - 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(gtk_separator_new (GTK_ORIENTATION_VERTICAL))); - gtk_box_append (top_box, GTK_WIDGET (get_RUN_STOP_box_lab())); - return GTK_WIDGET (top_box); -} - - -//------------------------------------------------------------------------------ - -// Chaque label "objet" ou "situation" sera remplacé par un curseur "transparence" (vertical) - -static GtkBox *get_objects_box(){ - GtkBox *objects_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkAdjustment *adjust = gtk_adjustment_new (0, 0, 255, 1, 0, 0); - if (0) for (int i = 0; i < 10; i++) - gtk_box_append (objects_box, gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust)); - char string[7]; - for (int i = 0; i < 16; i++){ - sprintf(string, "[%d] ", i); - if (0) printf("%s\n", string); // répété deux fois ! pourquoi ? - gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (string))); - } - gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" membrane "))); - gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" co-enzyme A "))); - gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" ribosome "))); - gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" ATP synthase "))); - return objects_box; -} - -static GtkBox *get_situations_box(){ - GtkBox *situations_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - char string[7]; - for (int i = 0; i < 64; i++){ - sprintf(string, "[%d] ", i); - if (0) printf("%s\n", string); // répété deux fois ! pourquoi ? - gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (string))); - } - gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" transcription "))); - gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" transport Na/K "))); - gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" ubiquitination "))); - gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" rotation moteur flagellaire "))); - return situations_box; -} - -static GtkWidget *get_frame_objects(){ - GtkWidget *scroll = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparence - gtk_widget_set_size_request (frame_objects, 0, H_STYLES_PANE); // < utile seulement pour la largeur min/max - gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_objects_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll), frame_objects); - return scroll; -} - -static GtkWidget *get_frame_situations(){ - GtkWidget *scroll = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification - gtk_widget_set_size_request (GTK_WIDGET (frame_situations), 0, H_STYLES_PANE); // < utile seulement pour la largeur min/max - gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (get_situations_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll), frame_situations); - return scroll; -} - -GtkWidget *get_OBJECTS_and_SITUATIONS(){ - GtkWidget *objects_and_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); - gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (get_frame_objects())); - gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (get_frame_situations())); - return objects_and_situations_horizontal_pane; -} - GtkBox *get_rules_comparator_new(){ GtkBox *comparator = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); @@ -323,6 +181,18 @@ GtkWidget *get_rules_page_new(){ return GTK_WIDGET (H_tree_vs_selected); } +GtkWidget *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"); + gtk_paned_set_start_child (H_tree_vs_selected, GTK_WIDGET (get_rules_tree_hpaned_new())); + gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (get_selected_rules_vpaned_new())); + gtk_paned_set_position (H_tree_vs_selected, 400); // WARNING : c'est une position "absolue" + gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE); + return GTK_WIDGET (H_tree_vs_selected); +} + +//--------------------------------------------------------------------------- GtkWidget *get_window_child_DATA_lab () { if (0) printf("widgets.get_window_child_DATA (line 279)\n"); diff --git a/src/widget.c/state.c b/src/widget.c/state.c new file mode 100644 index 0000000..ddb4523 --- /dev/null +++ b/src/widget.c/state.c @@ -0,0 +1,260 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Widgets * +* * +* Copyright © 2021 Libre en Communs * +* Copyright © 2023 Adrien Bourmault * +* Copyright © 2023 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/base.h" +#include "../../include/callbacks.h" +#include "../../include/widgets.h" + +#define W 1920 // TODO 2024-06-30 +#define H 960 // Ad hoc (pour mon écran) +#define H_STYLES_PANE 30 +#define LOWER_COMPARTMENT_PARTITION 1100 // 1186 +#define UPPER_COMPARTMENT_PARTITION 600 + +/* +static GtkWidget *get_scroll_speed(){ + GtkAdjustment *speed_adjust = gtk_adjustment_new (100, 0, 100, 1, 0, 0); + GtkWidget *scroll_speed = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, speed_adjust); + gtk_widget_set_size_request (GTK_WIDGET (scroll_speed), 120, 2); + return scroll_speed; +} + +static GtkBox *get_UNDO_SPEED_box(){ + GtkBox *SPEED_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); + gtk_box_append (SPEED_box, GTK_WIDGET(gtk_label_new ("< UNDO <\n"))); + gtk_box_append (SPEED_box, get_scroll_speed()); + return SPEED_box; +} + +static GtkBox *get_DO_SPEED_box(){ + GtkBox *SPEED_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); + gtk_box_append (SPEED_box, GTK_WIDGET(gtk_label_new ("> DO >\n"))); + gtk_box_append (SPEED_box, get_scroll_speed()); + return SPEED_box; +} +*/ + +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 = 2q + // 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); + GtkAdjustment *Y_adjust = gtk_adjustment_new (rand() % 200, 0, 380, 1, 0, 0); + GtkAdjustment *Z_adjust = gtk_adjustment_new (rand() % 300, 0, 380, 1, 0, 0); + GtkWidget *scroll_X = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, X_adjust); + GtkWidget *scroll_Y = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Y_adjust); + GtkWidget *scroll_Z = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Z_adjust); + gtk_widget_set_size_request (GTK_WIDGET (scroll_X), 1, 500); + + gtk_box_append (XYZ_scrollbar_box, GTK_WIDGET (gtk_label_new (" "))); // AD HOC (pour "centrer") + gtk_box_append (XYZ_scrollbar_box, scroll_X); + gtk_box_append (XYZ_scrollbar_box, scroll_Y); + gtk_box_append (XYZ_scrollbar_box, scroll_Z); + gtk_box_append (XYZ_scrollbar_box, GTK_WIDGET (gtk_label_new (" "))); // AD HOC (pour "centrer") + // + gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new ("\nX Y Z"))); + gtk_box_append (XYZ_labels_box, GTK_WIDGET (XYZ_scrollbar_box)); + gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new (""))); + return XYZ_labels_box; +} + +static GtkBox *get_ZOOM_box(){ + GtkBox *ZOOM_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); + GtkWidget *ZOOM_Label = GTK_WIDGET (gtk_label_new (\ + "\n TOOLS\n ---\n zoom\n ---\n space\n struct.\n\ + ---\n arrows\n struct.\n ---\n orient\n state\n in space\n")); + gtk_widget_set_size_request (GTK_WIDGET (ZOOM_box), 10, 80); + gtk_box_append (ZOOM_box, ZOOM_Label); + return ZOOM_box; +} + +static GtkBox *get_RUN_STOP_box(){ + GtkBox *RUN_STOP_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10)); + gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("R U N / S T O P"))); + gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("SPEED UP <> SLOW DOWN"))); + gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("STEP by STEP (+ show active rule)"))); + return RUN_STOP_box; +} + +static GtkWidget *get_OBJECTS_and_SITUATIONS(); + +GtkWidget *get_edit_space_page_new() { + GtkWidget *space_grid = gtk_grid_new(); + GtkWidget *image = gtk_picture_new_for_filename + ("/home/jean/Gem-Graph/gem-graph-client/data/image/E coli by D Goodsell.png"); + gtk_grid_attach (GTK_GRID(space_grid), image, 0, 0, 1, 3); + gtk_grid_attach (GTK_GRID(space_grid), get_OBJECTS_and_SITUATIONS(), 0, 4, 1, 1); + gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET (get_XYZ_box()), 1, 0, 1, 2); + gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET (get_ZOOM_box()), 1, 2, 1, 2); +// gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET (get_edit_TOOL_box()), 1, 3, 1, 2); + gtk_widget_set_size_request (space_grid, W, H); + return space_grid; +} + +//------------------------------------------------------------------------------ + +static GtkBox *get_DO_UNDO_REDO_box(){ + GtkBox *DO_UNDO_REDO_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\ + a progress bar showing the time elapsed during the simulation"))); + gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET (gtk_progress_bar_new ())); + GtkAdjustment *adjust = gtk_adjustment_new (30, 0, 100, 1, 0, 0); + gtk_box_append (DO_UNDO_REDO_box, + GTK_WIDGET (gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjust))); + gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\ + DO - UNDO - REDO"))); + return DO_UNDO_REDO_box; +} + + + + + + + + + + + +static GtkBox *get_OBJECTS_box(){ + GtkBox *objects_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); + GtkAdjustment *adjust = NULL; + for (int i = 0; i < 32; i++) { + adjust = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 4); + GtkScrollbar *scrollbar_i = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust)); + char tooltip_text[8]; + sprintf(tooltip_text, "\n%d\n", i); + if (0 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " membrane "); + if (1 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " co-enzyme A "); + if (2 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " ATP synthase "); + if (3 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " any object name "); + if (4 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), tooltip_text); + gtk_box_append (objects_box, gtk_label_new (" ")); + gtk_box_append (objects_box, GTK_WIDGET (scrollbar_i)); + } + return objects_box; +} + +static GtkBox *get_SITUATIONS_box(){ + GtkBox *situations_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); + GtkAdjustment *adjust = NULL; + for (int i = 0; i < 128; i++) { + adjust = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 4); + GtkScrollbar *scrollbar_i = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust)); + char tooltip_text[8]; + sprintf(tooltip_text, "\n%d\n", i); + if (0 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " transcription "); + if (1 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " transport Na/K "); + if (2 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " ubiquitination "); + if (3 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " glycolyse aérobie "); + if (4 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " cycle de Krebs "); + if (5 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " shunt des pentoses "); + if (6 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " any situation name "); + if (7 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), tooltip_text); + gtk_box_append (situations_box, gtk_label_new (" ")); + gtk_box_append (situations_box, GTK_WIDGET (scrollbar_i)); + } + return situations_box; +} + +/******************************************************************************/ +/* S T A T E p a g e > t h r e e t o p l e v e l b o x e s */ +/******************************************************************************/ + +static GtkWidget *get_OBJECTS_and_SITUATIONS(){ + GtkWidget *scroll_objects = gtk_scrolled_window_new (); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_objects), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); + GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparency + gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_OBJECTS_box())); + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_objects), frame_objects); + + GtkWidget *scroll_situations = gtk_scrolled_window_new (); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_situations), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); + GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification + gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (get_SITUATIONS_box())); + gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_situations), frame_situations); + + GtkWidget *objects_and_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); + gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_objects)); + gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_situations)); + gtk_paned_set_position (GTK_PANED (objects_and_situations_horizontal_pane), UPPER_COMPARTMENT_PARTITION); + gtk_widget_set_size_request (objects_and_situations_horizontal_pane, 0, 127); + + return objects_and_situations_horizontal_pane; +} + +GtkWidget *get_SPACE_VIEW_box() { + GtkBox *right_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (right_box, GTK_WIDGET (get_XYZ_box())); + gtk_box_append (right_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (right_box, GTK_WIDGET (get_ZOOM_box())); + + GtkBox *central_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); + + // TODO + GtkWidget *image = gtk_picture_new_for_filename + ("/home/jean/Gem-Graph/gem-graph-client/data/image/E coli (Goodsell) 2.png"); + gtk_box_append (central_box, GTK_WIDGET (image)); + // ui_setup_glarea (0, GTK_WIDGET (central_box)); + + gtk_box_append (central_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); + gtk_box_append (central_box, GTK_WIDGET (right_box)); + gtk_widget_set_size_request (GTK_WIDGET (central_box), W - 00, 00); + return GTK_WIDGET (central_box); +} + +static GtkWidget *get_SPACE_EDIT_CONTROLS_box(){ + return gtk_label_new + ("_____________\n SPACE EDIT\n controls\n'''''''''''''''''''''''"); +} + +static GtkWidget *get_TIME_EXEC_CONTROLS_box() { + GtkPaned *EXEC_CONTROLS_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); + gtk_paned_set_start_child (EXEC_CONTROLS_pane, GTK_WIDGET (get_DO_UNDO_REDO_box())); + gtk_paned_set_end_child (EXEC_CONTROLS_pane, GTK_WIDGET (get_RUN_STOP_box())); + gtk_paned_set_position (EXEC_CONTROLS_pane, LOWER_COMPARTMENT_PARTITION); + gtk_widget_set_size_request (GTK_WIDGET (EXEC_CONTROLS_pane), 00, 200); + return GTK_WIDGET (EXEC_CONTROLS_pane); +} + +/******************************************************************************/ +/* g e t S T A T E p a g e */ +/******************************************************************************/ + +GtkWidget *widget_get_STATE_page() { + GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS())); + gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box())); + gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + if (get_EXEC_EDIT ()) gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_CONTROLS_box())); + else gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_CONTROLS_box())); + return GTK_WIDGET (page_box); +} + diff --git a/src/widget.c/wdgt_lab_I b/src/widget.c/stock.c similarity index 52% rename from src/widget.c/wdgt_lab_I rename to src/widget.c/stock.c index d5d702c..cea8193 100644 --- a/src/widget.c/wdgt_lab_I +++ b/src/widget.c/stock.c @@ -1,10 +1,11 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Gem-graph client * +* Gem-graph client * * * -* Widgets header * +* Main * * * * Copyright © 2021 Libre en Communs * +* Copyright © 2021 Adrien Bourmault * * Copyright © 2021 Jean Sirmai * * * * This file is part of Gem-graph. * @@ -27,9 +28,41 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include "../../include/base.h" +#include "../../include/callbacks.h" #include "../../include/widgets.h" -// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO -// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery +GtkWidget *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"); + GtkBox *rule_effect_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8)); + gtk_frame_set_child (GTK_FRAME (frame_rule_effect), GTK_WIDGET (rule_effect_box)); + + GtkWidget* frame_rule_topic = gtk_frame_new ("rule topic"); + GtkBox *rule_topic_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8)); + gtk_frame_set_child (GTK_FRAME (frame_rule_topic), GTK_WIDGET (rule_topic_box)); + + GtkWidget* frame_data_type = gtk_frame_new ("data type"); + GtkBox *data_type_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8)); + gtk_frame_set_child (GTK_FRAME (frame_data_type), GTK_WIDGET (data_type_box)); + + gtk_box_append (data_box, GTK_WIDGET (frame_rule_effect)); + gtk_box_append (data_box, GTK_WIDGET (frame_rule_topic)); + gtk_box_append (data_box, GTK_WIDGET (frame_data_type)); + + gtk_box_append (rule_effect_box, gtk_button_new_with_label ("movement")); + gtk_box_append (rule_effect_box, gtk_button_new_with_label ("transport")); + gtk_box_append (rule_effect_box, gtk_button_new_with_label ("transformation")); + + gtk_box_append (rule_topic_box, gtk_button_new_with_label ("objects")); + gtk_box_append (rule_topic_box, gtk_button_new_with_label ("situations")); + + gtk_box_append (data_type_box, gtk_button_new_with_label ("repartitions")); + gtk_box_append (data_type_box, gtk_button_new_with_label ("evolutions")); + gtk_box_append (data_type_box, gtk_button_new_with_label ("correlations")); + + return GTK_WIDGET (data_box); +} diff --git a/src/widget.c/tree_lab.c b/src/widget.c/tree.c similarity index 100% rename from src/widget.c/tree_lab.c rename to src/widget.c/tree.c diff --git a/src/widget.c/widgets.c b/src/widget.c/widgets.c deleted file mode 100644 index 3949193..0000000 --- a/src/widget.c/widgets.c +++ /dev/null @@ -1,417 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * -* * -* Gem-graph client * -* * -* Widgets * -* * -* Copyright © 2021 Libre en Communs * -* Copyright © 2023 Adrien Bourmault * -* Copyright © 2023 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/base.h" -#include "../../include/callbacks.h" -#include "../../include/widgets.h" - -#define W 1920 // TODO 2024-06-30 -#define H 960 // Ad hoc (pour mon écran) -#define H_STYLES_PANE 30 -#define LOWER_COMPARTMENT_PARTITION 1100 // 1186 -#define UPPER_COMPARTMENT_PARTITION 600 - -static GtkWindow *main_window, *dialog_window; -static GtkButton *btt_open_STATE, *btt_open_RULES, *btt_open_DATA; - -GtkWindow *get_main_window() {return main_window;} -GtkWindow *get_dialog_window() {return dialog_window;} - -void set_main_window (GtkApplication *app) { - main_window = GTK_WINDOW (gtk_application_window_new (app)); -} - -void set_dialog_window (GtkApplication *app) { - dialog_window = GTK_WINDOW (gtk_application_window_new (app)); -} - -GtkButton *get_GtkButton (char *btt_name) { - if (strcmp (btt_name, "state")) return btt_open_STATE; - if (strcmp (btt_name, "rules")) return btt_open_RULES; - if (strcmp (btt_name, "data analysis")) return btt_open_DATA; - return NULL; -} - - -GtkFrame *get_frame_with_label() { // EN ATTENDANT DE SAVOIR UTILISER : GtkTextTagTable , GtkTextBuffer - GtkFrame *space_specif = GTK_FRAME(gtk_frame_new ("Space (run / edit) specifications")); - GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (get_space_run_edit_specif())); - gtk_frame_set_child (GTK_FRAME (space_specif), GTK_WIDGET (any_Label)); - return space_specif; -} - -GtkWidget *get_edit_rules_page_new() { - GtkPaned *hpaned = 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 = gtk_frame_new ("Édition de la règle sélectionnée"); - - gtk_paned_set_start_child (hpaned, GTK_WIDGET (arbre_des_règles)); - gtk_paned_set_end_child (hpaned, GTK_WIDGET (édition_de_la_règle_sélectionnée)); - // gtk_widget_set_size_request (GTK_WIDGET (hpaned), W, H); - gtk_paned_set_wide_handle (hpaned, TRUE); - - return GTK_WIDGET (hpaned); -} - -GtkWidget *get_edit_measures_page_new() { - GtkWidget *measures_grid = gtk_grid_new(); - return measures_grid; -} - -GtkWidget *get_edit_results_page_new() { - GtkWidget *xxx_grid = gtk_grid_new(); - return xxx_grid; -} - -GtkWidget *get_edit_discuss_page_new() { - GtkWidget *xxx_grid = gtk_grid_new(); - return xxx_grid; -} - -GtkWidget *get_edit_help_page_new() { - GtkWidget *edit_help_grid = gtk_grid_new(); - gtk_grid_attach (GTK_GRID(edit_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1); - return edit_help_grid; -} - -GtkWidget *get_measures_page_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 ("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 ("objects"), 0, 1, 1, 1); - gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("situations"), 1, 1, 1, 1); - return measures_grid; -} - -GtkWidget *get_results_page_new() { - GtkWidget *results_grid = gtk_grid_new(); - gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Repartitions"), 0, 0, 1, 1); - gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Correlations"), 0, 1, 1, 1); - gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Evolutions"), 0, 2, 1, 1); - return results_grid; -} - -GtkWidget *get_discuss_page_new() { - GtkWidget *discuss_grid = gtk_grid_new(); - gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Interpretations"), 0, 0, 1, 1); - gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Discussions"), 0, 1, 1, 1); - return discuss_grid; -} - -GtkWidget *get_help_page_new() { - GtkWidget *run_help_grid = gtk_grid_new(); - gtk_grid_attach (GTK_GRID(run_help_grid), GTK_WIDGET(get_frame_with_label()), 0, 0, 1, 1); - return run_help_grid; -} - -static GtkWidget *get_OBJECTS_and_SITUATIONS(); - -GtkWidget *get_edit_space_page_new() { - GtkWidget *space_grid = gtk_grid_new(); - GtkWidget *image = gtk_picture_new_for_filename - ("/home/jean/Gem-Graph/gem-graph-client/data/image/E coli by D Goodsell.png"); - gtk_grid_attach (GTK_GRID(space_grid), image, 0, 0, 1, 3); - gtk_grid_attach (GTK_GRID(space_grid), get_OBJECTS_and_SITUATIONS(), 0, 4, 1, 1); - gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET (get_XYZ_box()), 1, 0, 1, 2); - gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET (get_ZOOM_box()), 1, 2, 1, 2); - gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET (get_edit_TOOL_box()), 1, 3, 1, 2); - gtk_widget_set_size_request (space_grid, W, H); - return space_grid; -} - -//------------------------------------------------------------------------------ - -GtkWidget *get_selected_rules_vpaned_new() { - GtkPaned *EXEC_CONTROLS_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL)); - - 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 (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); - gtk_box_append (up_box, GTK_WIDGET (get_image_GLUTAMINE())); - - 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 (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); - gtk_box_append (bottom_box, GTK_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)); - - return GTK_WIDGET (EXEC_CONTROLS_pane); -} - -static GtkBox *get_DO_UNDO_REDO_box(){ - GtkBox *DO_UNDO_REDO_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\ - a progress bar showing the time elapsed during the simulation"))); - gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET (gtk_progress_bar_new ())); - GtkAdjustment *adjust = gtk_adjustment_new (30, 0, 100, 1, 0, 0); - gtk_box_append (DO_UNDO_REDO_box, - GTK_WIDGET (gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, adjust))); - gtk_box_append (DO_UNDO_REDO_box, GTK_WIDGET(gtk_label_new ("\ - DO - UNDO - REDO"))); - return DO_UNDO_REDO_box; -} - -static GtkBox *get_RUN_STOP_box(){ - GtkBox *RUN_STOP_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10)); - gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("R U N / S T O P"))); - gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("SPEED UP <> SLOW DOWN"))); - gtk_box_append (RUN_STOP_box, GTK_WIDGET (gtk_button_new_with_label ("STEP by STEP (+ show active rule)"))); - return RUN_STOP_box; -} - -static GtkWidget *get_TIME_EXEC_CONTROLS_box() { - GtkPaned *EXEC_CONTROLS_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); - gtk_paned_set_start_child (EXEC_CONTROLS_pane, GTK_WIDGET (get_DO_UNDO_REDO_box())); - gtk_paned_set_end_child (EXEC_CONTROLS_pane, GTK_WIDGET (get_RUN_STOP_box())); - gtk_paned_set_position (EXEC_CONTROLS_pane, LOWER_COMPARTMENT_PARTITION); - gtk_widget_set_size_request (GTK_WIDGET (EXEC_CONTROLS_pane), 00, 200); - return GTK_WIDGET (EXEC_CONTROLS_pane); -} - -GtkWidget *get_SPACE_VIEW_box() { - GtkBox *right_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (right_box, GTK_WIDGET (get_XYZ_box())); - gtk_box_append (right_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - gtk_box_append (right_box, GTK_WIDGET (get_ZOOM_box())); - - GtkBox *central_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); - - // TODO - GtkWidget *image = gtk_picture_new_for_filename - ("/home/jean/Gem-Graph/gem-graph-client/data/image/E coli (Goodsell) 2.png"); - gtk_box_append (central_box, GTK_WIDGET (image)); - // ui_setup_glarea (0, GTK_WIDGET (central_box)); - - gtk_box_append (central_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); - gtk_box_append (central_box, GTK_WIDGET (right_box)); - gtk_widget_set_size_request (GTK_WIDGET (central_box), W - 00, 00); - return GTK_WIDGET (central_box); -} - -static GtkWidget *get_SPACE_EDIT_CONTROLS_box(){ - return gtk_label_new - ("_____________\n SPACE EDIT\n controls\n'''''''''''''''''''''''"); -} - -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); - - gpointer no_local_data = NULL; - - GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ()); - gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic"); - gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "power-profile-balanced-rtl-symbolic"); - g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), no_local_data); - - GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | ")); - - GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_new ()); - - btt_open_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state")); - g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); - gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_STATE), group_STATE_RULES_DATA); - - btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules")); - g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); - gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_RULES), group_STATE_RULES_DATA); - - btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis")); - g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data); - gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA); - - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_XOR_EXEC_EDIT)); - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (any_Label)); - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_STATE)); - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_RULES)); - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_DATA)); - - // https://iconduck.com/sets/adwaita-icon-theme https://iconduck.com/sets/carbon-icons - - GtkButton *go_home = GTK_BUTTON (gtk_button_new ()); - gtk_button_set_icon_name (go_home, "go-home-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (go_home)); - - GtkButton *search = GTK_BUTTON (gtk_button_new ()); - gtk_button_set_icon_name (search, "user-trash-symbolic"); - gtk_button_set_icon_name (search, "emblem-documents-symbolic"); - gtk_button_set_icon_name (search, "preferences-desktop-appearance-symbolic"); - gtk_button_set_icon_name (search, "applications-utilities-symbolic"); - gtk_button_set_icon_name (search, "folder-saved-search-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (search)); - - GtkButton *open_menu = GTK_BUTTON (gtk_button_new ()); - gtk_button_set_icon_name (open_menu, "open-menu-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu)); -} - -void main_window_design (GtkWindow *main_window){ - window_header_bar (main_window, - "E coli (with permission from David S. Goodsell, 2009)"); - gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE); - gtk_window_present (GTK_WINDOW (main_window)); -} - - - - - - - - - - - -static GtkBox *get_objects_box(){ - GtkBox *objects_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkAdjustment *adjust = NULL; - for (int i = 0; i < 32; i++) { - adjust = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 4); - GtkScrollbar *scrollbar_i = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust)); - char tooltip_text[8]; - sprintf(tooltip_text, "\n%d\n", i); - if (0 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " membrane "); - if (1 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " co-enzyme A "); - if (2 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " ATP synthase "); - if (3 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " any object name "); - if (4 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), tooltip_text); - gtk_box_append (objects_box, gtk_label_new (" ")); - gtk_box_append (objects_box, GTK_WIDGET (scrollbar_i)); - } - return objects_box; -} - -static GtkBox *get_situations_box(){ - GtkBox *situations_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkAdjustment *adjust = NULL; - for (int i = 0; i < 128; i++) { - adjust = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 4); - GtkScrollbar *scrollbar_i = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust)); - char tooltip_text[8]; - sprintf(tooltip_text, "\n%d\n", i); - if (0 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " transcription "); - if (1 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " transport Na/K "); - if (2 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " ubiquitination "); - if (3 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " glycolyse aérobie "); - if (4 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " cycle de Krebs "); - if (5 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " shunt des pentoses "); - if (6 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " any situation name "); - if (7 == i % 8) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), tooltip_text); - gtk_box_append (situations_box, gtk_label_new (" ")); - gtk_box_append (situations_box, GTK_WIDGET (scrollbar_i)); - } - return situations_box; -} - -static GtkWidget *get_OBJECTS_and_SITUATIONS(){ - GtkWidget *scroll_objects = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_objects), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparency - gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_objects_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_objects), frame_objects); - - GtkWidget *scroll_situations = gtk_scrolled_window_new (); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_situations), GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); - GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification - gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (get_situations_box())); - gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scroll_situations), frame_situations); - - GtkWidget *objects_and_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); - gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_objects)); - gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (scroll_situations)); - gtk_paned_set_position (GTK_PANED (objects_and_situations_horizontal_pane), UPPER_COMPARTMENT_PARTITION); - gtk_widget_set_size_request (objects_and_situations_horizontal_pane, 0, 127); - - return objects_and_situations_horizontal_pane; -} - - - -GtkWidget *get_window_child_STATE() { - GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS())); - gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box())); - gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); - if (get_EXEC_EDIT ()) gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_CONTROLS_box())); - else gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_CONTROLS_box())); - return GTK_WIDGET (page_box); -} - -GtkWidget *get_window_child_RULES() { - 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"); - gtk_paned_set_start_child (H_tree_vs_selected, GTK_WIDGET (get_rules_tree_hpaned_new())); - gtk_paned_set_end_child (H_tree_vs_selected, GTK_WIDGET (get_selected_rules_vpaned_new())); - gtk_paned_set_position (H_tree_vs_selected, 400); // WARNING : c'est une position "absolue" - gtk_paned_set_wide_handle (H_tree_vs_selected, TRUE); - return GTK_WIDGET (H_tree_vs_selected); -} - -GtkWidget *get_window_child_DATA () { - GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 32)); - - GtkWidget* frame_rule_effect = gtk_frame_new ("rule effect"); - GtkBox *rule_effect_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8)); - gtk_frame_set_child (GTK_FRAME (frame_rule_effect), GTK_WIDGET (rule_effect_box)); - - GtkWidget* frame_rule_topic = gtk_frame_new ("rule topic"); - GtkBox *rule_topic_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8)); - gtk_frame_set_child (GTK_FRAME (frame_rule_topic), GTK_WIDGET (rule_topic_box)); - - GtkWidget* frame_data_type = gtk_frame_new ("data type"); - GtkBox *data_type_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8)); - gtk_frame_set_child (GTK_FRAME (frame_data_type), GTK_WIDGET (data_type_box)); - - gtk_box_append (data_box, GTK_WIDGET (frame_rule_effect)); - gtk_box_append (data_box, GTK_WIDGET (frame_rule_topic)); - gtk_box_append (data_box, GTK_WIDGET (frame_data_type)); - - gtk_box_append (rule_effect_box, gtk_button_new_with_label ("movement")); - gtk_box_append (rule_effect_box, gtk_button_new_with_label ("transport")); - gtk_box_append (rule_effect_box, gtk_button_new_with_label ("transformation")); - - gtk_box_append (rule_topic_box, gtk_button_new_with_label ("objects")); - gtk_box_append (rule_topic_box, gtk_button_new_with_label ("situations")); - - gtk_box_append (data_type_box, gtk_button_new_with_label ("repartitions")); - gtk_box_append (data_type_box, gtk_button_new_with_label ("evolutions")); - gtk_box_append (data_type_box, gtk_button_new_with_label ("correlations")); - - return GTK_WIDGET (data_box); -} - -// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO -// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery -