Compare commits

...

15 Commits

Author SHA1 Message Date
Jean Sirmai e93358f6dc
WIP: pas mieux... 2024-06-19 23:25:33 +02:00
Jean Sirmai 5c5bd709d9
WIP: toujours perdu... 2024-06-19 10:46:26 +02:00
Jean Sirmai 270b2feba5
WIP: toujours perdu entre stack, stack_child et stack_page (les noms sont mal choisis) 2024-06-19 10:24:35 +02:00
Jean Sirmai 6adcdc7d96
WIP: comment utiliser ce switcher pour afficher ses 'stack_pages' ? 2024-06-19 00:14:22 +02:00
Jean Sirmai b40b3e2598
un switcher avec trois 'titled' dans la header_bar (mais rien ne fonctionne encore) 2024-06-18 23:41:21 +02:00
Jean Sirmai 29b09fa771
WIP: adding a stack_switcher in the header_bar... a switcher, but not its pages ?... 2024-06-18 22:07:48 +02:00
Jean Sirmai 53f2fea60c
WIP: on repart du 'design' de la barre de titre simplifié 2024-06-17 21:24:24 +02:00
Jean Sirmai 31957b7835
WIP: https://docs.gtk.org/gtk4/class.ToggleButton.html < TODO 2024-06-17 11:48:20 +02:00
Jean Sirmai aa3c7bcc82
WIP: reprise de l'automate : états d'abord (using printf() only) - window design ensuite 2024-06-16 06:38:14 +02:00
Jean Sirmai e6871816a4
WIP: > Il faut fusionner les deux enums mode et choice (automaton.h) 2024-06-16 00:06:49 +02:00
Jean Sirmai bd252031c7
WIP: les GTK_CHECK_BUTTON sont 'toggled' > la fenêtre est réaffichée (2 fois) 2024-06-15 23:29:17 +02:00
Jean Sirmai 0f0c21b299
WIP: cleaning 2024-06-15 00:01:58 +02:00
Jean Sirmai 981886d79b
TROIS BOUTONS: STATE, RULES et DATA in a radio group (cleaning) 2024-06-14 07:48:24 +02:00
Jean Sirmai 4cd7a0215a
TROIS BOUTONS: STATE, RULES et DATA 2024-06-14 07:20:01 +02:00
Jean Sirmai 83c3254732
WIP: simple, facile mais soit 'rules' soit 'state' n'apparait pas quand toggle data_analysis 2024-06-14 00:08:02 +02:00
8 changed files with 257 additions and 110 deletions

14
(notes)
View File

@ -24,6 +24,20 @@ graph_stack.c: (316) stack->arrows_nb = set_arrow (stack_id, stack->arrows_nb
contain is called (#included) in : callback, display, tree, graph_stack, graph_area, init, contain is called (#included) in : callback, display, tree, graph_stack, graph_area, init,
--------------------------------------------------------------------------------
https://developer.gnome.org/documentation/guidelines.html
https://developer.gnome.org/documentation/guidelines/devel-docs.html
https://docs.gtk.org/gtk4/class.StackPage.html
https://docs.gtk.org/gtk4/class.Stack.html
https://docs.gtk.org/gtk4/class.StackSwitcher.html
https://docs.gtk.org/gtk4/method.StackSwitcher.set_stack.html
https://docs.gtk.org/gtk4/ctor.StackSwitcher.new.html
https://docs.gtk.org/gtk4/ctor.Stack.new.html
https://docs.gtk.org/gtk4/class.ToggleButton.html
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery // https://docs.gtk.org/gtk4/visual_index.html < widgets gallery

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 KiB

View File

@ -8,39 +8,34 @@
/* S T A T E S */ /* S T A T E S */
/******************************************************************************/ /******************************************************************************/
/* (exec / edit) /* (exec / edit) < MODE
* X * X
* (state / rules / data) * (state / rules / data) < VIEW
* X * X
* (measure / analyse / interpret) * (measure / analyse / interpret)
* X
* (read / write)
*/ */
static int status = INTER; // int get_status () {return status;} static int mode = RUN;
void set_mode (int prescribed) {mode = prescribed;}
int get_mode () {return mode;}
static int view = INTER; // int get_view () {return view;}
void set_view (int prescribed) {view = prescribed;}
int get_view () {return view;}
/******************************************************************************/ /******************************************************************************/
/* T R A N S I T I O N S */ /* T R A N S I T I O N S */
/******************************************************************************/ /******************************************************************************/
void SWITCH_TO (int asked) { void toggle_TO (int mode, int view) {
switch (asked) { switch (view) {
case (INTER) : // BEGIN_TO_EXEC_STOP case (INTER) : printf ("switch to INTER\n"); break;
status = STATE; printf ("SWITCH_TO INTER\n"); case (STATE) : printf ("switch to STATE\n"); break;
break; case (RULES) : printf ("switch to RULES\n"); break;
case (STATE) : // EXEC_STOP_TO_RUN case (DATA) : printf ("switch to DATA \n"); break;
status = RULES; printf ("SWITCH_TO STATE\n");
break;
case (RULES) : // EXEC_RUN_TO_STOP
status = DATA; printf ("SWITCH_TO RULES\n");
break;
case (DATA) : // EXEC_TO_INTER
status = INTER; printf ("SWITCH_TO DATA\n");
break;
default : ; default : ;
} }
//q gtk_window_present (GTK_WINDOW (main_window));
} }
@ -51,6 +46,31 @@ void SWITCH_TO (int asked) {
/* /*
enum { // S T A T E S enum { // S T A T E S
INTER, INTER,
@ -66,7 +86,7 @@ enum { // S T A T E S
CONFIGURE CONFIGURE
}; };
static int status = EXEC_STOP; // int get_status () {return status;} static int view = EXEC_STOP; // int get_view () {return view;}
enum { // T R A N S I T I O N S enum { // T R A N S I T I O N S
BEGIN_TO_EXEC_STOP BEGIN_TO_EXEC_STOP
@ -79,29 +99,29 @@ enum { // T R A N S I T I O N S
}; };
void set_status (int prescribed) { void set_view (int prescribed) {
status = prescribed; if (0) printf ("status = %d\n", status); view = prescribed; if (0) printf ("view = %d\n", view);
switch (status) { switch (view) {
case (0) : // EXEC_STOP DATA_ANALYSIS case (0) : // EXEC_STOP DATA_ANALYSIS
status = EXEC_RUN; view = EXEC_RUN;
break; break;
case (1) : // EXEC_RUN case (1) : // EXEC_RUN
// Ici, il faudra prévenir l'utilisateur par une pop-up window : (sauvegarde automatique sinon) // Ici, il faudra prévenir l'utilisateur par une pop-up window : (sauvegarde automatique sinon)
// S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues // S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues
status = EXEC_STOP; view = EXEC_STOP;
break; break;
case (2) : // EXEC_STOP_EDIT_STOP case (2) : // EXEC_STOP_EDIT_STOP
status = EXEC_RUN_EDIT_RULE; view = EXEC_RUN_EDIT_RULE;
break; break;
case (3) : // EXEC_RUN_EDIT_RULE case (3) : // EXEC_RUN_EDIT_RULE
status = EXEC_STOP_EDIT_RULE; view = EXEC_STOP_EDIT_RULE;
break; break;
case (4) : // EXEC_STOP_EDIT_MEASURE case (4) : // EXEC_STOP_EDIT_MEASURE
status = EXEC_RUN_EDIT_MEASURE; view = EXEC_RUN_EDIT_MEASURE;
break; break;
case (5) : // EXEC_RUN_EDIT_MEASURE case (5) : // EXEC_RUN_EDIT_MEASURE
status = EXEC_STOP_EDIT_MEASURE; view = EXEC_STOP_EDIT_MEASURE;
break; break;
case (6) : // EDIT_STATE case (6) : // EDIT_STATE
break; break;

View File

@ -1,9 +1,25 @@
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
#include <assert.h> #include <assert.h>
void set_status (int prescribed); /******************************************************************************/
int get_status (); /* S T A T E S */
/******************************************************************************/
enum choice { INTER, STATE, RULES, DATA }; /* (exec / edit) < MODE
* X
* (state / rules / data) < VIEW
* X
* (measure / analyse / interpret) < DATA
*/
/******************************************************************************/
void SWITCH_TO (int asked); void set_view (int prescribed);
int get_view ();
void set_mode (int prescribed);
int get_mode ();
enum mode { RUN, EDIT };
enum view { INTER, STATE, RULES, DATA };
// MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
void toggle_TO (int mode, int view);

View File

@ -166,44 +166,55 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
/******************************************************************************/ /******************************************************************************/
/* B U T T O N S */ /* B U T T O N S */
/******************************************************************************/ /******************************************************************************/
void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data) {} void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data) {
void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointer data) {} if (strcmp (gtk_button_get_label (GTK_BUTTON (btt_MODEL_RUN_STOP)), " run "))
void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec) { gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " run ");
// gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "power-profile-balanced-rtl-symbolic"); else gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " stop ");
// gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run "); }
// gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), TRUE);
void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *btt_MODEL_RUN_STOP) {
if (get_mode()) {
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "power-profile-performance-symbolic");
// gtk_button_set_label (GTK_BUTTON (btt_MODEL_RUN_STOP), " run ");
// gtk_widget_set_sensitive (GTK_WIDGET (btt_MODEL_RUN_STOP), TRUE);
set_mode (0);
} else {
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "preferences-system-symbolic");
gtk_button_set_icon_name (GTK_BUTTON (btt_XOR_EXEC_EDIT), "text-editor-symbolic");
// gtk_widget_set_sensitive (GTK_WIDGET (btt_MODEL_RUN_STOP), FALSE);
set_mode (1);
}
} }
void on_toggle_STATE_RULES_DATA (GtkWidget *btt_toggle_STATE_RULES_DATA, gpointer data) void on_open_STATE (GtkWidget *btt_open_STATE, gpointer data) {
{ g_print ("Toggle button %s is active: %s\n",
const char* current_label = gtk_button_get_label (GTK_BUTTON (btt_toggle_STATE_RULES_DATA)); gtk_button_get_label (GTK_BUTTON (btt_open_STATE)),
if (0) printf ("callback.c (line 191) - current_label = %s\n", current_label); gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_STATE)) ? "Yes" : "No");
}//{window_main_child (main_window, STATE); toggle_TO (RUN, STATE);}
if (! strcmp (current_label, "analyse")) { void on_open_RULES (GtkWidget *btt_open_RULES, gpointer data) {
gtk_button_set_label (GTK_BUTTON (btt_toggle_STATE_RULES_DATA), " state "); g_print ("Toggle button %s is active: %s\n",
window_main_child (main_window, 0); gtk_button_get_label (GTK_BUTTON (btt_open_RULES)),
} gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_RULES)) ? "Yes" : "No");
else if (! strcmp (current_label, " state ")) { }//{window_main_child (main_window, RULES); toggle_TO (RUN, RULES);}
gtk_button_set_label (GTK_BUTTON (btt_toggle_STATE_RULES_DATA), " rules ");
window_main_child (main_window, 1); void on_open_DATA (GtkWidget *btt_open_DATA, gpointer data) {
} g_print ("Toggle button %s is active: %s\n",
else { gtk_button_get_label (GTK_BUTTON (btt_open_DATA)),
gtk_button_set_label (GTK_BUTTON (btt_toggle_STATE_RULES_DATA), "analyse"); gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_DATA)) ? "Yes" : "No");
window_main_child (main_window, 2); }//{window_main_child (main_window, DATA); toggle_TO (RUN, DATA);}
}
}
void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { void on_SAVE_CURRENT_MODEL_BEFORE_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
printf ("callback.c (line 201) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n"); printf ("callback.c (line 201) - SAVE_CURRENT_MODEL_BEFORE_EDITING\n");
SWITCH_TO (INTER); toggle_TO (RUN, INTER);
} }
void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) { void on_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data) {
gtk_window_close (GTK_WINDOW (data)); gtk_window_close (GTK_WINDOW (data));
printf ("callback.c (line 206) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n"); printf ("callback.c (line 206) - DISCARD_CURRENT_MODEL_AND_START_EDITING\n");
SWITCH_TO (RULES); toggle_TO (RUN, RULES);
} }
void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) { void on_WRITE_CURRENT_MODEL (GtkWidget *btt_WRITE_CURRENT_MODEL, gpointer data) {

View File

@ -14,10 +14,14 @@ void on_glarea_unrealize (GtkWidget *widget);
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data); void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec); void on_toggle_EXEC_EDIT (GtkWidget *btt_XOR_EXEC_EDIT, GtkWidget *btt_MODEL_RUN_STOP);
void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data); void on_toggle_MODEL_RUN_STOP (GtkWidget *btt_MODEL_RUN_STOP, gpointer data);
void on_toggle_STATE_RULES_DATA (GtkWidget *btt_toggle_STATE_RULES_DATA, gpointer data);
void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointer data); // https://docs.gtk.org/gtk4/class.ToggleButton.html
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_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_DISCARD_CURRENT_MODEL_AND_START_EDITING (GtkWidget *btt_SAVE_CURRENT_MODEL, gpointer data);

168
contain.c
View File

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <gtk-4.0/gtk/gtk.h> #include <gtk-4.0/gtk/gtk.h>
#include <glib-object.h>
#include "callback.h" #include "callback.h"
#include "automaton.h" #include "automaton.h"
@ -146,77 +147,72 @@ GtkWidget *get_SPACE_EDIT_controls_box() {
return GTK_WIDGET (label_ad_hoc); return GTK_WIDGET (label_ad_hoc);
} }
GtkWidget *get_STATE_VIEW_box(){
GtkBox *space_view_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (space_view_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS()));
gtk_box_append (space_view_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (space_view_box, GTK_WIDGET (get_SPACE_VIEW_box()));
gtk_box_append (space_view_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (space_view_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
return GTK_WIDGET (space_view_box);
}
void window_main_child_bottom (GtkBox *page_box){ void window_main_child_bottom (GtkBox *page_box){
// gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box())); // gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
// gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box())); // gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
} }
static void icons_for_fun (GtkHeaderBar *header_bar); // static void icons_for_fun (GtkHeaderBar *header_bar);
void window_header_bar (GtkWindow *window, char *title){ void window_header_bar (GtkWindow *main_window, char *title){
GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ()); 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_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
gtk_window_set_titlebar (window, header_bar); gtk_window_set_titlebar (main_window, header_bar);
// GtkWidget my_window_controls = *gtk_window_controls_new (GTK_PACK_END); // _START GtkButton *btt_XOR_EXEC_EDIT = GTK_BUTTON (gtk_toggle_button_new ());
// gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS(my_window_controls), NULL); // const char* layout); gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "system-run-symbolic");
gtk_button_set_icon_name (btt_XOR_EXEC_EDIT, "power-profile-performance-symbolic");
g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), NULL);
gpointer no_local_data = NULL; GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | "));
GtkButton *exec_xor_edit = GTK_BUTTON (gtk_toggle_button_new ()); // https://docs.gtk.org/gtk4/class.Stack.html
gtk_button_set_icon_name (exec_xor_edit, "system-run-symbolic"); GtkWidget *switcher_SRD = gtk_stack_switcher_new ();
gtk_button_set_icon_name (exec_xor_edit, "power-profile-balanced-rtl-symbolic"); GtkWidget *stack_SRD = gtk_stack_new ();
// g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (on_toggle_exec_edit), run_stop_model_exec); gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher_SRD), GTK_STACK (stack_SRD));
/*
GtkStackPage* page_child_space = gtk_stack_add_child (GTK_STACK (stack_SRD), GTK_WIDGET (get_STATE_VIEW_box()));
GtkStackPage* page_child_rules = gtk_stack_add_child (GTK_STACK (stack_SRD), GTK_WIDGET (get_edit_rules_page_new()));
GtkStackPage* page_child_data = gtk_stack_add_child (GTK_STACK (stack_SRD), GTK_WIDGET (get_measures_page_new()));
*/
gtk_stack_add_titled (GTK_STACK (stack_SRD), GTK_WIDGET (get_STATE_VIEW_box()), "name_space", "space");
gtk_stack_add_titled (GTK_STACK (stack_SRD), GTK_WIDGET (get_edit_rules_page_new()), "name_rules", "rules");
gtk_stack_add_titled (GTK_STACK (stack_SRD), GTK_WIDGET (get_measures_page_new()), "name_data", "data analysis");
// GtkWidget* separe = gtk_separator_new (GTK_ORIENTATION_VERTICAL); // gtk_stack_set_visible_child (GTK_STACK (stack_SRD), GTK_STACK_PAGE (page_child_space));
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (separe)); // printf("gtk_stack_get_child = %s\n", gtk_stack_page_get_name (GTK_STACK_PAGE (gtk_stack_get_visible_child (GTK_STACK (stack_SRD)))));
// gtk_stack_page_get_name (GTK_STACK_PAGE (gtk_stack_get_visible_child (GTK_STACK (stack_SRD)))));
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new ("------------")); gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_XOR_EXEC_EDIT));
GtkButton *run_stop_model_exec = GTK_BUTTON (gtk_button_new_with_label (" run "));
g_signal_connect (run_stop_model_exec, "clicked", G_CALLBACK (on_toggle_model_exec), no_local_data);
GtkButton *btt_toggle_STATE_RULES_DATA = GTK_BUTTON (gtk_button_new_with_label (" state "));
g_signal_connect (btt_toggle_STATE_RULES_DATA, "clicked", G_CALLBACK (on_toggle_STATE_RULES_DATA), no_local_data);
// GtkButton *observ_interpret = GTK_BUTTON (gtk_button_new_with_label ("data analysis"));
// g_signal_connect (observ_interpret, "clicked", G_CALLBACK (on_toggle_observ_interpret), no_local_data);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (exec_xor_edit));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (run_stop_model_exec));
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 (any_Label));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_toggle_STATE_RULES_DATA)); gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (switcher_SRD));
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (observ_interpret));
icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme // gtk_window_set_child (main_window, GTK_WIDGET (get_STATE_VIEW_box()));
} }
void window_main_child (GtkWindow *main_window, int selected_page){ void window_main_child (GtkWindow *main_window, int selected_page){
// in_depth.c : enum { STATE, RULES, MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
switch (selected_page) {
case (0) : // STATE
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2)); GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS())); gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box())); gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL))); gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
window_main_child_bottom (page_box); gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
// if (get_status ()) gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
// else gtk_box_append (page_box, GTK_WIDGET (get_SPACE_EDIT_controls_box()));
gtk_window_set_child (main_window, GTK_WIDGET (page_box)); gtk_window_set_child (main_window, GTK_WIDGET (page_box));
break;
case (1) : gtk_window_set_child (main_window, GTK_WIDGET (get_rules_page_new())); break;
case (2) : gtk_window_set_child (main_window, GTK_WIDGET (get_measures_page_new())); break;
case (3) : gtk_window_set_child (main_window, GTK_WIDGET (get_results_page_new())); break;
case (4) : gtk_window_set_child (main_window, GTK_WIDGET (get_discuss_page_new())); break;
case (5) : gtk_window_set_child (main_window, GTK_WIDGET (get_help_page_new())); break;
default : gtk_window_set_child (main_window, GTK_WIDGET (get_SPACE_VIEW_box())); // + un "help message"
}
} }
void main_window_design (GtkWindow *main_window){ void main_window_design (GtkWindow *main_window){
window_main_child (main_window, 0); // 0 is the state page // window_main_child (main_window, STATE);
window_header_bar (main_window, window_header_bar (main_window,
"E coli (with permission from David S. Goodsell, 2009)"); "E coli (with permission from David S. Goodsell, 2009)");
gtk_window_present (GTK_WINDOW (main_window)); gtk_window_present (GTK_WINDOW (main_window));
@ -232,6 +228,8 @@ void main_window_design (GtkWindow *main_window){
/*
// icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
static void icons_for_fun (GtkHeaderBar *header_bar) static void icons_for_fun (GtkHeaderBar *header_bar)
{ {
@ -303,3 +301,87 @@ static void icons_for_fun (GtkHeaderBar *header_bar)
gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic"); gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic");
gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low)); gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low));
} }
*
*
*
*
*
*
*
*
*
*
*
*
*
Je fais un essai avec un stack_switcher 2024-06-18
void window_header_bar (GtkWindow *window, char *title){
GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new ());
gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), gtk_label_new (title));
gtk_window_set_titlebar (window, header_bar);
// GtkWidget my_window_controls = *gtk_window_controls_new (GTK_PACK_END); // _START
// gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS(my_window_controls), NULL); // const char* layout);
gpointer no_local_data = NULL;
GtkButton *btt_MODEL_RUN_STOP = GTK_BUTTON (gtk_button_new_with_label (" run "));
g_signal_connect (btt_MODEL_RUN_STOP, "clicked", G_CALLBACK (on_toggle_MODEL_RUN_STOP), no_local_data);
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-performance-symbolic");
g_signal_connect (btt_XOR_EXEC_EDIT, "clicked", G_CALLBACK (on_toggle_EXEC_EDIT), btt_MODEL_RUN_STOP);
// GtkWidget* separe = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (separe));
GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (" | "));
GtkButton *btt_open_STATE = GTK_BUTTON (gtk_check_button_new_with_label ("state"));
GtkButton *btt_open_RULES = GTK_BUTTON (gtk_check_button_new_with_label ("rules"));
GtkButton *btt_open_DATA = GTK_BUTTON (gtk_check_button_new_with_label ("data analysis"));
GtkCheckButton *group_STATE_RULES_DATA = GTK_CHECK_BUTTON (gtk_check_button_new ());
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_STATE), group_STATE_RULES_DATA);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_RULES), group_STATE_RULES_DATA);
gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_open_DATA), group_STATE_RULES_DATA);
gtk_check_button_set_active (GTK_CHECK_BUTTON (btt_open_STATE), TRUE);
// int selected = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_STATE));
// if (0) printf("%d\n", selected);
// if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (btt_open_STATE)))
// g_signal_connect (btt_open_STATE, "toggled", G_CALLBACK (on_open_STATE), no_local_data);
// g_signal_connect (btt_open_RULES, "toggled", G_CALLBACK (on_open_RULES), no_local_data);
// g_signal_connect (btt_open_DATA, "toggled", G_CALLBACK (on_open_DATA), no_local_data);
GtkBox *page_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 2));
gtk_box_append (page_box, GTK_WIDGET (get_OBJECTS_and_SITUATIONS()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (page_box, GTK_WIDGET (get_SPACE_VIEW_box()));
gtk_box_append (page_box, GTK_WIDGET (gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)));
gtk_box_append (page_box, GTK_WIDGET (get_TIME_EXEC_controls_box()));
// GObject *a_stack_page = g_object_new (GTK_STACK_PAGE ? );
// https://docs.gtk.org/gobject/tutorial.html#how-to-define-and-implement-a-new-gobject
GtkWidget *a_stack = gtk_stack_new ();
GtkWidget *switcher_SRD = gtk_stack_switcher_new ();
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher_SRD), GTK_STACK (a_stack));
gtk_stack_add_titled (GTK_STACK (a_stack), GTK_WIDGET (page_box), "a_name", "space");
// gtk_stack_page_set_visible (*self, TRUE);
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 (btt_MODEL_RUN_STOP));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (any_Label));
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_STATE));
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_RULES));
// gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (btt_open_DATA));
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (switcher_SRD));
// icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme
}
*/