Compare commits

...

4 Commits

13 changed files with 179 additions and 211 deletions

View File

@ -37,16 +37,16 @@
/* S T A T E M A C H I N E */
/******************************************************************************/
enum choice_EXEC_EDIT { EXEC, EDIT }; // xor
enum choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor
enum fsm_choice_EXEC_EDIT { EXEC, EDIT }; // xor
enum fsm_choice_STATE_RULES_DATA { STATE, RULES, DATA }; // xor
int fsm_get_EXEC_EDIT ();
int fsm_get_STATE_RULES_DATA ();
int fsm_get_OBJECTS_box_RESET_VALUE ();
int fsm_get_SITUATIONS_box_RESET_VALUE ();
int fsm_get_exec_edit ();
int fsm_get_state_rules_data ();
int fsm_get_objects_box_reset_value ();
int fsm_get_situations_box_reset_value ();
void fsm_set_EXEC_EDIT (int value);
void fsm_set_STATE_RULES_DATA (int value);
void fsm_set_exec_edit (int value);
void fsm_set_state_rules_data (int value);
void fsm_reset_all_objects_transparencies_at_value (int value);
void fsm_reset_all_situations_transparencies_at_value (int value);

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Callbacks header *
* Signals header *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
@ -31,21 +31,21 @@
#pragma once
#include <gtk-4.0/gtk/gtk.h>
// void on_auto_notification (const char *message);
// on_windows_activation (app) is in 'init.c' (not 'signal.c') for simplicity
void on_windows_activation (GtkApplication *app, gpointer user_data);
// all other callbacks are in 'signal.c'
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, gpointer user_data);
void on_toggle_STATE_RULES_DATA (GtkWidget *btt, gpointer user_data);
void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data);
void on_toggle_exec_edit (GtkWidget *btt_XOR_EXEC_EDIT, gpointer user_data);
void on_toggle_state_rules_data (GtkWidget *btt_STATE_RULES_DATA, gpointer user_data);
//void on_toggle_model_run_stop (GtkWidget *btt_MODEL_RUN_STOP, gpointer data);
void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data);
void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data);
void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data);
//void on_open_state (GtkWidget *btt_open_STATE, gpointer data);
//void on_open_rules (GtkWidget *btt_open_RULES, gpointer data);
//void on_open_data (GtkWidget *btt_open_DATA, gpointer data);
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data);
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data);
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data);
void on_save_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data);
void on_discard_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data);
void on_write_current_model (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data);
void on_setup_user_menu_factory (GtkSignalListItemFactory *factory,
@ -66,15 +66,17 @@ void on_glarea_unrealize (GtkWidget *widget);
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
void on_OBJECTS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_objects_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_clicked_HOME (GtkWidget *btt_reset, gpointer data);
void on_clicked_home (GtkWidget *btt_reset, gpointer data);
//void on_clicked_MENU_list_box (GtkWidget *btt_reset, gpointer data);
//void on_clicked_MENU_pop (GtkWidget *btt_reset, gpointer data);
void on_clicked_search (GtkWidget *btt_menu, gpointer list_box);
void on_clicked_menu_experiment (GtkWidget *btt_menu, gpointer list_box);
// void on_auto_notification (const char *message);

View File

@ -40,43 +40,36 @@
void widget_create_windows (GtkApplication *app);
void widget_create_main_window (GtkApplication *app);
void widget_create_dialog_window (GtkApplication *app);
void widget_create_text_window (GtkApplication *app);
void widget_design_main_window (GtkWindow *main_window);
void widget_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window);
void widget_design_text_window (GtkWindow *main_window, GtkWindow *text_window);
void widget_topbar_design_main_window (GtkWindow *main_window);
void widget_topbar_design_dialog_window (GtkWindow *main_window,
GtkWindow *dialog_window);
void widget_topbar_design_text_window (GtkWindow *main_window,
GtkWindow *text_window);
void *widget_topbar_get_main_window();
void *widget_topbar_get_dialog_window();
void *widget_topbar_get_text_window();
void *widget_get_main_window();
void *widget_get_dialog_window();
void *widget_get_text_window();
/******************************************************************************/
/* W I D G E T S */
/******************************************************************************/
GtkWidget *widget_rec_state_page();
GtkWidget *widget_rec_rules_page();
GtkWidget *widget_rec_stock_page();
void *widget_get_state_page();
void *widget_get_rules_page();
void *widget_get_stock_page();
void reset_all_objects_transparencies_to_value (int value);
void reset_all_situations_transparencies_to_value (int value);
void widget_reset_all_objects_transparencies_to_value (int value);
void widget_reset_all_situations_transparencies_to_value (int value);
GtkWidget *widget_rec_stock_text (gchar *text_name);
void *widget_get_stock_text (gchar *text_name);
/******************************************************************************/
/* M E N U */
/******************************************************************************/
struct MenuNode_t {gchar *text; struct MenuNode_t *child, *next;};
struct MenuNode_t *widget_create_user_menu_node (const gchar* text);
//struct MenuNode_t {gchar *text; struct MenuNode_t *child, *next;};
//struct MenuNode_t *widget_create_user_menu_node (const gchar* text);
GtkWidget *widget_rec_menu_anchor();
/******************************************************************************/
@ -87,37 +80,37 @@ struct TreeNode_t {gchar *text; struct TreeNode_t *child, *next;};
struct TreeNode_t *widget_create_user_tree_node (const gchar* text);
void widget_add_child_node (struct TreeNode_t *parent, struct TreeNode_t *child);
void labo_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root);
GtkScrolledWindow *widget_rec_user_rules_tree ();
void *widget_get_user_rules_tree ();
/******************************************************************************/
/* I M A G E S */
/******************************************************************************/
// images are in : data / image /
// images are in : data / image /
// functions are in : widget / stock.c
GtkWidget *widget_rec_image_E_coli();
GtkWidget *widget_rec_image_GLUTAMATE();
GtkWidget *widget_rec_image_GLUTAMINE();
GtkWidget *widget_rec_image_ATP();
GtkWidget *widget_rec_image_AMP();
void *widget_get_image_E_coli();
void *widget_get_image_glutamate();
void *widget_get_image_glutamine();
void *widget_get_image_ATP();
void *widget_get_image_AMP();
/******************************************************************************/
/* T E X T S */
/******************************************************************************/
// texts are in : data / text /
// texts are in : data / text /
// functions are in : widget / stock.c
gchar *widget_rec_text_address_theory ();
gchar *widget_rec_text_address_about_commands ();
gchar *widget_rec_text_address_any ();
char *widget_get_text_address_theory ();
char *widget_get_text_address_about_commands ();
char *widget_get_text_address_any ();
/******************************************************************************/
/* L A B O */
/******************************************************************************/
void learning_how_to_create_a_menu (GtkMenuButton* menu_button);
void labo_create_a_simple_gtk_string_list ();
void widget_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root);

View File

@ -49,7 +49,7 @@ static int choice_SITUATIONS_box_RESET_VALUE = 0;
static void debug_printing (int value, int sub_automaton);
void fsm_set_EXEC_EDIT (int value)
void fsm_set_exec_edit (int value)
{
if (choice_EXEC_EDIT != value) {
debug_printing (value, 0); // EXEC_EDIT is sub_automaton 0
@ -57,7 +57,7 @@ void fsm_set_EXEC_EDIT (int value)
}
}
void fsm_set_STATE_RULES_DATA (int value)
void fsm_set_state_rules_data (int value)
{
if (choice_STATE_RULES_DATA != value) {
debug_printing (value, 1); // STATE_RULES_DATA is sub_automaton 1
@ -73,7 +73,7 @@ void fsm_reset_all_objects_transparencies_at_value (int value)
debug_printing (value, 2); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
reset_all_objects_transparencies_to_value (value);
widget_reset_all_objects_transparencies_to_value (value);
}
void fsm_reset_all_situations_transparencies_at_value (int value)
@ -84,10 +84,10 @@ void fsm_reset_all_situations_transparencies_at_value (int value)
debug_printing (value, 3); // SITUATIONS_box_RESET_VALUE is sub_automaton 3
choice_SITUATIONS_box_RESET_VALUE = value;
reset_all_situations_transparencies_to_value (value);
widget_reset_all_situations_transparencies_to_value (value);
}
void fsm_set_SITUATIONS_box_RESET_VALUE (int value)
void fsm_set_situations_box_reset_value (int value)
{
if (choice_SITUATIONS_box_RESET_VALUE != value) {
debug_printing (value, 3); // SITUATIONS_box_RESET_VALUE is sub_automaton 3
@ -95,10 +95,10 @@ void fsm_set_SITUATIONS_box_RESET_VALUE (int value)
}
}
int fsm_get_EXEC_EDIT () {return choice_EXEC_EDIT;}
int fsm_get_STATE_RULES_DATA () {return choice_STATE_RULES_DATA;}
int fsm_get_OBJECTS_box_RESET_VALUE () {return choice_OBJECTS_box_RESET_VALUE;}
int fsm_get_SITUATIONS_box_RESET_VALUE () {return choice_SITUATIONS_box_RESET_VALUE;}
int fsm_get_exec_edit () {return choice_EXEC_EDIT;}
int fsm_get_state_rules_data () {return choice_STATE_RULES_DATA;}
int fsm_get_objects_box_reset_value () {return choice_OBJECTS_box_RESET_VALUE;}
int fsm_get_situations_box_reset_value () {return choice_SITUATIONS_box_RESET_VALUE;}
/******************************************************************************/
@ -124,11 +124,11 @@ static void debug_printing (int value, int sub_automaton)
tab_0 [choice_EXEC_EDIT],
tab_1 [value]);
break;
case (2) : printf("fsm_set_OBJECTS_box_RESET_VALUE : %3d > %3d\n",
fsm_get_OBJECTS_box_RESET_VALUE(), value);
case (2) : printf("fsm_set_objects_box_reset_value : %3d > %3d\n",
fsm_get_objects_box_reset_value(), value);
break;
case (3) : printf("fsm_set_SITUATIONS_box_RESET_VALUE : %3d > %3d\n",
fsm_get_SITUATIONS_box_RESET_VALUE(), value);
case (3) : printf("fsm_set_situations_box_reset_value : %3d > %3d\n",
fsm_get_situations_box_reset_value(), value);
break;
default : printf("default in automaton.debug_printing()\n");
}

View File

@ -146,7 +146,6 @@ int main (int argc, char **argv)
app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
if (0) widget_create_windows (app); // < Erreur de segmentation
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);

View File

@ -2,7 +2,7 @@
* *
* Gem-graph client *
* *
* Callbacks header *
* Signals *
* *
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
* Copyright © 2021 Adrien Bourmault <neox@a-lec.org> *
@ -56,23 +56,6 @@ static void on_auto_notification (const char *message)
}
void on_windows_activation (GtkApplication *app,
gpointer no_user_data)
{
widget_create_main_window (app);
widget_topbar_design_main_window (GTK_WINDOW (widget_topbar_get_main_window ()));
widget_create_dialog_window (app);
widget_topbar_design_dialog_window (GTK_WINDOW (widget_topbar_get_main_window ()),
GTK_WINDOW (widget_topbar_get_dialog_window()));
widget_create_text_window (app);
widget_topbar_design_text_window (GTK_WINDOW (widget_topbar_get_main_window ()),
GTK_WINDOW (widget_topbar_get_text_window()));
}
/******************************************************************************/
/* T R E E */
/******************************************************************************/
@ -216,26 +199,26 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
/* D I A L O G W I D G E T S */
/******************************************************************************/
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL,
void on_save_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL,
gpointer data)
{
gtk_widget_set_sensitive (GTK_WIDGET (data),
TRUE);
printf ("callback.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
printf ("signal.c - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
}
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL,
void on_discard_current_model_before_editing (GtkWidget *btt_SAVE_CURRENT_MODEL,
gpointer data)
{
gtk_window_close (GTK_WINDOW (data));
printf ("callback.c - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
printf ("signal.c - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
}
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL,
void on_write_current_model (GtkWidget *btt_WRITE_CURRENT_MODEL,
gpointer data)
{
gtk_window_close (GTK_WINDOW (data));
printf ("callback.c - WRITE_CURRENT_MODEL\n");
printf ("signal.c - WRITE_CURRENT_MODEL\n");
}
@ -244,37 +227,37 @@ void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL,
/* S T A T E W I D G E T */
/******************************************************************************/
static void switch_STATE_RULES_DATA()
static void switch_state_rules_data()
{
switch (fsm_get_STATE_RULES_DATA()) {
switch (fsm_get_state_rules_data()) {
case (STATE) :
gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()),
GTK_WIDGET (widget_rec_state_page()));
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_state_page()));
break;
case (RULES) :
gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()),
GTK_WIDGET (widget_rec_rules_page()));
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_rules_page()));
break;
case (DATA) :
gtk_window_set_child (GTK_WINDOW (widget_topbar_get_main_window ()),
GTK_WIDGET (widget_rec_stock_page()));
gtk_window_set_child (GTK_WINDOW (widget_get_main_window ()),
GTK_WIDGET (widget_get_stock_page()));
break;
default :
printf("default in callback.on_toggle_STATE_RULES_DATA()\n");
printf("default in signal.on_toggle_state_rule_data()\n");
}
}
void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data)
void on_toggle_exec_edit (GtkWidget *toggled_button, gpointer user_data)
{
if (fsm_get_EXEC_EDIT ()) {
if (fsm_get_exec_edit ()) {
gtk_button_set_icon_name (GTK_BUTTON (toggled_button),
"power-profile-balanced-rtl-symbolic");
fsm_set_EXEC_EDIT (EXEC);
fsm_set_exec_edit (EXEC);
} else {
@ -282,44 +265,45 @@ void on_toggle_EXEC_EDIT (GtkWidget *toggled_button, gpointer user_data)
"text-editor-symbolic");
// https://docs.gtk.org/gtk4/class.Window.html TODO 2024-06-30
// gtk_window_present (GTK_WINDOW (widget_topbar_get_dialog_window())); // works once only !
// gtk_window_present (GTK_WINDOW (widget_get_dialog_window())); // works once only !
fsm_set_EXEC_EDIT (EDIT);
fsm_set_exec_edit (EDIT);
}
switch_STATE_RULES_DATA();
switch_state_rules_data();
}
void on_toggle_STATE_RULES_DATA (GtkWidget *toggled_button, gpointer user_data)
// TODO Il doit y avoir plus élégant,...
void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data)
{
const char *toggled_button_name
= gtk_check_button_get_label (GTK_CHECK_BUTTON (toggled_button));
int is_active = gtk_check_button_get_active (GTK_CHECK_BUTTON (toggled_button));
if (! strcmp (toggled_button_name, "state")) {
fsm_set_STATE_RULES_DATA (STATE);
fsm_set_state_rules_data (STATE);
}
if (! strcmp (toggled_button_name, "rules")) {
fsm_set_STATE_RULES_DATA (RULES);
fsm_set_state_rules_data (RULES);
}
if (! strcmp (toggled_button_name, "data analysis")) {
fsm_set_STATE_RULES_DATA (DATA);
fsm_set_state_rules_data (DATA);
}
if (is_active) {
switch_STATE_RULES_DATA();
switch_state_rules_data();
}
}
void on_OBJECTS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
void on_objects_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{
GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar);
fsm_reset_all_objects_transparencies_at_value (gtk_adjustment_get_value (adj_obj));
}
void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{
GtkAdjustment *adj_situ = gtk_scrollbar_get_adjustment (reset_scrollbar);
fsm_reset_all_situations_transparencies_at_value (gtk_adjustment_get_value (adj_situ));
@ -333,14 +317,14 @@ void on_SITUATIONS_box_DO_RESET (GtkWidget *btt_reset, GtkScrollbar *reset_scrol
void on_clicked_search (GtkWidget *btt_menu, gpointer list_box) {
// next line presents the text_window and works only once.\nIt should present a menu.\n"); // TODO
gtk_window_present (GTK_WINDOW (widget_topbar_get_text_window()));
gtk_window_present (GTK_WINDOW (widget_get_text_window()));
}
void on_clicked_HOME (GtkWidget *btt_reset, gpointer data)
void on_clicked_home (GtkWidget *btt_reset, gpointer data)
{
printf ("callback.on_clicked_HOME() button presents the dialog_window\
printf ("signal.on_clicked_HOME() button presents the dialog_window\
( :- ) but it works only once.\n"); // TODO
gtk_window_present (GTK_WINDOW (widget_topbar_get_dialog_window()));
gtk_window_present (GTK_WINDOW (widget_get_dialog_window()));
}
@ -372,14 +356,14 @@ void on_clicked_HOME (GtkWidget *btt_reset, gpointer data)
/******************************************************************************/
void on_clicked_menu_experiment (GtkWidget *btt_menu, gpointer list_box) {
printf ("callback.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
printf ("signal.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
// gpointer list_box = gtk_popover_get_child (GTK_POPOVER (pop));
/*
if (gtk_list_box_get_row_at_index (list_box, 3))
printf ("callback.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
else printf ("callback.on_clicked_MENU() button > in list_box are the three buttons : %s, %s, %s\n\
printf ("signal.on_clicked_MENU() button > %p < &list_box > children nb > 3\n", list_box);
else printf ("signal.on_clicked_MENU() button > in list_box are the three buttons : %s, %s, %s\n\
and now : how to display these three buttons (and make use of them) ? 2024-07-13 (20h)\n",\
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (gtk_list_box_get_row_at_index (list_box, 0)))),
gtk_button_get_label (GTK_BUTTON (gtk_list_box_row_get_child (gtk_list_box_get_row_at_index (list_box, 1)))),

View File

@ -38,28 +38,21 @@
static GtkWindow *main_window, *dialog_window, *text_window;
void *widget_topbar_get_main_window() { return main_window; }
void *widget_topbar_get_dialog_window() { return dialog_window; }
void *widget_topbar_get_text_window() { return text_window; }
void *widget_get_main_window() { return main_window; }
void *widget_get_dialog_window() { return dialog_window; }
void *widget_get_text_window() { return text_window; }
void widget_create_windows (GtkApplication *app)
void on_windows_activation (GtkApplication *app)
{
// g_application_activate (G_APPLICATION (app)); < how ? > in main.c is
// g_signal_connect (app, "activate", G_CALLBACK (on_windows_activation), NULL);
main_window = GTK_WINDOW (gtk_application_window_new (app));
dialog_window = GTK_WINDOW (gtk_application_window_new (app));
text_window = GTK_WINDOW (gtk_application_window_new (app));
widget_topbar_design_main_window (main_window);
widget_topbar_design_dialog_window (main_window, dialog_window);
widget_topbar_design_text_window (main_window, text_window);
widget_design_main_window (main_window);
widget_design_dialog_window (main_window, dialog_window);
widget_design_text_window (main_window, text_window);
}
void widget_create_main_window (GtkApplication *app)
{ main_window = GTK_WINDOW (gtk_application_window_new (app)); }
void widget_create_dialog_window (GtkApplication *app)
{ dialog_window = GTK_WINDOW (gtk_application_window_new (app)); }
void widget_create_text_window (GtkApplication *app)
{ text_window = GTK_WINDOW (gtk_application_window_new (app)); }

View File

@ -68,20 +68,11 @@
/* C O N T A I N E R S */
/******************************************************************************/
// 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
// https://docs.gtk.org/gtk4/section-text-widget.html
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// https://docs.gtk.org/gtk4/class.TextView.html
// https://docs.gtk.org/gtk4/class.TextBuffer.html
// https://docs.gtk.org/gtk3/method.TextIter.get_text.html
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
void labo_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) {
struct TreeNode_t *a = widget_create_user_tree_node("We, the people");widget_add_child_node(tree_root, a);
struct TreeNode_t *b = widget_create_user_tree_node("in Order to"); widget_add_child_node(tree_root, b);
struct TreeNode_t *c = widget_create_user_tree_node("do establish"); widget_add_child_node(tree_root, c);
@ -113,14 +104,6 @@ void labo_let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t
struct TreeNode_t *cc = widget_create_user_tree_node("access"); widget_add_child_node(c, cc);
}
void labo_create_a_simple_gtk_string_list () {
char *array[] = {"one", "two", "three", "four", NULL};
GtkStringList *list = gtk_string_list_new ((const char * const *) array);
for (int i = 0; i < 4; i++)
printf ("in labo.a_simple_gtk_string_list() > list [%d + 1] = %s\n",\
i,
gtk_string_list_get_string (list, i));
}
/*
"rule effect"
@ -162,6 +145,16 @@ void labo_create_a_simple_gtk_string_list () {
*/
// 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
// https://docs.gtk.org/gtk4/section-text-widget.html
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
// https://docs.gtk.org/gtk4/class.TextView.html
// https://docs.gtk.org/gtk4/class.TextBuffer.html
// https://docs.gtk.org/gtk3/method.TextIter.get_text.html
/* https://iconduck.com/sets/adwaita-icon-theme
https://iconduck.com/sets/carbon-icons < pas mal ...

View File

@ -40,14 +40,14 @@ static GtkWidget *rec_selected_rules_vpaned_new() {
gtk_paned_set_shrink_end_child (EXEC_CONTROLS_pane, FALSE);
GtkBox *up_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (up_box, GTK_WIDGET (widget_rec_image_GLUTAMATE()));
gtk_box_append (up_box, GTK_WIDGET (widget_get_image_glutamate()));
gtk_box_append (up_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
gtk_box_append (up_box, GTK_WIDGET (widget_rec_image_GLUTAMINE()));
gtk_box_append (up_box, GTK_WIDGET (widget_get_image_glutamine()));
GtkBox *bottom_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
gtk_box_append (bottom_box, GTK_WIDGET (widget_rec_image_ATP()));
gtk_box_append (bottom_box, GTK_WIDGET (widget_get_image_ATP()));
gtk_box_append (bottom_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
gtk_box_append (bottom_box, GTK_WIDGET (widget_rec_image_AMP()));
gtk_box_append (bottom_box, GTK_WIDGET (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));
@ -58,13 +58,13 @@ static GtkWidget *rec_selected_rules_vpaned_new() {
static GtkBox *rec_rules_comparator_new(){
GtkBox *comparator = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_widget_set_size_request (GTK_WIDGET (comparator), W_IMAGE_LOCAL, H_IMAGE_LOCAL);
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_ATP()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_ATP()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_AMP()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_AMP()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_GLUTAMATE()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_glutamate()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (widget_rec_image_GLUTAMINE()));
gtk_box_append (comparator, GTK_WIDGET (widget_get_image_glutamine()));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (comparator, GTK_WIDGET (gtk_picture_new_for_filename ("/home/jean/Gem-Graph/gem-graph-client/data/image/histidine.png")));
gtk_box_append (comparator, GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
@ -80,8 +80,8 @@ static GtkWidget *rec_rules_tree_hpaned_new(){
// GtkWidget *arbre_des_règles = gtk_frame_new ("Arbre");
// GtkWidget *comparaison_des_règles_sélectionnées = gtk_frame_new ("Sélection");
gtk_paned_set_start_child (H_tree_vs_comparison, GTK_WIDGET (widget_rec_user_rules_tree()));
// GTK_SCROLLED_WINDOW
gtk_paned_set_start_child (H_tree_vs_comparison, GTK_WIDGET (widget_get_user_rules_tree()));
gtk_paned_set_end_child (H_tree_vs_comparison, GTK_WIDGET (rec_rules_comparator_new()));
gtk_paned_set_position (H_tree_vs_comparison, 300);
gtk_paned_set_wide_handle (H_tree_vs_comparison, TRUE);
@ -91,7 +91,7 @@ static GtkWidget *rec_rules_tree_hpaned_new(){
return GTK_WIDGET (H_tree_vs_comparison);
}
GtkWidget *widget_rec_rules_page() {
void *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");

View File

@ -67,7 +67,8 @@ static GtkBox *rec_XYZ_box()
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_with_label ("reset");
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));
@ -90,7 +91,7 @@ static GtkBox *rec_ZOOM_box()
static GtkScrollbar *object_bar [n_objects];
static GtkAdjustment *object_adjust [n_objects];
void reset_all_objects_transparencies_to_value (int value)
void widget_reset_all_objects_transparencies_to_value (int value)
{
for (int i = 0; i < n_objects; i++)
if (value > -1)
@ -107,7 +108,7 @@ static GtkBox *rec_OBJECTS_box()
gtk_box_append (objects_box, GTK_WIDGET (reset_scrollbar));
GtkWidget *btt_reset = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic");
g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_OBJECTS_box_DO_RESET), reset_scrollbar);
g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_objects_box_do_reset), reset_scrollbar);
gtk_box_append (objects_box, btt_reset);
// GtkAdjustment *object_adjust [n_objects]; // (value, lower, upper, step_increment, page_increment, page_size)
@ -126,7 +127,7 @@ static GtkBox *rec_OBJECTS_box()
gtk_box_append (objects_box, GTK_WIDGET (object_bar [i]));
}
reset_all_objects_transparencies_to_value (-1);
widget_reset_all_objects_transparencies_to_value (-1);
return objects_box;
}
@ -134,7 +135,7 @@ static GtkBox *rec_OBJECTS_box()
static GtkScrollbar *situation_bar [n_situations];
static GtkAdjustment *situation_adjust [n_situations];
void reset_all_situations_transparencies_to_value (int value)
void widget_reset_all_situations_transparencies_to_value (int value)
{
for (int i = 0; i < n_situations; i++)
if (value > -1)
@ -151,7 +152,7 @@ static GtkBox *rec_SITUATIONS_box()
gtk_box_append (situations_box, GTK_WIDGET (reset_scrollbar));
GtkWidget *btt_reset = gtk_toggle_button_new ();
gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic");
g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_SITUATIONS_box_DO_RESET), reset_scrollbar);
g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_situations_box_do_reset), reset_scrollbar);
gtk_box_append (situations_box, btt_reset);
for (int i = 0; i < n_situations; i++)
@ -172,7 +173,7 @@ static GtkBox *rec_SITUATIONS_box()
gtk_box_append (situations_box, GTK_WIDGET (situation_bar [i]));
}
reset_all_situations_transparencies_to_value (-1);
widget_reset_all_situations_transparencies_to_value (-1);
return situations_box;
}
@ -218,7 +219,7 @@ static GtkWidget *rec_SPACE_VIEW_box()
GtkBox *central_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
// TODO
gtk_box_append (central_box, GTK_WIDGET (widget_rec_image_E_coli()));
gtk_box_append (central_box, GTK_WIDGET (widget_get_image_E_coli()));
// ui_setup_glarea (0, GTK_WIDGET (central_box));
gtk_box_append (central_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_VERTICAL)));
@ -269,14 +270,14 @@ static GtkWidget *rec_SEQUENCE_CONTROL_box()
* - CONTRAST en haut permet de modifier un à un les contrastes des objets et des situations
* afin de mieux mettre en évidence l'objet ou le phénomène d'intérêt */
GtkWidget *widget_rec_state_page()
void *widget_get_state_page()
{
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (page_box, GTK_WIDGET (rec_OBJECTS_and_SITUATIONS()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (page_box, GTK_WIDGET (rec_SPACE_VIEW_box()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
if (fsm_get_EXEC_EDIT ()) gtk_box_append (page_box, GTK_WIDGET (rec_SPACE_EDIT_CONTROL_box()));
if (fsm_get_exec_edit ()) gtk_box_append (page_box, GTK_WIDGET (rec_SPACE_EDIT_CONTROL_box()));
else gtk_box_append (page_box, GTK_WIDGET (rec_SEQUENCE_CONTROL_box()));
return GTK_WIDGET (page_box);
}

View File

@ -31,7 +31,7 @@
#include "../../include/signal.h"
#include "../../include/widget.h"
GtkWidget *widget_rec_stock_page () {
void *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");
@ -64,7 +64,7 @@ GtkWidget *widget_rec_stock_page () {
return GTK_WIDGET (data_box);
}
GtkWidget *widget_rec_stock_text (gchar *text_address) {
void *widget_get_stock_text (gchar *text_address) {
GtkWidget *view = gtk_text_view_new ();
GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
gtk_text_buffer_set_text (buffer, read_file (text_address), -1);
@ -85,15 +85,15 @@ GtkWidget *widget_rec_stock_text (gchar *text_address) {
/* T E X T S */
/******************************************************************************/
gchar *widget_rec_text_address_theory () {
char *widget_get_text_address_theory () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/théorie.txt";
}
gchar *widget_rec_text_address_about_commands () {
char *widget_get_text_address_about_commands () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/about_commands.txt";
}
gchar *widget_rec_text_address_any () {
char *widget_get_text_address_any () {
return "/home/jean/Gem-Graph/gem-graph-client/data/text/any.txt";
}
@ -103,31 +103,31 @@ gchar *widget_rec_text_address_any () {
/* I M A G E S */
/******************************************************************************/
GtkWidget *widget_rec_image_E_coli(){
void *widget_get_image_E_coli(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/E coli by D Goodsell.png");
return image;
}
GtkWidget *widget_rec_image_GLUTAMATE(){
void *widget_get_image_glutamate(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamate.png");
return image;
}
GtkWidget *widget_rec_image_GLUTAMINE(){
void *widget_get_image_glutamine(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/glutamine.png");
return image;
}
GtkWidget *widget_rec_image_ATP(){
void *widget_get_image_ATP(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/ATP.png");
return image;
}
GtkWidget *widget_rec_image_AMP(){
void *widget_get_image_AMP(){
GtkWidget *image = gtk_picture_new_for_filename
("/home/jean/Gem-Graph/gem-graph-client/data/image/AMP.png");
return image;

View File

@ -43,15 +43,15 @@ static GtkButton *btt_STATE, *btt_RULES, *btt_DATA;
/* T E X T W I N D O W */
/******************************************************************************/
void widget_topbar_design_text_window (GtkWindow *main_window, GtkWindow *text_window)
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_rec_stock_text (widget_rec_text_address_theory());
child = widget_rec_stock_text (widget_rec_text_address_about_commands());
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);
@ -66,7 +66,7 @@ void widget_topbar_design_text_window (GtkWindow *main_window, GtkWindow *text_w
/* D I A L O G W I N D O W */
/******************************************************************************/
void widget_topbar_design_dialog_window (GtkWindow *main_window, GtkWindow *dialog_window)
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 ());
@ -79,15 +79,15 @@ void widget_topbar_design_dialog_window (GtkWindow *main_window, GtkWindow *dial
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);
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);
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);
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) ;
@ -110,16 +110,18 @@ 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_topbar_design_main_window (GtkWindow *main_window)
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);
// next line <=> calls.on_toggle_STATE_RULES_DATA (btt_STATE)
// next line <=> calls.on_toggle_state_rule_data (btt_STATE)
gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_STATE), 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)";
@ -142,23 +144,23 @@ static void window_header_bar_left (GtkWidget *header_bar)
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);
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 ());
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);
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);
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);
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));
@ -182,7 +184,7 @@ static void window_header_bar_right (GtkWidget *header_bar)
GtkButton *btt_go_home = GTK_BUTTON (gtk_button_new ());
gtk_button_set_icon_name (btt_go_home, "go-home-symbolic");
g_signal_connect (btt_go_home, "clicked", G_CALLBACK (on_clicked_HOME), no_local_data);
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 ());
@ -287,3 +289,4 @@ static void window_header_bar_right (GtkWidget *header_bar)
// gtk_button_set_icon_name (search, "preferences-desktop-appearance-symbolic");
// gtk_button_set_icon_name (search, "applications-utilities-symbolic");

View File

@ -83,10 +83,10 @@ static GListModel *get_user_tree_model (GObject *item, gpointer root)
return get_user_tree_model_child (cur);
}
GtkScrolledWindow *widget_rec_user_rules_tree ()
void *widget_get_user_rules_tree ()
{
struct TreeNode_t *tree_root = widget_create_user_tree_node("root");
labo_let_us_create_a_complex_useless_and_expensive_tree (tree_root);
widget_let_us_create_a_complex_useless_and_expensive_tree (tree_root);
GtkStringList *model = gtk_string_list_new(NULL);
gtk_string_list_append (model, tree_root->text);