From 415238c5d1263f61ac463f05ce63158676928543 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Fri, 5 Jul 2024 22:19:18 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20Comment=20remettre=20tous=20les=20curseu?= =?UTF-8?q?rs=20(Objects/Situations)=20=C3=A0=20Z=C3=89RO=20ou=20=C3=A0=20?= =?UTF-8?q?UN.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/widgets.h | 2 +- src/automat.c | 4 ++-- src/callbacks.c | 20 ++++++++++++---- src/widget.c/heads.c | 2 +- src/widget.c/labo.c | 56 +++++--------------------------------------- src/widget.c/state.c | 15 ++++++++---- 6 files changed, 35 insertions(+), 64 deletions(-) diff --git a/include/widgets.h b/include/widgets.h index 117fcea..549013d 100644 --- a/include/widgets.h +++ b/include/widgets.h @@ -61,7 +61,7 @@ GtkScrolledWindow *get_user_rules_tree (); void icons_for_fun (GtkHeaderBar *header_bar); GtkWidget *get_window_child_DATA_lab(); -void learning_menus_and_all_that_stuff(GtkMenuButton* menu_button); +void go_to_the_lab (GtkMenuButton* menu_button); /******************************************************************************/ /* I M A G E S */ diff --git a/src/automat.c b/src/automat.c index d3fa818..db188a6 100644 --- a/src/automat.c +++ b/src/automat.c @@ -85,13 +85,13 @@ static char *get_str_STATE_RULES_DATA (int value) { static void debug_printing (int prescribed, int sub_automaton) { switch (sub_automaton) { // sub_automaton 0 is EXEC_EDIT and // sub_automaton 1 is STATE_RULES_DATA - case (0) : printf("switch %5s x %5s > %5s X %5s\n", + case (0) : printf("switch %5s x %5s > %5s x %5s\n", get_str_EXEC_EDIT (choice_EXEC_EDIT), get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA), get_str_EXEC_EDIT (prescribed), get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA)); break; - case (1) : printf("switch %5s x %5s > %5s X %5s\n", + case (1) : printf("switch %5s x %5s > %5s x %5s\n", get_str_EXEC_EDIT (choice_EXEC_EDIT), get_str_STATE_RULES_DATA (choice_STATE_RULES_DATA), get_str_EXEC_EDIT (choice_EXEC_EDIT), diff --git a/src/callbacks.c b/src/callbacks.c index 3fdb50f..9926ac6 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -320,11 +320,21 @@ void on_clicked_HOME (GtkWidget *btt_reset, gpointer data) { gtk_window_present (GTK_WINDOW (get_dialog_window())); // works once only ! } -void on_clicked_MENU (GtkWidget *btt_reset, gpointer menu_button) { - printf ("callback.on_clicked_MENU button() presents the text_window ( :- ) but... it works only once.\n"); - learning_menus_and_all_that_stuff (menu_button); - gtk_window_present (GTK_WINDOW (get_text_window())); // works once only ! -} + + + + + + +void on_clicked_MENU (GtkWidget *btt_reset, gpointer menu_button) {go_to_the_lab (menu_button);} + + + + + + + + void on_reset_image (GtkWidget *btt_reset, gpointer data) { printf ("callback.on_reset_image() <> Comment remettre tous les curseurs à zéro ?\n"); diff --git a/src/widget.c/heads.c b/src/widget.c/heads.c index d85db2a..a634063 100644 --- a/src/widget.c/heads.c +++ b/src/widget.c/heads.c @@ -163,7 +163,7 @@ static void window_header_bar (GtkWindow *window, char *title){ gtk_button_set_icon_name (search, "folder-saved-search-symbolic"); gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (search)); - GtkButton *open_menu = GTK_BUTTON (gtk_button_new ()); + GtkButton *open_menu = GTK_BUTTON (gtk_button_new ()); // gtk_button_new or gtk_menu_button_new ? gtk_button_set_icon_name (open_menu, "open-menu-symbolic"); g_signal_connect (open_menu, "clicked", G_CALLBACK (on_clicked_MENU), open_menu); gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), GTK_WIDGET (open_menu)); diff --git a/src/widget.c/labo.c b/src/widget.c/labo.c index cd183ba..48042bb 100644 --- a/src/widget.c/labo.c +++ b/src/widget.c/labo.c @@ -53,60 +53,16 @@ -static void -setup_listitem_cb (GtkListItemFactory *factory, - GtkListItem *list_item) -{ - GtkWidget *image; - - image = gtk_image_new (); - gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE); - gtk_list_item_set_child (list_item, image); -} - -static void -bind_listitem_cb (GtkListItemFactory *factory, - GtkListItem *list_item) -{ - GtkWidget *image; - GAppInfo *app_info; - - image = gtk_list_item_get_child (list_item); - app_info = gtk_list_item_get_item (list_item); - gtk_image_set_from_gicon (GTK_IMAGE (image), g_app_info_get_icon (app_info)); -} - -static void -activate_cb (GtkListView *list, - guint position, - gpointer unused) -{ - GAppInfo *app_info; - - app_info = g_list_model_get_item (G_LIST_MODEL (gtk_list_view_get_model (list)), position); - g_app_info_launch (app_info, NULL, NULL, NULL); - g_object_unref (app_info); -} - -void learning_menus_and_all_that_stuff (GtkMenuButton* menu_button) { - printf ("labo.learning_menus_and_all_that_stuff...()\ - > presents the text_window ( ;- ))\n \ - which, at the present time,... works only once ( :- ((\n"); +void go_to_the_lab (GtkMenuButton* menu_button) { // Je veux que ce bouton ouvre un menu. gtk_window_present (GTK_WINDOW (get_text_window())); + char *array[] = {"one", "two", "three", "four", NULL}; + GtkStringList *list = gtk_string_list_new ((const char * const *) array); + printf ("labo.go_to_the_lab () > list [3] = %s\n", gtk_string_list_get_string (list, 2)); - GtkListItemFactory *factory = gtk_signal_list_item_factory_new (); - g_signal_connect (factory, "setup", G_CALLBACK (setup_listitem_cb), NULL); - g_signal_connect (factory, "bind", G_CALLBACK (bind_listitem_cb), NULL); - - // model = - GSList *list = NULL; - // list = gtk_list_view_new (GTK_SELECTION_MODEL (gtk_single_selection_new (model)), factory); - g_signal_connect (list, "activate", G_CALLBACK (activate_cb), NULL); // - gtk_menu_button_set_child (GTK_MENU_BUTTON (menu_button), NULL); // << list (a GtkWidget) - -// https://docs.gtk.org/gtk4/class.ListView.html +// https://docs.gtk.org/gtk4/class.ListView.html +// https://toshiocp.github.io/Gtk4-tutorial/sec29.html } diff --git a/src/widget.c/state.c b/src/widget.c/state.c index 84682b9..76337b8 100644 --- a/src/widget.c/state.c +++ b/src/widget.c/state.c @@ -72,16 +72,21 @@ static GtkBox *get_ZOOM_box(){ return ZOOM_box; } + static GtkBox *get_OBJECTS_box(){ GtkBox *objects_box = GTK_BOX (gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0)); GtkWidget *btt_reset = gtk_check_button_new_with_label ("reset"); g_signal_connect (btt_reset, "toggled", G_CALLBACK (on_reset_image), NULL); gtk_box_append (objects_box, btt_reset); - GtkAdjustment *adjust = NULL; - for (int i = 0; i < 32; i++) { - // (value, lower, upper, step_increment, page_increment, page_size) - adjust = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 0); - GtkScrollbar *scrollbar_i = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust)); + // Je veux pouvoir remettre tous les curseurs à ZÉRO ou à UN. TODO + int n = 32; + GtkAdjustment *adjust [n]; // (value, lower, upper, step_increment, page_increment, page_size) + for (int i = 0; i < n; i++) { + adjust [i] = gtk_adjustment_new (rand() % 127, 0, 127, 1, 0, 0); + } + for (int i = 0; i < n; i++) { + // adjust [i] = gtk_adjustment_new (127, 0, 127, 1, 0, 0); + GtkScrollbar *scrollbar_i = GTK_SCROLLBAR (gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, adjust [i])); char tooltip_text[8]; sprintf(tooltip_text, "\n%d\n", i); if (0 == i % 5) gtk_widget_set_tooltip_text (GTK_WIDGET (scrollbar_i), " membrane ");