From ab344575b0ac2926e21343f464ff76c15a631df1 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 30 May 2024 19:55:51 +0200 Subject: [PATCH] WIP: recherche convergence (dans le brouillard...) --- TODO (next version).txt | 26 ++++++++++- include/ui.h | 9 ++-- src/ui/application.c | 2 +- src/ui/contain.c | 16 ++++--- src/ui/events.c | 19 +++----- src/ui/gemgraph.ui | 2 +- src/ui/window.c | 99 +++++++++++++++++------------------------ 7 files changed, 91 insertions(+), 82 deletions(-) diff --git a/TODO (next version).txt b/TODO (next version).txt index d050a4c..a3b4547 100644 --- a/TODO (next version).txt +++ b/TODO (next version).txt @@ -310,4 +310,28 @@ body > script {display: none !important;} } .skip-links a:focus { position: static; -} \ No newline at end of file +} + + + + + + + + + + + + + + + + + + // https://docs.gtk.org/gtk4/class.Widget.html#building-composite-widgets-from-template-xml TODO Learn ! + // gtk_widget_class_bind_template_callback_full (GtkToggleButton, ui_toggle_sidebar, "clicked"); // "main_button_sidebar" + +// https://docs.gtk.org/gtk4/class.Widget.html#building-composite-widgets-from-template-xml +static void gtk_widget_class_dispose_template() {} // TODO ? + +/* -------------------------------------------------------------------------- */ diff --git a/include/ui.h b/include/ui.h index d7fd30f..fa9fb27 100644 --- a/include/ui.h +++ b/include/ui.h @@ -55,6 +55,9 @@ void ui_disable_action (const char *name); void set_run_edit_mode(int prescribed_mode); int get_run_edit_mode(); +// je vais déjà voir si j'arrive à manoeuvrer ces deux là... (2024-05-30) +// GtkWidget *btt_run_xor_edit = gtk_toggle_button_new (); +// GtkWidget *btt_run_stop_exec = gtk_toggle_button_new (); // https://docs.gtk.org/gio/method.ActionMap.add_action_entries.html // A function for creating multiple GSimpleAction instances and adding them to a GActionMap. @@ -103,7 +106,7 @@ void ui_debug_model_loading (GtkWindow *self, const char *file); void ui_set_stack(int mode); void ui_send_internal_notification(const char *message); void ui_close_internal_notification(void); -void ui_toggle_runedit_button(); +void ui_toggle_run_xor_edit(); void ui_toggle_runstop_button(); void ui_toggle_sidebar(); @@ -211,8 +214,8 @@ struct TreeNode_t *create_tree_node (const gchar* text) } // pourquoi je n'arrive pas à le déplacer ici ? -// l'initialisation de « struct TreeNode_t * » depuis « int » -// transforme un entier en pointeur sans transtypage +// > l'initialisation de « struct TreeNode_t * » depuis « int » +// transforme un entier en pointeur sans transtypage < ? static void let_us_create_a_complex_useless_and_expensive_tree (struct TreeNode_t *tree_root) { struct TreeNode_t *a = create_tree_node("We, the people");add_child_node(tree_root, a); diff --git a/src/ui/application.c b/src/ui/application.c index 6cb81ea..59d2a52 100644 --- a/src/ui/application.c +++ b/src/ui/application.c @@ -24,7 +24,7 @@ #include "../../include/ui.h" -#define COMMUTE 1 // 0 first design (2023) based on XML data +#define COMMUTE 0 // 0 first design (2023) based on XML data // 1 2024 May design, free of Builder & templates static int mode = 0; diff --git a/src/ui/contain.c b/src/ui/contain.c index 748b37d..da8e6dd 100644 --- a/src/ui/contain.c +++ b/src/ui/contain.c @@ -183,12 +183,12 @@ void experimental_activate_00 (GtkApplication *app, GtkWindow *window) { GtkWidget *title = GTK_WIDGET (gtk_label_new ("GemGraph 0.1.0")); title = GTK_WIDGET (gtk_label_new ("E coli (with permission from David S. Goodsell, 2009)")); gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header_bar), title); - GtkWidget *run_edit_mode = gtk_toggle_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (run_edit_mode), "document-edit-symbolic"); - gtk_button_set_icon_name (GTK_BUTTON (run_edit_mode), "text-editor-symbolic"); - gtk_button_set_icon_name (GTK_BUTTON (run_edit_mode), "system-run-symbolic"); - gtk_actionable_set_action_name (GTK_ACTIONABLE (run_edit_mode), "app.togglerunedit"); - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), run_edit_mode); + GtkWidget *btt_run_xor_edit = gtk_toggle_button_new (); + gtk_button_set_icon_name (GTK_BUTTON (btt_run_xor_edit), "document-edit-symbolic"); + gtk_button_set_icon_name (GTK_BUTTON (btt_run_xor_edit), "text-editor-symbolic"); + gtk_button_set_icon_name (GTK_BUTTON (btt_run_xor_edit), "system-run-symbolic"); + gtk_actionable_set_action_name (GTK_ACTIONABLE (btt_run_xor_edit), "app.togglerunedit"); + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), btt_run_xor_edit); gtk_window_set_titlebar (window, header_bar); GtkWidget *run_stop_model_exec = gtk_button_new (); @@ -243,6 +243,10 @@ void experimental_activate_00 (GtkApplication *app, GtkWindow *window) { gtk_button_set_icon_name (GTK_BUTTON (document_properties), "document-properties-symbolic"); gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), document_properties); + GtkWidget *text_edit = gtk_button_new (); + gtk_button_set_icon_name (GTK_BUTTON (text_edit), "text-editor-symbolic"); + gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), text_edit); + GtkWidget *applications_utilities = gtk_button_new (); gtk_button_set_icon_name (GTK_BUTTON (applications_utilities), "applications-utilities-symbolic"); gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), applications_utilities); diff --git a/src/ui/events.c b/src/ui/events.c index d1ea4a9..e638659 100644 --- a/src/ui/events.c +++ b/src/ui/events.c @@ -62,9 +62,9 @@ void on_quit_action(GSimpleAction *action, { GemGraphClientApplication *self = user_data; - g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self)); + g_assert (GEM_GRAPH_CLIENT_IS_APPLICATION(self)); - g_application_quit(G_APPLICATION(self)); + g_application_quit (G_APPLICATION(self)); } void on_preferences_action(GSimpleAction *action, @@ -73,9 +73,9 @@ void on_preferences_action(GSimpleAction *action, { GemGraphClientApplication *self = user_data; - g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self)); + g_assert (GEM_GRAPH_CLIENT_IS_APPLICATION(self)); - ui_send_internal_notification("Not implemented !"); + ui_send_internal_notification ("Not implemented !"); } void on_togglerunedit_action(GSimpleAction *action, @@ -83,15 +83,9 @@ void on_togglerunedit_action(GSimpleAction *action, gpointer user_data) { GemGraphClientApplication *self = user_data; - - g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self)); - - printf("events on_togglerunedit_action() <><><>\n"); - + g_assert (GEM_GRAPH_CLIENT_IS_APPLICATION(self)); + printf("| >>> events.on_togglerunedit_action() >>> "); ui_toggle_run_edit (); - - /* if (EDIT_MODE) ui_toggle_run_edit (RUN_MODE); - else if (RUN_MODE) ui_toggle_run_edit (EDIT_MODE); */ } void on_togglerunstop_action(GSimpleAction *action, @@ -115,6 +109,7 @@ void on_togglesidebar_action(GSimpleAction *action, g_assert(GEM_GRAPH_CLIENT_IS_APPLICATION(self)); + ui_toggle_sidebar(); } diff --git a/src/ui/gemgraph.ui b/src/ui/gemgraph.ui index c13ef28..7c4e9a1 100644 --- a/src/ui/gemgraph.ui +++ b/src/ui/gemgraph.ui @@ -61,7 +61,7 @@ - 300 + 400 diff --git a/src/ui/window.c b/src/ui/window.c index 0702fdf..0a4845e 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -40,15 +40,15 @@ struct _GemGraphClientWindow GtkApplicationWindow parent_instance; /* Template widgets */ - GtkHeaderBar *main_titlebar; +// GtkHeaderBar *main_titlebar; GtkStack *main_stack; GtkStack *side_stack; GtkPaned *main_paned; GtkToggleButton *main_button_run_edit; // GtkToggleButton *main_button_run_stop; - GtkMenuButton *main_button_mode; +// GtkMenuButton *main_button_mode; GtkToggleButton *main_button_sidebar; - GtkRevealer *toast_revealer; +// GtkRevealer *toast_revealer; GtkToggleButton *toast_close_button; GtkLabel *toast_text; GtkBox *control_zone; @@ -62,7 +62,7 @@ G_DEFINE_FINAL_TYPE (GemGraphClientWindow, gem_graph_client_window, GTK_TYPE_APPLICATION_WINDOW) -static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass) +static void gem_graph_client_window_class_init (GemGraphClientWindowClass *klass) { gchar *contents; gsize len; @@ -77,16 +77,14 @@ static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass) bytes = g_bytes_new_take(contents, len); gtk_widget_class_set_template(GTK_WIDGET_CLASS(klass), bytes); - // https://docs.gtk.org/gtk4/class.Widget.html#building-composite-widgets-from-template-xml TODO Learn ! - // gtk_widget_class_bind_template_callback_full (GtkToggleButton, ui_toggle_sidebar, "clicked"); // "main_button_sidebar" - + gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_button_run_edit); +/* gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_titlebar); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_stack); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, side_stack); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_paned); - gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_button_run_edit); -// gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_button_run_stop); + gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_button_run_stop); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_button_mode); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, main_button_sidebar); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, toast_revealer); @@ -97,6 +95,7 @@ static void gem_graph_client_window_class_init(GemGraphClientWindowClass *klass) gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, edition_glarea_box); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, presentation_glarea_box); gtk_widget_class_bind_template_child (widget_class, GemGraphClientWindow, run_conditions_tree_box); +*/ } static void gem_graph_client_window_init(GemGraphClientWindow *self) @@ -105,10 +104,28 @@ static void gem_graph_client_window_init(GemGraphClientWindow *self) window = self; } -// https://docs.gtk.org/gtk4/class.Widget.html#building-composite-widgets-from-template-xml -static void gtk_widget_class_dispose_template() {} // TODO ? +void ui_toggle_run_edit() +{ + if (window->main_button_run_edit == NULL) { // btt_run_xor_edit + g_printerr("Can't find self->main_button_run_edit !\n"); + return; + } + + printf("window.ui_toggle_run_edit() >>> mode = %d", get_run_edit_mode ()); + + if (get_run_edit_mode()) { + gtk_button_set_icon_name (GTK_BUTTON (window->main_button_run_edit), "system-run-symbolic"); + set_run_edit_mode (0); + } else { + gtk_button_set_icon_name (GTK_BUTTON (window->main_button_run_edit), "document-edit-symbolic"); + set_run_edit_mode (1); + } + + printf(" > %d\n", get_run_edit_mode ()); +} + + -/* -------------------------------------------------------------------------- */ void ui_set_stack(int mode) { @@ -126,75 +143,41 @@ void ui_set_stack(int mode) // Switch on the first letter of the mode, because switch is soooo simple :) switch(mode) { case EDIT_MODE: - // gtk_stack_set_visible_child_full(window->main_stack, "edition", GTK_STACK_TRANSITION_TYPE_CROSSFADE); + gtk_stack_set_visible_child_full(window->main_stack, "edition", GTK_STACK_TRANSITION_TYPE_CROSSFADE); gtk_stack_set_visible_child_full(window->side_stack, "edition", GTK_STACK_TRANSITION_TYPE_CROSSFADE); - gtk_menu_button_set_icon_name (window->main_button_mode, "document-edit-symbolic"); +// gtk_menu_button_set_icon_name (window->main_button_mode, "document-edit-symbolic"); ui_setup_glarea(EDIT_MODE, GTK_WIDGET(window->edition_glarea_box)); break; case RUN_MODE: gtk_stack_set_visible_child_full(window->main_stack, "run", GTK_STACK_TRANSITION_TYPE_CROSSFADE); gtk_stack_set_visible_child_full(window->side_stack, "run", GTK_STACK_TRANSITION_TYPE_CROSSFADE); - gtk_menu_button_set_icon_name (window->main_button_mode, "system-run-symbolic"); +// gtk_menu_button_set_icon_name (window->main_button_mode, "system-run-symbolic"); ui_setup_glarea(RUN_MODE, GTK_WIDGET(window->run_glarea_box)); ui_create_tree (GTK_WIDGET (window->run_conditions_tree_box)); break; case PRESENTATION_MODE: gtk_stack_set_visible_child_full(window->main_stack, "presentation", GTK_STACK_TRANSITION_TYPE_CROSSFADE); gtk_stack_set_visible_child_full(window->side_stack, "presentation", GTK_STACK_TRANSITION_TYPE_CROSSFADE); - gtk_menu_button_set_icon_name (window->main_button_mode, "x-office-presentation-symbolic"); +// gtk_menu_button_set_icon_name (window->main_button_mode, "x-office-presentation-symbolic"); ui_setup_glarea(PRESENTATION_MODE, GTK_WIDGET(window->presentation_glarea_box)); break; case HOME_MODE: gtk_stack_set_visible_child_full(window->main_stack, "home", GTK_STACK_TRANSITION_TYPE_CROSSFADE); gtk_stack_set_visible_child_full(window->side_stack, "home", GTK_STACK_TRANSITION_TYPE_CROSSFADE); gtk_paned_set_position(window->main_paned, 0); - gtk_menu_button_set_icon_name (window->main_button_mode, "user-home-symbolic"); +// gtk_menu_button_set_icon_name (window->main_button_mode, "user-home-symbolic"); break; default: break; } } -void ui_toggle_run_edit() -{ - if (window->main_button_run_edit == NULL) { - g_printerr("Can't find self->main_button_run_edit !\n"); - return; - } - - printf("window ui_toggle_run_edit() ------ mode = %d", get_run_edit_mode ()); - - switch(get_run_edit_mode()) { - case 1: - //gtk_stack_set_visible_child_full(window->main_stack, "edition", GTK_STACK_TRANSITION_TYPE_CROSSFADE); - //gtk_stack_set_visible_child_full(window->side_stack, "edition", GTK_STACK_TRANSITION_TYPE_CROSSFADE); - gtk_button_set_icon_name (GTK_BUTTON (window->main_button_run_edit), "document-edit-symbolic"); - //gtk_paned_set_position(window->main_paned, 300); - set_run_edit_mode (0); // (EDIT_MODE); - // ui_setup_glarea(EDIT_MODE, GTK_WIDGET(window->edition_glarea_box)); - break; - case 0: - //gtk_stack_set_visible_child_full(window->main_stack, "run", GTK_STACK_TRANSITION_TYPE_CROSSFADE); - //gtk_stack_set_visible_child_full(window->side_stack, "run", GTK_STACK_TRANSITION_TYPE_CROSSFADE); - gtk_button_set_icon_name (GTK_BUTTON (window->main_button_run_edit), "system-run-symbolic"); - //gtk_paned_set_position(window->main_paned, 200); - set_run_edit_mode (1); // (EDIT_MODE); - // ui_setup_glarea(RUN_MODE, GTK_WIDGET(window->run_glarea_box)); - // ui_create_tree (GTK_WIDGET (window->run_conditions_tree_box)); - break; - default: - break; - } - printf(" > %d\n", get_run_edit_mode ()); - gtk_widget_set_visible (GTK_BUTTON (window->main_button_run_edit), TRUE); -} - void ui_send_internal_notification(const char *message) { - if (window->toast_revealer == NULL) { +/* if (window->toast_revealer == NULL) { g_printerr("Can't find self->toast_overlay !\n"); return; - } + }*/ if (window->toast_text == NULL) { g_printerr("Can't find self->toast_overlay !\n"); @@ -202,23 +185,23 @@ void ui_send_internal_notification(const char *message) } gtk_label_set_label(window->toast_text, message); - gtk_revealer_set_reveal_child(window->toast_revealer, true); +// gtk_revealer_set_reveal_child(window->toast_revealer, true); g_printerr("%s\n", message); } void ui_close_internal_notification(void) { - if (window->toast_revealer == NULL) { +/* if (window->toast_revealer == NULL) { g_printerr("Can't find self->toast_overlay !\n"); return; - } + }*/ if (window->toast_text == NULL) { g_printerr("Can't find self->toast_overlay !\n"); return; } - gtk_revealer_set_reveal_child(window->toast_revealer, false); +// gtk_revealer_set_reveal_child(window->toast_revealer, false); } @@ -232,7 +215,7 @@ void ui_toggle_sidebar(void) if (verbose) printf("window ui_togglesidebar() ->||<-\n"); gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "sidebar-show-right-symbolic"); } else { - gtk_paned_set_position (window->main_paned, 300); + gtk_paned_set_position (window->main_paned, 400); if (verbose) printf("window ui_togglesidebar() <|==|>\n"); gtk_button_set_icon_name (GTK_BUTTON (window->main_button_sidebar), "sidebar-show-symbolic"); }