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-2017 Pierre Biava (grisbi@pierre.biava.name)                    */
9 /*          https://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_archives.h"
41 #include "dialog.h"
42 #include "grisbi_app.h"
43 #include "gsb_account_property.h"
44 #include "gsb_autofunc.h"
45 #include "gsb_data_account.h"
46 #include "gsb_data_archive.h"
47 #include "gsb_data_archive_store.h"
48 #include "gsb_data_fyear.h"
49 #include "gsb_data_transaction.h"
50 #include "gsb_dirs.h"
51 #include "gsb_file.h"
52 #include "gsb_transactions_list.h"
53 #include "navigation.h"
54 #include "structures.h"
55 #include "transaction_list.h"
56 #include "utils.h"
57 #include "utils_dates.h"
58 #include "utils_prefs.h"
59 #include "utils_str.h"
60 #include "erreur.h"
61 
62 /*END_INCLUDE*/
63 
64 /*START_EXTERN*/
65 /*END_EXTERN*/
66 
67 typedef struct _PrefsPageArchivesPrivate   PrefsPageArchivesPrivate;
68 
69 struct _PrefsPageArchivesPrivate
70 {
71 	GtkWidget *			vbox_archives;
72 
73 	GtkWidget *			treeview_archives;
74     GtkWidget *			checkbutton_archives_sort_order;
75 
76 	GtkWidget *			grid_archives_modification;
77 	GtkWidget *			entry_archives_name;
78 	GtkWidget * 		button_archives_delete;
79 	GtkWidget * 		button_archives_destroy;
80 
81 	GtkWidget *			checkbutton_archives_check_auto;
82     GtkWidget *         spinbutton_archives_check_auto;
83 
84 };
85 
86 G_DEFINE_TYPE_WITH_PRIVATE (PrefsPageArchives, prefs_page_archives, GTK_TYPE_BOX)
87 
88 /** Columns for archives tree */
89 enum ArchivesColumns
90 {
91     ARCHIVES_NAME_COLUMN = 0,
92     ARCHIVES_INIT_DATE,
93     ARCHIVES_FINAL_DATE,
94     ARCHIVES_FYEAR_NAME,
95     ARCHIVES_REPORT_TITLE,
96     ARCHIVES_NUMBER,
97 	ARCHIVES_BACKGROUND_COLOR,
98     NUM_ARCHIVES_COLUMNS
99 };
100 
101 
102 /******************************************************************************/
103 /* Private functions                                                          */
104 /******************************************************************************/
105 /**
106  * call by a click on the delete archive
107  * this will delete the archive and free the transactions from the link
108  * 	to that archive
109  * nothing will be deleted except the archive
110  *
111  * \param button
112  * \param tree_view
113  *
114  * \return FALSE
115  * */
prefs_page_archives_delete_archive(GtkWidget * button,GtkWidget * tree_view)116 static gboolean prefs_page_archives_delete_archive (GtkWidget *button,
117 													GtkWidget *tree_view)
118 {
119     GtkTreeSelection *selection;
120     GtkTreeIter iter;
121     gboolean good;
122 
123     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
124     good = gtk_tree_selection_get_selected (selection, NULL, &iter);
125 
126     if (good)
127     {
128 		GtkTreeModel *model;
129 		gchar* tmp_str;
130 		gint archive_number;
131 
132 		model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
133 		gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
134 							ARCHIVES_NUMBER, &archive_number,
135 							-1);
136 
137 		if (!archive_number)
138 		{
139 			return FALSE;
140 		}
141 
142 		tmp_str = g_strdup_printf (
143 							_("Warning, you are about the delete the archive \"%s\".\n\n"
144 							  "If you continue, all the transactions linked to that archive "
145 							  "will loose the link and will begin again not archived.\n"
146 							  "All the information about that archive will be destroyed.\n\n"
147 							  "Do you want to continue?"),
148 							gsb_data_archive_get_name (archive_number));
149 		if (!dialogue_yes_no (tmp_str, _("Deleting an archive"), GTK_RESPONSE_CANCEL))
150 		{
151 			g_free (tmp_str);
152 			return FALSE;
153 		}
154 			g_free (tmp_str);
155 
156 		/* ok, now we delete the archive */
157 		/* first step, we show it in the lists */
158 		gsb_transactions_list_restore_archive (archive_number, FALSE);
159 
160 		/* now we remove the link of all the transactions and the archive itself */
161 		gsb_data_archive_remove (archive_number);
162 
163 		/* remove from the list */
164 		gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
165 		gtk_tree_selection_select_path (selection, gtk_tree_path_new_first ());
166 
167 		gsb_file_set_modified (TRUE);
168     }
169     return FALSE;
170 }
171 
172 /**
173  * call by a click on the delete archive and transactions
174  * this will delete the archive and the associated transactions
175  * the initials amount of the accounts will be changed according to the new initial amount
176  *
177  * \param button
178  * \param tree_view
179  *
180  * \return FALSE
181  * */
prefs_page_archives_destroy_archive(GtkWidget * button,GtkWidget * tree_view)182 static gboolean prefs_page_archives_destroy_archive (GtkWidget *button,
183 													 GtkWidget *tree_view)
184 {
185     GtkTreeSelection *selection;
186     GtkTreeIter iter;
187     gboolean good;
188     GtkTreeModel *model;
189 
190     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
191     good = gtk_tree_selection_get_selected (selection, NULL, &iter);
192 
193     if (good)
194     {
195 		gint archive_number;
196 		GSList *tmp_list;
197 		gint account_number;
198 		gchar* tmp_str;
199 
200 		model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
201 		gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
202 							ARCHIVES_NUMBER, &archive_number,
203 							-1);
204 
205 		if (!archive_number)
206 		{
207 			return FALSE;
208 		}
209 
210 		tmp_str = g_strdup_printf (_("Warning, you are about the delete the archive \"%s\" and its "
211 									  "associated transactions.\n\nIf you continue, all the transactions "
212 									  "linked to that archive will be deleted and the initials amounts "
213 									  "of the accounts will be adjusted.\nAll the information about "
214 									  "that archive will be destroyed.\nYou should have at least exported "
215 									  "that archive into another file...\n\nAre you sure you want to "
216 									  "continue ?"),
217 								   gsb_data_archive_get_name (archive_number));
218 
219 		if (!dialogue_yes_no (tmp_str, _("Deleting an archive and its transactions"), GTK_RESPONSE_CANCEL))
220 		{
221 			g_free (tmp_str);
222 			return FALSE;
223 		}
224 		g_free (tmp_str);
225 
226 		/* remove the lines of that archive in the tree view of transactions */
227 		transaction_list_remove_archive (archive_number);
228 
229 		/* remove that archive from the archive store and modify the initial amount of accounts */
230 		tmp_list = gsb_data_archive_store_get_archives_list ();
231 		while (tmp_list)
232 		{
233 			gint archive_store_number;
234 
235 			archive_store_number = gsb_data_archive_store_get_number (tmp_list->data);
236 			if (gsb_data_archive_store_get_archive_number (archive_store_number) == archive_number)
237 			{
238 				/* change the initial amount of the corresponding account */
239 				account_number = gsb_data_archive_store_get_account_number (archive_store_number);
240 				gsb_data_account_set_init_balance (account_number,
241 												   gsb_real_add (gsb_data_account_get_init_balance (account_number, -1),
242 																 gsb_data_archive_store_get_balance (archive_store_number)));
243 
244 				/* remove the archive store */
245 				tmp_list = tmp_list->next;
246 				gsb_data_archive_store_remove (archive_store_number);
247 			}
248 			else
249 			{
250 				tmp_list = tmp_list->next;
251 			}
252 		}
253 
254 		/* delete the transactions associated to the archive */
255 		tmp_list = gsb_data_transaction_get_complete_transactions_list ();
256 		while (tmp_list)
257 		{
258 			gint transaction_number;
259 
260 			transaction_number = gsb_data_transaction_get_transaction_number (tmp_list->data);
261 			if (gsb_data_transaction_get_archive_number (transaction_number) == archive_number)
262 			{
263 				/* we have to remove that transaction */
264 				gsb_transactions_list_delete_transaction_from_tree_view (transaction_number);
265 
266 				/* need to go to the next tmp_list now, before deleting the transaction */
267 				tmp_list = tmp_list->next;
268 				gsb_data_transaction_remove_transaction_without_check (transaction_number);
269 			}
270 			else
271 			{
272 				tmp_list = tmp_list->next;
273 			}
274 		}
275 		/* now we remove the archive  */
276 		gsb_data_archive_remove (archive_number);
277 
278 		/* remove from the list */
279 		gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
280 		gtk_tree_selection_select_path (selection, gtk_tree_path_new_first ());
281 
282 		/* if we are on an account, we re-calculate the balances and mark the new initial balance in the account */
283 		account_number = gsb_gui_navigation_get_current_account ();
284 		if (account_number >= 0)
285 		{
286 			/* we are on an account */
287 			gsb_account_property_fill_page ();
288 			transaction_list_set_balances ();
289 		}
290 
291 		gsb_file_set_modified (TRUE);
292     }
293     return FALSE;
294 }
295 
296 /**
297  * Callback used when an archive is selected
298  *
299  * \param selection the tree selection
300  * \param paddingbox the modification paddingbox
301  *
302  * \return FALSE
303  */
prefs_page_archives_select_archive(GtkTreeSelection * selection,PrefsPageArchives * page)304 static gboolean prefs_page_archives_select_archive (GtkTreeSelection *selection,
305 													PrefsPageArchives *page)
306 {
307     GtkTreeIter iter;
308     gboolean good;
309 	PrefsPageArchivesPrivate *priv;
310 
311 	priv = prefs_page_archives_get_instance_private (page);
312 	good = gtk_tree_selection_get_selected (selection, NULL, &iter);
313 
314     if (good)
315     {
316 		GtkTreeModel *model;
317 		gint archive_number;
318 
319 		model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview_archives));
320 		gtk_tree_model_get (model, &iter,
321 							ARCHIVES_NUMBER, &archive_number,
322 							-1);
323 
324 		/* Filling entries */
325 		gsb_autofunc_entry_set_value (priv->entry_archives_name,
326 									  gsb_data_archive_get_name (archive_number),
327 									  archive_number);
328     }
329     else
330     {
331 		/* Blanking entries */
332 		gsb_autofunc_entry_set_value (priv->entry_archives_name, NULL, 0);
333     }
334 
335     return (FALSE);
336 }
337 
338 /**
339  * Callback called when the payment method name is changed in the
340  * GtkEntry associated.  It updates the GtkTreeView list of payment
341  * methods as well as it updates transaction form.
342  *
343  * \param entry the entry changed (payment method name)
344  * \param tree_view
345  *
346  * \return FALSE
347  */
prefs_page_archives_name_changed(GtkWidget * entry,GtkWidget * tree_view)348 static gboolean prefs_page_archives_name_changed (GtkWidget *entry,
349 												  GtkWidget *tree_view)
350 {
351     GtkTreeSelection *selection;
352     GtkTreeIter iter;
353     gboolean good;
354 
355     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
356     good = gtk_tree_selection_get_selected (selection, NULL, &iter);
357 
358     if (good)
359     {
360 		GtkTreeModel *model;
361 		gint archive_number;
362 
363 		model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
364 		gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, ARCHIVES_NUMBER, &archive_number, -1);
365 
366 		/* update the tree view */
367 		gtk_list_store_set (GTK_LIST_STORE (model),
368 							&iter,
369 							ARCHIVES_NAME_COLUMN, gsb_data_archive_get_name (archive_number),
370 							-1);
371     }
372     return FALSE;
373 }
374 
375 /**
376  * fill the tree view with the existings archives
377  *
378  * \param store
379  *
380  * \return
381  * */
prefs_page_archives_fill_list(GtkListStore * store)382 static void prefs_page_archives_fill_list (GtkListStore *store)
383 {
384     GSList *tmp_list;
385 
386     gtk_list_store_clear (GTK_LIST_STORE (store));
387     tmp_list = gsb_data_archive_get_archives_list ();
388 
389     while (tmp_list)
390     {
391 		gint archive_number;
392 		GtkTreeIter iter;
393 		gchar *init_date;
394 		gchar *final_date;
395 		const gchar *arch_name;
396 		const gchar *report_name;
397 		gchar *tmp_str1;
398 		gchar *tmp_str2;
399 
400 		archive_number = gsb_data_archive_get_no_archive (tmp_list->data);
401 
402 		init_date = gsb_format_gdate (gsb_data_archive_get_beginning_date (archive_number));
403 		final_date = gsb_format_gdate (gsb_data_archive_get_end_date (archive_number));
404 
405 		arch_name = gsb_data_archive_get_name (archive_number);
406 		tmp_str1 = utils_str_break_form_name_field (arch_name, TRUNC_FORM_FIELD);
407 
408 		report_name = gsb_data_archive_get_report_title (archive_number);
409 		if (report_name)
410 			tmp_str2 = utils_str_break_form_name_field (report_name, TRUNC_FORM_FIELD);
411 		else
412 			tmp_str2 = NULL;
413 
414 		gtk_list_store_append (GTK_LIST_STORE (store), &iter);
415 		gtk_list_store_set (GTK_LIST_STORE (store),
416 							&iter,
417 							ARCHIVES_NAME_COLUMN, tmp_str1,
418 							ARCHIVES_INIT_DATE, init_date,
419 							ARCHIVES_FINAL_DATE, final_date,
420 							ARCHIVES_FYEAR_NAME, gsb_data_fyear_get_name (gsb_data_archive_get_fyear (archive_number)),
421 							ARCHIVES_REPORT_TITLE, tmp_str2,
422 							ARCHIVES_NUMBER, archive_number,
423 							-1);
424 
425 		if (init_date)
426 			g_free (init_date);
427 		if (final_date)
428 			g_free (final_date);
429 		if (tmp_str1)
430 			g_free (tmp_str1);
431 		if (tmp_str2)
432 			g_free (tmp_str2);
433 
434 		tmp_list = tmp_list->next;
435     }
436 }
437 
438 /**
439  *
440  *
441  * \param
442  * \param
443  *
444  * \return
445  * */
prefs_page_archives_button_sort_order_clicked(GtkWidget * toggle_button,GtkWidget * treeview)446 static void prefs_page_archives_button_sort_order_clicked (GtkWidget *toggle_button,
447 														   GtkWidget *treeview)
448 {
449     GtkTreeModel *model;
450 	gboolean is_loading;
451 	GrisbiAppConf *a_conf;
452 
453 	a_conf = (GrisbiAppConf *) grisbi_app_get_a_conf ();
454 
455 	is_loading = grisbi_win_file_is_loading ();
456 	if (is_loading)
457 	{
458 		model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
459 		gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model),
460 											  ARCHIVES_FYEAR_NAME,
461 											  a_conf->prefs_archives_sort_order);
462 		gtk_tree_sortable_sort_column_changed (GTK_TREE_SORTABLE (model));
463 		prefs_page_archives_fill_list (GTK_LIST_STORE (model));
464     	utils_set_list_store_background_color (treeview, ARCHIVES_BACKGROUND_COLOR);
465 	}
466 }
467 
468 /**
469  *
470  *
471  * \param
472  *
473  * \return
474  **/
prefs_page_archives_setup_treeview_archives(PrefsPageArchives * page,GrisbiAppConf * a_conf)475 static void prefs_page_archives_setup_treeview_archives (PrefsPageArchives *page,
476 														 GrisbiAppConf *a_conf)
477 {
478 	PrefsPageArchivesPrivate *priv;
479     GtkListStore *archives_model;
480 	GtkTreeSelection *selection;
481     gint i;
482     const gchar *titles[] = {
483 	N_("Name"), N_("Initial date"), N_("Final date"), N_("Financial year"), N_("Report name") };
484     gfloat alignment[] = {
485 	COLUMN_LEFT, COLUMN_CENTER, COLUMN_CENTER , COLUMN_CENTER, COLUMN_CENTER };
486 
487 	priv = prefs_page_archives_get_instance_private (page);
488 
489 	/* Create tree model */
490     archives_model = gtk_list_store_new (NUM_ARCHIVES_COLUMNS,
491 										 G_TYPE_STRING,
492 										 G_TYPE_STRING,
493 										 G_TYPE_STRING,
494                                          G_TYPE_STRING,
495 										 G_TYPE_STRING,
496                                          G_TYPE_INT,
497 										 GDK_TYPE_RGBA);
498 	gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview_archives), GTK_TREE_MODEL (archives_model));
499     g_object_unref (G_OBJECT(archives_model));
500 
501     /* set the columns */
502     for (i=0 ; i<5 ; i++)
503     {
504         GtkTreeViewColumn *column;
505         GtkCellRenderer *cell;
506 
507         cell = gtk_cell_renderer_text_new ();
508         g_object_set (G_OBJECT (cell), "xalign", alignment[i], NULL);
509 
510         column = gtk_tree_view_column_new ();
511         gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
512         gtk_tree_view_column_set_alignment (column, alignment[i]);
513 
514         gtk_tree_view_column_pack_start (column, cell, TRUE);
515         gtk_tree_view_column_set_title (column, gettext (titles[i]));
516         gtk_tree_view_column_set_attributes (column,
517 											 cell,
518 											 "text", i,
519 											 "cell-background-rgba", ARCHIVES_BACKGROUND_COLOR,
520 											 NULL);
521         gtk_tree_view_column_set_expand (column, TRUE);
522         gtk_tree_view_column_set_resizable (column, TRUE);
523         gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview_archives), column);
524     }
525 
526     /* Sort columns accordingly */
527     gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (archives_model),
528                                           ARCHIVES_FYEAR_NAME,
529                                           a_conf->prefs_archives_sort_order);
530 
531 	/* fill the list */
532     prefs_page_archives_fill_list (archives_model);
533 
534     utils_set_list_store_background_color (priv->treeview_archives, ARCHIVES_BACKGROUND_COLOR);
535 
536 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview_archives));
537 	g_signal_connect (selection,
538                       "changed",
539                       G_CALLBACK (prefs_page_archives_select_archive),
540                       page);
541 
542 	/* select the first item */
543 	gtk_tree_selection_select_path (selection, gtk_tree_path_new_first ());
544 }
545 
546 /**
547  * Création de la page de gestion des archives
548  *
549  * \param prefs
550  *
551  * \return
552  */
prefs_page_archives_setup_page(PrefsPageArchives * page)553 static void prefs_page_archives_setup_page (PrefsPageArchives *page)
554 {
555 	GtkWidget *head_page;
556 	gchar* tmp_str;
557 	gboolean is_loading;
558 	GrisbiAppConf *a_conf;
559 	PrefsPageArchivesPrivate *priv;
560 
561 	devel_debug (NULL);
562 
563 	priv = prefs_page_archives_get_instance_private (page);
564 	a_conf = (GrisbiAppConf *) grisbi_app_get_a_conf ();
565 	is_loading = grisbi_win_file_is_loading ();
566 
567 	/* On récupère le nom de la page */
568 	head_page = utils_prefs_head_page_new_with_title_and_icon (_("Archives"), "gsb-archive-32.png");
569 	gtk_box_pack_start (GTK_BOX (priv->vbox_archives), head_page, FALSE, FALSE, 0);
570 	gtk_box_reorder_child (GTK_BOX (priv->vbox_archives), head_page, 0);
571 
572 	/* set the entry widget entry_archives_name */
573 	gsb_autofunc_entry_new_from_ui (priv->entry_archives_name,
574 	                                NULL,
575 								    G_CALLBACK (prefs_page_archives_name_changed),
576 								    priv->treeview_archives,
577 								    G_CALLBACK (gsb_data_archive_set_name),
578 								    0);
579 	gtk_widget_set_margin_bottom (priv->entry_archives_name, MARGIN_BOX);
580 
581 	/* setup treeview_archives */
582 	if (is_loading)
583 	{
584 		prefs_page_archives_setup_treeview_archives (page, a_conf);
585 	}
586 	else
587 	{
588 		gtk_widget_set_sensitive (priv->treeview_archives, FALSE);
589 		gtk_widget_set_sensitive (priv->button_archives_delete, FALSE);
590 		gtk_widget_set_sensitive (priv->button_archives_destroy, FALSE);
591 		gtk_widget_set_sensitive (priv->entry_archives_name, FALSE);
592 	}
593 
594     /* set the checkbutton to sort archives */
595     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbutton_archives_sort_order),
596 								  a_conf->prefs_archives_sort_order);
597 
598     /* Connect signal */
599     g_signal_connect (priv->checkbutton_archives_sort_order,
600 					  "toggled",
601 					  G_CALLBACK (utils_prefs_page_checkbutton_changed),
602 					  &a_conf->prefs_archives_sort_order);
603 
604 	g_signal_connect_after (priv->checkbutton_archives_sort_order,
605 							"toggled",
606 							G_CALLBACK (prefs_page_archives_button_sort_order_clicked),
607 							priv->treeview_archives);
608 
609     /* button to delete an archive and free the transactions */
610     tmp_str = g_build_filename (gsb_dirs_get_pixmaps_dir (), "gsb-import-24.png", NULL);
611     gtk_button_set_image (GTK_BUTTON (priv->button_archives_delete),
612 						  gtk_image_new_from_file (tmp_str));
613     g_free (tmp_str);
614     g_signal_connect (G_OBJECT (priv->button_archives_delete),
615                       "clicked",
616                       G_CALLBACK (prefs_page_archives_delete_archive),
617                       priv->treeview_archives);
618 
619 	/* button to delete an archive and delete the transactions */
620     tmp_str = g_build_filename (gsb_dirs_get_pixmaps_dir (), "gsb-import-24.png", NULL);
621     gtk_button_set_image (GTK_BUTTON (priv->button_archives_destroy),
622 						  gtk_image_new_from_file (tmp_str));
623     g_free (tmp_str);
624     g_signal_connect (G_OBJECT (priv->button_archives_destroy),
625                       "clicked",
626                       G_CALLBACK (prefs_page_archives_destroy_archive),
627                       priv->treeview_archives);
628 
629 	/* set the checkbutton for the automatic check */
630     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbutton_archives_check_auto),
631 								  a_conf->archives_check_auto);
632 
633 	/* Connect signal */
634     g_signal_connect (priv->checkbutton_archives_check_auto,
635 					  "toggled",
636 					  G_CALLBACK (utils_prefs_page_checkbutton_changed),
637 					  &a_conf->archives_check_auto);
638 
639 	/* set the max of transactions before archival and state */
640 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spinbutton_archives_check_auto),
641 							   a_conf->max_non_archived_transactions_for_check);
642 
643 	if (!a_conf->archives_check_auto)
644 		gtk_widget_set_sensitive (GTK_WIDGET (priv->spinbutton_archives_check_auto), FALSE);
645 
646     /* callback for spinbutton_ */
647     g_object_set_data (G_OBJECT (priv->spinbutton_archives_check_auto),
648                        "button", priv->checkbutton_archives_check_auto);
649 	g_object_set_data (G_OBJECT (priv->checkbutton_archives_check_auto),
650                        "spinbutton", priv->spinbutton_archives_check_auto);
651 
652     g_signal_connect (priv->spinbutton_archives_check_auto,
653 					  "value-changed",
654 					  G_CALLBACK (utils_prefs_spinbutton_changed),
655 					  &a_conf->max_non_archived_transactions_for_check);
656 }
657 
658 /******************************************************************************/
659 /* Fonctions propres à l'initialisation des fenêtres                          */
660 /******************************************************************************/
prefs_page_archives_init(PrefsPageArchives * page)661 static void prefs_page_archives_init (PrefsPageArchives *page)
662 {
663 	gtk_widget_init_template (GTK_WIDGET (page));
664 
665 	prefs_page_archives_setup_page (page);
666 }
667 
prefs_page_archives_dispose(GObject * object)668 static void prefs_page_archives_dispose (GObject *object)
669 {
670 	G_OBJECT_CLASS (prefs_page_archives_parent_class)->dispose (object);
671 }
672 
prefs_page_archives_class_init(PrefsPageArchivesClass * klass)673 static void prefs_page_archives_class_init (PrefsPageArchivesClass *klass)
674 {
675 	G_OBJECT_CLASS (klass)->dispose = prefs_page_archives_dispose;
676 
677 	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
678 												 "/org/gtk/grisbi/ui/prefs_page_archives.ui");
679 
680 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, vbox_archives);
681 
682 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, treeview_archives);
683 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, checkbutton_archives_sort_order);
684 
685 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, grid_archives_modification);
686 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, button_archives_delete);
687 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, button_archives_destroy);
688 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, entry_archives_name);
689 
690 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, checkbutton_archives_check_auto);
691 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageArchives, spinbutton_archives_check_auto);
692 }
693 
694 /******************************************************************************/
695 /* Public functions                                                           */
696 /******************************************************************************/
prefs_page_archives_new(GrisbiPrefs * win)697 PrefsPageArchives * prefs_page_archives_new (GrisbiPrefs *win)
698 {
699   return g_object_new (PREFS_PAGE_ARCHIVES_TYPE, NULL);
700 }
701 
702 /**
703  *
704  *
705  * \param
706  *
707  * \return
708  **/
709 /* Local Variables: */
710 /* c-basic-offset: 4 */
711 /* End: */
712 
713