]> Dogcows Code - chaz/homebank/blob - src/homebank.h
Merge branch 'upstream'
[chaz/homebank] / src / homebank.h
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2016 Maxime DOYEN
3 *
4 * This file is part of HomeBank.
5 *
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _HOMEBANK_H_
21 #define _HOMEBANK_H_
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <ctype.h> /* isprint */
28 #include <errno.h>
29 #include <math.h>
30 #include <libintl.h>
31 #include <locale.h>
32 #include <stdlib.h> /* atoi, atof, atol */
33 #include <string.h> /* memset, memcpy, strcmp, strcpy */
34 #include <time.h>
35
36 #include <glib.h>
37 #include <glib/gstdio.h>
38 #include <gtk/gtk.h>
39
40 #include "enums.h"
41 #include "hb-preferences.h"
42
43 #include "hb-transaction.h"
44 #include "hb-currency.h"
45 #include "hb-account.h"
46 #include "hb-archive.h"
47 #include "hb-assign.h"
48 #include "hb-category.h"
49 #include "hb-encoding.h"
50 #include "hb-export.h"
51 #include "hb-filter.h"
52 #include "hb-import.h"
53 #include "hb-misc.h"
54 #include "hb-payee.h"
55 #include "hb-report.h"
56 #include "hb-tag.h"
57 #include "hb-hbfile.h"
58 #include "hb-xml.h"
59
60 #include "ui-dialogs.h"
61 #include "ui-pref.h"
62 #include "ui-widgets.h"
63
64 #define _(str) gettext (str)
65 #define gettext_noop(str) (str)
66 #define N_(str) gettext_noop (str)
67
68 /* = = = = = = = = = = = = = = = = */
69 /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
70
71 #define HB_UNSTABLE FALSE
72
73 #define HB_VERSION_MAJOR 5
74 #define HB_VERSION_MINOR 1
75 #define HB_VERSION_MICRO 2
76
77 #define HB_VERSION "5.1.2"
78 #define HB_VERSION_NUM (HB_VERSION_MAJOR*10000) + (HB_VERSION_MINOR*100) + HB_VERSION_MICRO
79
80 #define FILE_VERSION 1.2
81 #define PREF_VERSION 512
82
83 #if HB_UNSTABLE == FALSE
84 #define PROGNAME "HomeBank"
85 #define HB_DATA_PATH "homebank"
86 #else
87 #define PROGNAME "HomeBank " HB_VERSION " (unstable)"
88 #define HB_DATA_PATH "homebank_unstable"
89 #endif
90
91
92 #ifdef G_OS_WIN32
93 #define GETTEXT_PACKAGE "homebank"
94 #define LOCALE_DIR "locale"
95 #define PIXMAPS_DIR "images"
96 #define HELP_DIR "help"
97 #define PACKAGE_VERSION HB_VERSION
98 #define PACKAGE "homebank"
99 #define VERSION HB_VERSION
100
101 //#define PORTABLE_APP
102 //#define NOOFX
103
104 #define ENABLE_NLS 1
105 #endif
106
107
108 /* container spacing */
109 #define SPACING_TINY 3
110 #define SPACING_SMALL 6
111 #define SPACING_MEDIUM 12
112 #define SPACING_LARGE 18
113
114
115 #define HB_MINDATE 693596 //01/01/1900
116 #define HB_MAXDATE 803533 //31/12/2200
117
118 /* widget minimum width */
119 #define HB_MINWIDTH_LIST 161
120 #define HB_MINHEIGHT_LIST 260
121
122 #define HB_MINWIDTH_SEARCH 240
123 #define HB_MINWIDTH_COLUMN 48
124
125
126 /* miscellaneous */
127 #define PHI 1.61803399
128
129 /* official GTK_RESPONSE are negative */
130 #define GTK_RESPONSE_ADD 1
131 #define GTK_RESPONSE_ADDKEEP 2
132
133 #define HB_NUMBER_SAMPLE 1234567.89
134
135
136 typedef enum
137 {
138 FILETYPE_UNKNOW,
139 FILETYPE_HOMEBANK,
140 FILETYPE_OFX,
141 FILETYPE_QIF,
142 FILETYPE_CSV_HB,
143 // FILETYPE_AMIGA_HB,
144 NUM_FILETYPE
145 } HbFileType;
146
147
148 /* ---- icon size as defined into gtkiconfactory.c ---- */
149 /* GTK_ICON_SIZE_MENU 16
150 * GTK_ICON_SIZE_BUTTON 20
151 * GTK_ICON_SIZE_SMALL_TOOLBAR 18
152 * GTK_ICON_SIZE_LARGE_TOOLBAR 24 (default for toolbar)
153 * GTK_ICON_SIZE_DND 32
154 * GTK_ICON_SIZE_DIALOG 48
155 */
156
157 /* -------- named icons (Standard Icon Name) -------- */
158 #define ICONNAME_NEW "document-new"
159 #define ICONNAME_OPEN "document-open"
160 #define ICONNAME_SAVE "document-save"
161 #define ICONNAME_SAVE_AS "document-save-as" //obsolete
162 #define ICONNAME_REVERT "document-revert" //obsolete
163 #define ICONNAME_PRINT "document-print" //unused
164 #define ICONNAME_PROPERTIES "document-properties" //obsolete
165 #define ICONNAME_CLOSE "window-close" //obsolete
166 #define ICONNAME_QUIT "application-exit" //obsolete
167 #define ICONNAME_FIND "edit-find"
168 #define ICONNAME_CLEAR "edit-clear"
169 #define ICONNAME_WARNING "dialog-warning"
170 #define ICONNAME_ERROR "dialog-error"
171 #define ICONNAME_INFO "dialog-information"
172 #define ICONNAME_HELP "help-browser" //obsolete
173 #define ICONNAME_ABOUT "help-about" //obsolete
174 #define ICONNAME_PREFERENCES "preferences-system" //obsolete
175 #define ICONNAME_REFRESH "view-refresh"
176
177 #define ICONNAME_FOLDER "folder-symbolic"
178
179 #define ICONNAME_LIST_ADD "list-add-symbolic"
180 #define ICONNAME_LIST_REMOVE "list-remove-symbolic"
181
182 //#define ICONNAME_HB_SCHED_SKIP "media-skip-forward"
183 //#define ICONNAME_HB_SCHED_POST "media-playback-start"
184
185 // custom or gnome not found
186 #define ICONNAME_HB_BUTTON_MENU "open-menu-symbolic"
187 #define ICONNAME_HB_TOGGLE_SIGN "toggle-sign-symbolic"
188
189
190 /* -------- named icons (Custom to homebank) -------- */
191 #define ICONNAME_HB_CURRENCY "hb-currency"
192 #define ICONNAME_HB_ACCOUNT "hb-account"
193 #define ICONNAME_HB_ARCHIVE "hb-archive"
194 #define ICONNAME_HB_ASSIGN "hb-assign"
195 #define ICONNAME_HB_BUDGET "hb-budget"
196 #define ICONNAME_HB_CATEGORY "hb-category"
197 #define ICONNAME_HB_PAYEE "hb-payee"
198 #define ICONNAME_HB_OPE_SHOW "hb-ope-show" //? "view-register
199 #define ICONNAME_HB_REP_STATS "hb-rep-stats"
200 #define ICONNAME_HB_REP_TIME "hb-rep-time"
201 #define ICONNAME_HB_REP_BALANCE "hb-rep-balance"
202 #define ICONNAME_HB_REP_BUDGET "hb-rep-budget"
203 #define ICONNAME_HB_REP_CAR "hb-rep-vehicle"
204
205 #define ICONNAME_HB_VIEW_LIST "hb-view-list" //"view-list-text"
206 #define ICONNAME_HB_VIEW_BAR "hb-view-bar" //"view-chart-bar"
207 #define ICONNAME_HB_VIEW_COLUMN "hb-view-column" //"view-chart-column"
208 #define ICONNAME_HB_VIEW_LINE "hb-view-line" //"view-chart-line"
209 #define ICONNAME_HB_VIEW_STACK "hb-view-stack" //"view-chart-stack"
210 #define ICONNAME_HB_VIEW_PIE "hb-view-pie" //"view-chart-pie"
211 #define ICONNAME_HB_VIEW_DONUT "hb-view-donut" //"view-chart-donut"
212 #define ICONNAME_HB_SHOW_LEGEND "hb-legend" //"view-legend"
213 #define ICONNAME_HB_SHOW_RATE "hb-rate" // obsolete ?
214 #define ICONNAME_HB_FILTER "hb-filter" //"edit-filter"
215
216 #define ICONNAME_HB_FILE_IMPORT "hb-file-import" //document-import
217 #define ICONNAME_HB_FILE_EXPORT "hb-file-export" //document-export
218 #define ICONNAME_HB_FILE_VALID "hb-file-valid"
219 #define ICONNAME_HB_FILE_INVALID "hb-file-invalid"
220
221 #define ICONNAME_HB_BUTTON_COLLAPSE "btn-collapse"
222 #define ICONNAME_HB_BUTTON_EXPAND "btn-expand"
223 #define ICONNAME_HB_BUTTON_SPLIT "btn-split"
224
225 #define ICONNAME_HB_OPE_AUTO "hb-ope-auto" //?
226 #define ICONNAME_HB_OPE_BUDGET "hb-ope-budget" //?
227 #define ICONNAME_HB_OPE_ADD "hb-ope-add" //? "edit-add"
228 #define ICONNAME_HB_OPE_HERIT "hb-ope-herit" //? "edit-clone"
229 #define ICONNAME_HB_OPE_EDIT "hb-ope-edit" //
230 #define ICONNAME_HB_OPE_MULTIEDIT "hb-ope-multiedit" //
231 #define ICONNAME_HB_OPE_DELETE "hb-ope-delete" //? "edit-delete"
232 #define ICONNAME_CONVERT "hb-ope-convert"
233 #define ICONNAME_HB_ASSIGN_RUN "hb-assign-run"
234
235 #define ICONNAME_HB_OPE_VALID "hb-ope-valid" // obsolete ?
236 #define ICONNAME_HB_OPE_CLEARED "hb-ope-cleared"
237 #define ICONNAME_HB_OPE_RECONCILED "hb-ope-reconciled"
238 #define ICONNAME_HB_OPE_REMIND "hb-ope-remind"
239
240
241
242 /*
243 ** Global application datas
244 */
245 struct HomeBank
246 {
247 // hbfile storage
248 GHashTable *h_cur; //currencies
249 GHashTable *h_acc; //accounts
250 GHashTable *h_pay; //payees
251 GHashTable *h_cat; //categories
252 GHashTable *h_tag; //tags
253 GHashTable *h_rul; //assign rules
254
255 GHashTable *h_memo; //memo/description
256
257 GList *arc_list; //archives
258
259 //#1419304 we keep the deleted txn to a stack trash
260 GTrashStack *txn_stk;
261
262 // hbfile (saved properties)
263 gchar *owner;
264 gshort auto_smode;
265 gshort auto_weekday;
266 gshort auto_nbdays;
267
268 guint32 vehicle_category;
269 guint32 kcur; // base currency
270
271 // hbfile (unsaved properties)
272 guint changes_count;
273 gboolean hbfile_is_new;
274 gchar *xhb_filepath;
275 gboolean xhb_hasbak; //file has backup (*.xhb~) used for revert menu sensitivity
276
277 // really global stuffs
278 gboolean first_run;
279 guint32 today; //today's date
280 gint define_off; //>0 when a stat, account window is opened
281 gboolean minor;
282
283 GtkWidget *mainwindow; //should be global to access attached window data
284 GtkIconTheme *icontheme;
285 //GdkPixbuf *lst_pixbuf[NUM_LST_PIXBUF];
286 //gint lst_pixbuf_maxwidth;
287
288 };
289
290 gint homebank_alienfile_recognize(gchar *filename);
291 gchar *homebank_filepath_with_extention(gchar *path, gchar *extension);
292 gchar *homebank_filename_without_extention(gchar *path);
293 void homebank_file_ensure_xhb(gchar *filename);
294 void homebank_backup_current_file(void);
295 gboolean homebank_util_url_show (const gchar *url);
296 gboolean homebank_lastopenedfiles_load(void);
297 gboolean homebank_lastopenedfiles_save(void);
298
299
300 void homebank_window_set_icon_from_file(GtkWindow *window, gchar *filename);
301
302 const gchar *homebank_app_get_config_dir (void);
303 const gchar *homebank_app_get_images_dir (void);
304 const gchar *homebank_app_get_pixmaps_dir (void);
305 const gchar *homebank_app_get_locale_dir (void);
306 const gchar *homebank_app_get_help_dir (void);
307 const gchar *homebank_app_get_datas_dir (void);
308 guint32 homebank_app_date_get_julian(void);
309
310 /* - - - - obsolete things - - - - */
311
312 /*
313 typedef struct _budget Budget;
314
315 struct _budget
316 {
317 guint key;
318 gushort flags;
319 guint cat_key;
320 guint year;
321 gdouble value[13];
322 };
323 */
324
325 /*
326 struct _investment
327 {
328 guint date;
329 gdouble buy_amount;
330 gdouble curr_amount;
331 gdouble commission;
332 guint number;
333 guint account;
334 gchar *name;
335 gchar *symbol;
336 gchar *note;
337 };
338 */
339
340 #endif
This page took 0.042478 seconds and 4 git commands to generate.