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_import.h"
41 #include "widget_import_asso.h"
42 #include "widget_import_files.h"
43 #include "structures.h"
44 #include "utils_prefs.h"
45 #include "erreur.h"
46 
47 /*END_INCLUDE*/
48 
49 /*START_EXTERN*/
50 /*END_EXTERN*/
51 
52 typedef struct _PrefsPageImportPrivate   PrefsPageImportPrivate;
53 
54 struct _PrefsPageImportPrivate
55 {
56 	GtkWidget *			vbox_import;
57 
58     GtkWidget *			notebook_import_pages;
59 };
60 
G_DEFINE_TYPE_WITH_PRIVATE(PrefsPageImport,prefs_page_import,GTK_TYPE_BOX)61 G_DEFINE_TYPE_WITH_PRIVATE (PrefsPageImport, prefs_page_import, GTK_TYPE_BOX)
62 
63 /******************************************************************************/
64 /* Private functions                                                          */
65 /******************************************************************************/
66 /**
67  * Création de la page de gestion des import
68  *
69  * \param prefs
70  *
71  * \return
72  **/
73 static void prefs_page_import_setup_page (PrefsPageImport *page,
74                                           GrisbiPrefs *win)
75 {
76 	GtkWidget *head_page;
77 	GtkWidget *vbox_import_files;
78 	GtkWidget *vbox_import_asso;
79 	GtkWidget *label;
80 	GrisbiWinRun *w_run;
81 	PrefsPageImportPrivate *priv;
82 
83 	devel_debug (NULL);
84 	priv = prefs_page_import_get_instance_private (page);
85 	w_run = (GrisbiWinRun *) grisbi_win_get_w_run ();
86 
87 	/* On récupère le nom de la page */
88 	head_page = utils_prefs_head_page_new_with_title_and_icon (_("Import"), "gsb-import-32.png");
89 	gtk_box_pack_start (GTK_BOX (priv->vbox_import), head_page, FALSE, FALSE, 0);
90 	gtk_box_reorder_child (GTK_BOX (priv->vbox_import), head_page, 0);
91 
92 	vbox_import_files = GTK_WIDGET (widget_import_files_new (win));
93 	gtk_widget_set_margin_top (vbox_import_files, MARGIN_TOP);
94 	gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook_import_pages), vbox_import_files, NULL);
95 	label = gtk_label_new (_("Files import"));
96 	gtk_notebook_set_tab_label (GTK_NOTEBOOK (priv->notebook_import_pages), vbox_import_files, label);
97 
98 	/* set manage associations */
99 	vbox_import_asso = GTK_WIDGET (widget_import_asso_new (win));
100 	gtk_widget_set_margin_top (vbox_import_asso, MARGIN_TOP);
101 	gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook_import_pages), vbox_import_asso, NULL);
102 	label = gtk_label_new (_("Associations for import"));
103 	gtk_notebook_set_tab_label (GTK_NOTEBOOK (priv->notebook_import_pages), vbox_import_asso, label);
104 
105 	/* set page of notebook */
106 	if (w_run->prefs_import_tab)
107 		gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook_import_pages), w_run->prefs_import_tab);
108 
109 	/* set signal notebook_impert */
110 	g_signal_connect (G_OBJECT (priv->notebook_import_pages),
111 	                  "switch-page",
112 	                  (GCallback) utils_prefs_page_notebook_switch_page,
113 	                  &w_run->prefs_import_tab);
114 }
115 
116 /******************************************************************************/
117 /* Fonctions propres à l'initialisation des fenêtres                          */
118 /******************************************************************************/
prefs_page_import_init(PrefsPageImport * page)119 static void prefs_page_import_init (PrefsPageImport *page)
120 {
121 	gtk_widget_init_template (GTK_WIDGET (page));
122 }
123 
prefs_page_import_dispose(GObject * object)124 static void prefs_page_import_dispose (GObject *object)
125 {
126 	G_OBJECT_CLASS (prefs_page_import_parent_class)->dispose (object);
127 }
128 
prefs_page_import_class_init(PrefsPageImportClass * klass)129 static void prefs_page_import_class_init (PrefsPageImportClass *klass)
130 {
131 	G_OBJECT_CLASS (klass)->dispose = prefs_page_import_dispose;
132 
133 	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
134 												 "/org/gtk/grisbi/ui/prefs_page_import.ui");
135 
136 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageImport, vbox_import);
137 	gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), PrefsPageImport, notebook_import_pages);
138 }
139 
140 /******************************************************************************/
141 /* Public functions                                                           */
142 /******************************************************************************/
143 /**
144  *
145  *
146  * \param
147  *
148  * \return
149  **/
prefs_page_import_new(GrisbiPrefs * win)150 PrefsPageImport *prefs_page_import_new (GrisbiPrefs *win)
151 {
152 	PrefsPageImport *page;
153 
154 	page = g_object_new (PREFS_PAGE_IMPORT_TYPE, NULL);
155 	prefs_page_import_setup_page (page,win);
156 
157 	return page;
158 }
159 
160 /**
161  *
162  *
163  * \param
164  *
165  * \return
166  **/
prefs_page_import_get_notebook(GtkWidget * page)167 GtkWidget *prefs_page_import_get_notebook (GtkWidget *page)
168 {
169 	PrefsPageImportPrivate *priv;
170 
171 	priv = prefs_page_import_get_instance_private (PREFS_PAGE_IMPORT (page));
172 
173 	return priv->notebook_import_pages;
174 }
175 
176 /**
177  *
178  *
179  * \param
180  *
181  * \return
182  **/
183 /* Local Variables: */
184 /* c-basic-offset: 4 */
185 /* End: */
186 
187