1 /* *******************************************************************************/
2 /*                                 GRISBI                                        */
3 /*              Programme de gestion financière personnelle                      */
4 /*                              license : GPLv2                                  */
5 /*                                                                               */
6 /*     Copyright (C)    2000-2008 Cédric Auger (cedric@grisbi.org)               */
7 /*                      2003-2008 Benjamin Drieu (bdrieu@april.org)              */
8 /*          2008-2020 Pierre Biava (grisbi@pierre.biava.name)                    */
9 /*          http://www.grisbi.org                                                */
10 /*                                                                               */
11 /*     This program is free software; you can redistribute it and/or modify      */
12 /*     it under the terms of the GNU General Public License as published by      */
13 /*     the Free Software Foundation; either version 2 of the License, or         */
14 /*     (at your option) any later version.                                       */
15 /*                                                                               */
16 /*     This program is distributed in the hope that it will be useful,           */
17 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of            */
18 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
19 /*     GNU General Public License for more details.                              */
20 /*                                                                               */
21 /*     You should have received a copy of the GNU General Public License         */
22 /*     along with this program; if not, write to the Free Software               */
23 /*     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
24 /*                                                                               */
25 /* *******************************************************************************/
26 
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30 
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34 
35 #include <errno.h>
36 #include <glib/gstdio.h>
37 #include <glib/gi18n.h>
38 
39 /*START_INCLUDE*/
40 #include "prefs_page_form_options.h"
41 #include "grisbi_app.h"
42 #include "gsb_automem.h"
43 #include "gsb_file.h"
44 #include "structures.h"
45 #include "utils_prefs.h"
46 #include "erreur.h"
47 
48 /*END_INCLUDE*/
49 
50 /*START_EXTERN*/
51 /*END_EXTERN*/
52 
53 typedef struct _PrefsPageFormOptionsPrivate   PrefsPageFormOptionsPrivate;
54 
55 struct _PrefsPageFormOptionsPrivate
56 {
57 	GtkWidget *			vbox_form_options;
58 
59 	GtkWidget *			box_affichage_exercice_automatique;
60 	GtkWidget *			box_fyear_combobox_sort_order;
61     GtkWidget *         box_form_date_force_prev_year;
62 	GtkWidget *			box_form_enter_key;
63 	GtkWidget *			box_form_validate_split;
64     GtkWidget *			checkbutton_automatic_separator;
65 };
66 
G_DEFINE_TYPE_WITH_PRIVATE(PrefsPageFormOptions,prefs_page_form_options,GTK_TYPE_BOX)67 G_DEFINE_TYPE_WITH_PRIVATE (PrefsPageFormOptions, prefs_page_form_options, GTK_TYPE_BOX)
68 
69 /******************************************************************************/
70 /* Private functions                                                          */
71 /******************************************************************************/
72 /**
73  * Création de la page de gestion des form_options
74  *
75  * \param prefs
76  *
77  * \return
78  **/
79 static void prefs_page_form_options_setup_form_options_page (PrefsPageFormOptions *page)
80 {
81 	GtkWidget *head_page;
82 	GtkWidget *button;
83 	gboolean is_loading;
84 	GrisbiAppConf *a_conf;
85 	GrisbiWinEtat *w_etat;
86 	PrefsPageFormOptionsPrivate *priv;
87 
88 	devel_debug (NULL);
89 	priv = prefs_page_form_options_get_instance_private (page);
90 	a_conf = (GrisbiAppConf *) grisbi_app_get_a_conf ();
91 	w_etat = (GrisbiWinEtat *) grisbi_win_get_w_etat ();
92 	is_loading = grisbi_win_file_is_loading ();
93 
94 	/* On récupère le nom de la page */
95 	head_page = utils_prefs_head_page_new_with_title_and_icon (_("Form behavior"), "gsb-form-32.png");
96 	gtk_box_pack_start (GTK_BOX (priv->vbox_form_options), head_page, FALSE, FALSE, 0);
97 	gtk_box_reorder_child (GTK_BOX (priv->vbox_form_options), head_page, 0);
98 
99 	/* set the form_enter_key variable */
100 	button = gsb_automem_radiobutton_gsettings_new (_("selects next field"),
101 													_("terminates transaction"),
102 													&a_conf->form_enter_key,
103 													NULL,
104 													NULL);
105 	gtk_box_pack_start (GTK_BOX (priv->box_form_enter_key), button, FALSE, FALSE, 0);
106 
107 	/* set the form_date_force_prev_year variable */
108 	button = gsb_automem_checkbutton_new (_("Replace the year of future dates with the previous year"),
109 										  &w_etat->form_date_force_prev_year,
110 										  NULL,
111 										  NULL);
112 	gtk_box_pack_start (GTK_BOX (priv->box_form_date_force_prev_year), button, FALSE, FALSE, 0);
113 	gtk_box_reorder_child (GTK_BOX (priv->box_form_date_force_prev_year), button, 0);
114 
115     /* set the affichage_exercice_automatique variable */
116     button = gsb_automem_radiobutton_gsettings_new (_("according to transaction date"),
117 													_("according to transaction value date"),
118 												    &a_conf->affichage_exercice_automatique,
119 												    NULL,
120 												    NULL);
121 	gtk_box_pack_start (GTK_BOX (priv->box_affichage_exercice_automatique), button, FALSE, FALSE, 0);
122 
123     /* set the fyear_combobox_sort_order variable */
124 	button = gsb_automem_checkbutton_gsettings_new (_("Sorting descending of the exercises"),
125 													&a_conf->fyear_combobox_sort_order,
126 													NULL,
127 													a_conf);
128 	gtk_box_pack_start (GTK_BOX (priv->box_fyear_combobox_sort_order), button, FALSE, FALSE, 0);
129 
130 	/* set automatic_separator variable */
131 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbutton_automatic_separator),
132 								  etat.automatic_separator);
133 
134 	/* set Selected transaction after validate split transaction */
135 	button = gsb_automem_radiobutton_gsettings_new (_("selects new transaction"),
136 													_("selects mother transaction"),
137 													&a_conf->form_validate_split,
138 													NULL,
139 													NULL);
140 	gtk_box_pack_start (GTK_BOX (priv->box_form_validate_split), button, FALSE, FALSE, 0);
141 
142 	if (!is_loading)
143 	{
144 		gtk_widget_set_sensitive (priv->box_form_date_force_prev_year, FALSE);
145 		gtk_widget_set_sensitive (priv->checkbutton_automatic_separator, FALSE);
146 	}
147 
148     /* Connect signal */
149     g_signal_connect (priv->checkbutton_automatic_separator,
150 					  "toggled",
151 					  G_CALLBACK (utils_prefs_page_checkbutton_changed),
152 					  &etat.automatic_separator);
153 }
154 
155 /******************************************************************************/
156 /* Fonctions propres à l'initialisation des fenêtres                          */
157 /******************************************************************************/
prefs_page_form_options_init(PrefsPageFormOptions * page)158 static void prefs_page_form_options_init (PrefsPageFormOptions *page)
159 {
160 	gtk_widget_init_template (GTK_WIDGET (page));
161 
162 	prefs_page_form_options_setup_form_options_page (page);
163 }
164 
prefs_page_form_options_dispose(GObject * object)165 static void prefs_page_form_options_dispose (GObject *object)
166 {
167 	G_OBJECT_CLASS (prefs_page_form_options_parent_class)->dispose (object);
168 }
169 
prefs_page_form_options_class_init(PrefsPageFormOptionsClass * klass)170 static void prefs_page_form_options_class_init (PrefsPageFormOptionsClass *klass)
171 {
172 	G_OBJECT_CLASS (klass)->dispose = prefs_page_form_options_dispose;
173 
174 	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
175 												 "/org/gtk/grisbi/ui/prefs_page_form_options.ui");
176 
177 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageFormOptions, vbox_form_options);
178 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
179 												  PrefsPageFormOptions,
180 												  box_affichage_exercice_automatique);
181 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
182 												  PrefsPageFormOptions,
183 												  box_fyear_combobox_sort_order);
184 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
185 												  PrefsPageFormOptions,
186 												  box_form_date_force_prev_year);
187 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
188 												  PrefsPageFormOptions,
189 												  box_form_enter_key);
190 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageFormOptions, box_form_enter_key);
191 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
192 												  PrefsPageFormOptions,
193 												  box_form_validate_split);
194 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
195 												  PrefsPageFormOptions,
196 												  checkbutton_automatic_separator);
197 }
198 
199 /******************************************************************************/
200 /* Public functions                                                           */
201 /******************************************************************************/
202 /**
203  *
204  *
205  * \param
206  *
207  * \return
208  **/
prefs_page_form_options_new(GrisbiPrefs * win)209 PrefsPageFormOptions *prefs_page_form_options_new (GrisbiPrefs *win)
210 {
211   return g_object_new (PREFS_PAGE_FORM_OPTIONS_TYPE, NULL);
212 }
213 
214 /**
215  *
216  *
217  * \param
218  *
219  * \return
220  **/
221 /* Local Variables: */
222 /* c-basic-offset: 4 */
223 /* End: */
224 
225