WIP: Comment remettre tous les curseurs (Objects/Situations) à ZÉRO ou à UN.

This commit is contained in:
Jean Sirmai 2024-07-05 22:19:18 +02:00
parent 76857c033e
commit 415238c5d1
Signed by: jean
GPG Key ID: FB3115C340E057E3
6 changed files with 35 additions and 64 deletions

View File

@ -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 */

View File

@ -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),

View File

@ -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");

View File

@ -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));

View File

@ -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()));
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)
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));
// https://docs.gtk.org/gtk4/class.ListView.html
// https://toshiocp.github.io/Gtk4-tutorial/sec29.html
}

View File

@ -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 ");