From 59e6c779fd9d6ebf4c8ccb38c9dfeb632dd1bc8d Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 2 Jun 2024 15:49:39 +0200 Subject: [PATCH] WIP: cleaning <> design : PRESENT(ATION) / WORK ? --- (notes) | 37 +++++++++++ callback.h | 3 + cold.c | 4 -- cold.h | 10 --- contain.c | 16 +++++ contain.h | 2 +- display.c | 1 - hot.c | 5 +- hot.h | 24 +++++++- main.c | 37 +---------- warm.c | 176 ----------------------------------------------------- warm.h | 33 ---------- 12 files changed, 82 insertions(+), 266 deletions(-) delete mode 100644 cold.c delete mode 100644 cold.h delete mode 100644 warm.c delete mode 100644 warm.h diff --git a/(notes) b/(notes) index 9d4cd8d..0a1a41a 100644 --- a/(notes) +++ b/(notes) @@ -54,6 +54,43 @@ GtkWidget *get_text_view(){ // WTF ?!& @Grr #~! return my_view; } + + + + + +/* +https://docs.gtk.org/gtk4/class.ApplicationWindow.html + +GtkApplication *app = gtk_application_new ("org.gtk.test", 0); + +GtkBuilder *builder = gtk_builder_new_from_string ( + "" + " " + " " + " _Edit" + " " + " _Copy" + " win.copy" + " " + " " + " _Paste" + " win.paste" + " " + " " + " " + "", + -1); + +GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")); +gtk_application_set_menubar (GTK_APPLICATION (app), menubar); +g_object_unref (builder); + +// ... + +GtkWidget *window = gtk_application_window_new (app); + +*/ //------------------------------------------------------------------------------ GtkScrolledWindow *get_scrolled_gl_area(){ diff --git a/callback.h b/callback.h index c77187e..9f6395d 100644 --- a/callback.h +++ b/callback.h @@ -1,3 +1,6 @@ +//#include +#include + void activate (GtkApplication *app, gpointer user_data); void ui_enable_action (const char *name); diff --git a/cold.c b/cold.c deleted file mode 100644 index 03f53e8..0000000 --- a/cold.c +++ /dev/null @@ -1,4 +0,0 @@ -#include -#include -#include "texts.h" - diff --git a/cold.h b/cold.h deleted file mode 100644 index 9681b07..0000000 --- a/cold.h +++ /dev/null @@ -1,10 +0,0 @@ -/******************************************************************************/ -/* */ -/* E coli by David S. Goodsell (2009) */ -/* --- */ -/* Let this freeze frame guide us towards the model */ -/* that alone can account for the phenomenon ! */ -/* */ -/******************************************************************************/ - - diff --git a/contain.c b/contain.c index 086573b..b2c5206 100644 --- a/contain.c +++ b/contain.c @@ -7,6 +7,22 @@ #include "texts.h" #include "callback.h" +// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO +// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery + + + + +//typedef anytype = {(int)(*fnct) {printf("typedef {(int)(*fnct) {printf("");}");} GtkModelFnct; + + + +GtkFrame *get_frame_with_label(){ // EN ATTENDANT DE SAVOIR UTILISER : GtkTextTagTable et GtkTextBuffer + GtkFrame *space_specif = GTK_FRAME(gtk_frame_new ("Space (run / edit) specifications")); + GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (get_space_run_edit_specif())); + gtk_frame_set_child (GTK_FRAME (space_specif), GTK_WIDGET (any_Label)); + return space_specif; +} GtkWidget *get_edit_rules_page_new(){ GtkPaned *hpaned = GTK_PANED (gtk_paned_new (GTK_ORIENTATION_HORIZONTAL)); diff --git a/contain.h b/contain.h index 6156ad2..71c6939 100644 --- a/contain.h +++ b/contain.h @@ -30,5 +30,5 @@ G_END_DECLS void two_notebooks_in_two_panes (GtkWindow *window); GtkWidget *get_selected_rules_vpaned_new(); - +GtkFrame *get_frame_with_label(); diff --git a/display.c b/display.c index fb2c37e..ecfd724 100644 --- a/display.c +++ b/display.c @@ -2,7 +2,6 @@ #include #include "hot.h" -#include "cold.h" #include "display.h" #include "contain.h" #include "texts.h" diff --git a/hot.c b/hot.c index fe87b0e..fc6bce2 100644 --- a/hot.c +++ b/hot.c @@ -1,9 +1,8 @@ #include #include -#include "warm.h" -#include "cold.h" -//#include "display.h" +#include + #include "contain.h" #include "texts.h" diff --git a/hot.h b/hot.h index 5831809..430f7e3 100644 --- a/hot.h +++ b/hot.h @@ -7,11 +7,31 @@ /* */ /******************************************************************************/ -#include "warm.h" -#include "cold.h" +#pragma once // < WTF !? + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//#include "cold.h" #include "display.h" #include "contain.h" + +// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO + + GtkScrolledWindow *get_user_rules_tree (); void set_run_edit_mode(int prescribed_mode); int get_run_edit_mode(); diff --git a/main.c b/main.c index 2f91e81..69beb76 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,6 @@ /* */ /******************************************************************************/ -#include "hot.h" #include "callback.h" int main (int argc, char **argv) @@ -15,44 +14,10 @@ int main (int argc, char **argv) GtkApplication *app; int status; - app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS); + app = gtk_application_new ("org.jean.GTK4_GG_hack", G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); return status; } - - -/* -https://docs.gtk.org/gtk4/class.ApplicationWindow.html - -GtkApplication *app = gtk_application_new ("org.gtk.test", 0); - -GtkBuilder *builder = gtk_builder_new_from_string ( - "" - " " - " " - " _Edit" - " " - " _Copy" - " win.copy" - " " - " " - " _Paste" - " win.paste" - " " - " " - " " - "", - -1); - -GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")); -gtk_application_set_menubar (GTK_APPLICATION (app), menubar); -g_object_unref (builder); - -// ... - -GtkWidget *window = gtk_application_window_new (app); - -*/ diff --git a/warm.c b/warm.c deleted file mode 100644 index cc884f8..0000000 --- a/warm.c +++ /dev/null @@ -1,176 +0,0 @@ -#include -#include - -#include "cold.h" -#include "display.h" -#include "contain.h" -#include "texts.h" - -// https://docs.gtk.org/gtk4/visual_index.html < widgets gallery - - - - -//typedef anytype = {(int)(*fnct) {printf("typedef {(int)(*fnct) {printf("");}");} GtkModelFnct; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -GtkFrame *get_frame_with_label(){ // EN ATTENDANT DE SAVOIR UTILISER : GtkTextTagTable et GtkTextBuffer - GtkFrame *space_specif = GTK_FRAME(gtk_frame_new ("Space (run / edit) specifications")); - GtkWidget *any_Label = GTK_WIDGET (gtk_label_new (get_space_run_edit_specif())); - gtk_frame_set_child (GTK_FRAME (space_specif), GTK_WIDGET (any_Label)); - return space_specif; -} - -//GtkFrame *space_specif = gtk_frame_new (char* const "Space (run / edit) specifications"); - -GtkWidget *get_text_view(){ // WTF ?!& @Grr #~! https://docs.gtk.org/gtk4/section-text-widget.html - GtkWidget *my_view = gtk_text_view_new (); - GtkTextTagTable *my_table = gtk_text_tag_table_new (); - GtkTextBuffer *my_buffer = gtk_text_buffer_new (my_table); - - gtk_text_buffer_set_text (my_buffer, "Hello, this is some text", -1); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (my_view), my_buffer); - - /* Now you might put the view in a container and display it on the - * screen; when the user edits the text, signals on the buffer - * will be emitted, such as "changed", "insert_text", and so on. - */ - return my_view; -} - - - - - - -//------------------------------------------------------------------------------ - -GtkScrolledWindow *get_scrolled_gl_area(){ - GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new()); - gtk_scrolled_window_set_min_content_width (scrolled, W_IMAGE); - gtk_scrolled_window_set_min_content_height (scrolled, H_IMAGE); -// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000); -// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000); - // (value, lower, upper, step_increment, page_increment, page_size) -// GtkWidget *GLarea = gtk_gl_area_new(); -// gtk_scrolled_window_set_child (scrolled, GLarea); -// https://docs.gtk.org/gtk4/class.GLArea.html - return scrolled; -} - - - - - - - - - - - - - - -/* - essai run-stop, speed et step by step dans une seule box controls - ----------------------------------------------------------------- - - -#include -#include -#include "cold.h" - -void print_text(GtkWidget *widget, gpointer data) {g_print (data);} - -GtkWidget *get_a_space_test_image(){ - GtkWidget *image; - image = GTK_WIDGET(get_scrolled_gl_area()); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/aXoris.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/gg sketch.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli resized.png"); - image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/Getting_Started_with_GTK/E coli by David S. Goodsell (2009).png"); - return image; -} - -GtkWidget *get_scroll_speed(){ - GtkAdjustment *speed_adjust = gtk_adjustment_new (0, 0, 100, 1, 0, 0); - GtkWidget *scroll_speed = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, speed_adjust); - return scroll_speed; -} - -// TODO cliquer sur "RUN" --> affiche "STOP" (et inversement) -GtkBox *get_RUN_STOP_box(){ - GtkBox *RUN_STOP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2 - - GtkWidget *RUN_Label = GTK_WIDGET (gtk_label_new (NULL)); // "RUN")); - const char *str = " RUN\n STOP"; - const char *format = "\%s"; - char *markup; - - markup = g_markup_printf_escaped (format, str); - gtk_label_set_markup (GTK_LABEL (RUN_Label), markup); // Sets the labels text and attributes from markup. - g_free (markup); - - gtk_label_set_max_width_chars (GTK_LABEL(RUN_Label), 12); - gtk_label_set_wrap (GTK_LABEL(RUN_Label), TRUE); - gtk_label_set_xalign (GTK_LABEL(RUN_Label), 0.5); // xalign value, between 0 and 1 - gtk_label_set_yalign (GTK_LABEL(RUN_Label), 0.5); - gtk_label_set_selectable (GTK_LABEL(RUN_Label), FALSE); // default = FALSE - gtk_label_set_single_line_mode (GTK_LABEL(RUN_Label), TRUE); // default = TRUE - // - gtk_box_append (RUN_STOP_box, RUN_Label); - return RUN_STOP_box; -} - -GtkBox *get_STEP_by_STEP_box(){ - GtkBox *STEP_by_STEP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); - GtkWidget *STEP_by_STEP_Label = GTK_WIDGET (gtk_label_new ("ONE\nSTEP")); - gtk_box_append (STEP_by_STEP_box, STEP_by_STEP_Label); - return STEP_by_STEP_box; -} - -GtkBox *get_CONTROL_box(){ - GtkBox *CONTROL_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_VERTICAL, 0)); - gtk_box_append (CONTROL_box, GTK_WIDGET (get_RUN_STOP_box())); - gtk_box_append (CONTROL_box, GTK_WIDGET (get_scroll_speed())); - gtk_box_append (CONTROL_box, GTK_WIDGET (get_STEP_by_STEP_box())); - return CONTROL_box; -} -*/ - diff --git a/warm.h b/warm.h deleted file mode 100644 index a183d8f..0000000 --- a/warm.h +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************/ -/* */ -/* E coli by David S. Goodsell (2009) */ -/* --- */ -/* Let this freeze frame guide us towards the model */ -/* that alone can account for the phenomenon ! */ -/* */ -/******************************************************************************/ - -#pragma once // < WTF !? - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "cold.h" -#include "display.h" -#include "contain.h" - - -// https://blog.gtk.org/2020/09/08/on-list-models/ < TODO -