From 7998a8426d5b20fc432ee42e6e583a674f8b0291 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Tue, 30 Jul 2024 13:17:16 +0200 Subject: [PATCH] WIP: cleaning (des pb de liens : reference indefinie vers...) --- include/widget.h | 6 +- src/widget/rules/distrib.c | 12 +- src/widget/rules/explore_edit | 17 +-- .../{select_one.c => select_one.c.forget} | 0 src/widget/rules/selected/distrib.c | 44 ++++++ src/widget/rules/selected/image.c | 109 +++++++++++++++ src/widget/rules/selected/text.c | 125 ++++++++++++++++++ src/widget/rules/user_tree.c | 14 -- 8 files changed, 297 insertions(+), 30 deletions(-) rename src/widget/rules/{select_one.c => select_one.c.forget} (100%) create mode 100644 src/widget/rules/selected/distrib.c create mode 100644 src/widget/rules/selected/image.c create mode 100644 src/widget/rules/selected/text.c diff --git a/include/widget.h b/include/widget.h index 9966d43..ce86113 100644 --- a/include/widget.h +++ b/include/widget.h @@ -87,13 +87,15 @@ int widget_get_object_transparency (int i); // top // called in : src/widget/rules/distrib.c void *widget_get_selected_rule(); -void *widget_get_rules_tree_and_pilot_box(); +void *widget_get_rules_left_pane(); void *widget_get_rules_page(); void *widget_get_rule_edit_controls(); void *widget_get_rule_explore_controls(); -void *widget_rule_itself_vs_explore_edit_pane(); +void *widget_get_rules_right_pane(); void *widget_get_rules_pilot_box(); void *widget_get_rules_tree(); +void *widget_get_selected_rule_texts(); +void *widget_get_selected_rule_images(); /******************************************************************************/ diff --git a/src/widget/rules/distrib.c b/src/widget/rules/distrib.c index d2ec4a5..dfe579a 100644 --- a/src/widget/rules/distrib.c +++ b/src/widget/rules/distrib.c @@ -44,7 +44,7 @@ void *widget_get_rule_edit_controls() ("___________\n RULE EDIT\n controls\n''''''''''''''''''''"); } -void *widget_rule_itself_vs_explore_edit_pane() +void *widget_get_rules_right_pane() { GtkPaned *rule_itself_vs_explore_edit_pane = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_VERTICAL)); gtk_paned_set_start_child (rule_itself_vs_explore_edit_pane, GTK_WIDGET (widget_get_selected_rule())); @@ -60,7 +60,7 @@ void *widget_rule_itself_vs_explore_edit_pane() return GTK_WIDGET (rule_itself_vs_explore_edit_pane); } -static void *static_widget_get_rules_pilot_box () +void *widget_get_rules_pilot_box () { GtkBox *rules_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); GtkButton *btt_show_rules_use = GTK_BUTTON (gtk_button_new_with_label ("rules use")); @@ -75,10 +75,10 @@ static void *static_widget_get_rules_pilot_box () return rules_pilot_box; } -void *widget_get_rules_tree_and_pilot_box () +void *widget_get_rules_left_pane () { GtkBox *rules_tree_and_pilot_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); - gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (static_widget_get_rules_pilot_box ())); + gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_pilot_box ())); // TODO non static génère une erreur : "référence indéfinie" <> a linkage pb ? see Makefile ? gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); gtk_box_append (rules_tree_and_pilot_box, GTK_WIDGET (widget_get_rules_tree ())); @@ -88,8 +88,8 @@ void *widget_get_rules_tree_and_pilot_box () void *widget_get_rules_page() { GtkPaned *tree_vs_selected = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); - gtk_paned_set_start_child (tree_vs_selected, GTK_WIDGET (widget_get_rules_tree_and_pilot_box())); - gtk_paned_set_end_child (tree_vs_selected, GTK_WIDGET (widget_rule_itself_vs_explore_edit_pane())); + gtk_paned_set_start_child (tree_vs_selected, GTK_WIDGET (widget_get_rules_left_pane())); + gtk_paned_set_end_child (tree_vs_selected, GTK_WIDGET (widget_get_rules_right_pane())); gtk_paned_set_position (tree_vs_selected, 340); // WARNING : c'est une position "absolue" gtk_paned_set_wide_handle (tree_vs_selected, TRUE); gtk_paned_set_shrink_start_child (tree_vs_selected, FALSE); diff --git a/src/widget/rules/explore_edit b/src/widget/rules/explore_edit index 9218967..56dd614 100644 --- a/src/widget/rules/explore_edit +++ b/src/widget/rules/explore_edit @@ -32,16 +32,17 @@ #include "../../../include/signal.h" -void *widget_get_rule_explore_controls() -{ - return gtk_label_new - ("_____________\n RULE EDIT\n controls\n'''''''''''''''''''''''"); -} - /* void *widget_get_rule_explore_controls() { - return gtk_label_new - ("_____________\n RULE EXPLORE\n controls\n'''''''''''''''''''''''"); + return gtk_label_new ("________________\n RULE EXPLORE\n\ + controls\n'''''''''''''''''''''''''''''"); +} + +void *widget_get_rule_edit_controls() +{ + return gtk_label_new + ("___________\n RULE EDIT\n controls\n''''''''''''''''''''"); } */ + diff --git a/src/widget/rules/select_one.c b/src/widget/rules/select_one.c.forget similarity index 100% rename from src/widget/rules/select_one.c rename to src/widget/rules/select_one.c.forget diff --git a/src/widget/rules/selected/distrib.c b/src/widget/rules/selected/distrib.c new file mode 100644 index 0000000..372a221 --- /dev/null +++ b/src/widget/rules/selected/distrib.c @@ -0,0 +1,44 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Rules * +* * +* 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/fsm.h" +#include "../../../../include/widget.h" +#include "../../../../include/signal.h" + + +void *widget_get_selected_rule() { + + GtkBox *images_and_texts = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (images_and_texts, GTK_WIDGET (widget_get_selected_rule_images ())); + gtk_box_append (images_and_texts, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (images_and_texts, GTK_WIDGET (widget_get_selected_rule_texts ())); + + return GTK_WIDGET (images_and_texts); +} + diff --git a/src/widget/rules/selected/image.c b/src/widget/rules/selected/image.c new file mode 100644 index 0000000..dd717d7 --- /dev/null +++ b/src/widget/rules/selected/image.c @@ -0,0 +1,109 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Rules * +* * +* 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/fsm.h" +#include "../../../../include/widget.h" +#include "../../../../include/signal.h" + + +static void *get_rule_before() +{ + GtkWidget *rule_before = GTK_WIDGET (gtk_picture_new_for_filename \ + ("/home/jean/Gem-Graph/gem-graph-client/data/image/AMP.png")); + gtk_widget_set_size_request (GTK_WIDGET (rule_before), 0, H_IMAGE_LOCAL); + return GTK_WIDGET (rule_before); +} + +static void *get_rule_after() +{ + GtkWidget *rule_after = GTK_WIDGET (gtk_picture_new_for_filename \ + ("/home/jean/Gem-Graph/gem-graph-client/data/image/ADP.png")); + gtk_widget_set_size_request (GTK_WIDGET (rule_after), 0, H_IMAGE_LOCAL); + return GTK_WIDGET (rule_after); +} + + +static GtkBox *rec_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)); + // 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, 400); + + 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") + + GtkWidget *btt_reset = gtk_toggle_button_new (); + gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic"); + 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 (btt_reset)); + gtk_box_append (XYZ_labels_box, GTK_WIDGET (gtk_label_new (""))); + return XYZ_labels_box; +} + +static GtkBox *rec_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; +} + + +void *widget_get_selected_rule_images() { + + GtkBox *right_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); + gtk_box_append (right_box, GTK_WIDGET (rec_XYZ_box())); + gtk_box_append (right_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); + gtk_box_append (right_box, GTK_WIDGET (rec_ZOOM_box())); + + GtkBox *before_vs_after = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); + gtk_box_append (before_vs_after, GTK_WIDGET (get_rule_before ())); + gtk_box_append (before_vs_after, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); + gtk_box_append (before_vs_after, GTK_WIDGET (get_rule_after ())); + gtk_box_append (before_vs_after, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL))); + gtk_box_append (before_vs_after, GTK_WIDGET (right_box)); + + return GTK_WIDGET (before_vs_after); +} + diff --git a/src/widget/rules/selected/text.c b/src/widget/rules/selected/text.c new file mode 100644 index 0000000..1c676cf --- /dev/null +++ b/src/widget/rules/selected/text.c @@ -0,0 +1,125 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Gem-graph client * +* * +* Rules * +* * +* 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/fsm.h" +#include "../../../../include/widget.h" +#include "../../../../include/signal.h" + + +static void *get_btt_conditions_list() +{ + GtkWidget* list_box = gtk_list_box_new(); + GtkWidget *label_A = GTK_WIDGET (gtk_label_new("if (value (0,0,1,3) == 2)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A); + GtkWidget *label_B = GTK_WIDGET (gtk_label_new("if (value (0,1,1,0) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B); + GtkWidget *label_C = GTK_WIDGET (gtk_label_new("if (value (0,1,1,2) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C); + GtkWidget *label_D = GTK_WIDGET (gtk_label_new("if (value (1,0,1,2) == 1)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_D); + GtkWidget *label_E = GTK_WIDGET (gtk_label_new("if (value (1,1,1,0) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_E); + + + GtkWidget *pop = gtk_popover_new (); + gtk_popover_set_child (GTK_POPOVER (pop), list_box); + gtk_popover_present (GTK_POPOVER (pop)); + gtk_popover_set_autohide (GTK_POPOVER (pop), FALSE); + gtk_popover_set_cascade_popdown (GTK_POPOVER (pop), TRUE); + + GtkMenuButton *conditions = GTK_MENU_BUTTON (gtk_menu_button_new ()); + gtk_menu_button_set_label (GTK_MENU_BUTTON (conditions), "conditions"); + gtk_menu_button_set_always_show_arrow (conditions, TRUE); + gtk_menu_button_set_popover (conditions, GTK_WIDGET (pop)); +// gtk_widget_set_halign (GTK_WIDGET (conditions), GTK_ALIGN_START); + + return conditions; +} + +static void *get_btt_assign_list() +{ + GtkWidget* list_box = gtk_list_box_new(); + GtkWidget *label_A = GTK_WIDGET (gtk_label_new("value (0,0,1,3) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A); + GtkWidget *label_B = GTK_WIDGET (gtk_label_new("value (0,1,1,0) == 2)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B); + GtkWidget *label_C = GTK_WIDGET (gtk_label_new("value (0,1,1,2) == 1)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C); + GtkWidget *label_D = GTK_WIDGET (gtk_label_new("value (1,0,1,2) == 0)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_D); + GtkWidget *label_E = GTK_WIDGET (gtk_label_new("value (1,1,1,0) == 2)")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_E); + + GtkWidget *pop = gtk_popover_new (); + gtk_popover_set_child (GTK_POPOVER (pop), list_box); + gtk_popover_present (GTK_POPOVER (pop)); + gtk_popover_set_autohide (GTK_POPOVER (pop), FALSE); + gtk_popover_set_cascade_popdown (GTK_POPOVER (pop), TRUE); + + GtkMenuButton *actions = GTK_MENU_BUTTON (gtk_menu_button_new ()); + gtk_menu_button_set_label (GTK_MENU_BUTTON (actions), "actions"); + gtk_menu_button_set_always_show_arrow (actions, TRUE); + gtk_menu_button_set_popover (actions, GTK_WIDGET (pop)); + // gtk_widget_set_halign (GTK_WIDGET (actions), GTK_ALIGN_START); + + return actions; +} + +static void *get_btt_rule_identity() +{ + GtkWidget* list_box = gtk_list_box_new(); + GtkWidget *label_A = GTK_WIDGET (gtk_label_new("AMP > ADP")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A); + GtkWidget *label_B = GTK_WIDGET (gtk_label_new("AMP-activated protein kinase")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B); + GtkWidget *label_C = GTK_WIDGET (gtk_label_new("date")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C); + GtkWidget *label_D = GTK_WIDGET (gtk_label_new("author")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_D); + GtkWidget *label_E = GTK_WIDGET (gtk_label_new("status, activity")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_E); + GtkWidget *label_F = GTK_WIDGET (gtk_label_new("links to other rules")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_F); + + GtkWidget *pop = gtk_popover_new (); + gtk_popover_set_child (GTK_POPOVER (pop), list_box); + gtk_popover_present (GTK_POPOVER (pop)); + gtk_popover_set_autohide (GTK_POPOVER (pop), FALSE); + gtk_popover_set_cascade_popdown (GTK_POPOVER (pop), TRUE); + + GtkMenuButton *identity = GTK_MENU_BUTTON (gtk_menu_button_new ()); + gtk_menu_button_set_label (GTK_MENU_BUTTON (identity), "identity"); + gtk_menu_button_set_always_show_arrow (identity, TRUE); + gtk_menu_button_set_popover (identity, GTK_WIDGET (pop)); +// gtk_widget_set_halign (GTK_WIDGET (identity), GTK_ALIGN_START); + + return identity; +} + +void *widget_get_selected_rule_texts() +{ + GtkWidget *label_ad_hoc = GTK_WIDGET (gtk_label_new (\ + " ")); + GtkBox *conditions_actions_names_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); + GtkLayoutManager *conditions_actions_identity_layout = gtk_box_layout_new (GTK_ORIENTATION_HORIZONTAL); + gtk_widget_set_layout_manager (GTK_WIDGET (conditions_actions_names_box), + GTK_LAYOUT_MANAGER (conditions_actions_identity_layout)); + gtk_box_layout_set_spacing (GTK_BOX_LAYOUT (conditions_actions_identity_layout), 180); +// allocate (GTK_LAYOUT_MANAGER (conditions_actions_identity_layout), get_btt_conditions_list (), 100, 20,100); TODO + gtk_box_append (conditions_actions_names_box, GTK_WIDGET (label_ad_hoc)); + gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_conditions_list ())); + gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_assign_list())); + gtk_box_append (conditions_actions_names_box, GTK_WIDGET (get_btt_rule_identity())); + return GTK_WIDGET (conditions_actions_names_box); +} + diff --git a/src/widget/rules/user_tree.c b/src/widget/rules/user_tree.c index cd8ab4f..e8a91c9 100644 --- a/src/widget/rules/user_tree.c +++ b/src/widget/rules/user_tree.c @@ -65,20 +65,6 @@ static void *static_widget_get_rules_use () return scroll_rules_use; } -static void *deprec_widget_get_rules_tree () -{ - GtkPaned *rules_tree_paned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); - gtk_paned_set_start_child (rules_tree_paned, GTK_WIDGET (widget_get_user_rules_tree())); - gtk_paned_set_end_child (rules_tree_paned, GTK_WIDGET (static_widget_get_rules_use ())); -// (get_an_impression_of_what_a_rules_comparator_could_be())); - gtk_paned_set_position (rules_tree_paned, 200); - gtk_paned_set_wide_handle (rules_tree_paned, TRUE); - gtk_widget_set_size_request (GTK_WIDGET (rules_tree_paned), W_IMAGE_LOCAL, H_IMAGE_LOCAL); - gtk_paned_set_shrink_start_child (rules_tree_paned, FALSE); - gtk_paned_set_resize_end_child (rules_tree_paned, FALSE); - gtk_paned_set_shrink_end_child (rules_tree_paned, FALSE); - return GTK_WIDGET (rules_tree_paned); -} void *widget_get_rules_tree () {