1 /* ************************************************************************** */
2 /*                                                                            */
3 /*     Copyright (C)    2000-2008 Cédric Auger (cedric@grisbi.org)            */
4 /*                      2003-2008 Benjamin Drieu (bdrieu@april.org)           */
5 /*          2008-2012 Pierre Biava (grisbi@pierre.biava.name)                 */
6 /*          https://www.grisbi.org/                                            */
7 /*                                                                            */
8 /*  This program is free software; you can redistribute it and/or modify      */
9 /*  it under the terms of the GNU General Public License as published by      */
10 /*  the Free Software Foundation; either version 2 of the License, or         */
11 /*  (at your option) any later version.                                       */
12 /*                                                                            */
13 /*  This program is distributed in the hope that it will be useful,           */
14 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of            */
15 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
16 /*  GNU General Public License for more details.                              */
17 /*                                                                            */
18 /*  You should have received a copy of the GNU General Public License         */
19 /*  along with this program; if not, write to the Free Software               */
20 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
21 /*                                                                            */
22 /* ************************************************************************** */
23 
24 
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28 
29 #include <glib/gi18n.h>
30 #include <gtk/gtk.h>
31 
32 
33 /*START_INCLUDE*/
34 #include "etats_config.h"
35 #include "dialog.h"
36 #include "etats_calculs.h"
37 #include "etats_config.h"
38 #include "etats_prefs.h"
39 #include "etats_onglet.h"
40 #include "grisbi_app.h"
41 #include "gsb_calendar_entry.h"
42 #include "gsb_currency.h"
43 #include "gsb_data_account.h"
44 #include "gsb_data_budget.h"
45 #include "gsb_data_category.h"
46 #include "gsb_data_fyear.h"
47 #include "gsb_data_payee.h"
48 #include "gsb_data_payment.h"
49 #include "gsb_data_report.h"
50 #include "gsb_data_report_amout_comparison.h"
51 #include "gsb_data_report_text_comparison.h"
52 #include "gsb_file.h"
53 #include "gsb_form_widget.h"
54 #include "navigation.h"
55 #include "structures.h"
56 #include "utils.h"
57 #include "utils_buttons.h"
58 #include "utils_dates.h"
59 #include "utils_gtkbuilder.h"
60 #include "utils_prefs.h"
61 #include "utils_real.h"
62 #include "utils_str.h"
63 #include "erreur.h"
64 /*END_INCLUDE*/
65 
66 
67 /*START_STATIC*/
68 static void etats_config_onglet_montants_get_buttons_add_remove ( GtkWidget *parent,
69                         gint text_comparison_number );
70 static void etats_config_onglet_texte_get_buttons_add_remove ( GtkWidget *parent,
71                         gint text_comparison_number );
72 /*END_STATIC*/
73 
74 
75 /*START_EXTERN*/
76 /*END_EXTERN*/
77 
78 /* last_report */
79 static gint last_report = -1;
80 
81 static gboolean payee_last_state;
82 
83 /* the def of the columns in the categ and budget list to filter by categ and budget */
84 enum
85 {
86     GSB_ETAT_CATEG_BUDGET_LIST_NAME = 0,
87     GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE,
88     GSB_ETAT_CATEG_BUDGET_LIST_ACTIVATABLE,
89     GSB_ETAT_CATEG_BUDGET_LIST_NUMBER,
90     GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER,
91     GSB_ETAT_CATEG_BUDGET_LIST_NB
92 };
93 
94 static const gchar *champs_type_recherche_texte[] =
95 {
96     N_("payee"),
97     N_("payee information"),
98     N_("category"),
99     N_("sub-category"),
100     N_("budgetary line"),
101     N_("sub-budgetary line"),
102     N_("note"),
103     N_("bank reference"),
104     N_("voucher"),
105     N_("cheque number"),
106     N_("reconciliation reference"),
107     NULL
108 };
109 
110 static const gchar *champs_operateur_recherche_texte[] =
111 {
112     N_("contains"),
113     N_("doesn't contain"),
114     N_("begins with"),
115     N_("ends with"),
116     N_("is empty"),
117     N_("isn't empty"),
118     NULL
119 };
120 
121 static const gchar *champs_lien_lignes_comparaison[] =
122 {
123     N_("and"),
124     N_("or"),
125     N_("except"),
126     NULL
127 };
128 
129 static const gchar *champs_comparateur_nombre[] =
130 {
131     N_("equal"),
132     N_("less than"),
133     N_("less than or equal"),
134     N_("greater than"),
135     N_("greater than or equal"),
136     N_("different from"),
137     N_("the biggest"),
138     NULL
139 };
140 
141 static const gchar *champs_lien_nombre_2[] =
142 {
143     N_("and"),
144     N_("or"),
145     N_("except"),
146     N_("stop"),
147     NULL
148 };
149 
150 static const gchar *champs_comparateur_montant[] =
151 {
152     N_("equal"),
153     N_("less than"),
154     N_("less than or equal"),
155     N_("greater than"),
156     N_("greater than or equal"),
157     N_("different from"),
158     N_("null"),
159     N_("not null"),
160     N_("positive"),
161     N_("negative"),
162     NULL
163 };
164 
165 /*END*/
166 
167 
168 /*COMMON_FUNCTIONS*/
169 /**
170  * Rend sensitif la suite de la comparaison de numéro
171  *
172  * \param combo_box
173  * \param widget        widget à rendre sensitif
174  *
175  * \return
176  */
etats_config_combo_lien_nombre_2_changed(GtkComboBox * combo,GtkWidget * widget)177 static void etats_config_combo_lien_nombre_2_changed ( GtkComboBox *combo,
178                         GtkWidget *widget )
179 {
180     gint index;
181 
182     index = gtk_combo_box_get_active ( combo );
183     if ( index == 3 )
184         gtk_widget_set_sensitive ( widget, FALSE );
185     else
186         gtk_widget_set_sensitive ( widget, TRUE );
187 }
188 
189 
190 /*ONGLET_PERIODE*/
191 /**
192  * Initialise les informations de l'onglet periode
193  *
194  * \param report_number
195  *
196  * \return
197  */
etats_config_initialise_onglet_periode(gint report_number)198 static void etats_config_initialise_onglet_periode ( gint report_number )
199 {
200     if ( gsb_data_report_get_use_financial_year ( report_number ) )
201     {
202         gint financial_year_type;
203 
204         etats_prefs_button_toggle_set_actif ( "radio_button_utilise_exo", TRUE );
205 
206         financial_year_type = gsb_data_report_get_financial_year_type ( report_number );
207         etats_prefs_buttons_radio_set_active_index ( "bouton_exo_tous", financial_year_type );
208 
209         if ( financial_year_type == 3 )
210             etats_prefs_tree_view_select_rows_from_list (
211                                 gsb_data_report_get_financial_year_list ( report_number ),
212                                 "treeview_exer",
213                                 1 );
214 
215         /* on initialise le tree_view des dates avec une valeur par défaut (mois en cours) */
216         etats_prefs_tree_view_select_single_row ( "treeview_dates", 3 );
217     }
218     else
219     {
220         etats_prefs_button_toggle_set_actif ( "radio_button_utilise_dates", TRUE );
221         etats_prefs_tree_view_select_single_row ( "treeview_dates",
222                         gsb_data_report_get_date_type ( report_number ) );
223 
224 		/* on active le choix du type de date */
225 		etats_prefs_onglet_periode_date_interval_sensitive (TRUE);
226 
227         if (gsb_data_report_get_date_type (report_number) == 1)
228         {
229             GDate *date;
230 
231             etats_prefs_onglet_periode_date_interval_sensitive (TRUE);
232 
233             /* on remplit les dates perso si elles existent */
234             if ( ( date = gsb_data_report_get_personal_date_start ( report_number ) ) )
235                 gsb_calendar_entry_set_date (
236                                 etats_prefs_widget_get_widget_by_name ( "hbox_date_init",
237                                 "entree_date_init_etat" ),
238                                 date );
239 
240             if ( ( date = gsb_data_report_get_personal_date_end ( report_number ) ) )
241             gsb_calendar_entry_set_date (
242                                 etats_prefs_widget_get_widget_by_name ( "hbox_date_finale",
243                                 "entree_date_finale_etat" ),
244                                 date );
245         }
246     }
247 }
248 
249 
250 /**
251  * Récupère les informations de l'onglet periode
252  *
253  * \param report_number  numéro d'état à mettre à jour
254  *
255  * \return
256  */
etats_config_recupere_info_onglet_periode(gint report_number)257 static void etats_config_recupere_info_onglet_periode ( gint report_number )
258 {
259     gint active;
260 
261     active = etats_prefs_button_toggle_get_actif ( "radio_button_utilise_exo" );
262     gsb_data_report_set_use_financial_year ( report_number, active );
263 
264     if ( !active )
265     {
266         gint item_selected;
267 
268         /* Check that custom dates are OK, but only if custom date range
269          * has been selected. */
270         if ( ( item_selected = etats_prefs_tree_view_get_single_row_selected ( "treeview_dates" ) ) == 1 )
271         {
272             GtkWidget *entry;
273 
274             entry = etats_prefs_widget_get_widget_by_name ( "hbox_date_init", "entree_date_init_etat" );
275             if ( !gsb_date_check_entry ( entry ) )
276             {
277                 gchar *text;
278                 gchar *hint;
279 
280                 text = g_strdup ( _("Grisbi can't parse date.  For a list of date formats"
281                                     " that Grisbi can use, refer to Grisbi manual.") );
282                 hint = g_strdup_printf ( _("Invalid initial date '%s'"),
283                                 gtk_entry_get_text ( GTK_ENTRY ( entry ) ) );
284                 dialogue_error_hint ( text, hint );
285                 g_free ( text );
286                 g_free ( hint );
287 
288                 return;
289             }
290             else
291                 gsb_data_report_set_personal_date_start ( report_number,
292                                 gsb_calendar_entry_get_date ( entry ) );
293 
294             entry = etats_prefs_widget_get_widget_by_name ( "hbox_date_finale", "entree_date_finale_etat" );
295             if ( !gsb_date_check_entry ( entry ) )
296             {
297                 gchar *text;
298                 gchar *hint;
299 
300                 text = g_strdup ( _("Grisbi can't parse date.  For a list of date formats"
301                                     " that Grisbi can use, refer to Grisbi manual.") );
302                 hint = g_strdup_printf ( _("Invalid final date '%s'"),
303                                 gtk_entry_get_text ( GTK_ENTRY ( entry ) ) );
304                 dialogue_error_hint ( text, hint );
305                 g_free ( text );
306                 g_free ( hint );
307 
308                 return;
309             }
310             else
311                 gsb_data_report_set_personal_date_end ( report_number,
312                                 gsb_calendar_entry_get_date ( entry ) );
313         }
314         gsb_data_report_set_date_type ( report_number, item_selected );
315     }
316     else
317     {
318         gint index;
319 
320         index = etats_prefs_buttons_radio_get_active_index ( "bouton_exo_tous" );
321         gsb_data_report_set_financial_year_type ( report_number, index );
322 
323         if ( index == 3 )
324         {
325             gsb_data_report_free_financial_year_list ( report_number );
326             gsb_data_report_set_financial_year_list ( report_number,
327                                 etats_prefs_tree_view_get_list_rows_selected ( "treeview_exer" ) );
328             if ( utils_tree_view_all_rows_are_selected ( GTK_TREE_VIEW (
329              etats_prefs_widget_get_widget_by_name ( "treeview_exer", NULL ) ) ) )
330             {
331                 gchar *text;
332                 gchar *hint;
333 
334                 hint = g_strdup ( _("Performance issue.") );
335                 text = g_strdup ( _("All financial years have been selected.  Grisbi will run "
336                                 "faster without the \"Detail financial years\" option activated.") );
337 
338                 dialogue_hint ( text, hint );
339                 etats_prefs_button_toggle_set_actif ( "bouton_exo_tous", FALSE );
340                 gsb_data_report_set_financial_year_type ( report_number, 0 );
341 
342                 g_free ( text );
343                 g_free ( hint );
344             }
345         }
346     }
347 }
348 
349 
350 /**
351  * retourne la liste des exercices
352  *
353  * \param
354  *
355  * \return un GtkTreeModel
356  */
etats_config_onglet_periode_get_model_exercices(void)357 GtkTreeModel *etats_config_onglet_periode_get_model_exercices ( void )
358 {
359     GtkListStore *list_store;
360     GSList *list_tmp;
361 
362     list_store = gtk_list_store_new ( 2, G_TYPE_STRING, G_TYPE_INT );
363     gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE ( list_store ),
364                         0, GTK_SORT_DESCENDING );
365 
366     /* on remplit la liste des exercices */
367     list_tmp = gsb_data_fyear_get_fyears_list ();
368 
369     while ( list_tmp )
370     {
371         GtkTreeIter iter;
372         gchar *name;
373         gint fyear_number;
374 
375         fyear_number = gsb_data_fyear_get_no_fyear ( list_tmp -> data );
376 
377         name = my_strdup ( gsb_data_fyear_get_name ( fyear_number ) );
378 
379         gtk_list_store_append ( list_store, &iter );
380         gtk_list_store_set ( list_store, &iter, 0, name, 1, fyear_number, -1 );
381 
382         if ( name )
383             g_free ( name );
384 
385         list_tmp = list_tmp -> next;
386     }
387 
388     return GTK_TREE_MODEL ( list_store );
389 }
390 
391 
392 /**
393  * ajoute les entrées pour saisir les dates personnalisées
394  *
395  * \param
396  *
397  * \return
398  */
etats_config_onglet_periode_make_calendar_entry(void)399 void etats_config_onglet_periode_make_calendar_entry ( void )
400 {
401     GtkWidget *hbox;
402     GtkWidget *entry;
403 
404     hbox =  etats_prefs_widget_get_widget_by_name ( "hbox_date_init", NULL );
405     entry = gsb_calendar_entry_new ( FALSE );
406     gtk_widget_set_size_request ( entry, 100, -1 );
407     g_object_set_data ( G_OBJECT ( hbox ), "entree_date_init_etat", entry );
408     gtk_box_pack_end ( GTK_BOX ( hbox ), entry, FALSE, FALSE, 0 );
409 
410     hbox =  etats_prefs_widget_get_widget_by_name ( "hbox_date_finale", NULL );
411     entry = gsb_calendar_entry_new ( FALSE );
412     gtk_widget_set_size_request ( entry, 100, -1 );
413     g_object_set_data ( G_OBJECT ( hbox ), "entree_date_finale_etat", entry );
414     gtk_box_pack_end ( GTK_BOX ( hbox ), entry, FALSE, FALSE, 0 );
415 }
416 
417 
418 /*ONGLET_VIREMENTS*/
419 /**
420  * Initialise les informations de l'onglet virements
421  *
422  * \param report_number
423  *
424  * \return
425  */
etats_config_initialise_onglet_virements(gint report_number)426 static void etats_config_initialise_onglet_virements ( gint report_number )
427 {
428     gint index;
429 
430     index = gsb_data_report_get_transfer_choice ( report_number );
431     etats_prefs_buttons_radio_set_active_index ( "bouton_non_inclusion_virements", index );
432 
433     if ( index == 3 )
434     {
435         etats_prefs_tree_view_select_rows_from_list (
436                                 gsb_data_report_get_transfer_account_numbers_list ( report_number ),
437                                 "treeview_virements",
438                                 1 );
439         if ( g_slist_length ( gsb_data_report_get_account_numbers_list ( report_number ) ) )
440         {
441             utils_togglebutton_set_label_position_unselect (
442                                 etats_prefs_widget_get_widget_by_name (
443                                 "togglebutton_select_all_virements", NULL ),
444                                 G_CALLBACK ( etats_prefs_onglet_comptes_select_unselect ),
445                                 etats_prefs_widget_get_widget_by_name ( "treeview_virements", NULL ) );
446         }
447     }
448 
449     if ( index > 0 )
450     {
451         etats_prefs_widget_set_sensitive ( "bouton_exclure_non_virements_etat", TRUE );
452         etats_prefs_button_toggle_set_actif ( "bouton_exclure_non_virements_etat",
453                                 gsb_data_report_get_transfer_reports_only ( report_number ) );
454     }
455     else
456         etats_prefs_widget_set_sensitive ( "bouton_exclure_non_virements_etat", FALSE );
457 }
458 
459 
460 /**
461  * Récupère les informations de l'onglet virements
462  *
463  * \param report_number
464  *
465  * \return
466  */
etats_config_recupere_info_onglet_virements(gint report_number)467 static void etats_config_recupere_info_onglet_virements ( gint report_number )
468 {
469     gint index;
470 
471     index = etats_prefs_buttons_radio_get_active_index ( "bouton_non_inclusion_virements" );
472     gsb_data_report_set_transfer_choice ( report_number, index );
473 
474     if ( index == 3 )
475     {
476         gsb_data_report_free_transfer_account_numbers_list ( report_number );
477         gsb_data_report_set_transfer_account_numbers_list ( report_number,
478                             etats_prefs_tree_view_get_list_rows_selected ( "treeview_virements" ) );
479     }
480 
481     gsb_data_report_set_transfer_reports_only ( report_number,
482                         etats_prefs_button_toggle_get_actif ( "bouton_exclure_non_virements_etat" ) );
483 }
484 
485 
486 /*ONGLET_COMPTES*/
487 /**
488  * Initialise les informations de l'onglet comptes
489  *
490  * \param report_number
491  *
492  * \return
493  */
etats_config_initialise_onglet_comptes(gint report_number)494 static void etats_config_initialise_onglet_comptes ( gint report_number )
495 {
496     gint active;
497 
498     active = gsb_data_report_get_account_use_chosen ( report_number );
499     etats_prefs_button_toggle_set_actif ( "bouton_detaille_comptes_etat", active );
500 
501     if ( active )
502     {
503         etats_prefs_tree_view_select_rows_from_list (
504                                 gsb_data_report_get_account_numbers_list ( report_number ),
505                                 "treeview_comptes",
506                                 1 );
507 
508         if ( g_slist_length ( gsb_data_report_get_account_numbers_list ( report_number ) ) )
509             utils_togglebutton_set_label_position_unselect (
510                                 etats_prefs_widget_get_widget_by_name (
511                                 "togglebutton_select_all_comptes", NULL ),
512                                 G_CALLBACK ( etats_prefs_onglet_comptes_select_unselect ),
513                                 etats_prefs_widget_get_widget_by_name ( "treeview_comptes", NULL ) );
514     }
515 }
516 
517 
518 /**
519  * Récupère les informations de l'onglet comptes
520  *
521  * \param numéro d'état à mettre à jour
522  *
523  * \return
524  */
etats_config_recupere_info_onglet_comptes(gint report_number)525 static void etats_config_recupere_info_onglet_comptes ( gint report_number )
526 {
527     gint active;
528 
529     active = etats_prefs_button_toggle_get_actif ( "bouton_detaille_comptes_etat" );
530     gsb_data_report_set_account_use_chosen ( report_number, active );
531 
532     if ( active )
533     {
534         gsb_data_report_free_account_numbers_list ( report_number );
535 
536         if ( utils_tree_view_all_rows_are_selected ( GTK_TREE_VIEW (
537          etats_prefs_widget_get_widget_by_name ( "treeview_comptes", NULL ) ) ) )
538         {
539             gchar *text;
540             gchar *hint;
541 
542             hint = g_strdup ( _("Performance issue.") );
543             text = g_strdup ( _("All accounts have been selected.  Grisbi will run "
544                             "faster without the \"Detail accounts used\" option activated") );
545 
546             dialogue_hint ( text, hint );
547             etats_prefs_button_toggle_set_actif ( "gsb_data_report_set_account_use_chosen", FALSE );
548             gsb_data_report_set_account_use_chosen ( report_number, FALSE );
549 
550             g_free ( text );
551             g_free ( hint );
552         }
553         else
554             gsb_data_report_set_account_numbers_list ( report_number,
555                             etats_prefs_tree_view_get_list_rows_selected ( "treeview_comptes" ) );
556     }
557 }
558 
559 
560 /**
561  * retourne la liste des comptes dans un GtkTreeModel
562  *
563  * \param
564  *
565  * \return model
566  */
etats_config_onglet_get_liste_comptes(void)567 GtkTreeModel *etats_config_onglet_get_liste_comptes ( void )
568 {
569     GtkListStore *list_store;
570     GSList *list_tmp;
571 
572     list_store = gtk_list_store_new ( 2, G_TYPE_STRING, G_TYPE_INT );
573 
574     /* on remplit la liste des exercices */
575     list_tmp = gsb_data_account_get_list_accounts ( );
576 
577     while ( list_tmp )
578     {
579         GtkTreeIter iter;
580         gchar *name;
581         gint account_number;
582 
583         account_number = gsb_data_account_get_no_account ( list_tmp -> data );
584 
585         name = my_strdup ( gsb_data_account_get_name ( account_number ) );
586 
587         gtk_list_store_append ( list_store, &iter );
588         gtk_list_store_set ( list_store, &iter, 0, name, 1, account_number, -1 );
589 
590         if ( name )
591             g_free ( name );
592 
593         list_tmp = list_tmp -> next;
594     }
595 
596     return GTK_TREE_MODEL ( list_store );
597 }
598 
599 
600 /**
601  * sélectionne une partie de la liste des comptes
602  *
603  * \param
604  * \param
605  *
606  * \return
607  * */
etats_config_onglet_select_partie_liste_comptes(GtkWidget * tree_view,gint type_compte)608 void etats_config_onglet_select_partie_liste_comptes ( GtkWidget *tree_view,
609                         gint type_compte )
610 {
611         GtkTreeModel *model;
612         GtkTreeIter iter;
613         GtkTreeSelection *selection;
614 
615         selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) );
616 
617         model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
618         if ( !gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter ) )
619             return;
620 
621         do
622         {
623             gint account_number;
624 
625             gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter, 1, &account_number, -1 );
626             if ( gsb_data_account_get_kind ( account_number ) == type_compte )
627                 gtk_tree_selection_select_iter ( selection, &iter );
628         }
629         while (gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
630 }
631 
632 /*ONGLET_TIERS*/
633 /**
634  * Initialise les informations de l'onglet tiers
635  *
636  * \param report_number
637  *
638  * \return
639  */
etats_config_initialise_onglet_tiers(gint report_number)640 static void etats_config_initialise_onglet_tiers ( gint report_number )
641 {
642     gint active;
643 
644     active = gsb_data_report_get_payee_detail_used ( report_number );
645     etats_prefs_button_toggle_set_actif ( "bouton_detaille_tiers_etat", active );
646 
647     if ( active )
648     {
649         etats_prefs_tree_view_select_rows_from_list (
650                                 gsb_data_report_get_payee_numbers_list ( report_number ),
651                                 "treeview_tiers",
652                                 1 );
653 
654         if ( g_slist_length ( gsb_data_report_get_payee_numbers_list ( report_number ) ) )
655             utils_togglebutton_set_label_position_unselect (
656                                 etats_prefs_widget_get_widget_by_name (
657                                 "togglebutton_select_all_tiers", NULL ),
658                                 NULL,
659                                 etats_prefs_widget_get_widget_by_name ( "treeview_tiers", NULL ) );
660     }
661 }
662 
663 
664 /**
665  * retourne la liste des tiers
666  *
667  * \param
668  *
669  * \return model
670  * */
etats_config_onglet_get_liste_tiers(void)671 GtkTreeModel *etats_config_onglet_get_liste_tiers ( void )
672 {
673     GtkListStore *list_store;
674     GSList *list_tmp;
675 
676     list_store = gtk_list_store_new ( 2, G_TYPE_STRING, G_TYPE_INT );
677 
678     gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE ( list_store ),
679                         0, GTK_SORT_ASCENDING );
680 
681     /* on remplit la liste des tiers */
682     list_tmp = gsb_data_payee_get_payees_list ( );
683 
684     while ( list_tmp )
685     {
686         GtkTreeIter iter;
687         gchar *name;
688         gint payee_number;
689 
690         payee_number = gsb_data_payee_get_no_payee ( list_tmp -> data );
691 
692         name = my_strdup ( gsb_data_payee_get_name ( payee_number, FALSE ) );
693 
694         gtk_list_store_append ( list_store, &iter );
695         gtk_list_store_set ( list_store, &iter, 0, name, 1, payee_number, -1 );
696 
697         if ( name )
698             g_free ( name );
699 
700         list_tmp = list_tmp -> next;
701     }
702 
703     return GTK_TREE_MODEL ( list_store );
704 }
705 
706 
707 /**
708  * Récupère les informations de l'onglet tiers
709  *
710  * \param numéro d'état à mettre à jour
711  *
712  * \return
713  */
etats_config_recupere_info_onglet_tiers(gint report_number)714 static void etats_config_recupere_info_onglet_tiers ( gint report_number )
715 {
716     gint active;
717 
718     active = etats_prefs_button_toggle_get_actif ( "bouton_detaille_tiers_etat" );
719     gsb_data_report_set_payee_detail_used ( report_number, active );
720     if ( active )
721     {
722         gsb_data_report_free_payee_numbers_list ( report_number );
723 
724         if ( utils_tree_view_all_rows_are_selected ( GTK_TREE_VIEW (
725          etats_prefs_widget_get_widget_by_name ( "treeview_tiers", NULL ) ) ) )
726         {
727             gchar *text;
728             gchar *hint;
729 
730             hint = g_strdup ( _("Performance issue.") );
731             text = g_strdup ( _("All payees have been selected.  Grisbi will run "
732                             "faster without the \"Detail payees used\" option activated.") );
733 
734             dialogue_hint ( text, hint );
735             etats_prefs_button_toggle_set_actif ( "togglebutton_select_all_tiers", FALSE );
736             gsb_data_report_set_payee_detail_used ( report_number, FALSE );
737 
738             g_free ( text );
739             g_free ( hint );
740         }
741         else
742             gsb_data_report_set_payee_numbers_list ( report_number,
743                             etats_prefs_tree_view_get_list_rows_selected ( "treeview_tiers" ) );
744     }
745 }
746 
747 
748 /*ONGLET_CATEGORIES BUDGETS*/
749 /**
750  * fill the categories selection list for report
751  *
752  * \param model
753  * \param is_categ  TRUE for category, FALSE for budget
754  *
755  * \return FALSE
756  * */
etats_config_onglet_categ_budget_fill_model(GtkTreeModel * model,gboolean is_categ)757 static gboolean etats_config_onglet_categ_budget_fill_model ( GtkTreeModel *model,
758                         gboolean is_categ )
759 {
760     GtkTreeIter parent_iter;
761     GtkTreeIter child_iter;
762     GSList *list_tmp;
763     gchar *name;
764     gchar *without_name;
765     gchar *without_sub_name;
766 
767     if ( is_categ )
768     {
769         list_tmp = gsb_data_category_get_categories_list ( );
770 
771         gtk_tree_store_clear ( GTK_TREE_STORE ( model ) );
772 
773         without_name = _("No category");
774         without_sub_name = _("No subcategory");
775     }
776     else
777     {
778         list_tmp = gsb_data_budget_get_budgets_list ( );
779         gtk_tree_store_clear ( GTK_TREE_STORE ( model ) );
780 
781         without_name = _("No budgetary line");
782         without_sub_name = _("No sub-budgetary line");
783     }
784 
785     while ( list_tmp )
786     {
787         gint div_number;
788         GSList *tmp_list_sub_div;
789 
790         /* get the category to append */
791         if ( is_categ )
792         {
793             div_number = gsb_data_category_get_no_category ( list_tmp -> data );
794             name = gsb_data_category_get_name (div_number, 0, NULL );
795             tmp_list_sub_div = gsb_data_category_get_sub_category_list ( div_number );
796         }
797         else
798         {
799             div_number = gsb_data_budget_get_no_budget ( list_tmp -> data );
800             name = gsb_data_budget_get_name ( div_number, 0, NULL );
801             tmp_list_sub_div = gsb_data_budget_get_sub_budget_list ( div_number );
802         }
803 		if (name)
804 		{
805 			/* append to the model */
806 				gtk_tree_store_append ( GTK_TREE_STORE ( model ), &parent_iter, NULL );
807 				gtk_tree_store_set (GTK_TREE_STORE ( model ),
808 									&parent_iter,
809 									GSB_ETAT_CATEG_BUDGET_LIST_NAME, name,
810 									GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, div_number,
811 									GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, -1,
812 									GSB_ETAT_CATEG_BUDGET_LIST_ACTIVATABLE, TRUE,
813 									-1 );
814 
815 			g_free (name);
816 
817 			/* append the sub categories */
818 			while (tmp_list_sub_div)
819 			{
820 				gint sub_div_number;
821 
822 				if ( is_categ )
823 				{
824 					sub_div_number = gsb_data_category_get_no_sub_category ( tmp_list_sub_div -> data );
825 					name = gsb_data_category_get_sub_category_name ( div_number, sub_div_number, NULL );
826 				}
827 				else
828 				{
829 					sub_div_number = gsb_data_budget_get_no_sub_budget ( tmp_list_sub_div -> data );
830 					name = gsb_data_budget_get_sub_budget_name ( div_number, sub_div_number, NULL );
831 				}
832 				if (!name)
833 					name = g_strdup (_("Not available"));
834 
835 				/* append to the model */
836 				gtk_tree_store_append ( GTK_TREE_STORE ( model ), &child_iter, &parent_iter );
837 				gtk_tree_store_set ( GTK_TREE_STORE ( model ),
838 									&child_iter,
839 									GSB_ETAT_CATEG_BUDGET_LIST_NAME, name,
840 									GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, -1,
841 									GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, sub_div_number,
842 									GSB_ETAT_CATEG_BUDGET_LIST_ACTIVATABLE, TRUE,
843 									-1 );
844 
845 				g_free (name);
846 
847 				tmp_list_sub_div = tmp_list_sub_div -> next;
848 			}
849 		}
850         /* append without sub-div */
851             gtk_tree_store_append ( GTK_TREE_STORE ( model ), &child_iter, &parent_iter );
852             gtk_tree_store_set ( GTK_TREE_STORE ( model ),
853                                 &child_iter,
854                                 GSB_ETAT_CATEG_BUDGET_LIST_NAME, without_sub_name,
855                                 GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, -1,
856                                 GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, 0,
857                                 GSB_ETAT_CATEG_BUDGET_LIST_ACTIVATABLE, TRUE,
858                                 -1 );
859 
860         list_tmp = list_tmp -> next;
861     }
862 
863     /* append without div and sub-div*/
864     gtk_tree_store_append ( GTK_TREE_STORE ( model ), &parent_iter, NULL );
865     gtk_tree_store_set (GTK_TREE_STORE ( model ),
866                         &parent_iter,
867                         GSB_ETAT_CATEG_BUDGET_LIST_NAME, without_name,
868                         GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, 0,
869                         GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, -1,
870                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVATABLE, TRUE,
871                         -1 );
872 
873     gtk_tree_store_append ( GTK_TREE_STORE ( model ), &child_iter, &parent_iter );
874     gtk_tree_store_set ( GTK_TREE_STORE ( model ),
875                         &child_iter,
876                         GSB_ETAT_CATEG_BUDGET_LIST_NAME, without_sub_name,
877                         GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, -1,
878                         GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, 0,
879                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVATABLE, TRUE,
880                         -1 );
881 
882     return FALSE;
883 }
884 
885 
886 /**
887  * retourne la liste des lignes sélectionnées
888  *
889  * \param treeview_name nom du tree_view
890  *
891  * \return a GSList of CategBudgetSel or NULL if all the categories/sub-categ were selected
892  *          to avoid to filter by categ, to improve speed
893  * */
etats_config_onglet_categ_budget_get_selected(const gchar * treeview_name)894 static GSList *etats_config_onglet_categ_budget_get_selected ( const gchar *treeview_name )
895 {
896     GtkWidget *tree_view;
897     GtkTreeModel *model;
898     GtkTreeIter parent_iter;
899     gboolean all_selected = TRUE;
900     GSList *tmp_list = NULL;
901 
902     /* on récupère le modèle */
903     tree_view = etats_prefs_widget_get_widget_by_name ( treeview_name, NULL );
904     model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
905 
906     if ( !gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &parent_iter ) )
907         return NULL;
908 
909     do
910     {
911         gint div_number;
912         gboolean active;
913         CategBudgetSel *categ_budget_struct;
914         GtkTreeIter iter_children;
915 
916         gtk_tree_model_get (GTK_TREE_MODEL (model),
917                         &parent_iter,
918                         GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, &div_number,
919                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, &active,
920                         -1 );
921         if (!active)
922         {
923             all_selected = FALSE;
924             continue;
925         }
926 
927         /* ok, we are on a selected category/budget, create and fill the structure */
928         categ_budget_struct = g_malloc0 ( sizeof ( CategBudgetSel ) );
929 
930         categ_budget_struct -> div_number = div_number;
931         tmp_list = g_slist_append ( tmp_list, categ_budget_struct );
932 
933         /* check the children */
934         if (gtk_tree_model_iter_children ( GTK_TREE_MODEL (model), &iter_children, &parent_iter))
935         {
936             /* we are on the children */
937             do
938             {
939                 gint sub_div_number;
940 
941                 gtk_tree_model_get (GTK_TREE_MODEL (model),
942                                 &iter_children,
943                                 GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, &sub_div_number,
944                                 GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, &active,
945                                 -1 );
946                 if (active)
947                     categ_budget_struct -> sub_div_numbers = g_slist_append (
948                                                                 categ_budget_struct -> sub_div_numbers,
949                                                                 GINT_TO_POINTER ( sub_div_number ) );
950                 else
951                     all_selected = FALSE;
952             }
953             while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter_children ) );
954         }
955     }
956     while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &parent_iter ) );
957 
958     /* if all is selected, erase the new list and set an info message */
959     if ( all_selected )
960     {
961         if ( strcmp ( treeview_name, "treeview_categ" ) == 0 )
962             dialogue_hint (
963                         _("All categories have been selected.  Grisbi will run faster without "
964                         "the \"Detail categories used\" option activated."),
965                         _("Performance issue.") );
966         else
967             dialogue_hint (
968                         _("All budgets have been selected.  Grisbi will run faster without the "
969                         "\"Detail budgets used\" option activated."),
970                         _("Performance issue.") );
971 
972         etats_config_onglet_categ_budget_tree_model_check_uncheck_all ( model, FALSE );
973         gsb_data_report_free_categ_budget_struct_list ( tmp_list );
974 
975         tmp_list = NULL;
976     }
977     return tmp_list;
978 }
979 
980 
981 /**
982  * Initialisation du tree_view
983  *
984  * \param treeview_name
985  * \param tmp_list
986  *
987  * \return
988  * */
etats_config_onglet_categ_budget_init_treeview(const gchar * treeview_name,GSList * tmp_list)989 static void etats_config_onglet_categ_budget_init_treeview ( const gchar *treeview_name,
990                             GSList *tmp_list )
991 {
992     GtkWidget *tree_view;
993     GtkTreeModel *model;
994     GtkTreeIter parent_iter;
995 
996     /* on récupère le modèle */
997     tree_view = etats_prefs_widget_get_widget_by_name ( treeview_name, NULL );
998     model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
999 
1000     etats_config_onglet_categ_budget_tree_model_check_uncheck_all ( model, FALSE );
1001 
1002     while ( tmp_list )
1003     {
1004         CategBudgetSel *categ_budget_struct = tmp_list -> data;
1005 
1006 		if ( !gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &parent_iter ) )
1007 			return;
1008         do
1009         {
1010             gint div_number;
1011 
1012             gtk_tree_model_get ( GTK_TREE_MODEL ( model ),
1013                                 &parent_iter,
1014                                 GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, &div_number,
1015                                 -1 );
1016 
1017             /* we check the children only if the category is selected */
1018             if ( div_number == categ_budget_struct -> div_number )
1019             {
1020                 gtk_tree_store_set ( GTK_TREE_STORE ( model ),
1021                                 &parent_iter,
1022                                 GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, TRUE,
1023                                 -1 );
1024 
1025                 if ( categ_budget_struct -> sub_div_numbers )
1026                 {
1027                     GtkTreeIter iter_child;
1028 
1029                     if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &iter_child, &parent_iter ) )
1030                     {
1031                         do
1032                         {
1033                             gint sub_div_number;
1034 
1035                             gtk_tree_model_get ( GTK_TREE_MODEL ( model ),
1036                                                 &iter_child,
1037                                                 GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, &sub_div_number,
1038                                                 -1 );
1039 
1040                             if  ( g_slist_find ( categ_budget_struct -> sub_div_numbers,
1041                              GINT_TO_POINTER ( sub_div_number ) ) )
1042                                 gtk_tree_store_set ( GTK_TREE_STORE ( model ),
1043                                                 &iter_child,
1044                                                 GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, TRUE,
1045                                                 -1 );
1046                         }
1047                         while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter_child ) );
1048                     }
1049                 }
1050                 /* we have found the category, can stop here */
1051                 break;
1052             }
1053         }
1054         while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &parent_iter ) );
1055 
1056         tmp_list = tmp_list -> next;
1057     }
1058 }
1059 
1060 
1061 /**
1062  * Initialise les informations des onglets catégories ou budgets
1063  *
1064  * \param report_number
1065  * \param is_categ      TRUE = Categories FALSE = Budgets
1066  *
1067  * \return
1068  */
etats_config_initialise_onglet_categ_budget(gint report_number,gboolean is_categ)1069 static void etats_config_initialise_onglet_categ_budget ( gint report_number,
1070                         gboolean is_categ )
1071 {
1072     gint active;
1073     gchar *checkbutton_name;
1074     gchar *button_name;
1075     gchar *treeview_name;
1076     GSList *tmp_list;
1077 
1078     if ( is_categ )
1079     {
1080         active = gsb_data_report_get_category_detail_used ( report_number );
1081         checkbutton_name = g_strdup ( "bouton_detaille_categ_etat" );
1082         treeview_name = g_strdup ( "treeview_categ" );
1083         button_name = g_strdup ( "togglebutton_select_all_categ" );
1084         tmp_list = gsb_data_report_get_category_struct_list ( report_number );
1085     }
1086     else
1087     {
1088         active = gsb_data_report_get_budget_detail_used ( report_number );
1089         checkbutton_name = g_strdup ( "bouton_detaille_budget_etat" );
1090         treeview_name = g_strdup ( "treeview_budget" );
1091         button_name = g_strdup ( "togglebutton_select_all_budget" );
1092         tmp_list = gsb_data_report_get_budget_struct_list ( report_number );
1093     }
1094 
1095     etats_prefs_button_toggle_set_actif ( checkbutton_name, active );
1096 
1097     if ( active )
1098     {
1099         etats_config_onglet_categ_budget_init_treeview ( treeview_name, tmp_list );
1100 
1101         if ( g_slist_length ( tmp_list ) )
1102             utils_togglebutton_set_label_position_unselect (
1103                                 etats_prefs_widget_get_widget_by_name (
1104                                 button_name, NULL ),
1105                                 G_CALLBACK ( etats_prefs_onglet_categ_budget_check_uncheck_all ),
1106                                 etats_prefs_widget_get_widget_by_name ( treeview_name, NULL ) );
1107     }
1108 
1109     g_free ( checkbutton_name );
1110     g_free ( treeview_name );
1111     g_free ( button_name );
1112 }
1113 
1114 
1115 /**
1116  *
1117  *
1118  * \param
1119  *
1120  * \return
1121  * */
etats_config_onglet_categ_budget_sort_function(GtkTreeModel * model,GtkTreeIter * iter_1,GtkTreeIter * iter_2,gpointer ptr)1122 static gint etats_config_onglet_categ_budget_sort_function ( GtkTreeModel *model,
1123                         GtkTreeIter *iter_1,
1124                         GtkTreeIter *iter_2,
1125                         gpointer ptr )
1126 {
1127     gchar *name_1;
1128     gchar *name_2;
1129     gint number_1;
1130     gint number_2;
1131     gint sub_number_1;
1132     gint sub_number_2;
1133     gint return_value = 0;
1134 
1135     /* first, we sort by date (col 0) */
1136     gtk_tree_model_get ( model,
1137                         iter_1,
1138                         GSB_ETAT_CATEG_BUDGET_LIST_NAME, &name_1,
1139                         GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, &number_1,
1140                         GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, &sub_number_1,
1141                         -1 );
1142 
1143     gtk_tree_model_get ( model,
1144                         iter_2,
1145                         GSB_ETAT_CATEG_BUDGET_LIST_NAME, &name_2,
1146                         GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, &number_2,
1147                         GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER, &sub_number_2,
1148                         -1 );
1149 
1150 
1151     if ( number_1 != -1 && number_2 != -1 && number_1 - number_2 )
1152     {
1153         if ( number_1 == 0 )
1154             return_value = -1;
1155         else if ( number_2 == 0 )
1156             return_value = 1;
1157         else
1158             return_value =  strcmp ( g_utf8_collate_key ( name_1, -1 ),
1159                         g_utf8_collate_key ( name_2, -1 ) );
1160 
1161         if ( name_1)
1162 		{
1163 			g_free ( name_1);
1164 			name_1 = NULL;
1165 		}
1166         if ( name_2)
1167 		{
1168 			g_free ( name_2);
1169 			name_2 = NULL;
1170 		}
1171     }
1172 
1173     if ( return_value )
1174         return return_value;
1175 
1176     if ( sub_number_1 == 0 )
1177             return_value = -1;
1178     else if ( sub_number_2 == 0 )
1179             return_value = 1;
1180     else
1181         return_value =  strcmp ( g_utf8_collate_key ( name_1, -1 ),
1182                         g_utf8_collate_key ( name_2, -1 ) );
1183 
1184     if ( name_1) g_free ( name_1);
1185     if ( name_2) g_free ( name_2);
1186 
1187     return return_value;
1188 }
1189 
1190 
1191 /**
1192  * Récupère les informations des onglets catégories ou budgets
1193  *
1194  * \param report_number
1195  * \param is_categ      TRUE = Categories FALSE = Budgets
1196  *
1197  * \return
1198  */
etats_config_recupere_info_onglet_categ_budget(gint report_number,gboolean is_categ)1199 static void etats_config_recupere_info_onglet_categ_budget ( gint report_number,
1200                         gboolean is_categ )
1201 {
1202     gint active;
1203     gchar *treeview_name;
1204 
1205     if ( is_categ )
1206     {
1207         active = etats_prefs_button_toggle_get_actif ( "bouton_detaille_categ_etat" );
1208         treeview_name = g_strdup ( "treeview_categ" );
1209 
1210         gsb_data_report_set_category_detail_used ( report_number, active );
1211         if ( active )
1212         {
1213             gsb_data_report_set_category_struct_list ( report_number,
1214                                 etats_config_onglet_categ_budget_get_selected ( treeview_name ) );
1215         }
1216     }
1217     else
1218     {
1219         active = etats_prefs_button_toggle_get_actif ( "bouton_detaille_budget_etat" );
1220         treeview_name = g_strdup ( "treeview_budget" );
1221 
1222         gsb_data_report_set_budget_detail_used ( report_number, active );
1223         if ( active )
1224         {
1225             gsb_data_report_set_budget_struct_list ( report_number,
1226                                 etats_config_onglet_categ_budget_get_selected ( treeview_name ) );
1227         }
1228     }
1229 
1230     g_free ( treeview_name );
1231 }
1232 
1233 
1234 /**
1235  * création du model
1236  *
1237  * \param is_categ
1238  *
1239  * \return a GtkWidget : the GtkTreeView
1240  * */
etats_config_onglet_categ_budget_get_model(gboolean is_categ)1241 GtkTreeModel *etats_config_onglet_categ_budget_get_model ( gboolean is_categ )
1242 {
1243     GtkTreeStore *store;
1244 
1245     store = gtk_tree_store_new ( GSB_ETAT_CATEG_BUDGET_LIST_NB,
1246                         G_TYPE_STRING,          /* GSB_ETAT_CATEG_BUDGET_LIST_NAME */
1247                         G_TYPE_BOOLEAN,         /* GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE */
1248                         G_TYPE_BOOLEAN,         /* GSB_ETAT_CATEG_BUDGET_LIST_ACTIVATABLE */
1249                         G_TYPE_INT,             /* GSB_ETAT_CATEG_BUDGET_LIST_NUMBER */
1250                         G_TYPE_INT );           /* GSB_ETAT_CATEG_BUDGET_LIST_SUB_NUMBER */
1251 
1252     gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE ( store ),
1253                         GSB_ETAT_CATEG_BUDGET_LIST_NAME, GTK_SORT_ASCENDING );
1254 
1255     gtk_tree_sortable_set_sort_func ( GTK_TREE_SORTABLE ( store ),
1256                         GSB_ETAT_CATEG_BUDGET_LIST_NAME,
1257                         (GtkTreeIterCompareFunc) etats_config_onglet_categ_budget_sort_function,
1258                         GINT_TO_POINTER ( is_categ ),
1259                         NULL );
1260 
1261     etats_config_onglet_categ_budget_fill_model ( GTK_TREE_MODEL ( store ), is_categ );
1262 
1263     /* return */
1264     return GTK_TREE_MODEL ( store );
1265 }
1266 
1267 
1268 /**
1269  * callback if we toggle a checkbox in the category/budget list
1270  * if we toggle a div, toggle all the sub-div
1271  * if we toggle a sub-div, toggle also the div
1272  *
1273  * \param radio_renderer
1274  * \param path          the string of path
1275  * \param store         the GtkTreeStore of categ/budget
1276  *
1277  * \return FALSE
1278  * */
etats_config_onglet_categ_budget_toggled(GtkCellRendererToggle * radio_renderer,gchar * path_str,GtkTreeStore * store)1279 gboolean etats_config_onglet_categ_budget_toggled ( GtkCellRendererToggle *radio_renderer,
1280                         gchar *path_str,
1281                         GtkTreeStore *store )
1282 {
1283     GtkTreePath *path;
1284     GtkTreeIter iter;
1285     GtkTreeIter iter_children;
1286     gboolean toggle_value;
1287 
1288     g_return_val_if_fail (path_str != NULL, FALSE);
1289     g_return_val_if_fail (store != NULL && GTK_IS_TREE_STORE (store), FALSE);
1290 
1291     /* first get the iter and the value of the checkbutton */
1292     path = gtk_tree_path_new_from_string (path_str);
1293     gtk_tree_model_get_iter ( GTK_TREE_MODEL ( store ), &iter, path );
1294     gtk_tree_model_get ( GTK_TREE_MODEL ( store ),
1295                         &iter,
1296                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, &toggle_value,
1297                         -1 );
1298 
1299     /* ok, we invert the button */
1300     toggle_value = !toggle_value;
1301 
1302     gtk_tree_store_set ( GTK_TREE_STORE ( store ),
1303                         &iter,
1304                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, toggle_value,
1305                         -1 );
1306 
1307     /* if we are on a mother, we set the same value to all the children */
1308     if (gtk_tree_model_iter_children ( GTK_TREE_MODEL ( store ), &iter_children, &iter ) )
1309     {
1310         /* we are on the children */
1311         do
1312             gtk_tree_store_set ( GTK_TREE_STORE (store),
1313                         &iter_children,
1314                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, toggle_value,
1315                         -1 );
1316         while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( store ), &iter_children ) );
1317     }
1318 
1319     /* if we are activating a child, activate the mother */
1320     if (toggle_value
1321      &&
1322      gtk_tree_model_iter_parent ( GTK_TREE_MODEL ( store ), &iter_children, &iter ) )
1323         gtk_tree_store_set ( GTK_TREE_STORE ( store ),
1324                         &iter_children,
1325                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, toggle_value,
1326                         -1 );
1327 
1328     gtk_tree_path_free ( path );
1329 
1330     return FALSE;
1331 }
1332 
1333 
1334 /**
1335  * check or uncheck all the budgets or categories
1336  *
1337  * \param model         the model to fill (is model_categ or model_budget
1338  * \param select_ptr    TRUE or FALSE to select/unselect all
1339  *
1340  * \return FALSE
1341  * */
etats_config_onglet_categ_budget_tree_model_check_uncheck_all(GtkTreeModel * model,gboolean toggle_value)1342 void etats_config_onglet_categ_budget_tree_model_check_uncheck_all ( GtkTreeModel *model,
1343                         gboolean toggle_value )
1344 {
1345     GtkTreeIter parent_iter;
1346 
1347     if ( !gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &parent_iter ) )
1348         return;
1349 
1350     do
1351     {
1352         GtkTreeIter iter_children;
1353 
1354         gtk_tree_store_set ( GTK_TREE_STORE ( model ),
1355                         &parent_iter,
1356                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, toggle_value,
1357                         -1 );
1358 
1359         if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &iter_children, &parent_iter ) )
1360         {
1361             /* we are on the children */
1362             do
1363                 gtk_tree_store_set ( GTK_TREE_STORE ( model ),
1364                         &iter_children,
1365                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, toggle_value,
1366                         -1 );
1367             while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter_children ) );
1368         }
1369     }
1370     while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &parent_iter ) );
1371 }
1372 
1373 
1374 /**
1375  *
1376  *
1377  * \param
1378  * \param
1379  * \param
1380  *
1381  * \return
1382  * */
etats_config_onglet_categ_budget_select_partie_liste(GtkWidget * button,GdkEventButton * event,GtkWidget * tree_view)1383 gboolean etats_config_onglet_categ_budget_select_partie_liste ( GtkWidget *button,
1384                         GdkEventButton *event,
1385                         GtkWidget *tree_view )
1386 {
1387     GtkTreeModel *model;
1388     GtkTreeIter iter;
1389     gboolean is_categ;
1390     gboolean type_div;
1391 
1392     model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
1393 
1394     if ( !gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter ) )
1395         return FALSE;
1396 
1397     etats_config_onglet_categ_budget_tree_model_check_uncheck_all ( model, FALSE );
1398 
1399     is_categ = GPOINTER_TO_INT ( g_object_get_data ( G_OBJECT ( button ), "is_categ" ) );
1400     type_div = GPOINTER_TO_INT ( g_object_get_data ( G_OBJECT ( button ), "type_div" ) );
1401 
1402     do
1403     {
1404         gint div_number;
1405 
1406         gtk_tree_model_get ( GTK_TREE_MODEL ( model ),
1407                         &iter,
1408                         GSB_ETAT_CATEG_BUDGET_LIST_NUMBER, &div_number,
1409                         -1 );
1410 
1411         /* we always select without categories/budget ?? set yes by default */
1412         if ( !div_number
1413          ||
1414          (is_categ && ( gsb_data_category_get_type ( div_number ) == type_div ) )
1415          ||
1416          (!is_categ && ( gsb_data_budget_get_type ( div_number ) == type_div ) ) )
1417         {
1418             GtkTreeIter iter_children;
1419 
1420             gtk_tree_store_set ( GTK_TREE_STORE ( model ),
1421                         &iter,
1422                         GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, TRUE,
1423                         -1 );
1424 
1425             if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &iter_children, &iter ) )
1426             {
1427                 /* we are on the children */
1428                 do
1429                     gtk_tree_store_set ( GTK_TREE_STORE ( model ),
1430                                 &iter_children,
1431                                 GSB_ETAT_CATEG_BUDGET_LIST_ACTIVE, TRUE,
1432                                 -1 );
1433 
1434                 while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter_children ) );
1435             }
1436         }
1437     }
1438     while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
1439 
1440     return FALSE;
1441 }
1442 
1443 
1444 /*ONGLET_TEXTES*/
1445 /**
1446  * Rend sensitif la ligne en fonction du choix du combo_box
1447  *
1448  * \param combo_box
1449  * \param number        gpointer sur text_comparison_number
1450  *
1451  * \return
1452  */
etats_config_onglet_texte_combo_texte_changed(GtkComboBox * combo,gpointer data)1453 static void etats_config_onglet_texte_combo_texte_changed ( GtkComboBox *combo,
1454                         gpointer data )
1455 {
1456     gint index;
1457     gint text_comparison_number;
1458 
1459     text_comparison_number = GPOINTER_TO_INT ( data );
1460 
1461     index = gtk_combo_box_get_active ( combo );
1462     if ( index == 8 || index == 9 || index == 10 )
1463     {
1464         gtk_toggle_button_set_active ( gsb_data_report_text_comparison_get_button_use_text (
1465                                 text_comparison_number ), FALSE );
1466         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_button_use_text (
1467                                 text_comparison_number ), FALSE );
1468         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_hbox_text (
1469                                 text_comparison_number ), FALSE );
1470 
1471         gtk_toggle_button_set_active ( gsb_data_report_text_comparison_get_button_use_number (
1472                                 text_comparison_number ), TRUE );
1473         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_button_use_number (
1474                                 text_comparison_number ), TRUE );
1475         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_hbox_cheque (
1476                                 text_comparison_number ), TRUE );
1477     }
1478     else
1479     {
1480         gtk_toggle_button_set_active ( gsb_data_report_text_comparison_get_button_use_text (
1481                                 text_comparison_number ), TRUE );
1482         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_button_use_text (
1483                                 text_comparison_number ), TRUE );
1484         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_hbox_text (
1485                                 text_comparison_number ), TRUE );
1486 
1487         gtk_toggle_button_set_active ( gsb_data_report_text_comparison_get_button_use_number (
1488                                 text_comparison_number ), FALSE );
1489         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_button_use_number (
1490                                 text_comparison_number ), FALSE );
1491         gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_hbox_cheque (
1492                                 text_comparison_number ), FALSE );
1493     }
1494 }
1495 
1496 
1497 /**
1498  * crée une ligne de recherche de texte
1499  *
1500  * \parent  vbox qui contiendra toutes les lignes
1501  * \param   première ligne ou ligne supplémentaire
1502  * \param   avec lien
1503  *
1504  * \return la nouvelle ligne
1505  */
etats_config_onglet_texte_new_comparison_line(GtkWidget * parent,gint text_comparison_number,gint with_link)1506 static GtkWidget *etats_config_onglet_texte_new_comparison_line ( GtkWidget *parent,
1507                         gint text_comparison_number,
1508                         gint with_link )
1509 {
1510     GtkWidget *vbox;
1511     GtkWidget *hbox;
1512     GtkWidget *hbox_1;
1513     GtkWidget *hbox_2;
1514     GtkWidget *combo;
1515     GtkWidget *label;
1516     GtkWidget *button;
1517     GtkWidget *entry;
1518     GtkWidget *radio_1;
1519     GtkWidget *radio_2;
1520 
1521     /* la vbox qui contient la ligne complète */
1522     vbox = gtk_box_new ( GTK_ORIENTATION_VERTICAL, MARGIN_BOX );
1523 
1524     /* la première hbox pour le type de donnée concernée */
1525     hbox = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX );
1526     gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );
1527 
1528     /* on crée le premier lien ne sert pas si c'est la première ligne */
1529     if ( with_link )
1530     {
1531         combo = utils_combo_box_make_from_string_array ( champs_lien_lignes_comparaison );
1532         gsb_data_report_text_comparison_set_button_link ( text_comparison_number, combo );
1533         gtk_box_pack_start ( GTK_BOX ( hbox ), combo, FALSE, FALSE, 5 );
1534     }
1535 
1536     label = gtk_label_new ( _("Transactions whose ") );
1537     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 5 );
1538 
1539     /* avant de créer le bouton des champs, on doit créer hbox_txt, hbox_chq et les 2 check button */
1540     gsb_data_report_text_comparison_set_hbox_text ( text_comparison_number,
1541                         gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX ) );
1542     gsb_data_report_text_comparison_set_hbox_cheque ( text_comparison_number,
1543                         gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX ) );
1544 
1545     /* on crée le radio bouton de sélection entre les deux types de recherche caché par défaut */
1546     radio_1 = gtk_radio_button_new ( NULL );
1547     gsb_data_report_text_comparison_set_button_use_text ( text_comparison_number,radio_1 );
1548 
1549     radio_2 = gtk_radio_button_new_from_widget ( GTK_RADIO_BUTTON ( radio_1 ) );
1550     gsb_data_report_text_comparison_set_button_use_number ( text_comparison_number, radio_2 );
1551 
1552     /* on crée et initialise le combobox du type de choix pour la recherche de texte */
1553     combo = utils_combo_box_make_from_string_array ( champs_type_recherche_texte );
1554     gsb_data_report_text_comparison_set_button_field ( text_comparison_number, combo );
1555     gtk_box_pack_start ( GTK_BOX ( hbox ), combo, FALSE, FALSE, 0 );
1556 
1557     /* on définit l'action a faire lorsque l'on change le choix du combobox */
1558     g_signal_connect ( G_OBJECT ( combo ),
1559                         "changed",
1560                         G_CALLBACK ( etats_config_onglet_texte_combo_texte_changed ),
1561                         GINT_TO_POINTER ( text_comparison_number ) );
1562 
1563     /* la suite se met dans hbox_txt en 2ème row */
1564     hbox = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX );
1565     gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );
1566 
1567     label = gtk_label_new ( NULL );
1568     gtk_widget_set_size_request ( label, 12, -1 );
1569     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
1570 
1571     /* on met le check button utilisé en cas de champ à no */
1572     button = gsb_data_report_text_comparison_get_button_use_text ( text_comparison_number );
1573     hbox_1 = gsb_data_report_text_comparison_get_hbox_text ( text_comparison_number );
1574 
1575     g_signal_connect ( G_OBJECT ( button ),
1576                         "toggled",
1577                         G_CALLBACK ( sens_desensitive_pointeur ),
1578                         hbox_1 );
1579     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
1580 
1581     /* on met maintenant le comparateur txt */
1582     gtk_box_pack_start ( GTK_BOX ( hbox ), hbox_1, FALSE, FALSE, 0 );
1583 
1584     /* avant de créer l'opérateur, on doit créer l'entrée de txt */
1585     entry = gtk_entry_new ( );
1586     gsb_data_report_text_comparison_set_entry_text ( text_comparison_number, entry );
1587 
1588     combo = utils_combo_box_make_from_string_array ( champs_operateur_recherche_texte );
1589     gsb_data_report_text_comparison_set_button_operator ( text_comparison_number, combo );
1590     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), combo, FALSE, FALSE, 0 );
1591     g_signal_connect ( G_OBJECT ( combo ),
1592                         "changed",
1593                         G_CALLBACK ( sensitive_widget ),
1594                         entry );
1595 
1596     /* on peut maintenant mettre l'entrée de txt */
1597     gtk_widget_set_size_request ( entry, 150, -1 );
1598     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), entry, FALSE, FALSE, 0 );
1599 
1600     /* on crée maintenant la 2ème row qui concerne les tests de chq */
1601     hbox = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX );
1602     gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );
1603 
1604     label = gtk_label_new ( NULL );
1605     gtk_widget_set_size_request ( label, 12, -1 );
1606     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
1607 
1608     /* on met le check button utilisé en cas de champ à no */
1609     button = gsb_data_report_text_comparison_get_button_use_number ( text_comparison_number );
1610     hbox_1 = gsb_data_report_text_comparison_get_hbox_cheque ( text_comparison_number );
1611 
1612     g_signal_connect ( G_OBJECT ( button ),
1613                         "toggled",
1614                         G_CALLBACK ( sens_desensitive_pointeur ),
1615                         hbox_1 );
1616     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
1617 
1618     /* mise en place de la hbox des montants de chq */
1619     gtk_box_pack_start ( GTK_BOX ( hbox ), hbox_1, FALSE, FALSE, 0 );
1620 
1621     label = gtk_label_new ( _("is ") );
1622     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), label, FALSE, FALSE, 0 );
1623 
1624     /* on crée et initialise le combobox pour la première comparaison de nombre */
1625     combo = utils_combo_box_make_from_string_array ( champs_comparateur_nombre );
1626     gsb_data_report_text_comparison_set_button_first_comparison ( text_comparison_number, combo );
1627     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), combo, FALSE, FALSE, 0 );
1628 
1629     label = gtk_label_new ( _("to") );
1630     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), label, FALSE, FALSE, 0 );
1631 
1632     /* on crée le champs texte pour entrer la première comparaison */
1633     entry = gtk_entry_new ( );
1634     gtk_widget_set_size_request ( entry, 100, -1 );
1635     gsb_data_report_text_comparison_set_entry_first_amount ( text_comparison_number, entry );
1636     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), entry, FALSE, FALSE, 0 );
1637 
1638     /* on crée et initialise le combobox pour autoriser la seconde comparaison de nombre */
1639     combo = utils_combo_box_make_from_string_array ( champs_lien_nombre_2 );
1640     gsb_data_report_text_comparison_set_button_link_first_to_second_part ( text_comparison_number, combo );
1641     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), combo, FALSE, FALSE, 0 );
1642 
1643     /* on crée la hbox pour la deuxième partie de la comparaison*/
1644     hbox_2 = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX );
1645     gsb_data_report_text_comparison_set_hbox_second_part ( text_comparison_number, hbox_2 );
1646     gtk_box_pack_start ( GTK_BOX ( hbox_1 ), hbox_2, FALSE, FALSE, 0 );
1647 
1648     /* maintenant que hbox_2 est définie on met le signal lorsque l'on change le choix du combobox */
1649     g_signal_connect ( G_OBJECT ( combo ),
1650                         "changed",
1651                         G_CALLBACK ( etats_config_combo_lien_nombre_2_changed ),
1652                         hbox_2 );
1653 
1654     /* on peut maintenant ajouter dans hbox_partie_2 */
1655     /* on crée et initialise le combobox pour la seconde comparaison de nombre */
1656     combo = utils_combo_box_make_from_string_array ( champs_comparateur_nombre );
1657     gtk_widget_set_size_request ( entry, 100, -1 );
1658     gsb_data_report_text_comparison_set_button_second_comparison ( text_comparison_number, combo );
1659     gtk_box_pack_start ( GTK_BOX ( hbox_2 ), combo, FALSE, FALSE, 0 );
1660 
1661     label = gtk_label_new ( _("at") );
1662     gtk_box_pack_start ( GTK_BOX ( hbox_2 ), label, FALSE, FALSE, 0 );
1663 
1664     /* on crée le champs texte pour entrer la seconde comparaison */
1665     entry = gtk_entry_new ( );
1666     gsb_data_report_text_comparison_set_entry_second_amount ( text_comparison_number, entry );
1667     gtk_box_pack_start ( GTK_BOX ( hbox_2 ), entry, FALSE, FALSE, 0 );
1668 
1669     /* on ajoute le bouton ajouter une nouvelle ligne */
1670     etats_config_onglet_texte_get_buttons_add_remove ( hbox, text_comparison_number );
1671 
1672     /* on met la ligne complète (vbox) dans son parent */
1673     gtk_box_pack_start ( GTK_BOX ( parent ), vbox, FALSE, FALSE, 0 );
1674     gtk_widget_show_all ( vbox );
1675 
1676     /* return */
1677     return vbox;
1678 }
1679 
1680 
1681 /**
1682  * ajoute une ligne de recherche de texte à la liste des lignes de recherche de texte
1683  *
1684  *\param last_text_comparison_number
1685  *
1686  *\return
1687  */
etats_config_onglet_texte_ajoute_ligne_liste_comparaisons(gint last_text_comparison_number)1688 static void etats_config_onglet_texte_ajoute_ligne_liste_comparaisons ( gint last_text_comparison_number )
1689 {
1690     GtkWidget *lignes;
1691     GtkWidget *widget;
1692     gint text_comparison_number;
1693     gint position;
1694     gint current_report_number;
1695 
1696     lignes = etats_prefs_widget_get_widget_by_name ( "liste_textes_etat", NULL );
1697     current_report_number = gsb_gui_navigation_get_current_report ();
1698 
1699     /* on récupère tout de suite la position à laquelle il faut insérer la row */
1700     if ( last_text_comparison_number )
1701         position = g_slist_index ( gsb_data_report_get_text_comparison_list ( current_report_number ),
1702                                 GINT_TO_POINTER ( last_text_comparison_number ) ) + 1;
1703     else
1704         position = 0;
1705 
1706     /* on commence par créer une structure vide */
1707     text_comparison_number = gsb_data_report_text_comparison_new ( 0 );
1708     gsb_data_report_text_comparison_set_report_number ( text_comparison_number,
1709                         current_report_number );
1710 
1711     /* on crée la row et remplit les widget de la structure */
1712     widget = etats_config_onglet_texte_new_comparison_line ( lignes, text_comparison_number, TRUE );
1713     gsb_data_report_text_comparison_set_vbox_line ( text_comparison_number, widget );
1714 
1715     /* on vire le lien de la row s'il n'y a pas encore de liste (cad si c'est la 1ère row) */
1716     if ( !gsb_data_report_get_text_comparison_list ( current_report_number ) )
1717     {
1718         gtk_widget_destroy ( gsb_data_report_text_comparison_get_button_link ( text_comparison_number ) );
1719         gsb_data_report_text_comparison_set_button_link ( text_comparison_number, NULL );
1720     }
1721 
1722     /* par défaut, le bouton bouton_lien_1_2 est sur stop */
1723     widget = gsb_data_report_text_comparison_get_button_link_first_to_second_part ( text_comparison_number );
1724     gtk_combo_box_set_active ( GTK_COMBO_BOX ( widget ), 3 );
1725     gsb_data_report_text_comparison_set_link_first_to_second_part ( text_comparison_number, 3 );
1726     gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_hbox_second_part (
1727                         text_comparison_number ),
1728                         FALSE );
1729 
1730     /* par défaut, la row de chq est non sensitive */
1731     gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_button_use_text (
1732                         text_comparison_number ),
1733                         FALSE );
1734     gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_button_use_number (
1735                         text_comparison_number ),
1736                         FALSE );
1737     gtk_widget_set_sensitive ( gsb_data_report_text_comparison_get_hbox_cheque (
1738                         text_comparison_number ),
1739                         FALSE );
1740 
1741     /* on met la structure dans la liste à la position demandée */
1742     gsb_data_report_set_text_comparison_list ( current_report_number,
1743                         g_slist_insert ( gsb_data_report_get_text_comparison_list ( current_report_number ),
1744                         GINT_TO_POINTER ( text_comparison_number ),
1745                         position ) );
1746 
1747     /* on met la row à sa place dans la liste */
1748     gtk_box_reorder_child ( GTK_BOX ( lignes ),
1749                         gsb_data_report_text_comparison_get_vbox_line ( text_comparison_number ),
1750                         position );
1751 }
1752 
1753 
1754 /**
1755  *
1756  *
1757  * \param
1758  *
1759  * \return
1760  * */
etats_config_onglet_texte_sensitive_hbox_fonction_bouton_txt(gint text_comparison_number)1761 static void etats_config_onglet_texte_sensitive_hbox_fonction_bouton_txt ( gint text_comparison_number )
1762 {
1763     sens_desensitive_pointeur ( gsb_data_report_text_comparison_get_button_use_text ( text_comparison_number ),
1764                         gsb_data_report_text_comparison_get_hbox_text ( text_comparison_number ) );
1765     sens_desensitive_pointeur ( gsb_data_report_text_comparison_get_button_use_number ( text_comparison_number ),
1766                         gsb_data_report_text_comparison_get_hbox_cheque ( text_comparison_number ) );
1767 }
1768 
1769 /**
1770  * fixes error [-Werror=cast-function-type]
1771  *
1772  * \param
1773  * \param
1774  *
1775  * \return
1776  **/
etats_config_onglet_texte_montant_gtk_callback(GtkWidget * widget,gpointer null)1777 static void etats_config_onglet_texte_montant_gtk_callback (GtkWidget *widget,
1778 													gpointer null)
1779 {
1780 	gtk_widget_destroy (widget);
1781 }
1782 
1783 /**
1784  * remplit la liste des comparaisons de texte
1785  *
1786  * \param report_number
1787  *
1788  * \return
1789  */
etats_config_onglet_texte_remplit_liste_comparaisons(gint report_number)1790 static void etats_config_onglet_texte_remplit_liste_comparaisons ( gint report_number )
1791 {
1792     GtkWidget *lignes;
1793     GSList *tmp_list;
1794     gchar *tmp_str;
1795     gboolean multi_lignes = FALSE;
1796 
1797     /* on commence par effacer les anciennes lignes */
1798     lignes = etats_prefs_widget_get_widget_by_name ( "liste_textes_etat", NULL );
1799     gtk_container_foreach (GTK_CONTAINER (lignes), (GtkCallback) etats_config_onglet_texte_montant_gtk_callback, NULL);
1800 
1801     tmp_list = gsb_data_report_get_text_comparison_list ( report_number );
1802     /*   s'il n'y a rien dans la liste, on met juste une row vide */
1803     if ( !tmp_list )
1804     {
1805         etats_config_onglet_texte_ajoute_ligne_liste_comparaisons ( 0 );
1806         return;
1807     }
1808 
1809     /* on fait le tour de la liste des comparaisons de texte, ajoute une row
1810      * et la remplit à chaque fois */
1811     while ( tmp_list )
1812     {
1813         gint text_comparison_number;
1814         GtkWidget *widget;
1815 
1816         text_comparison_number = GPOINTER_TO_INT ( tmp_list -> data );
1817 
1818         /* on crée la row et remplit les widget de la structure */
1819         widget = etats_config_onglet_texte_new_comparison_line ( lignes, text_comparison_number, multi_lignes );
1820         gsb_data_report_text_comparison_set_vbox_line ( text_comparison_number, widget );
1821 
1822         /* on remplit maintenant les widget avec les valeurs de la stucture */
1823         /* on rajoute le && si plusieurs lignes */
1824         if ( gsb_data_report_text_comparison_get_link_to_last_text_comparison ( text_comparison_number ) != -1
1825          &&
1826          tmp_list != gsb_data_report_get_text_comparison_list ( report_number ) )
1827         {
1828             gtk_combo_box_set_active ( GTK_COMBO_BOX (
1829                                 gsb_data_report_text_comparison_get_button_link ( text_comparison_number ) ),
1830                                 gsb_data_report_text_comparison_get_link_to_last_text_comparison (
1831                                 text_comparison_number ) );
1832         }
1833 
1834         gtk_combo_box_set_active ( GTK_COMBO_BOX (
1835                                 gsb_data_report_text_comparison_get_button_field ( text_comparison_number ) ),
1836                                 gsb_data_report_text_comparison_get_field ( text_comparison_number ) );
1837         gtk_combo_box_set_active ( GTK_COMBO_BOX (
1838                                 gsb_data_report_text_comparison_get_button_operator ( text_comparison_number ) ),
1839                                 gsb_data_report_text_comparison_get_operator ( text_comparison_number ) );
1840 
1841         if ( gsb_data_report_text_comparison_get_text ( text_comparison_number ) )
1842             gtk_entry_set_text ( GTK_ENTRY (
1843                                 gsb_data_report_text_comparison_get_entry_text ( text_comparison_number ) ),
1844                                 gsb_data_report_text_comparison_get_text ( text_comparison_number ) );
1845 
1846         gtk_combo_box_set_active ( GTK_COMBO_BOX (
1847                                 gsb_data_report_text_comparison_get_button_first_comparison (
1848                                 text_comparison_number ) ),
1849                                 gsb_data_report_text_comparison_get_first_comparison ( text_comparison_number ) );
1850         gtk_combo_box_set_active ( GTK_COMBO_BOX (
1851                                 gsb_data_report_text_comparison_get_button_link_first_to_second_part (
1852                                 text_comparison_number ) ),
1853                                 gsb_data_report_text_comparison_get_link_first_to_second_part (
1854                                 text_comparison_number ) );
1855         gtk_combo_box_set_active ( GTK_COMBO_BOX (
1856                                 gsb_data_report_text_comparison_get_button_second_comparison (
1857                                 text_comparison_number ) ),
1858                                 gsb_data_report_text_comparison_get_second_comparison ( text_comparison_number ) );
1859 
1860         tmp_str = utils_str_itoa ( gsb_data_report_text_comparison_get_first_amount ( text_comparison_number ) );
1861         gtk_entry_set_text ( GTK_ENTRY (
1862                                 gsb_data_report_text_comparison_get_entry_first_amount (
1863                                 text_comparison_number ) ),
1864                                 tmp_str );
1865         g_free ( tmp_str );
1866 
1867         tmp_str = utils_str_itoa ( gsb_data_report_text_comparison_get_second_amount ( text_comparison_number ) );
1868         gtk_entry_set_text ( GTK_ENTRY (
1869                                 gsb_data_report_text_comparison_get_entry_second_amount (
1870                                 text_comparison_number ) ),
1871                                 tmp_str );
1872         g_free ( tmp_str );
1873 
1874         if ( gsb_data_report_text_comparison_get_use_text ( text_comparison_number ) )
1875             gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (
1876                                 gsb_data_report_text_comparison_get_button_use_text ( text_comparison_number ) ),
1877                                 TRUE );
1878         else
1879             gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (
1880                                 gsb_data_report_text_comparison_get_button_use_number ( text_comparison_number ) ),
1881                                 TRUE );
1882 
1883         /* on désensitive tous ce qui est nécessaire */
1884         if ( gsb_data_report_text_comparison_get_field ( text_comparison_number ) == 8
1885              ||
1886              gsb_data_report_text_comparison_get_field ( text_comparison_number ) == 9
1887              ||
1888              gsb_data_report_text_comparison_get_field ( text_comparison_number ) == 10 )
1889         {
1890             /* 	  on est sur un chq ou une pc */
1891             /* on rend sensitif les check button et la hbox correspondante */
1892             sensitive_widget ( NULL, gsb_data_report_text_comparison_get_button_use_text (
1893                                 text_comparison_number ) );
1894             sensitive_widget ( NULL, gsb_data_report_text_comparison_get_button_use_number (
1895                                 text_comparison_number ) );
1896             etats_config_onglet_texte_sensitive_hbox_fonction_bouton_txt (
1897                                 text_comparison_number );
1898         }
1899         else
1900         {
1901             desensitive_widget ( NULL, gsb_data_report_text_comparison_get_button_use_text (
1902                                 text_comparison_number ) );
1903             desensitive_widget (NULL, gsb_data_report_text_comparison_get_button_use_number (
1904                                 text_comparison_number ) );
1905             desensitive_widget (NULL, gsb_data_report_text_comparison_get_hbox_cheque (
1906                                 text_comparison_number ) );
1907             sensitive_widget (NULL, gsb_data_report_text_comparison_get_hbox_text (
1908                                 text_comparison_number ) );
1909         }
1910 
1911         /* on sensitive/désensitive l'entrée txt*/
1912         if ( gsb_data_report_text_comparison_get_operator ( text_comparison_number ) >= 4 )
1913             desensitive_widget (NULL, gsb_data_report_text_comparison_get_entry_text (
1914                                 text_comparison_number ) );
1915 
1916         /* on sensitive/désensitive les entrées de montant si nécessaire */
1917         if ( gsb_data_report_text_comparison_get_first_comparison ( text_comparison_number ) == 6 )
1918             desensitive_widget (NULL, gsb_data_report_text_comparison_get_entry_first_amount (
1919                                 text_comparison_number ) );
1920 
1921         if ( gsb_data_report_text_comparison_get_second_comparison ( text_comparison_number ) == 6 )
1922             desensitive_widget (NULL, gsb_data_report_text_comparison_get_entry_second_amount (
1923                                 text_comparison_number ) );
1924 
1925         /* on sensitive/désensitive la hbox_2 si nécessaire */
1926         if ( gsb_data_report_text_comparison_get_link_first_to_second_part ( text_comparison_number ) == 3 )
1927             desensitive_widget (NULL, gsb_data_report_text_comparison_get_hbox_second_part (
1928                                 text_comparison_number ) );
1929 
1930         gtk_widget_show ( widget );
1931 
1932         multi_lignes = TRUE;
1933         tmp_list = tmp_list -> next;
1934     }
1935 }
1936 
1937 
1938 /**
1939  * Supprime une ligne de comparaison de texte
1940  *
1941  * \param last_text_comparison_number
1942  *
1943  * \return
1944  */
etats_config_onglet_texte_retire_ligne_liste_comparaisons(gint last_text_comparison_number)1945 static void etats_config_onglet_texte_retire_ligne_liste_comparaisons ( gint last_text_comparison_number )
1946 {
1947     gint current_report_number;
1948 
1949     current_report_number = gsb_gui_navigation_get_current_report ( );
1950 
1951     /* il faut qu'il y ai plus d'une row affichée */
1952     if ( g_slist_length ( gsb_data_report_get_text_comparison_list ( current_report_number ) ) < 2 )
1953         return;
1954 
1955     /* on commence par supprimer la row dans la liste */
1956     gtk_widget_destroy ( gsb_data_report_text_comparison_get_vbox_line ( last_text_comparison_number ) );
1957 
1958     /* si la structure qu'on retire est la 1ère, on vire le widget de lient */
1959     if ( !g_slist_index ( gsb_data_report_get_text_comparison_list ( current_report_number ),
1960      GINT_TO_POINTER ( last_text_comparison_number ) ) )
1961     {
1962         gint text_comparison_number;
1963 
1964         text_comparison_number = GPOINTER_TO_INT ( gsb_data_report_get_text_comparison_list (
1965                                     current_report_number)-> next -> data ) ;
1966         gtk_widget_destroy ( gsb_data_report_text_comparison_get_button_link ( text_comparison_number ) );
1967         gsb_data_report_text_comparison_set_button_link ( text_comparison_number, NULL );
1968     }
1969 
1970     /* et on retire la struct de la sliste */
1971     gsb_data_report_set_text_comparison_list ( current_report_number,
1972                         g_slist_remove ( gsb_data_report_get_text_comparison_list ( current_report_number ),
1973                         GINT_TO_POINTER ( last_text_comparison_number ) ) );
1974 }
1975 
1976 
1977 /**
1978  * création des boutons add et remove
1979  *
1980  * \param parent
1981  * \param text_comparison_number numéro à transmettre à la fonction de callback
1982  *
1983  * \return
1984  * */
etats_config_onglet_texte_get_buttons_add_remove(GtkWidget * parent,gint text_comparison_number)1985 static void etats_config_onglet_texte_get_buttons_add_remove ( GtkWidget *parent,
1986                         gint text_comparison_number )
1987 {
1988     GtkWidget *button;
1989 
1990     button = gtk_button_new_with_label ( _("Add") );
1991     gtk_widget_show ( button );
1992     gtk_button_set_relief ( GTK_BUTTON ( button ), GTK_RELIEF_NORMAL );
1993 
1994     g_signal_connect_swapped ( G_OBJECT ( button ),
1995                         "clicked",
1996                         G_CALLBACK ( etats_config_onglet_texte_ajoute_ligne_liste_comparaisons ),
1997                         GINT_TO_POINTER ( text_comparison_number ) );
1998 
1999     gtk_box_pack_start ( GTK_BOX ( parent ), button, TRUE, TRUE, MARGIN_BOX );
2000 
2001     button = gtk_button_new_with_label ( _("Remove") );
2002     gtk_button_set_relief ( GTK_BUTTON ( button ), GTK_RELIEF_NORMAL );
2003 
2004     g_signal_connect_swapped ( G_OBJECT ( button ),
2005                         "clicked",
2006                         G_CALLBACK ( etats_config_onglet_texte_retire_ligne_liste_comparaisons ),
2007                         GINT_TO_POINTER ( text_comparison_number ) );
2008 
2009     gtk_box_pack_start ( GTK_BOX ( parent ), button, TRUE, TRUE, MARGIN_BOX );
2010 }
2011 
2012 
2013 /**
2014  * Initialise les informations de l'onglet textes
2015  *
2016  * \param report_number
2017  *
2018  * \return
2019  */
etats_config_initialise_onglet_textes(gint report_number)2020 static void etats_config_initialise_onglet_textes ( gint report_number )
2021 {
2022     /* on affiche ou pas le choix des textes */
2023     etats_prefs_button_toggle_set_actif ( "bouton_utilise_texte",
2024                         gsb_data_report_get_text_comparison_used ( report_number ) );
2025 
2026     /* on remplit la liste des lignes de recherche */
2027     etats_config_onglet_texte_remplit_liste_comparaisons ( report_number );
2028 }
2029 
2030 
2031 /**
2032  * Récupère les informations de l'onglet textes
2033  *
2034  * \param numéro d'état à mettre à jour
2035  *
2036  * \return
2037  */
etats_config_recupere_info_onglet_textes(gint report_number)2038 static void etats_config_recupere_info_onglet_textes ( gint report_number )
2039 {
2040     GSList *comparison_list;
2041 
2042     /* on récupère le choix des textes */
2043     gsb_data_report_set_text_comparison_used ( report_number,
2044                         etats_prefs_button_toggle_get_actif ( "bouton_utilise_texte" ) );
2045 
2046     /* récupération de la liste des comparaisons de texte */
2047     /* on a rentré au moins une comparaison */
2048     /* on rempli les champs de la structure */
2049     comparison_list = gsb_data_report_get_text_comparison_list ( report_number );
2050 
2051     while ( comparison_list )
2052     {
2053         const gchar *string;
2054         gint text_comparison_number;
2055 
2056         text_comparison_number = GPOINTER_TO_INT ( comparison_list -> data );
2057 
2058         if ( gsb_data_report_text_comparison_get_button_link ( text_comparison_number ) )
2059             gsb_data_report_text_comparison_set_link_to_last_text_comparison ( text_comparison_number,
2060                         gtk_combo_box_get_active ( GTK_COMBO_BOX (
2061                         gsb_data_report_text_comparison_get_button_link ( text_comparison_number ) ) ) );
2062         else
2063             gsb_data_report_text_comparison_set_link_to_last_text_comparison ( text_comparison_number, -1 );
2064 
2065         gsb_data_report_text_comparison_set_field ( text_comparison_number,
2066                                 gtk_combo_box_get_active ( GTK_COMBO_BOX (
2067                                 gsb_data_report_text_comparison_get_button_field (
2068                                 text_comparison_number ) ) ) );
2069 
2070         gsb_data_report_text_comparison_set_use_text ( text_comparison_number,
2071                                 gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (
2072                                 gsb_data_report_text_comparison_get_button_use_text (
2073                                 text_comparison_number ) ) ) );
2074         gsb_data_report_text_comparison_set_operator ( text_comparison_number,
2075                                 gtk_combo_box_get_active ( GTK_COMBO_BOX (
2076                                 gsb_data_report_text_comparison_get_button_operator (
2077                                 text_comparison_number ) ) ) );
2078 
2079         string = gtk_entry_get_text ( GTK_ENTRY (
2080                                 gsb_data_report_text_comparison_get_entry_text ( text_comparison_number ) ) );
2081         gsb_data_report_text_comparison_set_text ( text_comparison_number, string );
2082 
2083         gsb_data_report_text_comparison_set_first_comparison ( text_comparison_number,
2084                                 gtk_combo_box_get_active ( GTK_COMBO_BOX (
2085                                 gsb_data_report_text_comparison_get_button_first_comparison (
2086                                 text_comparison_number ) ) ) );
2087 
2088         gsb_data_report_text_comparison_set_link_first_to_second_part ( text_comparison_number,
2089                                 gtk_combo_box_get_active ( GTK_COMBO_BOX (
2090                                 gsb_data_report_text_comparison_get_button_link_first_to_second_part (
2091                                 text_comparison_number ) ) ) );
2092         gsb_data_report_text_comparison_set_second_comparison ( text_comparison_number,
2093                                 gtk_combo_box_get_active ( GTK_COMBO_BOX (
2094                                 gsb_data_report_text_comparison_get_button_second_comparison (
2095                                 text_comparison_number ) ) ) );
2096         gsb_data_report_text_comparison_set_first_amount ( text_comparison_number,
2097                                 utils_str_atoi ( gtk_entry_get_text ( GTK_ENTRY (
2098                                 gsb_data_report_text_comparison_get_entry_first_amount (
2099                                 text_comparison_number ) ) ) ) );
2100         gsb_data_report_text_comparison_set_second_amount ( text_comparison_number,
2101                                 utils_str_atoi (gtk_entry_get_text ( GTK_ENTRY (
2102                                 gsb_data_report_text_comparison_get_entry_second_amount (
2103                                 text_comparison_number ) ) ) ) );
2104 
2105         comparison_list = comparison_list -> next;
2106     }
2107 }
2108 
2109 
2110 /*ONGLET_MONTANTS*/
2111 /**
2112  * crée une ligne de recherche de montant
2113  *
2114  * \parent  vbox qui contiendra toutes les lignes
2115  * \param   première ligne ou ligne supplémentaire
2116  * \param   avec lien
2117  *
2118  * \return la nouvelle ligne
2119  */
etats_config_onglet_montants_new_comparison_line(GtkWidget * parent,gint amount_comparison_number,gint with_link)2120 static GtkWidget *etats_config_onglet_montants_new_comparison_line ( GtkWidget *parent,
2121                         gint amount_comparison_number,
2122                         gint with_link )
2123 {
2124     GtkWidget *hbox;
2125     GtkWidget *hbox_2;
2126     GtkWidget *label;
2127     GtkWidget *entry;
2128     GtkWidget *combo;
2129 
2130     hbox = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX );
2131 
2132     /* on crée le premier lien ne sert pas si c'est la première ligne */
2133     if ( with_link )
2134     {
2135         combo = utils_combo_box_make_from_string_array ( champs_lien_lignes_comparaison );
2136         gsb_data_report_amount_comparison_set_button_link ( amount_comparison_number, combo );
2137         gtk_box_pack_start ( GTK_BOX ( hbox ), combo, FALSE, FALSE, 5 );
2138     }
2139 
2140     label = gtk_label_new ( _("Transactions with an amount of") );
2141     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
2142 
2143     /* on crée et initialise le premier combobox de comparaison de montant */
2144     combo = utils_combo_box_make_from_string_array ( champs_comparateur_montant );
2145     gsb_data_report_amount_comparison_set_button_first_comparison ( amount_comparison_number, combo );
2146     gtk_box_pack_start ( GTK_BOX ( hbox ), combo, FALSE, FALSE, 0 );
2147 
2148     label = gtk_label_new ( _("to") );
2149     gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, FALSE, 0 );
2150 
2151     /* on ajoute l'entry pour la saisie du premier montant */
2152     entry = gtk_entry_new ( );
2153     gtk_widget_set_size_request ( entry, 100, -1 );
2154     gtk_box_pack_start ( GTK_BOX ( hbox ), entry, FALSE, FALSE, 0 );
2155     gsb_data_report_amount_comparison_set_entry_first_amount ( amount_comparison_number, entry );
2156 
2157     /* on crée le bouton de lien pour la deuxième partie de la comparaison*/
2158     combo = utils_combo_box_make_from_string_array ( champs_lien_nombre_2 );
2159     gtk_box_pack_start ( GTK_BOX ( hbox ), combo, FALSE, FALSE, 0 );
2160     gsb_data_report_amount_comparison_set_button_link_first_to_second_part ( amount_comparison_number, combo );
2161 
2162     /* the hbox is created in hbox_2 and is used later */
2163     hbox_2 = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, MARGIN_BOX );
2164     gsb_data_report_amount_comparison_set_hbox_second_part ( amount_comparison_number, hbox_2 );
2165     gtk_box_pack_start ( GTK_BOX ( hbox ), hbox_2, FALSE, FALSE, 0 );
2166 
2167     /* maintenant que hbox_2 est définie on met le signal lorsque l'on change le choix du combobox */
2168     g_signal_connect ( G_OBJECT ( combo ),
2169                         "changed",
2170                         G_CALLBACK ( etats_config_combo_lien_nombre_2_changed ),
2171                         hbox_2 );
2172 
2173     /* on peut maintenant ajouter dans comp_montants -> hbox_partie_2 */
2174     combo = utils_combo_box_make_from_string_array ( champs_comparateur_montant );
2175     gsb_data_report_amount_comparison_set_button_second_comparison ( amount_comparison_number, combo );
2176     gtk_box_pack_start ( GTK_BOX ( hbox_2 ), combo, FALSE, FALSE, 0 );
2177 
2178     label = gtk_label_new ( _("to") );
2179     gtk_box_pack_start ( GTK_BOX ( hbox_2 ), label, FALSE, FALSE, 0 );
2180 
2181     /* on ajoute l'entry pour la saisie du premier montant */
2182     entry = gtk_entry_new ( );
2183     gtk_widget_set_size_request ( entry, 100, -1 );
2184     gtk_box_pack_start ( GTK_BOX ( hbox_2 ), entry, FALSE, FALSE, 0 );
2185     gsb_data_report_amount_comparison_set_entry_second_amount ( amount_comparison_number, entry );
2186 
2187     /* on ajoute le bouton ajouter une nouvelle ligne */
2188     etats_config_onglet_montants_get_buttons_add_remove ( hbox, amount_comparison_number );
2189 
2190     /* on met la ligne complète (vbox) dans son parent */
2191     gtk_box_pack_start ( GTK_BOX ( parent ), hbox, FALSE, FALSE, 0 );
2192     gtk_widget_show_all ( hbox );
2193 
2194     /* return */
2195     return hbox;
2196 }
2197 
2198 
2199 /**
2200  * ajoute une ligne de recherche de montant à la liste des lignes de recherche de montant
2201  *
2202  *\param last_amount_comparison_number
2203  *
2204  *\return
2205  */
etats_config_onglet_montants_ajoute_ligne_liste_comparaisons(gint last_amount_comparison_number)2206 static void etats_config_onglet_montants_ajoute_ligne_liste_comparaisons ( gint last_amount_comparison_number )
2207 {
2208     GtkWidget *lignes;
2209     GtkWidget *widget;
2210     gint amount_comparison_number;
2211     gint position;
2212     gint current_report_number;
2213 
2214     lignes = etats_prefs_widget_get_widget_by_name ( "liste_montants_etat", NULL );
2215     current_report_number = gsb_gui_navigation_get_current_report ();
2216 
2217     /* on récupère tout de suite la position à laquelle il faut insérer la row */
2218     if ( last_amount_comparison_number )
2219         position = g_slist_index ( gsb_data_report_get_amount_comparison_list ( current_report_number ),
2220                                 GINT_TO_POINTER ( last_amount_comparison_number ) ) + 1;
2221     else
2222         position = 0;
2223 
2224     /* on commence par créer une structure vide */
2225     amount_comparison_number = gsb_data_report_amount_comparison_new ( 0 );
2226     gsb_data_report_amount_comparison_set_report_number ( amount_comparison_number,
2227                         current_report_number);
2228 
2229     /* on crée la row et remplit les widget de la structure */
2230     widget = etats_config_onglet_montants_new_comparison_line ( lignes, amount_comparison_number, TRUE );
2231     gsb_data_report_amount_comparison_set_hbox_line ( amount_comparison_number, widget );
2232 
2233     /* on vire le lien de la row s'il n'y a pas encore de liste (cad si c'est la 1ère row) */
2234     if ( !gsb_data_report_get_amount_comparison_list ( current_report_number ) )
2235     {
2236         gtk_widget_destroy ( gsb_data_report_amount_comparison_get_button_link ( amount_comparison_number ) );
2237         gsb_data_report_amount_comparison_set_button_link ( amount_comparison_number, NULL );
2238     }
2239 
2240     /*   par défaut, le bouton bouton_lien_1_2 est sur stop */
2241     gtk_combo_box_set_active ( GTK_COMBO_BOX (
2242                         gsb_data_report_amount_comparison_get_button_link_first_to_second_part (
2243                         amount_comparison_number ) ),
2244                         3 );
2245     gsb_data_report_amount_comparison_set_link_first_to_second_part ( amount_comparison_number, 3 );
2246     gtk_widget_set_sensitive ( gsb_data_report_amount_comparison_get_hbox_second_part (
2247                         amount_comparison_number ),
2248                         FALSE );
2249 
2250     /* on met la structure dans la liste à la position demandée */
2251     gsb_data_report_set_amount_comparison_list ( current_report_number,
2252                         g_slist_insert ( gsb_data_report_get_amount_comparison_list ( current_report_number ),
2253                         GINT_TO_POINTER ( amount_comparison_number ),
2254                         position ) );
2255 
2256 
2257     /* on met la row à sa place dans la liste */
2258     gtk_box_reorder_child ( GTK_BOX ( lignes ),
2259                         gsb_data_report_amount_comparison_get_hbox_line ( amount_comparison_number ),
2260                         position );
2261 }
2262 
2263 
2264 /**
2265  * remplit la liste des comparaisons de montants
2266  *
2267  * \param report_number
2268  *
2269  * \return
2270  */
etats_config_onglet_montants_remplit_liste_comparaisons(gint report_number)2271 static void etats_config_onglet_montants_remplit_liste_comparaisons ( gint report_number )
2272 {
2273     GtkWidget *lignes;
2274     GSList *list_tmp;
2275     gchar* tmp_str;
2276     gboolean multi_lignes = FALSE;
2277 
2278     /* on commence par effacer les anciennes lignes */
2279     lignes = etats_prefs_widget_get_widget_by_name ( "liste_montants_etat", NULL );
2280     gtk_container_foreach (GTK_CONTAINER (lignes), (GtkCallback) etats_config_onglet_texte_montant_gtk_callback, NULL);
2281 
2282     list_tmp = gsb_data_report_get_amount_comparison_list ( report_number );
2283     /*   s'il n'y a rien dans la liste, on met juste une row vide */
2284     if ( !list_tmp )
2285     {
2286         etats_config_onglet_montants_ajoute_ligne_liste_comparaisons ( 0 );
2287         return;
2288     }
2289 
2290     /* on fait le tour de la liste des comparaisons de montant, ajoute une row
2291      * et la remplit à chaque fois */
2292     while ( list_tmp )
2293     {
2294         gint amount_comparison_number;
2295         GtkWidget *hbox;
2296 
2297         amount_comparison_number = GPOINTER_TO_INT ( list_tmp -> data );
2298         hbox = etats_config_onglet_montants_new_comparison_line ( lignes, amount_comparison_number, multi_lignes );
2299 
2300         /* on crée la row et remplit les widget de la structure */
2301         gsb_data_report_amount_comparison_set_hbox_line ( amount_comparison_number, hbox );
2302 
2303         /* on remplit maintenant les widget avec les valeurs de la stucture */
2304         /* s'il n'y a pas de lien avec la struct précédente, on le vire
2305          * on rajoute le && car parfois le bouton de lien se met quand même en 1ère row */
2306 
2307         if ( gsb_data_report_amount_comparison_get_link_to_last_amount_comparison ( amount_comparison_number ) != -1
2308          &&
2309          list_tmp != gsb_data_report_get_amount_comparison_list ( report_number ) )
2310         {
2311             gtk_combo_box_set_active ( GTK_COMBO_BOX (
2312                         gsb_data_report_amount_comparison_get_button_link ( amount_comparison_number ) ),
2313                         gsb_data_report_amount_comparison_get_link_to_last_amount_comparison (
2314                         amount_comparison_number ) );
2315         }
2316 
2317         gtk_combo_box_set_active ( GTK_COMBO_BOX (
2318                         gsb_data_report_amount_comparison_get_button_first_comparison (
2319                         amount_comparison_number ) ),
2320                         gsb_data_report_amount_comparison_get_first_comparison ( amount_comparison_number ) );
2321         gtk_combo_box_set_active ( GTK_COMBO_BOX (
2322                         gsb_data_report_amount_comparison_get_button_link_first_to_second_part (
2323                         amount_comparison_number ) ),
2324                         gsb_data_report_amount_comparison_get_link_first_to_second_part (
2325                         amount_comparison_number ) );
2326         gtk_combo_box_set_active ( GTK_COMBO_BOX (
2327                         gsb_data_report_amount_comparison_get_button_second_comparison (
2328                         amount_comparison_number ) ),
2329                         gsb_data_report_amount_comparison_get_second_comparison (
2330                         amount_comparison_number ) );
2331 
2332         tmp_str = utils_real_get_string ( gsb_data_report_amount_comparison_get_first_amount (
2333                         amount_comparison_number ) );
2334         gtk_entry_set_text ( GTK_ENTRY ( gsb_data_report_amount_comparison_get_entry_first_amount (
2335                         amount_comparison_number ) ),
2336                         tmp_str );
2337         g_free ( tmp_str );
2338 
2339         tmp_str = utils_real_get_string ( gsb_data_report_amount_comparison_get_second_amount (
2340                         amount_comparison_number ) );
2341         gtk_entry_set_text ( GTK_ENTRY ( gsb_data_report_amount_comparison_get_entry_second_amount (
2342                         amount_comparison_number ) ),
2343                         tmp_str );
2344         g_free ( tmp_str );
2345 
2346         /* on sensitive/désensitive les entrées si nécessaire */
2347         if ( gsb_data_report_amount_comparison_get_first_comparison ( amount_comparison_number ) > 5 )
2348             desensitive_widget ( NULL, gsb_data_report_amount_comparison_get_entry_first_amount (
2349                         amount_comparison_number ) );
2350         else
2351             sensitive_widget ( NULL, gsb_data_report_amount_comparison_get_entry_first_amount (
2352                         amount_comparison_number ) );
2353 
2354         if ( gsb_data_report_amount_comparison_get_second_comparison ( amount_comparison_number ) > 5 )
2355             desensitive_widget ( NULL, gsb_data_report_amount_comparison_get_entry_second_amount (
2356                         amount_comparison_number ) );
2357         else
2358             sensitive_widget ( NULL, gsb_data_report_amount_comparison_get_entry_second_amount (
2359                         amount_comparison_number ) );
2360 
2361         /* on sensitive/désensitive la hbox_2 si nécessaire */
2362         if ( gsb_data_report_amount_comparison_get_link_first_to_second_part ( amount_comparison_number ) == 3 )
2363             desensitive_widget ( NULL, gsb_data_report_amount_comparison_get_hbox_second_part (
2364                         amount_comparison_number ) );
2365         else
2366             sensitive_widget ( NULL, gsb_data_report_amount_comparison_get_hbox_second_part (
2367                         amount_comparison_number ) );
2368 
2369         list_tmp = list_tmp -> next;
2370     }
2371 }
2372 
2373 
2374 /**
2375  * supprime une liste de comparaison
2376  *
2377  * \param
2378  *
2379  * \return
2380  * */
etats_config_onglet_montants_retire_ligne_liste_comparaisons(gint last_amount_comparison_number)2381 static void etats_config_onglet_montants_retire_ligne_liste_comparaisons ( gint last_amount_comparison_number )
2382 {
2383      gint current_report_number;
2384 
2385     current_report_number = gsb_gui_navigation_get_current_report ();
2386 
2387     /* il faut qu'il y ai plus d'une row affichée */
2388     if ( g_slist_length ( gsb_data_report_get_amount_comparison_list ( current_report_number ) ) < 2 )
2389         return;
2390 
2391     /* on commence par supprimer la row dans la liste */
2392     gtk_widget_destroy ( gsb_data_report_amount_comparison_get_hbox_line ( last_amount_comparison_number ) );
2393 
2394     /* si la structure qu'on retire est la 1ère, on vire le widget de lient */
2395     if ( !g_slist_index ( gsb_data_report_get_amount_comparison_list ( current_report_number ),
2396      GINT_TO_POINTER ( last_amount_comparison_number ) ) )
2397     {
2398         gint amount_comparison_number;
2399 
2400         amount_comparison_number = GPOINTER_TO_INT ( gsb_data_report_get_amount_comparison_list (
2401                         current_report_number )-> next -> data );
2402         gtk_widget_destroy ( gsb_data_report_amount_comparison_get_button_link ( amount_comparison_number ) );
2403         gsb_data_report_amount_comparison_set_button_link ( amount_comparison_number, NULL );
2404     }
2405 
2406     /* et on retire la struct de la sliste */
2407     gsb_data_report_set_amount_comparison_list ( current_report_number,
2408                         g_slist_remove ( gsb_data_report_get_amount_comparison_list ( current_report_number ),
2409                         GINT_TO_POINTER ( last_amount_comparison_number ) ) );
2410 }
2411 
2412 
2413 /**
2414  * création des boutons add et remove
2415  *
2416  * \param parent
2417  * \param text_comparison_number numéro à transmettre à la fonction de callback
2418  *
2419  * \return
2420  * */
etats_config_onglet_montants_get_buttons_add_remove(GtkWidget * parent,gint text_comparison_number)2421 static void etats_config_onglet_montants_get_buttons_add_remove ( GtkWidget *parent,
2422                         gint text_comparison_number )
2423 {
2424     GtkWidget *button;
2425 
2426     button = gtk_button_new_with_label ( _("Add") );
2427     gtk_widget_show ( button );
2428     gtk_button_set_relief ( GTK_BUTTON ( button ), GTK_RELIEF_NONE );
2429 
2430     g_signal_connect_swapped ( G_OBJECT ( button ),
2431                         "clicked",
2432                         G_CALLBACK ( etats_config_onglet_montants_ajoute_ligne_liste_comparaisons ),
2433                         GINT_TO_POINTER ( text_comparison_number ) );
2434 
2435     gtk_box_pack_start ( GTK_BOX ( parent ), button, TRUE, TRUE, 0 );
2436 
2437     button = gtk_button_new_with_label ( _("Remove") );
2438     gtk_button_set_relief ( GTK_BUTTON ( button ), GTK_RELIEF_NONE );
2439 
2440     g_signal_connect_swapped ( G_OBJECT ( button ),
2441                         "clicked",
2442                         G_CALLBACK ( etats_config_onglet_montants_retire_ligne_liste_comparaisons ),
2443                         GINT_TO_POINTER ( text_comparison_number ) );
2444 
2445     gtk_box_pack_start ( GTK_BOX ( parent ), button, TRUE, TRUE, 0 );
2446 }
2447 
2448 
2449 /**
2450  * Initialise les informations de l'onglet montants
2451  *
2452  * \param report_number
2453  *
2454  * \return
2455  */
etats_config_initialise_onglet_montants(gint report_number)2456 static void etats_config_initialise_onglet_montants ( gint report_number )
2457 {
2458     /* on affiche ou pas le choix des montants */
2459     etats_prefs_button_toggle_set_actif ( "bouton_utilise_montant",
2460                         gsb_data_report_get_amount_comparison_used ( report_number ) );
2461 
2462     /* on remplit la liste des lignes de recherche */
2463     etats_config_onglet_montants_remplit_liste_comparaisons ( report_number );
2464 }
2465 
2466 
2467 /**
2468  * Récupère les informations de l'onglet montants
2469  *
2470  * \param numéro d'état à mettre à jour
2471  *
2472  * \return
2473  */
etats_config_recupere_info_onglet_montants(gint report_number)2474 static void etats_config_recupere_info_onglet_montants ( gint report_number )
2475 {
2476     gint amount_comparison_number;
2477 
2478     /* on récupère le choix des montants */
2479     gsb_data_report_set_amount_comparison_used ( report_number,
2480                         etats_prefs_button_toggle_get_actif ( "bouton_utilise_montant" ) );
2481 
2482     /* récupération de la liste des comparaisons de montant */
2483     /*   il y a au moins une structure de créé, si celle si a les 2 montants vides, */
2484     /* c'est qu'il n'y a aucune liste */
2485     amount_comparison_number = GPOINTER_TO_INT ( gsb_data_report_get_amount_comparison_list (
2486                                 report_number )-> data );
2487 
2488     if ( g_slist_length ( gsb_data_report_get_amount_comparison_list ( report_number ) ) == 1
2489      &&
2490      !strlen ( gtk_entry_get_text ( GTK_ENTRY ( gsb_data_report_amount_comparison_get_entry_first_amount (
2491      amount_comparison_number ) ) ) )
2492      &&
2493      !strlen ( gtk_entry_get_text ( GTK_ENTRY ( gsb_data_report_amount_comparison_get_entry_second_amount (
2494      amount_comparison_number ) ) ) )
2495      &&
2496      gtk_widget_get_sensitive ( gsb_data_report_amount_comparison_get_entry_first_amount (
2497      amount_comparison_number ) )
2498      &&
2499      gtk_widget_get_sensitive ( gsb_data_report_amount_comparison_get_entry_second_amount (
2500      amount_comparison_number ) ) )
2501     {
2502         g_slist_free ( gsb_data_report_get_amount_comparison_list ( report_number ) );
2503         gsb_data_report_set_amount_comparison_list ( report_number, NULL );
2504     }
2505     else
2506     {
2507         /* on a rentré au moins une comparaison */
2508         /* on rempli les champs de la structure */
2509         GSList *comparison_list;
2510 
2511         comparison_list = gsb_data_report_get_amount_comparison_list ( report_number );
2512 
2513         while ( comparison_list )
2514         {
2515             amount_comparison_number = GPOINTER_TO_INT ( comparison_list -> data );
2516 
2517             if ( gsb_data_report_amount_comparison_get_button_link ( amount_comparison_number ) )
2518                 gsb_data_report_amount_comparison_set_link_to_last_amount_comparison ( amount_comparison_number,
2519                                 gtk_combo_box_get_active ( GTK_COMBO_BOX (
2520                                 gsb_data_report_amount_comparison_get_button_link (
2521                                 amount_comparison_number ) ) ) );
2522             else
2523                 gsb_data_report_amount_comparison_set_link_to_last_amount_comparison (
2524                                 amount_comparison_number,
2525                                 -1 );
2526 
2527             gsb_data_report_amount_comparison_set_first_comparison ( amount_comparison_number,
2528                         gtk_combo_box_get_active ( GTK_COMBO_BOX (
2529                         gsb_data_report_amount_comparison_get_button_first_comparison (
2530                         amount_comparison_number ) ) ) );
2531 
2532             gsb_data_report_amount_comparison_set_link_first_to_second_part ( amount_comparison_number,
2533                         gtk_combo_box_get_active ( GTK_COMBO_BOX (
2534                         gsb_data_report_amount_comparison_get_button_link_first_to_second_part (
2535                         amount_comparison_number ) ) ) );
2536             gsb_data_report_amount_comparison_set_second_comparison ( amount_comparison_number,
2537                         gtk_combo_box_get_active ( GTK_COMBO_BOX (
2538                         gsb_data_report_amount_comparison_get_button_second_comparison (
2539                         amount_comparison_number ) ) ) );
2540 
2541             gsb_data_report_amount_comparison_set_first_amount ( amount_comparison_number,
2542                         utils_real_get_from_string ( gtk_entry_get_text ( GTK_ENTRY (
2543                         gsb_data_report_amount_comparison_get_entry_first_amount (
2544                         amount_comparison_number ) ) ) ) );
2545             gsb_data_report_amount_comparison_set_second_amount ( amount_comparison_number,
2546                         utils_real_get_from_string ( gtk_entry_get_text ( GTK_ENTRY (
2547                         gsb_data_report_amount_comparison_get_entry_second_amount (
2548                         amount_comparison_number ) ) ) ) );
2549 
2550             comparison_list = comparison_list -> next;
2551         }
2552     }
2553 
2554     gsb_data_report_set_amount_comparison_only_report_non_null ( report_number,
2555                         etats_prefs_button_toggle_get_actif ( "bouton_exclure_ope_nulles_etat" ) );
2556 }
2557 
2558 
2559 /*ONGLET_MODE_PAIEMENT*/
2560 /**
2561  * Initialise les informations de l'onglet modes de paiement
2562  *
2563  * \param report_number
2564  *
2565  * \return
2566  */
etats_config_initialise_onglet_mode_paiement(gint report_number)2567 static void etats_config_initialise_onglet_mode_paiement ( gint report_number )
2568 {
2569     gint active;
2570 
2571     active = gsb_data_report_get_method_of_payment_used ( report_number );
2572     etats_prefs_button_toggle_set_actif ( "bouton_detaille_mode_paiement_etat", active );
2573 
2574     if ( active )
2575     {
2576         etats_prefs_onglet_mode_paiement_select_rows_from_list (
2577                                 gsb_data_report_get_method_of_payment_list ( report_number ),
2578                                 "treeview_mode_paiement" );
2579 
2580         if ( g_slist_length ( gsb_data_report_get_method_of_payment_list ( report_number ) ) )
2581             utils_togglebutton_set_label_position_unselect (
2582                                 etats_prefs_widget_get_widget_by_name (
2583                                 "togglebutton_select_all_mode_paiement", NULL ),
2584                                 NULL,
2585                                 etats_prefs_widget_get_widget_by_name ( "treeview_mode_paiement", NULL ) );
2586     }
2587 }
2588 
2589 
2590 /**
2591  * Récupère les informations de l'onglet mode de paiement
2592  *
2593  * \param numéro d'état à mettre à jour
2594  *
2595  * \return
2596  */
etats_config_recupere_info_onglet_mode_paiement(gint report_number)2597 static void etats_config_recupere_info_onglet_mode_paiement ( gint report_number )
2598 {
2599     gint active;
2600 
2601     active = etats_prefs_button_toggle_get_actif ( "bouton_detaille_mode_paiement_etat" );
2602     gsb_data_report_set_method_of_payment_used ( report_number, active );
2603     if ( active )
2604     {
2605         gsb_data_report_free_method_of_payment_list ( report_number );
2606 
2607         if ( utils_tree_view_all_rows_are_selected ( GTK_TREE_VIEW (
2608          etats_prefs_widget_get_widget_by_name ( "treeview_mode_paiement", NULL ) ) ) )
2609         {
2610             gchar *text;
2611             gchar *hint;
2612 
2613             hint = g_strdup ( _("Performance issue.") );
2614             text = g_strdup ( _("All methods of payment have been selected.  Grisbi will run "
2615                             "faster without the \"Detail methods of payment used\" option activated.") );
2616 
2617             dialogue_hint ( text, hint );
2618             etats_prefs_button_toggle_set_actif ( "togglebutton_select_all_mode_paiement", FALSE );
2619             gsb_data_report_set_method_of_payment_used ( report_number, 0 );
2620 
2621             g_free ( text );
2622             g_free ( hint );
2623         }
2624         else
2625             gsb_data_report_set_method_of_payment_list ( report_number,
2626                             etats_prefs_onglet_mode_paiement_get_list_rows_selected (
2627                             "treeview_mode_paiement" ) );
2628 
2629     }
2630 }
2631 
2632 
2633 /**
2634  *
2635  *
2636  * \param
2637  *
2638  * \return
2639  * */
etats_config_onglet_mode_paiement_get_model(void)2640 GtkTreeModel *etats_config_onglet_mode_paiement_get_model ( void )
2641 {
2642     GtkListStore *list_store;
2643     GSList *liste_nom_types = NULL;
2644     GSList *list_tmp;
2645 
2646     list_store = gtk_list_store_new ( 2, G_TYPE_STRING, G_TYPE_INT );
2647 
2648     gtk_tree_sortable_set_sort_column_id ( GTK_TREE_SORTABLE ( list_store ),
2649                         0, GTK_SORT_ASCENDING );
2650 
2651     /* create a list of unique names */
2652     list_tmp = gsb_data_payment_get_payments_list ( );
2653 
2654     while ( list_tmp )
2655     {
2656         GtkTreeIter iter;
2657         gchar *name;
2658         gint payment_number;
2659 
2660         payment_number = gsb_data_payment_get_number (list_tmp -> data);
2661         name = my_strdup ( gsb_data_payment_get_name ( payment_number ) );
2662 
2663         if ( !g_slist_find_custom ( liste_nom_types,
2664                         name,
2665                         ( GCompareFunc ) cherche_string_equivalente_dans_slist ) )
2666         {
2667             liste_nom_types = g_slist_append ( liste_nom_types, name );
2668             gtk_list_store_append ( list_store, &iter );
2669             gtk_list_store_set ( list_store, &iter, 0, name, 1, payment_number, -1 );
2670         }
2671         else
2672             g_free ( name );
2673 
2674         list_tmp = list_tmp -> next;
2675     }
2676 
2677     /* on libère la mémoire utilisée par liste_nom_types */
2678     g_slist_free_full ( liste_nom_types, ( GDestroyNotify ) g_free );
2679 
2680     /* return */
2681     return GTK_TREE_MODEL ( list_store );
2682 }
2683 
2684 
2685 /*ONGLET_DIVERS*/
2686 /**
2687  * Initialise les informations de l'onglet divers
2688  *
2689  * \param report_number
2690  *
2691  * \return
2692  */
etats_config_initialise_onglet_divers(gint report_number)2693 static void etats_config_initialise_onglet_divers ( gint report_number )
2694 {
2695     gint index;
2696 
2697     index = gsb_data_report_get_show_m ( report_number );
2698     etats_prefs_buttons_radio_set_active_index ( "radiobutton_marked_all", index );
2699 
2700     etats_prefs_button_toggle_set_actif ( "checkbutton_marked_P",
2701                         gsb_data_report_get_show_p ( report_number ) );
2702     etats_prefs_button_toggle_set_actif ( "checkbutton_marked_R",
2703                         gsb_data_report_get_show_r ( report_number ) );
2704     etats_prefs_button_toggle_set_actif ( "checkbutton_marked_T",
2705                         gsb_data_report_get_show_t ( report_number ) );
2706 
2707     etats_prefs_button_toggle_set_actif ( "bouton_pas_detailler_ventilation",
2708                         gsb_data_report_get_not_detail_split ( report_number ) );
2709 }
2710 
2711 
2712 /**
2713  * Récupère les informations de l'onglet divers
2714  *
2715  * \param numéro d'état à mettre à jour
2716  *
2717  * \return
2718  */
etats_config_recupere_info_onglet_divers(gint report_number)2719 static void etats_config_recupere_info_onglet_divers ( gint report_number )
2720 {
2721     gint index;
2722 
2723     index = etats_prefs_buttons_radio_get_active_index ( "radiobutton_marked_all" );
2724     gsb_data_report_set_show_m ( report_number, index );
2725 
2726     gsb_data_report_set_show_p ( report_number,
2727                         etats_prefs_button_toggle_get_actif ( "checkbutton_marked_P" ) );
2728     gsb_data_report_set_show_r ( report_number,
2729                         etats_prefs_button_toggle_get_actif ( "checkbutton_marked_R" ) );
2730     gsb_data_report_set_show_t ( report_number,
2731                         etats_prefs_button_toggle_get_actif ( "checkbutton_marked_T" ) );
2732 
2733     gsb_data_report_set_not_detail_split ( report_number,
2734                         etats_prefs_button_toggle_get_actif ( "bouton_pas_detailler_ventilation" ) );
2735 }
2736 
2737 
2738 /*ONGLET_DATA_GROUPING*/
2739 /**
2740  * return la liste des données par ordre de tri
2741  *
2742  * \param report_number
2743  *
2744  * \return a GSList
2745  * */
etats_config_onglet_data_grouping_get_list(gint report_number)2746 static GSList *etats_config_onglet_data_grouping_get_list ( gint report_number )
2747 {
2748     GtkWidget *tree_view;
2749     GtkTreeModel *model;
2750     GtkTreeIter iter;
2751     GSList *tmp_list = NULL;
2752 
2753     tree_view = etats_prefs_widget_get_widget_by_name ( "treeview_data_grouping", NULL );
2754     model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
2755 
2756     if ( gtk_tree_model_get_iter_first ( model, &iter ) )
2757     {
2758         do
2759         {
2760             gint type_data;
2761 
2762             gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter, 2, &type_data, -1 );
2763             tmp_list = g_slist_append ( tmp_list, GINT_TO_POINTER ( type_data ) );
2764 
2765             /* on ajoute les sous catégories ici */
2766             if ( type_data == 1 )
2767             {
2768                 tmp_list = g_slist_append ( tmp_list, GINT_TO_POINTER ( 2 ) );
2769             }
2770             /* et les sous imputations ici */
2771             else if ( type_data == 3 )
2772             {
2773                 tmp_list = g_slist_append ( tmp_list, GINT_TO_POINTER ( 4 ) );
2774             }
2775         }
2776         while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
2777 
2778         return tmp_list;
2779     }
2780 
2781     /* return */
2782     return NULL;
2783 }
2784 
2785 /**
2786  * Update le modèle avec les données sauvegardées
2787  *
2788  * \param report_number
2789  *
2790  * \return TRUE
2791  */
etats_config_onglet_data_grouping_update_model(gint report_number)2792 static gboolean etats_config_onglet_data_grouping_update_model ( gint report_number )
2793 {
2794     GtkWidget *tree_view;
2795     GtkTreeModel *model;
2796     GSList *tmp_list;
2797     gint i = 0;
2798 
2799     tree_view = etats_prefs_widget_get_widget_by_name ( "treeview_data_grouping", NULL );
2800     model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
2801 
2802     /* on reset le model */
2803     gtk_list_store_clear ( GTK_LIST_STORE ( model ) );
2804 
2805     /* on remplit la liste des données */
2806     tmp_list = gsb_data_report_get_sorting_type_list ( report_number );
2807 
2808     while ( tmp_list )
2809     {
2810         GtkTreeIter iter;
2811         gchar *string = NULL;
2812         gint type_data;
2813 
2814         type_data = GPOINTER_TO_INT ( tmp_list->data );
2815 
2816         string = etats_config_onglet_data_grouping_get_string ( type_data, i );
2817         if ( !string )
2818         {
2819             tmp_list = tmp_list->next;
2820             continue;
2821         }
2822 
2823         gtk_list_store_append ( GTK_LIST_STORE ( model ), &iter );
2824         gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter, 0, string, 1, i, 2, type_data, -1 );
2825 
2826         g_free ( string );
2827 
2828         i++;
2829         tmp_list = tmp_list->next;
2830     }
2831 
2832     /* return */
2833     return TRUE;
2834 }
2835 
2836 
2837 /**
2838  * Initialise les informations de l'onglet groupement des données
2839  *
2840  * \param report_number
2841  *
2842  * \return
2843  */
etats_config_initialise_onglet_data_grouping(gint report_number)2844 static void etats_config_initialise_onglet_data_grouping ( gint report_number )
2845 {
2846     etats_prefs_button_toggle_set_actif ( "bouton_regroupe_ope_compte_etat",
2847                         gsb_data_report_get_account_group_reports ( report_number ) );
2848     etats_prefs_button_toggle_set_actif ( "bouton_utilise_tiers_etat",
2849                         gsb_data_report_get_payee_used ( report_number ) );
2850     etats_prefs_button_toggle_set_actif ( "bouton_group_by_categ",
2851                         gsb_data_report_get_category_used ( report_number ) );
2852     etats_prefs_button_toggle_set_actif ( "bouton_utilise_ib_etat",
2853                         gsb_data_report_get_budget_used ( report_number ) );
2854 
2855     etats_config_onglet_data_grouping_update_model ( report_number );
2856 }
2857 
2858 
2859 /**
2860  * Récupère les informations de l'onglet groupement des données
2861  *
2862  * \param numéro d'état à mettre à jour
2863  *
2864  * \return
2865  */
etats_config_recupere_info_onglet_data_grouping(gint report_number)2866 static void etats_config_recupere_info_onglet_data_grouping ( gint report_number )
2867 {
2868     gsb_data_report_set_account_group_reports ( report_number,
2869                         etats_prefs_button_toggle_get_actif ( "bouton_regroupe_ope_compte_etat" ) );
2870     gsb_data_report_set_payee_used ( report_number,
2871                         etats_prefs_button_toggle_get_actif ( "bouton_utilise_tiers_etat" ) );
2872     gsb_data_report_set_category_used ( report_number,
2873                         etats_prefs_button_toggle_get_actif ( "bouton_group_by_categ" ) );
2874     gsb_data_report_set_budget_used ( report_number,
2875                         etats_prefs_button_toggle_get_actif ( "bouton_utilise_ib_etat" ) );
2876 
2877     /* on récupère les données servant au tri des données pour l'affichage */
2878     gsb_data_report_free_sorting_type_list ( report_number );
2879     gsb_data_report_set_sorting_type_list ( report_number,
2880                         etats_config_onglet_data_grouping_get_list ( report_number ) );
2881 }
2882 
2883 
2884 /**
2885  * retourne une chaine de caractère formatée en fonction du type de donnée
2886  * et de la position dans la liste
2887  *
2888  * \param type_data     type de donnée : 1 Categ, 3 IB, 5 Account, 6 Payee.
2889  * \param pos           numéro de ligne dans le modèle
2890  *
2891  * \return NULL or a formatted string
2892  */
etats_config_onglet_data_grouping_get_string(gint type_data,gint pos)2893 gchar *etats_config_onglet_data_grouping_get_string ( gint type_data,
2894                         gint pos )
2895 {
2896     gchar *string = NULL;
2897     gchar *text = NULL;
2898 
2899     switch ( type_data )
2900     {
2901         case 1:
2902         text = g_strdup ( _("Category") );
2903         break;
2904 
2905         case 3:
2906         text = g_strdup ( _("Budgetary line") );
2907         break;
2908 
2909         case 5:
2910         text = g_strdup ( _("Account") );
2911         break;
2912 
2913         case 6:
2914         text = g_strdup ( _("Payee") );
2915         break;
2916     }
2917 
2918     if ( !text )
2919         return NULL;
2920 
2921     if ( pos <= 0 )
2922         string = text;
2923     else if ( pos == 1 )
2924     {
2925         string = g_strconcat ( "\t", text, NULL );
2926         g_free ( text );
2927     }
2928     else if ( pos == 2 )
2929     {
2930         string = g_strconcat ( "\t\t", text, NULL );
2931         g_free ( text );
2932     }
2933     else if ( pos == 3 )
2934     {
2935         string = g_strconcat ( "\t\t\t", text, NULL );
2936         g_free ( text );
2937     }
2938 
2939     return string;
2940 }
2941 
2942 /**
2943  * déplace un item suite à un drag and drop dans le tree_view
2944  *
2945  * \param src_pos           position avant
2946  * \param src_type_data     type de donnée
2947  * \param dst_pos           position après drag and drop
2948  *
2949  * \return
2950  * */
etats_config_onglet_data_grouping_move_in_list(gint src_pos,gint src_type_data,gint dst_pos)2951 void etats_config_onglet_data_grouping_move_in_list ( gint src_pos,
2952                         gint src_type_data,
2953                         gint dst_pos )
2954 {
2955     GtkWidget *tree_view;
2956     GtkTreeModel *model;
2957     GSList *tmp_list;
2958     gint report_number;
2959     gint i = 0;
2960 
2961     report_number = gsb_gui_navigation_get_current_report ( );
2962     tmp_list = g_slist_copy ( gsb_data_report_get_sorting_type_list ( report_number ) );
2963 
2964     /* on supprime les sous categ et les sous IB */
2965     tmp_list = g_slist_remove ( tmp_list, GINT_TO_POINTER ( 4 ) );
2966     tmp_list = g_slist_remove ( tmp_list, GINT_TO_POINTER ( 2 ) );
2967 
2968     /* on supprime la donnée à la position initiale */
2969     tmp_list = g_slist_remove ( tmp_list, GINT_TO_POINTER ( src_type_data ) );
2970 
2971     /* on insère la donnée à la position finale */
2972     tmp_list = g_slist_insert ( tmp_list, GINT_TO_POINTER ( src_type_data ), dst_pos );
2973 
2974     tree_view = etats_prefs_widget_get_widget_by_name ( "treeview_data_grouping", NULL );
2975     model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );
2976 
2977     /* on reset le model */
2978     gtk_list_store_clear ( GTK_LIST_STORE ( model ) );
2979 
2980     while ( tmp_list )
2981     {
2982         GtkTreeIter iter;
2983         gchar *string = NULL;
2984         gint type_data;
2985         gpointer ptr;
2986 
2987         ptr = tmp_list->data;
2988         type_data = GPOINTER_TO_INT ( ptr );
2989 
2990         string = etats_config_onglet_data_grouping_get_string ( type_data, i );
2991 
2992         gtk_list_store_append ( GTK_LIST_STORE ( model ), &iter );
2993         gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter, 0, string, 1, i, 2, type_data, -1 );
2994 
2995         g_free ( string );
2996 
2997         i++;
2998         tmp_list = tmp_list->next;
2999     }
3000 }
3001 
3002 
3003 /*ONGLET_DATA_SEPARATION*/
3004 /**
3005  * Initialise les informations de l'onglet separation des données
3006  *
3007  * \param report_number
3008  *
3009  * \return
3010  */
etats_config_initialise_onglet_data_separation(gint report_number)3011 static void etats_config_initialise_onglet_data_separation ( gint report_number )
3012 {
3013     GtkWidget *combo_1;
3014     GtkWidget *combo_2;
3015 
3016     etats_prefs_button_toggle_set_actif ( "bouton_separer_revenus_depenses",
3017                         gsb_data_report_get_split_credit_debit ( report_number ) );
3018     etats_prefs_button_toggle_set_actif ( "bouton_separe_exo_etat",
3019                         gsb_data_report_get_financial_year_split ( report_number ) );
3020 
3021     /* on initialise le combo bouton_type_separe_plages_etat */
3022     combo_1 = etats_prefs_widget_get_widget_by_name ( "bouton_type_separe_plages_etat", NULL );
3023     gtk_combo_box_set_active ( GTK_COMBO_BOX ( combo_1 ),
3024                         gsb_data_report_get_period_split_type ( report_number ) );
3025 
3026     /* on initialise le combo bouton_debut_semaine */
3027     combo_2 = etats_prefs_widget_get_widget_by_name ( "bouton_debut_semaine", NULL );
3028     gtk_combo_box_set_active ( GTK_COMBO_BOX ( combo_2 ),
3029                         gsb_data_report_get_period_split_day ( report_number ) - G_DATE_MONDAY);
3030 
3031     if ( gsb_data_report_get_period_split ( report_number ) )
3032     {
3033         GtkWidget *button;
3034 
3035         button = etats_prefs_widget_get_widget_by_name ( "bouton_separe_plages_etat", NULL );
3036         etats_prefs_button_toggle_set_actif ( "bouton_separe_plages_etat", TRUE );
3037         sens_desensitive_pointeur ( button,
3038                         etats_prefs_widget_get_widget_by_name ( "paddingbox_data_separation2", NULL ) );
3039 
3040         if ( gtk_combo_box_get_active ( GTK_COMBO_BOX ( combo_1 ) ) == 1 )
3041             gtk_widget_set_sensitive ( combo_2, TRUE );
3042     }
3043 }
3044 
3045 
3046 /**
3047  * Récupère les informations de l'onglet separation des données
3048  *
3049  * \param numéro d'état à mettre à jour
3050  *
3051  * \return
3052  */
etats_config_recupere_info_onglet_data_separation(gint report_number)3053 static void etats_config_recupere_info_onglet_data_separation ( gint report_number )
3054 {
3055     gsb_data_report_set_split_credit_debit ( report_number,
3056                         etats_prefs_button_toggle_get_actif ( "bouton_separer_revenus_depenses" ) );
3057     gsb_data_report_set_financial_year_split ( report_number,
3058                         etats_prefs_button_toggle_get_actif ( "bouton_separe_exo_etat" ) );
3059     gsb_data_report_set_period_split ( report_number,
3060                         etats_prefs_button_toggle_get_actif ( "bouton_separe_plages_etat" ) );
3061 
3062     /* récupère des index des GtkComboBox */
3063     gsb_data_report_set_period_split_type ( report_number,
3064                         gtk_combo_box_get_active ( GTK_COMBO_BOX (
3065                         etats_prefs_widget_get_widget_by_name ( "bouton_type_separe_plages_etat", NULL ) ) ) );
3066 
3067     gsb_data_report_set_period_split_day ( report_number,
3068                         gtk_combo_box_get_active ( GTK_COMBO_BOX (
3069                         etats_prefs_widget_get_widget_by_name ( "bouton_debut_semaine", NULL ) ) ) );
3070 }
3071 
3072 
3073 /**
3074  * fonction de callback appellée quand on change le type de période
3075  *
3076  * \param combo         le GtkComboBox qui change
3077  * \param widget        le widget qu'on rend sensible ou pas.
3078  *
3079  * \return
3080  */
etats_config_onglet_data_separation_combo_changed(GtkComboBox * combo,GtkWidget * widget)3081 void etats_config_onglet_data_separation_combo_changed ( GtkComboBox *combo,
3082                         GtkWidget *widget )
3083 {
3084     gint report_number;
3085 
3086     report_number = gsb_gui_navigation_get_current_report ( );
3087     if ( gsb_data_report_get_period_split ( report_number ) )
3088     {
3089         if ( gtk_combo_box_get_active ( GTK_COMBO_BOX ( combo ) ) == 1 )
3090             gtk_widget_set_sensitive ( widget, TRUE );
3091         else
3092             gtk_widget_set_sensitive ( widget, FALSE );
3093     }
3094 }
3095 
3096 
3097 /*ONGLET_AFFICHAGE_GENERALITES*/
3098 /**
3099  * pré visualise le titre avec son complément
3100  *
3101  * \param report_number
3102  *
3103  * \return
3104  **/
etats_config_display_name_with_complement(gint report_number)3105 static void etats_config_display_name_with_complement (gint report_number)
3106 {
3107 	gchar **tab;
3108 	gchar *report_name = NULL;
3109 	gchar *compl_str;
3110 	gchar *tmp_str = NULL;
3111 	gint function;
3112 	gint position;
3113 
3114 	devel_debug_int (report_number);
3115 	report_name = gsb_data_report_get_report_name (report_number);
3116 	function = gsb_data_report_get_compl_name_function (report_number);
3117 	position = gsb_data_report_get_compl_name_position (report_number);
3118 	tab = gsb_date_get_date_time_now_local ();
3119 
3120 	if (function == 1)
3121 	{
3122 		if (position == 2)
3123 		{
3124 			compl_str = g_strconcat (tab[0], " ", _("at"), " ", tab[1], NULL);
3125 		}
3126 		else
3127 		{
3128 			compl_str = g_strconcat (tab[0], " ", tab[1], NULL);
3129 		}
3130 	}
3131 	else
3132 	{
3133 		compl_str = g_strdup (tab[0]);
3134 	}
3135 
3136 	switch (position)
3137 	{
3138 		case 1:
3139 			tmp_str = g_strconcat (report_name, " - ", compl_str, NULL);
3140 			break;
3141 		case 2:
3142 			tmp_str = g_strconcat (report_name, "\n(", _("Edited"), " ", compl_str, ")", NULL);
3143 			break;
3144 		default:
3145 			tmp_str = g_strconcat (compl_str, " - ", report_name, NULL);
3146 	}
3147 	g_free (compl_str);
3148 	g_strfreev (tab);
3149 
3150 	if (tmp_str)
3151 	{
3152 		GtkWidget *textview;
3153 		GtkTextBuffer *buffer;
3154 
3155 		textview = etats_prefs_widget_get_widget_by_name ("textview_compl_name", NULL);
3156 		buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
3157 		gtk_text_buffer_set_text (buffer, tmp_str, -1);
3158 		g_free (tmp_str);
3159 	}
3160 }
3161 
3162 /**
3163  *
3164  *
3165  * \param
3166  * \param
3167  *
3168  * \return
3169  **/
etats_config_combo_box_compl_name_changed(GtkComboBox * widget,void function (gint report_number,gint compl_name_int))3170 static void etats_config_combo_box_compl_name_changed (GtkComboBox *widget,
3171 													   void function (gint report_number,
3172 																	  gint compl_name_int))
3173 {
3174 	gint report_number;
3175 
3176 	report_number = gsb_gui_navigation_get_current_report ();
3177 	function (report_number, gtk_combo_box_get_active (GTK_COMBO_BOX (widget)));
3178 	etats_config_display_name_with_complement (report_number);
3179 }
3180 
3181 /**
3182  *
3183  *
3184  * \param
3185  * \param
3186  *
3187  * \return
3188  **/
etats_config_check_button_compl_name_toggled(GtkWidget * check_button,GtkWidget * widget)3189 static gboolean etats_config_check_button_compl_name_toggled (GtkWidget *check_button,
3190 															  GtkWidget *widget)
3191 {
3192 	gboolean activ;
3193 
3194 	activ = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button));
3195     gtk_widget_set_sensitive ( widget, activ);
3196 
3197 	if (activ)
3198 		etats_config_display_name_with_complement (gsb_gui_navigation_get_current_report ());
3199 	else
3200 	{
3201 		GtkWidget *textview;
3202 		GtkTextBuffer *buffer;
3203 
3204 		textview = etats_prefs_widget_get_widget_by_name ("textview_compl_name", NULL);
3205 		buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
3206 		gtk_text_buffer_set_text (buffer, "", -1);
3207 	}
3208 
3209 	return FALSE;
3210 }
3211 
3212 /**
3213  * Initialise les informations de l'onglet généraités
3214  *
3215  * \param report_number
3216  *
3217  * \return
3218  **/
etats_config_initialise_onglet_affichage_generalites(gint report_number)3219 static void etats_config_initialise_onglet_affichage_generalites ( gint report_number )
3220 {
3221 	GtkWidget *checkbutton;
3222 	GtkWidget *widget;
3223 	gchar *report_name = NULL;
3224 	gboolean activ;
3225 
3226 	report_name = gsb_data_report_get_report_name (report_number);
3227     gtk_entry_set_text ( GTK_ENTRY ( etats_prefs_widget_get_widget_by_name ( "entree_nom_etat", NULL ) ),
3228                         report_name);
3229 
3230     /* on initialise le complément du nom si actif */
3231 	checkbutton = etats_prefs_widget_get_widget_by_name ("check_button_compl_name", NULL);
3232 	widget = etats_prefs_widget_get_widget_by_name ("hbox_combo_compl_name", NULL);
3233 	activ = gsb_data_report_get_compl_name_used (report_number);
3234     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), activ);
3235 	if (report_name && activ)
3236 	{
3237 		gsb_button_sensitive_by_checkbutton (checkbutton, widget);
3238 		gtk_combo_box_set_active (GTK_COMBO_BOX (etats_prefs_widget_get_widget_by_name ("combo_box_compl_name_function", NULL)),
3239 								  gsb_data_report_get_compl_name_function (report_number));
3240 		gtk_combo_box_set_active (GTK_COMBO_BOX (etats_prefs_widget_get_widget_by_name ("combo_box_compl_name_position", NULL)),
3241 								  gsb_data_report_get_compl_name_position (report_number));
3242 		etats_config_display_name_with_complement (report_number);
3243 	}
3244 
3245     /* Connect signal */
3246     g_signal_connect (checkbutton,
3247 					  "toggled",
3248 					  G_CALLBACK (etats_config_check_button_compl_name_toggled),
3249 					  widget);
3250 
3251 	g_signal_connect (etats_prefs_widget_get_widget_by_name ("combo_box_compl_name_function", NULL),
3252 					  "changed",
3253 					  G_CALLBACK (etats_config_combo_box_compl_name_changed),
3254 					  gsb_data_report_set_compl_name_function);
3255     g_signal_connect (etats_prefs_widget_get_widget_by_name ("combo_box_compl_name_position", NULL),
3256 					  "changed",
3257 					  G_CALLBACK (etats_config_combo_box_compl_name_changed),
3258 					  gsb_data_report_set_compl_name_position);
3259 
3260     /* on initialise le type de date à sélectionner */
3261     etats_prefs_button_toggle_set_actif ( "button_sel_value_date",
3262                         gsb_data_report_get_date_select_value ( report_number ) );
3263 
3264     /* on initialise les autres données */
3265     etats_prefs_button_toggle_set_actif ( "bouton_ignore_archives",
3266                         gsb_data_report_get_ignore_archives ( report_number ) );
3267     etats_prefs_button_toggle_set_actif ( "bouton_afficher_nb_opes",
3268                         gsb_data_report_get_show_report_transaction_amount ( report_number ) );
3269 
3270 	/* mémorisation de l'état avant initialisation */
3271 	payee_last_state = gsb_data_report_get_append_in_payee (report_number);
3272     etats_prefs_button_toggle_set_actif ("bouton_inclure_dans_tiers", payee_last_state);
3273 }
3274 
3275 /**
3276  * Récupère les informations de l'onglet généralités
3277  *
3278  * \param numéro d'état à mettre à jour
3279  *
3280  * \return
3281  */
etats_config_recupere_info_onglet_affichage_generalites(gint report_number)3282 static void etats_config_recupere_info_onglet_affichage_generalites ( gint report_number )
3283 {
3284     const gchar *text;
3285 
3286     /* on récupère le nom de l'état */
3287     text = gtk_entry_get_text ( GTK_ENTRY (
3288                         etats_prefs_widget_get_widget_by_name ( "entree_nom_etat", NULL ) ) );
3289 
3290     if ( strlen ( text )
3291      &&
3292      strcmp ( text, gsb_data_report_get_report_name ( report_number ) ) )
3293     {
3294         gsb_data_report_set_report_name ( report_number, text );
3295     }
3296 
3297 	if (etats_prefs_button_toggle_get_actif ("check_button_compl_name"))
3298 	{
3299 		GtkWidget *widget;
3300 
3301 		gsb_data_report_set_compl_name_used (report_number, TRUE);
3302 		widget = etats_prefs_widget_get_widget_by_name ("combo_box_compl_name_function", NULL);
3303 		gsb_data_report_set_compl_name_function (report_number,
3304 												 gtk_combo_box_get_active (GTK_COMBO_BOX (widget)));
3305 		widget = etats_prefs_widget_get_widget_by_name ("combo_box_compl_name_position", NULL);
3306 		gsb_data_report_set_compl_name_position (report_number,
3307 												 gtk_combo_box_get_active (GTK_COMBO_BOX (widget)));
3308 	}
3309 	else
3310 	{
3311 		gsb_data_report_set_compl_name_used (report_number, FALSE);
3312 		gsb_data_report_set_compl_name_function (report_number, 0);
3313 		gsb_data_report_set_compl_name_function (report_number, 0);
3314 	}
3315 
3316     /* on récupère les autres informations */
3317     gsb_data_report_set_date_select_value ( report_number,
3318                         etats_prefs_button_toggle_get_actif ( "button_sel_value_date" ) );
3319     gsb_data_report_set_ignore_archives ( report_number,
3320                         etats_prefs_button_toggle_get_actif ( "bouton_ignore_archives" ) );
3321     gsb_data_report_set_show_report_transaction_amount ( report_number,
3322                         etats_prefs_button_toggle_get_actif ( "bouton_afficher_nb_opes" ) );
3323     gsb_data_report_set_append_in_payee ( report_number,
3324                         etats_prefs_button_toggle_get_actif ( "bouton_inclure_dans_tiers" ) );
3325 }
3326 
3327 
3328 /*ONGLET_AFFICHAGE_TITLES*/
3329 /**
3330  * Initialise les informations de l'onglet titres
3331  *
3332  * \param report_number
3333  *
3334  * \return
3335  */
etats_config_initialise_onglet_affichage_titres(gint report_number)3336 static void etats_config_initialise_onglet_affichage_titres ( gint report_number )
3337 {
3338     GtkWidget *button;
3339     GtkWidget *widget;
3340 
3341     /* données des comptes */
3342     etats_prefs_button_toggle_set_actif ( "bouton_afficher_noms_comptes",
3343                         gsb_data_report_get_account_show_name ( report_number ) );
3344 
3345     button = etats_prefs_widget_get_widget_by_name ( "bouton_regroupe_ope_compte_etat", NULL );
3346 
3347     widget = etats_prefs_widget_get_widget_by_name ( "bouton_affiche_sous_total_compte", NULL );
3348     sens_desensitive_pointeur ( button, widget );
3349     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3350                         gsb_data_report_get_account_show_amount ( report_number ) );
3351 
3352     /* données des tiers */
3353     button = etats_prefs_widget_get_widget_by_name ( "bouton_utilise_tiers_etat", NULL );
3354 
3355     widget = etats_prefs_widget_get_widget_by_name ( "bouton_afficher_noms_tiers", NULL );
3356     sens_desensitive_pointeur ( button, widget );
3357     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3358                         gsb_data_report_get_payee_show_name ( report_number ) );
3359 
3360     widget = etats_prefs_widget_get_widget_by_name ( "bouton_affiche_sous_total_tiers", NULL );
3361     sens_desensitive_pointeur ( button, widget );
3362     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3363                         gsb_data_report_get_payee_show_payee_amount ( report_number ) );
3364 
3365     /* données des catégories */
3366     button = etats_prefs_widget_get_widget_by_name ( "bouton_group_by_categ", NULL );
3367 
3368     widget = etats_prefs_widget_get_widget_by_name ( "bouton_afficher_noms_categ", NULL );
3369     sens_desensitive_pointeur ( button, widget );
3370     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3371 				   gsb_data_report_get_category_show_name ( report_number ) );
3372 
3373     widget = etats_prefs_widget_get_widget_by_name ( "bouton_affiche_sous_total_categ", NULL );
3374     sens_desensitive_pointeur ( button, widget );
3375     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3376 				   gsb_data_report_get_category_show_category_amount ( report_number ) );
3377 
3378     widget = etats_prefs_widget_get_widget_by_name ( "bouton_afficher_sous_categ", NULL );
3379     sens_desensitive_pointeur ( button, widget );
3380     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3381 				   gsb_data_report_get_category_show_sub_category ( report_number ) );
3382 
3383     widget = etats_prefs_widget_get_widget_by_name ( "bouton_affiche_sous_total_sous_categ", NULL );
3384     sens_desensitive_pointeur ( button, widget );
3385     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3386 				   gsb_data_report_get_category_show_sub_category_amount ( report_number ) );
3387 
3388     widget = etats_prefs_widget_get_widget_by_name ( "bouton_afficher_pas_de_sous_categ", NULL );
3389     sens_desensitive_pointeur ( button, widget );
3390     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3391 				   gsb_data_report_get_category_show_without_category ( report_number ) );
3392 
3393     /* données des IB */
3394     button = etats_prefs_widget_get_widget_by_name ( "bouton_utilise_ib_etat", NULL );
3395 
3396     widget = etats_prefs_widget_get_widget_by_name ( "bouton_afficher_noms_ib", NULL );
3397     sens_desensitive_pointeur ( button, widget );
3398     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3399 				   gsb_data_report_get_budget_show_name ( report_number ) );
3400 
3401     widget = etats_prefs_widget_get_widget_by_name ( "bouton_affiche_sous_total_ib", NULL );
3402     sens_desensitive_pointeur ( button, widget );
3403     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3404 				   gsb_data_report_get_budget_show_budget_amount ( report_number ) );
3405 
3406     widget = etats_prefs_widget_get_widget_by_name ( "bouton_afficher_sous_ib", NULL );
3407     sens_desensitive_pointeur ( button, widget );
3408     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3409 				   gsb_data_report_get_budget_show_sub_budget ( report_number ) );
3410 
3411     widget = etats_prefs_widget_get_widget_by_name ( "bouton_affiche_sous_total_sous_ib", NULL );
3412     sens_desensitive_pointeur ( button, widget );
3413     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3414 				   gsb_data_report_get_budget_show_sub_budget_amount ( report_number ) );
3415 
3416     widget = etats_prefs_widget_get_widget_by_name ( "bouton_afficher_pas_de_sous_ib", NULL );
3417     sens_desensitive_pointeur ( button, widget );
3418     gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ),
3419 				   gsb_data_report_get_budget_show_without_budget ( report_number ) );
3420 }
3421 
3422 
3423 /**
3424  * Récupère les informations de l'onglet titres
3425  *
3426  * \param numéro d'état à mettre à jour
3427  *
3428  * \return
3429  */
etats_config_recupere_info_onglet_affichage_titres(gint report_number)3430 static void etats_config_recupere_info_onglet_affichage_titres ( gint report_number )
3431 {
3432     /* données des comptes */
3433     gsb_data_report_set_account_show_name ( report_number,
3434     				    etats_prefs_button_toggle_get_actif ( "bouton_afficher_noms_comptes" ) );
3435     gsb_data_report_set_account_show_amount ( report_number,
3436     				    etats_prefs_button_toggle_get_actif ( "bouton_affiche_sous_total_compte" ) );
3437 
3438     /* données des tiers */
3439     gsb_data_report_set_payee_show_name ( report_number,
3440     				  etats_prefs_button_toggle_get_actif ( "bouton_afficher_noms_tiers" ) );
3441     gsb_data_report_set_payee_show_payee_amount ( report_number,
3442     				  etats_prefs_button_toggle_get_actif ( "bouton_affiche_sous_total_tiers" ) );
3443 
3444     /* données des catégories */
3445     gsb_data_report_set_category_show_name ( report_number,
3446     				  etats_prefs_button_toggle_get_actif ( "bouton_afficher_noms_categ" ) );
3447     gsb_data_report_set_category_show_category_amount ( report_number,
3448     				  etats_prefs_button_toggle_get_actif ( "bouton_affiche_sous_total_categ" ) );
3449     gsb_data_report_set_category_show_sub_category ( report_number,
3450     				  etats_prefs_button_toggle_get_actif ( "bouton_afficher_sous_categ" ) );
3451     gsb_data_report_set_category_show_sub_category_amount ( report_number,
3452     				  etats_prefs_button_toggle_get_actif ( "bouton_affiche_sous_total_sous_categ" ) );
3453     gsb_data_report_set_category_show_without_category ( report_number,
3454     				  etats_prefs_button_toggle_get_actif ( "bouton_afficher_pas_de_sous_categ" ) );
3455 
3456     /* données des IB */
3457     gsb_data_report_set_budget_show_name ( report_number,
3458     				  etats_prefs_button_toggle_get_actif ( "bouton_afficher_noms_ib" ) );
3459     gsb_data_report_set_budget_show_budget_amount ( report_number,
3460     				  etats_prefs_button_toggle_get_actif ( "bouton_affiche_sous_total_ib" ) );
3461     gsb_data_report_set_budget_show_sub_budget ( report_number,
3462     				  etats_prefs_button_toggle_get_actif ( "bouton_afficher_sous_ib" ) );
3463     gsb_data_report_set_budget_show_sub_budget_amount ( report_number,
3464     				  etats_prefs_button_toggle_get_actif ( "bouton_affiche_sous_total_ib" ) );
3465     gsb_data_report_set_budget_show_without_budget ( report_number,
3466     				  etats_prefs_button_toggle_get_actif ( "bouton_afficher_pas_de_sous_ib" ) );
3467 }
3468 
3469 
3470 /*ONGLET_AFFICHAGE_OPERATIONS*/
3471 /**
3472  * Initialise les informations de l'onglet opérations
3473  *
3474  * \param report_number
3475  *
3476  * \return
3477  */
etats_config_initialise_onglet_affichage_operations(gint report_number)3478 static void etats_config_initialise_onglet_affichage_operations ( gint report_number )
3479 {
3480     GtkWidget *combo;
3481 
3482     /* on affiche ou pas le choix des données des opérations */
3483     etats_prefs_button_toggle_set_actif ( "bouton_afficher_opes",
3484                         gsb_data_report_get_show_report_transactions ( report_number ) );
3485 
3486     /* données des opérations à afficher */
3487     etats_prefs_button_toggle_set_actif ( "bouton_afficher_no_ope",
3488                         gsb_data_report_get_show_report_transaction_number ( report_number ) );
3489     etats_prefs_button_toggle_set_actif ( "bouton_afficher_date_opes",
3490                         gsb_data_report_get_show_report_date ( report_number ) );
3491     etats_prefs_button_toggle_set_actif ( "bouton_afficher_value_date_opes",
3492                         gsb_data_report_get_show_report_value_date ( report_number ) );
3493     etats_prefs_button_toggle_set_actif ( "bouton_afficher_tiers_opes",
3494                         gsb_data_report_get_show_report_payee ( report_number ) );
3495     etats_prefs_button_toggle_set_actif ( "bouton_afficher_categ_opes",
3496                         gsb_data_report_get_show_report_category ( report_number ) );
3497     etats_prefs_button_toggle_set_actif ( "bouton_afficher_sous_categ_opes",
3498                         gsb_data_report_get_show_report_sub_category ( report_number ) );
3499     etats_prefs_button_toggle_set_actif ( "bouton_afficher_ib_opes",
3500                         gsb_data_report_get_show_report_budget ( report_number ) );
3501     etats_prefs_button_toggle_set_actif ( "bouton_afficher_sous_ib_opes",
3502                         gsb_data_report_get_show_report_sub_budget ( report_number ) );
3503     etats_prefs_button_toggle_set_actif ( "bouton_afficher_notes_opes",
3504                         gsb_data_report_get_show_report_note ( report_number ) );
3505     etats_prefs_button_toggle_set_actif ( "bouton_afficher_type_ope",
3506                         gsb_data_report_get_show_report_method_of_payment ( report_number ) );
3507     etats_prefs_button_toggle_set_actif ( "bouton_afficher_no_cheque",
3508                         gsb_data_report_get_show_report_method_of_payment_content ( report_number ) );
3509     etats_prefs_button_toggle_set_actif ( "bouton_afficher_pc_opes",
3510                         gsb_data_report_get_show_report_voucher ( report_number ) );
3511     etats_prefs_button_toggle_set_actif ( "bouton_afficher_exo_opes",
3512                         gsb_data_report_get_show_report_financial_year ( report_number ) );
3513     etats_prefs_button_toggle_set_actif ( "bouton_afficher_infobd_opes",
3514                         gsb_data_report_get_show_report_bank_references ( report_number ) );
3515     etats_prefs_button_toggle_set_actif ( "bouton_afficher_no_rappr",
3516                         gsb_data_report_get_show_report_marked ( report_number ) );
3517 
3518     /* affichage des titres des colonnes */
3519     etats_prefs_button_toggle_set_actif ( "bouton_afficher_titres_colonnes",
3520                         gsb_data_report_get_column_title_show ( report_number ) );
3521 
3522     if ( !gsb_data_report_get_column_title_type ( report_number ) )
3523         etats_prefs_button_toggle_set_actif ( "bouton_titre_en_haut", TRUE );
3524 
3525     /* sélectionner le type de classement des opérations */
3526     combo = etats_prefs_widget_get_widget_by_name ( "bouton_choix_classement_ope_etat", NULL );
3527     gtk_combo_box_set_active ( GTK_COMBO_BOX ( combo ),
3528                         gsb_data_report_get_sorting_report ( report_number ) );
3529 
3530     /* rendre les opérations cliquables */
3531     etats_prefs_button_toggle_set_actif ( "bouton_rendre_ope_clickables",
3532                         gsb_data_report_get_report_can_click ( report_number ) );
3533 }
3534 
3535 
3536 /**
3537  * Récupère les informations de l'onglet opérations
3538  *
3539  * \param numéro d'état à mettre à jour
3540  *
3541  * \return
3542  */
etats_config_recupere_info_onglet_affichage_operations(gint report_number)3543 static void etats_config_recupere_info_onglet_affichage_operations ( gint report_number )
3544 {
3545     GtkWidget *combo;
3546 	gboolean affich_opes = FALSE;
3547 	gboolean detail_ope;
3548 	gboolean is_actif = FALSE;
3549 
3550 	affich_opes = etats_prefs_button_toggle_get_actif ("bouton_afficher_opes");
3551     gsb_data_report_set_show_report_transactions (report_number, affich_opes);
3552 
3553     /* données des opérations */
3554 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_no_ope");
3555 	if (detail_ope && !is_actif)
3556 		is_actif = TRUE;
3557     gsb_data_report_set_show_report_transaction_number (report_number, detail_ope);
3558 
3559 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_date_opes");
3560 	if (detail_ope && !is_actif)
3561 		is_actif = TRUE;
3562     gsb_data_report_set_show_report_date (report_number, detail_ope);
3563 
3564 	if (detail_ope && !is_actif)
3565 		is_actif = TRUE;
3566 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_value_date_opes");
3567     gsb_data_report_set_show_report_value_date (report_number, detail_ope);
3568 
3569 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_tiers_opes");
3570 	if (detail_ope && !is_actif)
3571 		is_actif = TRUE;
3572     gsb_data_report_set_show_report_payee (report_number, detail_ope);
3573 
3574 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_categ_opes");
3575 	if (detail_ope && !is_actif)
3576 		is_actif = TRUE;
3577     gsb_data_report_set_show_report_category (report_number, detail_ope);
3578 
3579 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_sous_categ_opes");
3580 	if (detail_ope && !is_actif)
3581 		is_actif = TRUE;
3582     gsb_data_report_set_show_report_sub_category (report_number, detail_ope);
3583 
3584 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_ib_opes");
3585 	if (detail_ope && !is_actif)
3586 		is_actif = TRUE;
3587     gsb_data_report_set_show_report_budget (report_number, detail_ope);
3588 
3589 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_sous_ib_opes");
3590 	if (detail_ope && !is_actif)
3591 		is_actif = TRUE;
3592     gsb_data_report_set_show_report_sub_budget (report_number, detail_ope);
3593 
3594 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_notes_opes");
3595 	if (detail_ope && !is_actif)
3596 		is_actif = TRUE;
3597     gsb_data_report_set_show_report_note (report_number, detail_ope);
3598 
3599 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_type_ope");
3600 	if (detail_ope && !is_actif)
3601 		is_actif = TRUE;
3602     gsb_data_report_set_show_report_method_of_payment (report_number, detail_ope);
3603 
3604 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_no_cheque");
3605 	if (detail_ope && !is_actif)
3606 		is_actif = TRUE;
3607     gsb_data_report_set_show_report_method_of_payment_content (report_number, detail_ope);
3608 
3609 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_pc_opes");
3610 	if (detail_ope && !is_actif)
3611 		is_actif = TRUE;
3612     gsb_data_report_set_show_report_voucher (report_number, detail_ope);
3613 
3614 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_exo_opes");
3615 	if (detail_ope && !is_actif)
3616 		is_actif = TRUE;
3617     gsb_data_report_set_show_report_financial_year (report_number, detail_ope);
3618 
3619 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_infobd_opes");
3620 	if (detail_ope && !is_actif)
3621 		is_actif = TRUE;
3622     gsb_data_report_set_show_report_bank_references (report_number, detail_ope);
3623 
3624 	detail_ope = etats_prefs_button_toggle_get_actif ("bouton_afficher_no_rappr");
3625 	if (detail_ope && !is_actif)
3626 		is_actif = TRUE;
3627     gsb_data_report_set_show_report_marked (report_number, detail_ope);
3628 
3629 	if (affich_opes && !is_actif)
3630 		gsb_data_report_set_show_report_transactions (report_number, FALSE);
3631 
3632     /* titres des colonnes */
3633     gsb_data_report_set_column_title_show ( report_number,
3634                         etats_prefs_button_toggle_get_actif ( "bouton_afficher_titres_colonnes" ) );
3635 
3636     gsb_data_report_set_column_title_type ( report_number,
3637                         etats_prefs_button_toggle_get_actif ( "bouton_titre_changement" ) );
3638 
3639     /* type de classement des opérations */
3640     combo = etats_prefs_widget_get_widget_by_name ( "bouton_choix_classement_ope_etat", NULL );
3641     gsb_data_report_set_sorting_report ( report_number,
3642                         gtk_combo_box_get_active ( GTK_COMBO_BOX ( combo ) ) );
3643 
3644     /* opérations cliquables */
3645     gsb_data_report_set_report_can_click ( report_number,
3646                         etats_prefs_button_toggle_get_actif ( "bouton_rendre_ope_clickables" ) );
3647 }
3648 
3649 
3650 /*ONGLET_AFFICHAGE_DEVISES*/
3651 /**
3652  * Initialise les informations de l'onglet devises
3653  *
3654  * \param report_number
3655  *
3656  * \return
3657  */
etats_config_initialise_onglet_affichage_devises(gint report_number)3658 static void etats_config_initialise_onglet_affichage_devises ( gint report_number )
3659 {
3660     GtkWidget *button;
3661 
3662     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_general_etat", "button" );
3663     gsb_currency_set_combobox_history ( button,
3664                         gsb_data_report_get_currency_general ( report_number ) );
3665 
3666     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_tiers_etat", "button" );
3667     gsb_currency_set_combobox_history ( button,
3668                         gsb_data_report_get_payee_currency ( report_number ) );
3669 
3670     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_categ_etat", "button" );
3671     gsb_currency_set_combobox_history ( button,
3672                         gsb_data_report_get_category_currency ( report_number ) );
3673 
3674     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_ib_etat", "button" );
3675     gsb_currency_set_combobox_history ( button,
3676                         gsb_data_report_get_budget_currency ( report_number ) );
3677 
3678     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_montant_etat", "button" );
3679     gsb_currency_set_combobox_history ( button,
3680                         gsb_data_report_get_amount_comparison_currency ( report_number ) );
3681 
3682 }
3683 
3684 
3685 /**
3686  * Récupère les informations de l'onglet devises
3687  *
3688  * \param numéro d'état à mettre à jour
3689  *
3690  * \return
3691  */
etats_config_recupere_info_onglet_affichage_devises(gint report_number)3692 static void etats_config_recupere_info_onglet_affichage_devises ( gint report_number )
3693 {
3694     GtkWidget *button;
3695 
3696     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_general_etat", "button" );
3697     gsb_data_report_set_currency_general ( report_number,
3698                         gsb_currency_get_currency_from_combobox ( button ) );
3699 
3700     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_tiers_etat", "button" );
3701     gsb_data_report_set_payee_currency ( report_number,
3702                         gsb_currency_get_currency_from_combobox ( button ) );
3703 
3704     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_categ_etat", "button" );
3705     gsb_data_report_set_category_currency ( report_number,
3706                         gsb_currency_get_currency_from_combobox ( button ) );
3707 
3708     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_ib_etat", "button" );
3709     gsb_data_report_set_budget_currency ( report_number,
3710                         gsb_currency_get_currency_from_combobox ( button ) );
3711 
3712     button = etats_prefs_widget_get_widget_by_name ( "hbox_devise_montant_etat", "button" );
3713     gsb_data_report_set_amount_comparison_currency ( report_number,
3714                         gsb_currency_get_currency_from_combobox ( button ) );
3715 
3716 }
3717 
3718 
3719 /**
3720  * ajoute les combobox pour les devises
3721  *
3722  * \param
3723  *
3724  * \return
3725  */
etats_config_onglet_affichage_devises_make_combobox(void)3726 void etats_config_onglet_affichage_devises_make_combobox ( void )
3727 {
3728     GtkWidget *hbox;
3729     GtkWidget *button;
3730 
3731     hbox = etats_prefs_widget_get_widget_by_name ( "hbox_devise_general_etat", NULL );
3732     button = gsb_currency_make_combobox (FALSE);
3733     g_object_set_data ( G_OBJECT ( hbox ), "button", button );
3734     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
3735 
3736     hbox = etats_prefs_widget_get_widget_by_name ( "hbox_devise_tiers_etat", NULL );
3737     button = gsb_currency_make_combobox (FALSE);
3738     g_object_set_data ( G_OBJECT ( hbox ), "button", button );
3739     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
3740 
3741     hbox = etats_prefs_widget_get_widget_by_name ( "hbox_devise_categ_etat", NULL );
3742     button = gsb_currency_make_combobox (FALSE);
3743     g_object_set_data ( G_OBJECT ( hbox ), "button", button );
3744     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
3745 
3746     hbox = etats_prefs_widget_get_widget_by_name ( "hbox_devise_ib_etat", NULL );
3747     button = gsb_currency_make_combobox (FALSE);
3748     g_object_set_data ( G_OBJECT ( hbox ), "button", button );
3749     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
3750 
3751     hbox = etats_prefs_widget_get_widget_by_name ( "hbox_devise_montant_etat", NULL );
3752     button = gsb_currency_make_combobox (FALSE);
3753     g_object_set_data ( G_OBJECT ( hbox ), "button", button );
3754     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
3755 }
3756 /*END_ONGLETS*/
3757 /**
3758  * Initialise la boite de dialogue propriétés de l'état.
3759  *
3760  * \param
3761  *
3762  * \return
3763  */
etats_config_initialise_dialog_from_etat(gint report_number)3764 static gboolean etats_config_initialise_dialog_from_etat ( gint report_number )
3765 {
3766     /* onglet période */
3767     etats_config_initialise_onglet_periode ( report_number );
3768 
3769     /* onglet virements */
3770     etats_config_initialise_onglet_virements ( report_number );
3771 
3772     /* onglet comptes */
3773     etats_config_initialise_onglet_comptes ( report_number );
3774 
3775     /* onglet tiers */
3776     etats_config_initialise_onglet_tiers ( report_number );
3777 
3778     /* onglet Categories */
3779     etats_config_initialise_onglet_categ_budget ( report_number, TRUE );
3780 
3781     /* onglet Budgets */
3782     etats_config_initialise_onglet_categ_budget ( report_number, FALSE );
3783 
3784     /* onglet Textes */
3785     etats_config_initialise_onglet_textes ( report_number );
3786 
3787     /* onglet Montants */
3788     etats_config_initialise_onglet_montants ( report_number );
3789 
3790     /* onglet modes de paiement */
3791     etats_config_initialise_onglet_mode_paiement ( report_number );
3792 
3793     /* onglet divers */
3794     etats_config_initialise_onglet_divers ( report_number );
3795 
3796     /* onglet data grouping */
3797     etats_config_initialise_onglet_data_grouping ( report_number );
3798 
3799     /* onglet data separation */
3800     etats_config_initialise_onglet_data_separation ( report_number );
3801 
3802     /* onglet generalites */
3803     etats_config_initialise_onglet_affichage_generalites ( report_number );
3804 
3805     /* onglet titres */
3806     etats_config_initialise_onglet_affichage_titres ( report_number );
3807 
3808     /* onglet opérations */
3809     etats_config_initialise_onglet_affichage_operations ( report_number );
3810 
3811     /* onglet devises */
3812     etats_config_initialise_onglet_affichage_devises ( report_number );
3813 
3814     /* return */
3815     return TRUE;
3816 }
3817 
3818 
3819 /**
3820  *
3821  *
3822  * \param
3823  *
3824  * \return
3825  */
etats_config_recupere_info_to_etat(gint report_number)3826 static gboolean etats_config_recupere_info_to_etat ( gint report_number )
3827 {
3828 	gboolean payee_new_state = FALSE;
3829 
3830     /* onglet période */
3831     etats_config_recupere_info_onglet_periode ( report_number );
3832 
3833     /* onglet virements */
3834     etats_config_recupere_info_onglet_virements ( report_number );
3835 
3836     /* onglet comptes */
3837     etats_config_recupere_info_onglet_comptes ( report_number );
3838 
3839     /* onglet tiers */
3840     etats_config_recupere_info_onglet_tiers ( report_number );
3841 
3842     /* onglet Categories */
3843     etats_config_recupere_info_onglet_categ_budget ( report_number, TRUE );
3844 
3845     /* onglet Budgets */
3846     etats_config_recupere_info_onglet_categ_budget ( report_number, FALSE );
3847 
3848     /* onglet Textes */
3849     etats_config_recupere_info_onglet_textes ( report_number );
3850 
3851     /* onglet Montants */
3852     etats_config_recupere_info_onglet_montants ( report_number );
3853 
3854     /* onglet mode de paiement */
3855     etats_config_recupere_info_onglet_mode_paiement ( report_number );
3856 
3857     /* onglet modes divers */
3858     etats_config_recupere_info_onglet_divers ( report_number );
3859 
3860     /* onglet modes data grouping */
3861     etats_config_recupere_info_onglet_data_grouping ( report_number );
3862 
3863     /* onglet modes data separation */
3864     etats_config_recupere_info_onglet_data_separation ( report_number );
3865 
3866     /* onglet generalites */
3867     etats_config_recupere_info_onglet_affichage_generalites ( report_number );
3868 
3869     /* onglet titres */
3870     etats_config_recupere_info_onglet_affichage_titres ( report_number );
3871 
3872     /* onglet opérations */
3873     etats_config_recupere_info_onglet_affichage_operations ( report_number );
3874 
3875     /* onglet devises */
3876     etats_config_recupere_info_onglet_affichage_devises ( report_number );
3877 
3878     /* update the payee combofix in the form, to add that report if asked */
3879 	payee_new_state = gsb_data_report_get_append_in_payee (report_number);
3880     if (payee_last_state || payee_new_state)
3881         gsb_form_widget_update_payee_combofix (report_number, payee_new_state);
3882 
3883     /* on avertit grisbi de la modification à enregistrer */
3884     gsb_file_set_modified ( TRUE );
3885 
3886     /* on réaffiche l'état */
3887     rafraichissement_etat ( report_number );
3888 
3889     /* on repasse à la 1ère page du notebook */
3890     gtk_notebook_set_current_page ( GTK_NOTEBOOK ( etats_onglet_get_notebook_etats ( ) ), 0 );
3891     gtk_widget_set_sensitive ( gsb_gui_navigation_get_tree_view ( ), TRUE );
3892 
3893     gsb_gui_navigation_update_report ( report_number );
3894 
3895     /* return */
3896     return TRUE;
3897 }
3898 
3899 /**
3900  * affiche la fenetre de personnalisation
3901  *
3902  * \param
3903  *
3904  * \return
3905  */
etats_config_personnalisation_etat(void)3906 gint etats_config_personnalisation_etat ( void )
3907 {
3908     GtkWidget *dialog;
3909     GtkWidget *notebook_general;
3910     gint current_report_number;
3911 	gint result = 0;
3912 
3913     devel_debug (NULL);
3914 
3915     if ( !( current_report_number = gsb_gui_navigation_get_current_report ( ) ) )
3916         return result;
3917 
3918     notebook_general = grisbi_win_get_notebook_general ( );
3919     if ( gtk_notebook_get_current_page ( GTK_NOTEBOOK ( notebook_general)) != GSB_REPORTS_PAGE )
3920         gtk_notebook_set_current_page ( GTK_NOTEBOOK ( notebook_general), GSB_REPORTS_PAGE );
3921 
3922     /* Création de la fenetre de dialog */
3923     dialog = etats_prefs_new (GTK_WIDGET (grisbi_app_get_active_window (NULL)));
3924     if ( dialog == NULL )
3925         return result;
3926 
3927     /* initialisation des données de la fenetre de dialog */
3928     etats_config_initialise_dialog_from_etat ( current_report_number );
3929 
3930     gtk_widget_show_all ( dialog );
3931 
3932     /* on se repositionne sur le dernier onglet si on a le même rapport */
3933 	if ( current_report_number == last_report )
3934 		etats_prefs_left_panel_tree_view_select_last_page ();
3935 
3936 	result = gtk_dialog_run (GTK_DIALOG (dialog));
3937     switch (result)
3938     {
3939         case GTK_RESPONSE_OK:
3940             etats_config_recupere_info_to_etat ( current_report_number );
3941             last_report = current_report_number;
3942             break;
3943 
3944 		case GTK_RESPONSE_CANCEL:
3945 			{
3946 				GrisbiWinRun *w_run;
3947 
3948 				w_run = grisbi_win_get_w_run ();
3949 				if (w_run->empty_report)
3950 				{
3951 					gsb_gui_navigation_remove_report (current_report_number);
3952 					gsb_data_report_remove (current_report_number);
3953 				}
3954 			}
3955 			break;
3956         default:
3957             break;
3958     }
3959 
3960     etats_prefs_free_all_var ();
3961 
3962     gtk_widget_destroy ( dialog );
3963 
3964 	return result;
3965 }
3966 
3967 
3968 /**
3969  *
3970  *
3971  * \param
3972  *
3973  * \return
3974  * */
3975 /* Local Variables: */
3976 /* c-basic-offset: 4 */
3977 /* End: */
3978