WIP: debugging, cleaning, simplifying

This commit is contained in:
Jean Sirmai 2024-07-23 19:43:21 +02:00
parent d132261f1e
commit 57db1a46ca
Signed by: jean
GPG Key ID: FB3115C340E057E3
7 changed files with 130 additions and 52 deletions

View File

@ -50,8 +50,8 @@ void fsm_set_exec_edit (int value);
void fsm_set_state_rules_data (int value);
void fsm_reset_all_objects_transparencies_at_value (int value);
void fsm_memorize_all_objects_transparencies_current_values (int value);
void fsm_reset_all_objects_transparencies_from_mem (int value);
void fsm_store_all_objects_transparencies_current_values (int value);
void fsm_restore_all_objects_transparencies_from_mem (int value);
void fsm_reset_all_situations_transparencies_at_value (int value);

35
include/prefer.h Normal file
View File

@ -0,0 +1,35 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Main *
* *
* Copyright © 2024 Libre en Communs <contact@a-lec.org> *
* Copyright © 2024 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#pragma once
#include <gtk-4.0/gtk/gtk.h>
void print_sth(char *msg);

View File

@ -127,10 +127,12 @@ void on_clicked_search (GtkWidget *btt_menu, gpointer list_box);
/* M A I N W I N D O W S T A T E P A G E (upper part) */
/******************************************************************************/
void on_updating_objects_transparencies (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
/*
void on_objects_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_objects_box_do_memorize (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_objects_box_do_reset_from_mem (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_objects_box_do_store (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
void on_objects_box_do_restore (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);
*/
void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar);

View File

@ -29,6 +29,7 @@
#include "../include/fsm.h"
#include "../include/prefer.h"
#include "../include/widget.h"
@ -76,48 +77,45 @@ void fsm_set_state_rules_data (int value)
void fsm_restore_all_objects_transparencies_from_mem (int value)
{
print_sth("Officially introducing : ' P R E F E R E N C E S' !");
debug_printing (value, 2); // OBJECTS_box_RESET_VALUES is sub_automaton 2
}
void fsm_store_all_objects_transparencies_current_values (int value)
{
debug_printing (value, 3); // OBJECTS_box_STORE_VALUES is sub_automaton 3
}
void fsm_reset_all_objects_transparencies_at_value (int value)
{
// if (choice_OBJECTS_box_RESET_VALUE != value) { << NON: Je veux pouvoir
// d'emblée tout remettre à zéro sans avoir à manipuler le curseur auparavant.
// d'emblée tout remettre à zéro sans avoir eu à manipuler le curseur auparavant.
// Tant pis si cette fonction s'exécute parce qu'un reset inutile a été demandé.
debug_printing (value, 2); // OBJECTS_box_RESET_VALUE is sub_automaton 2
debug_printing (value, 4); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
widget_reset_all_objects_transparencies_to_value (value);
}
void fsm_memorize_all_objects_transparencies_current_values (int value)
{
debug_printing (value, 3); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
widget_reset_all_objects_transparencies_to_value (value);
}
void fsm_reset_all_objects_transparencies_from_mem (int value)
{
debug_printing (value, 2); // OBJECTS_box_RESET_VALUE is sub_automaton 2
choice_OBJECTS_box_RESET_VALUE = value;
widget_reset_all_objects_transparencies_to_value (value);
}
// ---------------------- S I T U A T I O N S ---------------------------//
void fsm_reset_all_situations_transparencies_at_value (int value)
{
debug_printing (value, 4); // SITUATIONS_box_RESET_VALUE is sub_automaton 5
debug_printing (value, 5); // SITUATIONS_box_RESTORE_VALUES is sub_automaton 4
choice_SITUATIONS_box_RESET_VALUE = value;
widget_reset_all_situations_transparencies_to_value (value);
}
void fsm_set_situations_box_reset_value (int value)
{
if (choice_SITUATIONS_box_RESET_VALUE != value) {
@ -155,15 +153,9 @@ static void debug_printing (int value, int sub_automaton)
tab_0 [choice_EXEC_EDIT],
tab_1 [value]);
break;
case (2) : printf("fsm_set_objects_box_reset_value : %3d > %3d\n",
fsm_get_objects_box_reset_value(), value);
break;
case (3) : printf("fsm_set_objects_box_memorize : %3d > %3d\n",
fsm_get_objects_box_reset_value(), value);
break;
case (4) : printf("fsm_set_objects_box_restore : %3d > %3d\n",
fsm_get_objects_box_reset_value(), value);
break;
case (2) : printf("fsm_store_all_objects_transparencies_current_values\n"); break;
case (3) : printf("fsm_restore_all_objects_transparencies_from_mem\n"); break;
case (4) : printf("fsm_reset_all_objects_transparencies_at_value\n"); break;
case (5) : printf("fsm_set_situations_box_reset_value : %3d > %3d\n",
fsm_get_situations_box_reset_value(), value);
break;

36
src/prefer.c Normal file
View File

@ -0,0 +1,36 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Gem-graph client *
* *
* Main *
* *
* Copyright © 2024 Libre en Communs <contact@a-lec.org> *
* Copyright © 2024 Adrien Bourmault <neox@a-lec.org> *
* Copyright © 2024 Jean Sirmai <jean@a-lec.org> *
* *
* This file is part of Gem-graph. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Affero General Public License *
* as published by the Free Software Foundation, *
* either version 3 of the License, *
* or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; *
* without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "../include/fsm.h"
#include "../include/signal.h"
#include "../include/widget.h"
void print_sth(char *msg){printf("%s\n", msg);}

View File

@ -32,6 +32,7 @@
#include "../include/fsm.h"
#include "../include/signal.h"
#include "../include/widget.h"
#include "../include/prefer.h"
#include "../include/graphics.h"
@ -298,24 +299,39 @@ void on_toggle_state_rules_data (GtkWidget *toggled_button, gpointer user_data)
}
void on_updating_objects_transparencies (GtkWidget *btt_source, GtkScrollbar *reset_scrollbar)
{
const char *btt_name = gtk_button_get_icon_name (GTK_BUTTON (btt_source));
GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar);
// print_sth (btt_name);
if (strcmp (btt_name, "view-restore-symbolic"))
fsm_restore_all_objects_transparencies_from_mem (gtk_adjustment_get_value (adj_obj));
if (strcmp (btt_name, "view-fullscreen-symbolic"))
fsm_store_all_objects_transparencies_current_values (gtk_adjustment_get_value (adj_obj));
if (strcmp (btt_name, "view-refresh-symbolic"))
fsm_reset_all_objects_transparencies_at_value (gtk_adjustment_get_value (adj_obj));
}
/*
void on_objects_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{
GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar);
fsm_reset_all_objects_transparencies_at_value (gtk_adjustment_get_value (adj_obj));
}
void on_objects_box_do_memorize (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
void on_objects_box_do_store (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{
GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar);
fsm_memorize_all_objects_transparencies_current_values (gtk_adjustment_get_value (adj_obj));
fsm_store_all_objects_transparencies_current_values (gtk_adjustment_get_value (adj_obj));
}
void on_objects_box_do_reset_from_mem (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
void on_objects_box_do_restore (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{
GtkAdjustment *adj_obj = gtk_scrollbar_get_adjustment (reset_scrollbar);
fsm_reset_all_objects_transparencies_from_mem (gtk_adjustment_get_value (adj_obj));
fsm_restore_all_objects_transparencies_from_mem (gtk_adjustment_get_value (adj_obj));
}
*/
void on_situations_box_do_reset (GtkWidget *btt_reset, GtkScrollbar *reset_scrollbar)
{

View File

@ -67,10 +67,9 @@ static void *get_objects_box()
char tooltip_text_for_btt_store [140];
sprintf(tooltip_text_for_btt_store, btt_store_this_tip);
gtk_widget_set_tooltip_text (GTK_WIDGET (btt_store_this), btt_store_this_tip);
gtk_button_set_icon_name (GTK_BUTTON (btt_store_this),
"view-restore-symbolic");
gtk_button_set_icon_name (GTK_BUTTON (btt_store_this), "view-restore-symbolic");
g_signal_connect (btt_store_this, "toggled",
G_CALLBACK (on_objects_box_do_memorize), reset_scrollbar);
G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar);
GtkWidget *btt_restore = gtk_toggle_button_new ();
const char *btt_restore_this_tip = " restore transparencies\n\
@ -78,10 +77,9 @@ static void *get_objects_box()
char tooltip_text_for_btt_restore [140];
sprintf(tooltip_text_for_btt_restore, btt_restore_this_tip);
gtk_widget_set_tooltip_text (GTK_WIDGET (btt_restore), btt_restore_this_tip);
gtk_button_set_icon_name (GTK_BUTTON (btt_restore),
"view-fullscreen-symbolic");
gtk_button_set_icon_name (GTK_BUTTON (btt_restore), "view-fullscreen-symbolic");
g_signal_connect (btt_restore, "toggled",
G_CALLBACK (on_objects_box_do_reset_from_mem), reset_scrollbar);
G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar);
GtkWidget *btt_reset = gtk_toggle_button_new ();
const char *btt_reset_all = "reset all transparencies to the value\n\
@ -89,10 +87,9 @@ static void *get_objects_box()
char tooltip_text_for_btt_reset [140];
sprintf(tooltip_text_for_btt_reset, btt_reset_all);
gtk_widget_set_tooltip_text (GTK_WIDGET (btt_reset), btt_reset_all);
gtk_button_set_icon_name (GTK_BUTTON (btt_reset),
"view-refresh-symbolic");
gtk_button_set_icon_name (GTK_BUTTON (btt_reset), "view-refresh-symbolic");
g_signal_connect (btt_reset, "toggled",
G_CALLBACK (on_objects_box_do_reset), reset_scrollbar);
G_CALLBACK (on_updating_objects_transparencies), reset_scrollbar);
gtk_box_append (reset_box, btt_store_this);
gtk_box_append (reset_box, btt_restore);