WIP: un peu crade, mais... donne une idée des switch de pages par toggles
This commit is contained in:
parent
40a27a68e6
commit
72736a6165
8
(notes)
8
(notes)
|
@ -22,6 +22,14 @@ 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,
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery
|
||||
// https://docs.gtk.org/gtk4/section-text-widget.html
|
||||
// https://docs.gtk.org/gtk4/class.Widget.html#height-for-width-geometry-management
|
||||
// GTK_ORIENTATION_VERTICAL GTK_ORIENTATION_HORIZONTAL
|
||||
|
||||
|
||||
|
||||
|
|
63
callback.c
63
callback.c
|
@ -8,19 +8,22 @@
|
|||
#include "parsing.h"
|
||||
#include "graph_area.h"
|
||||
|
||||
static GtkWindow *main_window;
|
||||
|
||||
/******************************************************************************/
|
||||
/* M A I N W I N D O W A C T I V A T I O N */
|
||||
/******************************************************************************/
|
||||
void ui_main_window (GtkApplication *self, gpointer user_data)
|
||||
void on_main_window_activation (GtkApplication *self, gpointer user_data)
|
||||
{
|
||||
GtkWindow *main_window = GTK_WINDOW (gtk_application_window_new (self));
|
||||
main_window = GTK_WINDOW (gtk_application_window_new (self));
|
||||
window_main_child (main_window, 0); // 0 is the state page (see contain.c)
|
||||
window_header_bar (main_window,
|
||||
"E coli (with permission from David S. Goodsell, 2009)");
|
||||
two_notebooks_in_two_panes (main_window);
|
||||
// gtk_window_fullscreen (main_window); << WARNING : no more header bar !
|
||||
gtk_window_present (GTK_WINDOW (main_window));
|
||||
}
|
||||
|
||||
void ui_send_internal_notification(const char *message)
|
||||
void on_auto_notification (const char *message)
|
||||
{
|
||||
/* Ignored (2024-06-06) because I don't know how to get "main_window" easily
|
||||
|
||||
|
@ -69,12 +72,12 @@ gboolean on_glarea_render(GtkGLArea *area, GdkGLContext *context)
|
|||
{
|
||||
// Check if the widget is a glarea
|
||||
if(gtk_gl_area_get_error(area) != NULL) {
|
||||
////////////////////////// ui_send_internal_notification("An OpenGL error occured !");
|
||||
////////////////////////// on_auto_notification("An OpenGL error occured !");
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////// if (ui_render_stack(gtk_widget_get_parent(GTK_WIDGET(area))) == false) {
|
||||
////////////////////////// ui_send_internal_notification("Failed to render corresponding graphic stack !");
|
||||
////////////////////////// on_auto_notification("Failed to render corresponding graphic stack !");
|
||||
////////////////////////// return false;
|
||||
////////////////////////// }
|
||||
|
||||
|
@ -92,14 +95,14 @@ void on_glarea_realize(GtkWidget *widget)
|
|||
|
||||
// Check if the widget is a glarea
|
||||
if(gtk_gl_area_get_error(GTK_GL_AREA(widget)) != NULL) {
|
||||
ui_send_internal_notification("An OpenGL error occured !");
|
||||
on_auto_notification("An OpenGL error occured !");
|
||||
return;
|
||||
}
|
||||
|
||||
// Link graphical stack to widget
|
||||
if (ui_init_graphic_stack(gtk_widget_get_parent(widget),
|
||||
internal_error) == false) {
|
||||
ui_send_internal_notification(
|
||||
on_auto_notification(
|
||||
"Failed to link the graphic stack to widgets !");
|
||||
return;
|
||||
}
|
||||
|
@ -117,14 +120,14 @@ void on_glarea_unrealize(GtkWidget *widget)
|
|||
|
||||
// Check if the widget is a glarea
|
||||
if(gtk_gl_area_get_error(GTK_GL_AREA(widget)) != NULL) {
|
||||
ui_send_internal_notification("An OpenGL error occured !");
|
||||
on_auto_notification("An OpenGL error occured !");
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy graphic stack
|
||||
if (ui_shutdown_graphic_stack(gtk_widget_get_parent(widget),
|
||||
internal_error) == false) {
|
||||
ui_send_internal_notification(
|
||||
on_auto_notification(
|
||||
"Failed to shutdown the graphic stack !");
|
||||
return;
|
||||
}
|
||||
|
@ -156,11 +159,11 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
|
|||
/******************************************************************************/
|
||||
/* B U T T O N S */
|
||||
/******************************************************************************/
|
||||
void ui_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec)
|
||||
void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec)
|
||||
{
|
||||
if (get_exec_edit_mode()) {
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "system-run-symbolic");
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_run_stop_model_exec), "media-playback-start-symbolic");
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "power-profile-balanced-rtl-symbolic");
|
||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run ");
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), TRUE);
|
||||
set_exec_edit_mode (0);
|
||||
} else {
|
||||
|
@ -169,21 +172,47 @@ void ui_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_
|
|||
set_exec_edit_mode (1);
|
||||
// Ici, il faudra prévenir l'utilisateur par une pop-up window : TODO (sauvegarde automatique sinon)
|
||||
// S'il ne prend pas la main, les données de la simulation en cours risquent d'être perdues
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_run_stop_model_exec), "media-playback-pause-symbolic");
|
||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " off ");
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (btt_run_stop_model_exec), FALSE);
|
||||
set_run_xor_stop_exec (0);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data)
|
||||
void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data)
|
||||
{
|
||||
if (get_run_xor_stop_exec() && ! get_exec_edit_mode()) {
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_run_stop_model_exec), "media-playback-start-symbolic");
|
||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), " run ");
|
||||
set_run_xor_stop_exec (0);
|
||||
} else {
|
||||
gtk_button_set_icon_name (GTK_BUTTON (btt_run_stop_model_exec), "media-playback-pause-symbolic");
|
||||
gtk_button_set_label (GTK_BUTTON (btt_run_stop_model_exec), "stop");
|
||||
set_run_xor_stop_exec (1);
|
||||
}
|
||||
}
|
||||
|
||||
// in_depth.c : enum { STATE, RULES, MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
|
||||
|
||||
void on_toggle_state_rules (GtkWidget *btt_toggle_state_rules, gpointer data)
|
||||
{
|
||||
if (get_run_xor_stop_exec()) {
|
||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "state");
|
||||
window_main_child (main_window, 0); // 0 = state page (see contain.c)
|
||||
set_run_xor_stop_exec (0);
|
||||
} else {
|
||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_state_rules), "rules");
|
||||
window_main_child (main_window, 1); // 1 = rules page (see contain.c)
|
||||
set_run_xor_stop_exec (1);
|
||||
}
|
||||
}
|
||||
|
||||
void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointer data)
|
||||
{
|
||||
if (get_observ_interpret()) {
|
||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "observe");
|
||||
window_main_child (main_window, 2); // 2 = measures page (see contain.c)
|
||||
set_observ_interpret (0);
|
||||
} else {
|
||||
gtk_button_set_label (GTK_BUTTON (btt_toggle_observ_interpret), "interpret");
|
||||
window_main_child (main_window, 3); // 3 = observe page (see contain.c)
|
||||
set_observ_interpret (1);
|
||||
}
|
||||
}
|
||||
|
|
10
callback.h
10
callback.h
|
@ -1,8 +1,8 @@
|
|||
#include <gtk-4.0/gtk/gtk.h>
|
||||
|
||||
|
||||
void ui_main_window (GtkApplication *app, gpointer user_data);
|
||||
void ui_send_internal_notification(const char *message);
|
||||
void on_main_window_activation (GtkApplication *app, gpointer user_data);
|
||||
void on_auto_notification (const char *message);
|
||||
|
||||
void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data);
|
||||
void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data);
|
||||
|
@ -13,8 +13,10 @@ void on_glarea_unrealize(GtkWidget *widget);
|
|||
|
||||
void on_axis_value_change (GtkAdjustment *adjustment, gpointer data);
|
||||
|
||||
void ui_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, gpointer data);
|
||||
void ui_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data);
|
||||
void on_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, gpointer data);
|
||||
void on_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data);
|
||||
void on_toggle_state_rules (GtkWidget *btt_toggle_state_rules, gpointer data);
|
||||
void on_toggle_observ_interpret (GtkWidget *btt_toggle_observ_interpret, gpointer data);
|
||||
|
||||
|
||||
|
||||
|
|
39
contain.c
39
contain.c
|
@ -154,31 +154,48 @@ static void icons_for_fun (GtkHeaderBar *header_bar);
|
|||
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);
|
||||
|
||||
GtkButton *run_stop_model_exec = GTK_BUTTON (gtk_toggle_button_new ());
|
||||
gtk_button_set_icon_name (run_stop_model_exec, "system-shutdown-symbolic");
|
||||
gtk_button_set_icon_name (run_stop_model_exec, "media-playback-pause-symbolic");
|
||||
gtk_button_set_icon_name (run_stop_model_exec, "media-playback-start-symbolic");
|
||||
g_signal_connect (run_stop_model_exec, "clicked", G_CALLBACK (ui_toggle_model_exec), NULL);
|
||||
gpointer no_local_data = NULL;
|
||||
|
||||
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 *exec_xor_edit = GTK_BUTTON (gtk_toggle_button_new ());
|
||||
// gtk_button_set_icon_name (exec_xor_edit, "system-run-symbolic");
|
||||
// g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (ui_toggle_run_edit), NULL);
|
||||
gtk_button_set_icon_name (exec_xor_edit, "document-edit-symbolic");
|
||||
gtk_button_set_icon_name (exec_xor_edit, "text-editor-symbolic");
|
||||
gtk_button_set_icon_name (exec_xor_edit, "system-run-symbolic");
|
||||
g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (ui_toggle_exec_edit), run_stop_model_exec);
|
||||
gtk_button_set_icon_name (exec_xor_edit, "power-profile-balanced-rtl-symbolic");
|
||||
g_signal_connect (exec_xor_edit, "clicked", G_CALLBACK (on_toggle_exec_edit), run_stop_model_exec);
|
||||
|
||||
GtkButton *toggle_state_rules = GTK_BUTTON (gtk_button_new_with_label ("state"));
|
||||
g_signal_connect (toggle_state_rules, "clicked", G_CALLBACK (on_toggle_state_rules), no_local_data);
|
||||
|
||||
GtkButton *observ_interpret = GTK_BUTTON (gtk_button_new_with_label ("observe"));
|
||||
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_window_set_titlebar (window, header_bar);
|
||||
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (toggle_state_rules));
|
||||
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
|
||||
}
|
||||
|
||||
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) : gtk_window_set_child (main_window, GTK_WIDGET (get_run_space_page_new())); break;
|
||||
case (1) : gtk_window_set_child (main_window, GTK_WIDGET (get_run_rules_page_new())); break;
|
||||
case (2) : gtk_window_set_child (main_window, GTK_WIDGET (get_run_measures_page_new())); break;
|
||||
case (3) : gtk_window_set_child (main_window, GTK_WIDGET (get_run_results_page_new())); break;
|
||||
case (4) : gtk_window_set_child (main_window, GTK_WIDGET (get_run_discuss_page_new())); break;
|
||||
case (5) : gtk_window_set_child (main_window, GTK_WIDGET (get_run_help_page_new())); break;
|
||||
default : gtk_window_set_child (main_window, GTK_WIDGET (get_run_space_page_new()));
|
||||
}
|
||||
}
|
||||
|
||||
void two_notebooks_in_two_panes (GtkWindow *window) {
|
||||
GtkNotebook *run_notebook = GTK_NOTEBOOK(gtk_notebook_new());
|
||||
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(run_notebook), GTK_POS_TOP); // GTK_POS_LEFT
|
||||
|
|
|
@ -31,6 +31,7 @@ G_END_DECLS
|
|||
*/
|
||||
|
||||
void window_header_bar (GtkWindow *window, char *title);
|
||||
void window_main_child (GtkWindow *window, int selected_page);
|
||||
void two_notebooks_in_two_panes (GtkWindow *window);
|
||||
GtkWidget *get_selected_rules_vpaned_new();
|
||||
GtkFrame *get_frame_with_label();
|
||||
|
|
23
in_depth.c
23
in_depth.c
|
@ -8,10 +8,10 @@
|
|||
/******************************************************************************/
|
||||
|
||||
enum { EXEC_MODE, EDIT_MODE};
|
||||
static int run_edit_mode_val = EXEC_MODE;
|
||||
static int exec_edit_mode = EXEC_MODE;
|
||||
|
||||
int get_exec_edit_mode () {return run_edit_mode_val;}
|
||||
void set_exec_edit_mode (int prescribed_mode) {run_edit_mode_val = prescribed_mode;}
|
||||
int get_exec_edit_mode () {return exec_edit_mode;}
|
||||
void set_exec_edit_mode (int prescribed) {exec_edit_mode = prescribed;}
|
||||
|
||||
|
||||
|
||||
|
@ -20,9 +20,20 @@ void set_exec_edit_mode (int prescribed_mode) {run_edit_mode_val = prescribed_mo
|
|||
/******************************************************************************/
|
||||
|
||||
enum { STOP, RUN };
|
||||
static int run_stop_val = STOP;
|
||||
static int run_stop = STOP;
|
||||
|
||||
int get_run_xor_stop_exec () {return run_stop_val;}
|
||||
void set_run_xor_stop_exec (int prescribed_state) {run_stop_val = prescribed_state;}
|
||||
int get_run_xor_stop_exec () {return run_stop;}
|
||||
void set_run_xor_stop_exec (int prescribed) {run_stop = prescribed;}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* STATE / RULES / MEASURES / INTERPRETATIONS */
|
||||
/******************************************************************************/
|
||||
|
||||
enum { STATE, RULES, MEASURE, OBSERVE, INTERPRET, HELP, CONFIGURE };
|
||||
static int switch_observ_interpret = STATE;
|
||||
|
||||
int get_observ_interpret () {return switch_observ_interpret;}
|
||||
void set_observ_interpret (int prescribed) {switch_observ_interpret = prescribed;}
|
||||
|
||||
// if (0) printf ("switch_observ_interpret = %d\n", switch_observ_interpret);
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
#include <gtk-4.0/gtk/gtk.h>
|
||||
#include <assert.h>
|
||||
|
||||
void set_exec_edit_mode (int prescribed_mode);
|
||||
void set_exec_edit_mode (int prescribed);
|
||||
int get_exec_edit_mode ();
|
||||
|
||||
void set_run_xor_stop_exec (int prescribed_state);
|
||||
void set_run_xor_stop_exec (int prescribed);
|
||||
int get_run_xor_stop_exec ();
|
||||
|
||||
void set_observ_interpret (int prescribed);
|
||||
int get_observ_interpret ();
|
||||
|
||||
|
|
2
main.c
2
main.c
|
@ -15,7 +15,7 @@ int main (int argc, char **argv)
|
|||
int status;
|
||||
|
||||
app = gtk_application_new ("org.jean.GTK4_GG_hack", G_APPLICATION_DEFAULT_FLAGS);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (ui_main_window), NULL);
|
||||
g_signal_connect (app, "activate", G_CALLBACK (on_main_window_activation), NULL);
|
||||
status = g_application_run (G_APPLICATION (app), argc, argv);
|
||||
g_object_unref (app);
|
||||
|
||||
|
|
Loading…
Reference in New Issue