Compare commits

..

3 Commits

16 changed files with 729 additions and 384 deletions

View File

@ -49,15 +49,25 @@ void *widget_get_main_window();
void *widget_get_dialog_window(); void *widget_get_dialog_window();
void *widget_get_text_window(); void *widget_get_text_window();
// functions are in topbar
void *widget_get_btt_state();
void *widget_get_btt_rules();
void *widget_get_btt_data();
void window_header_bar_left (GtkWidget *header_bar);
void window_header_bar_right (GtkWidget *header_bar);
/******************************************************************************/ /******************************************************************************/
/* W I D G E T S */ /* W I D G E T S */
/******************************************************************************/ /******************************************************************************/
// called in signal.c // called in signal.c
void *widget_get_state_page(); // in : src/widget/state/distrib.c void *widget_get_state_page(); // in : src/widget/state/dispatch.c
void *widget_get_rules_page(); // in : src/widget/rules.c void *widget_get_rules_page(); // in : src/widget/rules/dispatch.c
void *widget_get_stock_page(); // in : src/widget/stock.c void *widget_get_data_page(); // in : src/widget/data /dispatch.c
void *widget_get_stock_page(); // in : src/widget/data /stock.c < to delete
#define W_IMAGE_LOCAL 1920 / 32 // 1920 x 960 ad hoc (pour mon écran) #define W_IMAGE_LOCAL 1920 / 32 // 1920 x 960 ad hoc (pour mon écran)
#define H_IMAGE_LOCAL 800 #define H_IMAGE_LOCAL 800
@ -100,12 +110,15 @@ void *widget_get_selected_rule_images();
/******************************************************************************/ /******************************************************************************/
/* S T O C K */ /* D A T A */
/******************************************************************************/ /******************************************************************************/
// in : stock.c // in : stock.c
// called by topbar.c.widget_design_text_window() // called by topbar.c.widget_design_text_window()
void *widget_get_stock_text (gchar *text_name); void *widget_get_stock_text (gchar *text_name);
void *widget_get_measures_page();
void *widget_get_stock_page();
void *widget_get_analysis_page();
/******************************************************************************/ /******************************************************************************/
@ -138,11 +151,12 @@ char *widget_get_text_address_any ();
// images in : data / image / // images in : data / image /
// used by : widget / rules.c // used by : widget / rules.c
void *get_an_impression_of_what_a_rules_comparator_could_be(); void *widget_get_an_impression_of_what_a_rules_comparator_could_be();
/******************************************************************************/ /******************************************************************************/
/* L A B O */ /* L A B O */
/******************************************************************************/ /******************************************************************************/
// now in : src/widget/rules/tree_tools/
// called by tree.c widget_get_user_rules_tree() // called by tree.c widget_get_user_rules_tree()
void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root); void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root);

View File

@ -274,7 +274,7 @@ static void switch_state_rules_data()
case (DATA) : case (DATA) :
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()), gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_stock_page())); GTK_WIDGET (widget_get_data_page()));
break; break;
default : default :

50
src/widget/data/analysis Normal file
View File

@ -0,0 +1,50 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Stock *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
void *widget_get_analysis_page () {
GtkWidget *btt_A = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (btt_left), "view-refresh-symbolic");
GtkWidget *btt_B = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (btt_left), "view-refresh-symbolic");
GtkWidget* frame_analysis = gtk_frame_new ("analysis");
GtkBox *analysis_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 8));
gtk_frame_set_child (GTK_FRAME (frame_analysis), GTK_WIDGET (btt_A));
gtk_frame_set_child (GTK_FRAME (frame_analysis), GTK_WIDGET (btt_B));
return GTK_WIDGET (frame_analysis);
}

View File

@ -0,0 +1,69 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Stock *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
#define PARTITION 200
static void *widget_get_stock_and_analysis_page()
{
GtkWidget *stock_and_analyse_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_paned_set_start_child (GTK_PANED(stock_and_analyse_horizontal_pane), GTK_WIDGET (widget_get_measures_page()));
gtk_paned_set_end_child (GTK_PANED(stock_and_analyse_horizontal_pane), GTK_WIDGET (widget_get_stock_page()));
gtk_paned_set_position (GTK_PANED (stock_and_analyse_horizontal_pane), PARTITION);
gtk_paned_set_shrink_start_child (GTK_PANED (stock_and_analyse_horizontal_pane), FALSE);
gtk_paned_set_shrink_end_child (GTK_PANED (stock_and_analyse_horizontal_pane), FALSE);
return stock_and_analyse_horizontal_pane;
}
void *widget_get_data_page()
{
GtkWidget *btt_left = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (btt_left), "view-refresh-symbolic");
GtkWidget *stock_and_analyse_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_paned_set_start_child (GTK_PANED(stock_and_analyse_horizontal_pane), GTK_WIDGET (widget_get_measures_page()));
gtk_paned_set_end_child (GTK_PANED(stock_and_analyse_horizontal_pane), GTK_WIDGET (widget_get_stock_page()));
gtk_paned_set_position (GTK_PANED (stock_and_analyse_horizontal_pane), PARTITION);
gtk_paned_set_shrink_start_child (GTK_PANED (stock_and_analyse_horizontal_pane), FALSE);
gtk_paned_set_shrink_end_child (GTK_PANED (stock_and_analyse_horizontal_pane), FALSE);
GtkWidget *measures_and_data_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_paned_set_start_child (GTK_PANED(measures_and_data_horizontal_pane), GTK_WIDGET (btt_left));
gtk_paned_set_end_child (GTK_PANED(measures_and_data_horizontal_pane), GTK_WIDGET (stock_and_analyse_horizontal_pane));
gtk_paned_set_position (GTK_PANED (measures_and_data_horizontal_pane), PARTITION);
gtk_paned_set_shrink_start_child (GTK_PANED (measures_and_data_horizontal_pane), FALSE);
gtk_paned_set_shrink_end_child (GTK_PANED (measures_and_data_horizontal_pane), FALSE);
gtk_widget_set_size_request (measures_and_data_horizontal_pane, 1920, 800);
return measures_and_data_horizontal_pane;
}

50
src/widget/data/measure.c Normal file
View File

@ -0,0 +1,50 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Stock *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
void *widget_get_measures_page () {
GtkWidget *btt_A = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (btt_A), "view-refresh-symbolic");
GtkWidget *btt_B = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (btt_B), "folder-saved-search-symbolic");
GtkWidget* frame_measures = gtk_frame_new ("measures");
GtkBox *measures_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 8));
gtk_frame_set_child (GTK_FRAME (frame_measures), GTK_WIDGET (btt_A));
gtk_frame_set_child (GTK_FRAME (frame_measures), GTK_WIDGET (btt_B));
return GTK_WIDGET (frame_measures);
}

View File

@ -27,9 +27,9 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../include/base.h" #include "../../../include/base.h"
#include "../../include/signal.h" #include "../../../include/signal.h"
#include "../../include/widget.h" #include "../../../include/widget.h"
void *widget_get_stock_page () { void *widget_get_stock_page () {
GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 32)); GtkBox *data_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 32));
@ -61,6 +61,7 @@ void *widget_get_stock_page () {
gtk_box_append (data_type_box, gtk_button_new_with_label ("evolutions")); gtk_box_append (data_type_box, gtk_button_new_with_label ("evolutions"));
gtk_box_append (data_type_box, gtk_button_new_with_label ("correlations")); gtk_box_append (data_type_box, gtk_button_new_with_label ("correlations"));
// gtk_widget_set_size_request (GTK_WIDGET (data_box), W_IMAGE_LOCAL * 32, H_IMAGE_LOCAL + 200);
return GTK_WIDGET (data_box); return GTK_WIDGET (data_box);
} }
@ -81,20 +82,48 @@ void *widget_get_stock_text (gchar *text_address) {
/******************************************************************************/ /******************************************************************************/
/* T E X T S */ /* C O N T A I N E R S */
/******************************************************************************/ /******************************************************************************/
char *widget_get_text_address_theory () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/théorie.txt";
}
char *widget_get_text_address_about_commands () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/about_commands.txt";
}
char *widget_get_text_address_any () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/any.txt";
}
/*
"rule effect"
"rule topic"
"data type"
"interpretation"
"discussion"
"game"
"help"
"movement"
"transport"
"transformation"
"objects"
"situations"
"accuracy"
"pattern recognition"
"repartitions"
"evolutions"
"correlations"
"stochastic"
"deterministic"
"physical"
"chemical"
"biological"
"social"
"context"
"methodology"
"comparisons"
"to improve"
"summary"
"single player"
"multiple players"
"edition facilities"
"modelization"
"measurements"
"results"
"data analysis"
"preferences"
*/

View File

@ -144,7 +144,7 @@ static GtkWidget *peek(Stack *stack)
static void *push_images_onto_stack (Stack stack_b); static void *push_images_onto_stack (Stack stack_b);
static GtkWidget *do_rtfd (Stack stack_b); static GtkWidget *do_rtfd (Stack stack_b);
void *get_an_impression_of_what_a_rules_comparator_could_be(){ void *widget_get_an_impression_of_what_a_rules_comparator_could_be(){
GtkBox *compare_left = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); GtkBox *compare_left = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_widget_set_size_request (GTK_WIDGET (compare_left), W_IMAGE_ABSURD, H_IMAGE_ABSURD); gtk_widget_set_size_request (GTK_WIDGET (compare_left), W_IMAGE_ABSURD, H_IMAGE_ABSURD);

View File

@ -27,7 +27,8 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../include/widget.h" #include "../../../../include/widget.h"
// (NB à terme, labo.c disparaitra, bien sûr !) // (NB à terme, labo.c disparaitra, bien sûr !)
@ -86,6 +87,11 @@ void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_
struct TreeNode_t *aaab = widget_create_user_tree_node("write"); widget_add_child_node(aaa, aaab); struct TreeNode_t *aaab = widget_create_user_tree_node("write"); widget_add_child_node(aaa, aaab);
struct TreeNode_t *aaac = widget_create_user_tree_node("compute"); widget_add_child_node(aaa, aaac); struct TreeNode_t *aaac = widget_create_user_tree_node("compute"); widget_add_child_node(aaa, aaac);
struct TreeNode_t *aaad = widget_create_user_tree_node("code"); widget_add_child_node(aaa, aaad); struct TreeNode_t *aaad = widget_create_user_tree_node("code"); widget_add_child_node(aaa, aaad);
struct TreeNode_t *aaag = widget_create_user_tree_node("imagine"); widget_add_child_node(aaad, aaag);
struct TreeNode_t *aaah = widget_create_user_tree_node("combine"); widget_add_child_node(aaad, aaah);
struct TreeNode_t *aaai = widget_create_user_tree_node("invent"); widget_add_child_node(aaad, aaai);
struct TreeNode_t *aaaj = widget_create_user_tree_node("create"); widget_add_child_node(aaad, aaaj);
struct TreeNode_t *aaak = widget_create_user_tree_node("enjoy !"); widget_add_child_node(aaad, aaak);
// struct TreeNode_t *aaae = widget_create_user_tree_node("interact"); widget_add_child_node(aaa, aaae); // struct TreeNode_t *aaae = widget_create_user_tree_node("interact"); widget_add_child_node(aaa, aaae);
struct TreeNode_t *aaaco = widget_create_user_tree_node("copy"); widget_add_child_node(aaaa, aaaco); struct TreeNode_t *aaaco = widget_create_user_tree_node("copy"); widget_add_child_node(aaaa, aaaco);
@ -116,51 +122,17 @@ void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_
struct TreeNode_t *ca = widget_create_user_tree_node("free"); widget_add_child_node(c, ca); struct TreeNode_t *ca = widget_create_user_tree_node("free"); widget_add_child_node(c, ca);
struct TreeNode_t *cb = widget_create_user_tree_node("code"); widget_add_child_node(c, cb); struct TreeNode_t *cb = widget_create_user_tree_node("code"); widget_add_child_node(c, cb);
struct TreeNode_t *cc = widget_create_user_tree_node("access"); widget_add_child_node(c, cc); struct TreeNode_t *cc = widget_create_user_tree_node("access"); widget_add_child_node(c, cc);
}
struct TreeNode_t *cca = widget_create_user_tree_node("tiens ?"); widget_add_child_node(cc, cca);
struct TreeNode_t *ccb = widget_create_user_tree_node("y a comme"); widget_add_child_node(cc, ccb);
struct TreeNode_t *ccc = widget_create_user_tree_node("un bug..."); widget_add_child_node(cc, ccc);
struct TreeNode_t *ccd = widget_create_user_tree_node("imprévu"); widget_add_child_node(cc, ccd);
struct TreeNode_t *cce = widget_create_user_tree_node("ici ( ;- )"); widget_add_child_node(cc, cce);
} // TODO bug in this tree
/*
"rule effect"
"rule topic"
"data type"
"interpretation"
"discussion"
"game"
"help"
"movement"
"transport"
"transformation"
"objects"
"situations"
"accuracy"
"pattern recognition"
"repartitions"
"evolutions"
"correlations"
"stochastic"
"deterministic"
"physical"
"chemical"
"biological"
"social"
"context"
"methodology"
"comparisons"
"to improve"
"summary"
"single player"
"multiple players"
"edition facilities"
"modelization"
"measurements"
"results"
"data analysis"
"preferences"
*/
// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO // https://blog.gtk.org/2020/09/08/on-list-models/ < TODO
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery // https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
// https://iconduck.com/sets/adwaita-icon-theme // https://iconduck.com/sets/adwaita-icon-theme

View File

@ -52,7 +52,7 @@ void *widget_get_rules_tree_tools ()
GtkBox *rules_tree_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); GtkBox *rules_tree_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
gtk_box_append (rules_tree_box, GTK_WIDGET (widget_get_user_rules_tree())); gtk_box_append (rules_tree_box, GTK_WIDGET (widget_get_user_rules_tree()));
gtk_box_append (rules_tree_box, GTK_WIDGET (widget_get_rules_use ())); gtk_box_append (rules_tree_box, GTK_WIDGET (widget_get_rules_use ()));
gtk_box_append (rules_tree_box, GTK_WIDGET (get_an_impression_of_what_a_rules_comparator_could_be())); gtk_box_append (rules_tree_box, GTK_WIDGET (widget_get_an_impression_of_what_a_rules_comparator_could_be()));
return GTK_WIDGET (rules_tree_box); return GTK_WIDGET (rules_tree_box);
} }

View File

@ -1,297 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Windows && Headers *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../include/base.h"
#include "../../include/signal.h"
#include "../../include/widget.h"
#define W_TEXT_WINDOW 700 // ad hoc (mais sans conséquences ici)
#define H_TEXT_WINDOW 1000
static GtkButton *btt_STATE, *btt_RULES, *btt_DATA;
/******************************************************************************/
/* T E X T W I N D O W */
/******************************************************************************/
void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window)
{
char *title = " Learn more about Gem Graph. ";
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 (text_window, header_bar);
GtkWidget *child = widget_get_stock_text (widget_get_text_address_theory());
child = widget_get_stock_text (widget_get_text_address_about_commands());
gtk_window_set_child (GTK_WINDOW (text_window), GTK_WIDGET (child));
gtk_widget_set_size_request (GTK_WIDGET (child), W_TEXT_WINDOW, H_TEXT_WINDOW);
// gtk_window_set_resizable (GTK_WINDOW (text_window), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (text_window), GTK_WINDOW (main_window));
gtk_window_set_destroy_with_parent (GTK_WINDOW (text_window), TRUE);
}
/******************************************************************************/
/* D I A L O G W I N D O W */
/******************************************************************************/
void widget_design_dialog_window (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_before_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);
}
/******************************************************************************/
/* M A I N W I N D O W T O P B A R ( C E N T E R ) */
/******************************************************************************/
static GtkWidget *window_header_bar (GtkWindow *window);
static void window_header_bar_left (GtkWidget *header_bar);
static void window_header_bar_right (GtkWidget *header_bar);
void widget_design_main_window (GtkWindow *main_window)
{
GtkWidget *header_bar = window_header_bar (main_window);
window_header_bar_left (header_bar);
window_header_bar_right (header_bar);
// use the next line to select the page that will be presented first
// it triggers <=> signal.on_toggle_state_rule_data (a btt_NAME)
// gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_STATE), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_RULES), TRUE);
gtk_window_present (GTK_WINDOW (main_window));
}
static GtkWidget *window_header_bar (GtkWindow *window)
{
char *title = "E coli (with permission from David S. Goodsell, 2009)";
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);
return header_bar;
}
/******************************************************************************/
/* M A I N W I N D O W T O P B A R ( L E F T ) */
/******************************************************************************/
static void window_header_bar_left (GtkWidget *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_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state"));
g_signal_connect (btt_STATE, "toggled", G_CALLBACK (on_toggle_state_rules_data), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_STATE), group_state_rules_data);
btt_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules"));
g_signal_connect (btt_RULES, "toggled", G_CALLBACK (on_toggle_state_rules_data), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_RULES), group_state_rules_data);
btt_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis"));
g_signal_connect (btt_DATA, "toggled", G_CALLBACK (on_toggle_state_rules_data), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_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_STATE));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_RULES));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_DATA));
}
/******************************************************************************/
/* M A I N W I N D O W T O P B A R ( R I G H T ) */
/******************************************************************************/
static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); }
static void window_header_bar_right (GtkWidget *header_bar)
{
gpointer no_local_data = NULL;
GtkButton *btt_go_home = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (btt_go_home, "go-home-symbolic");
// gtk_widget_error_bell (GTK_WIDGET (btt_go_home)); << TODO si c'est possible ?
g_signal_connect (btt_go_home, "clicked", G_CALLBACK (on_clicked_home), no_local_data);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_go_home));
GtkButton *search = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (search, "folder-saved-search-symbolic");
g_signal_connect (search, "clicked", G_CALLBACK (on_clicked_search), no_local_data);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (search));
// https://discourse.gnome.org/t/when-do-we-really-have-to-use-gtk-popover-present-to-show-a-popover-at-a-given-widget/17566/5
// https://stackoverflow.com/questions/69135934/creating-a-simple-menubar-menu-and-menu-item-in-c-using-gtk4
GtkWidget* list_box = gtk_list_box_new();
GtkWidget *label_A = GTK_WIDGET (gtk_label_new("A")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A);
GtkWidget *label_B = GTK_WIDGET (gtk_label_new("B")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B);
GtkWidget *label_C = GTK_WIDGET (gtk_label_new("C")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C);
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 *open_menu = GTK_MENU_BUTTON (gtk_menu_button_new ());
gtk_menu_button_set_icon_name (open_menu, "open-menu-symbolic");
gtk_menu_button_set_always_show_arrow (open_menu, TRUE);
gtk_menu_button_set_popover (open_menu, GTK_WIDGET (pop));
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu));
GSimpleAction *act_connect = g_simple_action_new("connect", NULL);
g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL);
// gtk_menu_button_popup (open_menu); gtk_menu_button_popdown (open_menu);
// gtk_menu_item_activate (label_C);
// g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect));
// GMenuItem *label_E = g_menu_item_new("connect", "app.connect");
// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (label_E));
/*
https://docs.gtk.org/gtk4/class.ListView.html
GtkStringList *model = gtk_string_list_new (NULL); // model = create_application_list ();
GtkSignalListItemFactory *factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new());
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
GtkStringList *list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
*/
// ce qui suit ira dans le callback
GtkListBoxRow *selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (list_box));
if (selected_row != NULL)
printf("selected_row = %s\n",
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (selected_row))));
// g_signal_connect (label_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data);
}
/******************************************************************************/
/* L O C A L L A B ( I C O N S ) */
/******************************************************************************/
// https://iconduck.com/sets/adwaita-icon-theme
// https://iconduck.com/sets/carbon-icons
//
// 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");

View File

@ -0,0 +1,75 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Windows && Headers *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
/******************************************************************************/
/* D I A L O G W I N D O W */
/******************************************************************************/
void widget_design_dialog_window (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_before_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);
}

View File

@ -0,0 +1,103 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Windows && Headers *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
/******************************************************************************/
/* M A I N W I N D O W T O P B A R ( C E N T E R ) */
/******************************************************************************/
static GtkWidget *window_header_bar (GtkWindow *window);
void window_header_bar_left (GtkWidget *header_bar);
void window_header_bar_right (GtkWidget *header_bar);
void widget_design_main_window (GtkWindow *main_window)
{
GtkWidget *header_bar = window_header_bar (main_window);
window_header_bar_left (header_bar);
window_header_bar_right (header_bar);
// use the next line to select the page that will be presented first
// it triggers <=> signal.on_toggle_state_rule_data (a btt_NAME)
// gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_STATE), TRUE);
gtk_check_button_set_active (GTK_CHECK_BUTTON (widget_get_btt_data()), TRUE);
gtk_window_present (GTK_WINDOW (main_window));
}
static GtkWidget *window_header_bar (GtkWindow *window)
{
char *title = "E coli (with permission from David S. Goodsell, 2009)";
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);
return header_bar;
}
/******************************************************************************/
/* L O C A L L A B ( I C O N S ) */
/******************************************************************************/
// https://iconduck.com/sets/adwaita-icon-theme
// https://iconduck.com/sets/carbon-icons
//
// 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");
/******************************************************************************/
/* T E X T S */
/******************************************************************************/
char *widget_get_text_address_theory () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/théorie.txt";
}
char *widget_get_text_address_about_commands () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/about_commands.txt";
}
char *widget_get_text_address_any () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/any.txt";
}

79
src/widget/topbar/left.c Normal file
View File

@ -0,0 +1,79 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Windows && Headers *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
/******************************************************************************/
/* M A I N W I N D O W T O P B A R ( L E F T ) */
/******************************************************************************/
static GtkButton *btt_STATE, *btt_RULES, *btt_DATA;
void *widget_get_btt_state () {return btt_STATE;}
void *widget_get_btt_rules () {return btt_RULES;}
void *widget_get_btt_data () {return btt_DATA;}
void window_header_bar_left (GtkWidget *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_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state"));
g_signal_connect (btt_STATE, "toggled", G_CALLBACK (on_toggle_state_rules_data), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_STATE), group_state_rules_data);
btt_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules"));
g_signal_connect (btt_RULES, "toggled", G_CALLBACK (on_toggle_state_rules_data), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_RULES), group_state_rules_data);
btt_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis"));
g_signal_connect (btt_DATA, "toggled", G_CALLBACK (on_toggle_state_rules_data), no_local_data);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_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_STATE));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_RULES));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_DATA));
}

View File

@ -0,0 +1,62 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Windows && Headers *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
#define W_TEXT_WINDOW 700 // ad hoc (mais sans conséquences ici)
#define H_TEXT_WINDOW 1000
/******************************************************************************/
/* T E X T W I N D O W */
/******************************************************************************/
void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window)
{
char *title = " Learn more about Gem Graph. ";
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 (text_window, header_bar);
GtkWidget *child = widget_get_stock_text (widget_get_text_address_theory());
child = widget_get_stock_text (widget_get_text_address_about_commands());
gtk_window_set_child (GTK_WINDOW (text_window), GTK_WIDGET (child));
gtk_widget_set_size_request (GTK_WIDGET (child), W_TEXT_WINDOW, H_TEXT_WINDOW);
// gtk_window_set_resizable (GTK_WINDOW (text_window), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (text_window), GTK_WINDOW (main_window));
gtk_window_set_destroy_with_parent (GTK_WINDOW (text_window), TRUE);
}

139
src/widget/topbar/right.c Normal file
View File

@ -0,0 +1,139 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Windows && Headers *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2021 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../../../include/base.h"
#include "../../../include/signal.h"
#include "../../../include/widget.h"
/******************************************************************************/
/* M A I N W I N D O W T O P B A R ( R I G H T ) */
/******************************************************************************/
static void connect(GApplication *app, gpointer *data) { puts("Connect menu item clicked.\n"); }
void window_header_bar_right (GtkWidget *header_bar)
{
gpointer no_local_data = NULL;
GtkButton *btt_go_home = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (btt_go_home, "go-home-symbolic");
// gtk_widget_error_bell (GTK_WIDGET (btt_go_home)); << TODO si c'est possible ?
g_signal_connect (btt_go_home, "clicked", G_CALLBACK (on_clicked_home), no_local_data);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_go_home));
GtkButton *search = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (search, "folder-saved-search-symbolic");
g_signal_connect (search, "clicked", G_CALLBACK (on_clicked_search), no_local_data);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (search));
// https://discourse.gnome.org/t/when-do-we-really-have-to-use-gtk-popover-present-to-show-a-popover-at-a-given-widget/17566/5
// https://stackoverflow.com/questions/69135934/creating-a-simple-menubar-menu-and-menu-item-in-c-using-gtk4
GtkWidget* list_box = gtk_list_box_new();
GtkWidget *label_A = GTK_WIDGET (gtk_label_new("A")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_A);
GtkWidget *label_B = GTK_WIDGET (gtk_label_new("B")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_B);
GtkWidget *label_C = GTK_WIDGET (gtk_label_new("C")); gtk_list_box_append (GTK_LIST_BOX (list_box), label_C);
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 *open_menu = GTK_MENU_BUTTON (gtk_menu_button_new ());
gtk_menu_button_set_icon_name (open_menu, "open-menu-symbolic");
gtk_menu_button_set_always_show_arrow (open_menu, TRUE);
gtk_menu_button_set_popover (open_menu, GTK_WIDGET (pop));
gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu));
GSimpleAction *act_connect = g_simple_action_new("connect", NULL);
g_signal_connect(act_connect, "activate", G_CALLBACK(connect), NULL);
// gtk_menu_button_popup (open_menu); gtk_menu_button_popdown (open_menu);
// gtk_menu_item_activate (label_C);
// g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(act_connect));
// GMenuItem *label_E = g_menu_item_new("connect", "app.connect");
// gtk_list_box_append (GTK_LIST_BOX (list_box), GTK_WIDGET (label_E));
/*
https://docs.gtk.org/gtk4/class.ListView.html
GtkStringList *model = gtk_string_list_new (NULL); // model = create_application_list ();
GtkSignalListItemFactory *factory = GTK_SIGNAL_LIST_ITEM_FACTORY (gtk_signal_list_item_factory_new());
g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL);
GtkStringList *list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory);
g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
*/
// ce qui suit ira dans le callback
GtkListBoxRow *selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (list_box));
if (selected_row != NULL)
printf("selected_row = %s\n",
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (selected_row))));
// g_signal_connect (label_C, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data);
}