diff --git a/include/prefer.h b/include/prefer.h index e4f0c37..fc91618 100644 --- a/include/prefer.h +++ b/include/prefer.h @@ -32,5 +32,5 @@ #pragma once #include -void pref_set_store_restore_reset (int choice, int value, GtkScrollbar *scrollbar); -int *pref_get_all_objects_transparencies(); +void pref_set_store_restore_reset (int choice, int value); + diff --git a/include/widget.h b/include/widget.h index b1b41b4..008bcdc 100644 --- a/include/widget.h +++ b/include/widget.h @@ -74,9 +74,8 @@ void *widget_get_sequence_control(); // bottom // called in : src/widget/state/top.c void widget_reset_all_situations_transparencies_to_value (int value); // top -void widget_reset_objects_transparency_to_values (int *value); // top -void *widget_get_objects_transparencies(); // top - +void widget_set_object_transparency_to_value (int rank, int value); // top +int widget_get_object_transparency (int i); // top /******************************************************************************/ /* S T O C K */ diff --git a/src/prefer.c b/src/prefer.c index 9544fe3..b96c43b 100644 --- a/src/prefer.c +++ b/src/prefer.c @@ -34,56 +34,39 @@ #include "../include/widget.h" -struct preferences { - int transparency [n_objects]; // may become a long, long list... -}; - +struct preferences { int transparency [n_objects]; }; // may become a long, long list... +struct preferences *pref_jean = NULL; // TODO (voir graphics_init(...)) + // pour remplacer p[i] par : pref_jean->transparency [i] + // en attendant: +static int p[n_objects] = {}; static int choice_STORE_RESTORE_RESET = STORE; -static int p [n_objects]; - -void pref_set_all_objects_transparencies (int *q) -{ - for (int i = 0; i < n_objects; i++) p [i] = q [i]; -} - -int *pref_get_all_objects_transparencies () { return p; } - - -static void print_p (int *abc) { - for (int i = 0; i < n_objects; i++) printf("%3d ", abc [i]); printf("\n");} - - void pref_set_store_restore_reset (int choice, int value) { choice_STORE_RESTORE_RESET = choice; - int ppp [n_objects]; - switch (choice) { - case (STORE) : printf("STORE current values in MEM [%d]\n", n_objects); - // GtkScrollbar *reset_scrollbar = - // GTK_SCROLLBAR (widget_get_objects_transparencies ()); - for (int i = 0; i < n_objects; i++) ppp [i] = i * 4; - // widget_get_object_transparency_scrollbar (i); - pref_set_all_objects_transparencies (ppp); // print_p (ppp); - widget_reset_objects_transparency_to_values (ppp); - fsm_set_preferences_state (TRUE); + case (STORE) : + printf("STORE (value = %d)\n", value); + for (int i = 0; i < n_objects; i++) { + p [i] = widget_get_object_transparency (i); + widget_set_object_transparency_to_value (i, p [i]); + } break; - case (RESTORE) : printf("RESTORE values from MEM [%d]\n", n_objects); - for (int i = 0; i < n_objects; i++) ppp [i] = i * 4; - pref_set_all_objects_transparencies (ppp); // print_p (ppp); - widget_reset_objects_transparency_to_values (ppp); - fsm_set_preferences_state (TRUE); + case (RESTORE) : + printf("RESTORE (value = %d)\n", value); + for (int i = 0; i < n_objects; i++) + widget_set_object_transparency_to_value (i, p [i]); break; - case (RESET) : printf("RESET \n"); - for (int i = 0; i < n_objects; i++) ppp [i] = rand() % 127; - pref_set_all_objects_transparencies (ppp); // print_p (ppp); - widget_reset_objects_transparency_to_values (ppp); - fsm_set_preferences_state (TRUE); + case (RESET) : + printf("RESET (value = %d)\n", value); + for (int i = 0; i < n_objects; i++) + widget_set_object_transparency_to_value (i, value); // i * 4 // rand() % 127 break; default : printf("default in signal.switch_store_restore_reset()\n"); } + + fsm_set_preferences_state (TRUE); } diff --git a/src/signal.c b/src/signal.c index 382b856..875cf3d 100644 --- a/src/signal.c +++ b/src/signal.c @@ -328,9 +328,9 @@ void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *sc const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source)); int value = gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (scrollbar)); - if ( ! strcmp (btt_name, "view-restore-symbolic")) pref_set_store_restore_reset (STORE, value, scrollbar); - if ( ! strcmp (btt_name, "view-fullscreen-symbolic")) pref_set_store_restore_reset (RESTORE, value, scrollbar); - if ( ! strcmp (btt_name, "view-refresh-symbolic")) pref_set_store_restore_reset (RESET, value, scrollbar); + if ( ! strcmp (btt_name, "document-revert-rtl-symbolic")) pref_set_store_restore_reset (STORE, value); + if ( ! strcmp (btt_name, "edit-undo-symbolic")) pref_set_store_restore_reset (RESTORE, value); + if ( ! strcmp (btt_name, "view-refresh-symbolic")) pref_set_store_restore_reset (RESET, value); fsm_set_preferences_state (TRUE); // << à détailler TODO } diff --git a/src/widget/state/top.c b/src/widget/state/top.c index 4a53f63..b0562a8 100644 --- a/src/widget/state/top.c +++ b/src/widget/state/top.c @@ -40,12 +40,14 @@ static GtkScrollbar *object_bar [n_objects]; static GtkAdjustment *object_adjust [n_objects]; -void *widget_get_objects_transparencies () {return object_bar;} - -void widget_reset_objects_transparency_to_values (int *value) +int widget_get_object_transparency (int rank) { - for (int i = 0; i < n_objects; i++) - gtk_adjustment_set_value (object_adjust [i], value [i]); + return gtk_adjustment_get_value (gtk_scrollbar_get_adjustment (object_bar [rank])); +} + +void widget_set_object_transparency_to_value (int rank, int value) +{ + gtk_adjustment_set_value (object_adjust [rank], value); } static void *get_objects_box() @@ -69,7 +71,7 @@ static void *get_objects_box() sprintf(tooltip_text_for_btt_store, btt_store_tip); gtk_widget_set_tooltip_text (GTK_WIDGET (btt_store), btt_store_tip); - gtk_button_set_icon_name (GTK_BUTTON (btt_store), "view-restore-symbolic"); + gtk_button_set_icon_name (GTK_BUTTON (btt_store), "document-revert-rtl-symbolic"); // gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_store), group_transparencies); g_signal_connect (btt_store, "toggled", G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar); @@ -80,7 +82,7 @@ static void *get_objects_box() char tooltip_text_for_btt_restore [140]; sprintf(tooltip_text_for_btt_restore, btt_restore_tip); gtk_widget_set_tooltip_text (GTK_WIDGET (btt_restore), btt_restore_tip); - gtk_button_set_icon_name (GTK_BUTTON (btt_restore), "view-fullscreen-symbolic"); + gtk_button_set_icon_name (GTK_BUTTON (btt_restore), "edit-undo-symbolic");//send to symbolic // gtk_check_button_set_group (GTK_CHECK_BUTTON (btt_restore), group_transparencies); g_signal_connect (btt_restore, "toggled", G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar);