]> Dogcows Code - chaz/homebank/blob - src/homebank.h
import homebank-5.2.4
[chaz/homebank] / src / homebank.h
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2019 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 #define HB_UNSTABLE_SHOW FALSE
73
74
75 #define HB_VERSION_MAJOR 5
76 #define HB_VERSION_MINOR 2
77 #define HB_VERSION_MICRO 4
78
79 #define HB_VERSION "5.2.4"
80 #define HB_VERSION_NUM (HB_VERSION_MAJOR*10000) + (HB_VERSION_MINOR*100) + HB_VERSION_MICRO
81
82 #define FILE_VERSION 1.3
83 #define PREF_VERSION 524
84
85 #if HB_UNSTABLE == FALSE
86 #define PROGNAME "HomeBank"
87 #define HB_DATA_PATH "homebank"
88 #else
89 #define PROGNAME "HomeBank " HB_VERSION " (unstable)"
90 #define HB_DATA_PATH "homebank_unstable"
91 #endif
92
93
94 #ifdef G_OS_WIN32
95 #define GETTEXT_PACKAGE "homebank"
96 #define LOCALE_DIR "locale"
97 #define PIXMAPS_DIR "images"
98 #define HELP_DIR "help"
99 #define PACKAGE_VERSION HB_VERSION
100 #define PACKAGE "homebank"
101 #define VERSION HB_VERSION
102
103 //#define PORTABLE_APP
104 //#define NOOFX
105
106 #define ENABLE_NLS 1
107 #endif
108
109
110 /* container spacing */
111 #define SPACING_TINY 3
112 #define SPACING_SMALL 6
113 #define SPACING_MEDIUM 12
114 #define SPACING_LARGE 18
115
116 #define HB_DATE_MAX_GAP 7
117
118 // those 2 line are duplicated into dateentry
119 #define HB_MINDATE 693596 //01/01/1900
120 #define HB_MAXDATE 803533 //31/12/2200
121
122 /* widget minimum width */
123 #define HB_MINWIDTH_LIST 161
124 #define HB_MINHEIGHT_LIST 260
125
126 #define HB_MINWIDTH_SEARCH 240
127 #define HB_MINWIDTH_COLUMN 48
128
129
130 /* miscellaneous */
131 #define PHI 1.61803399
132
133
134
135 #define HB_NUMBER_SAMPLE 1234567.89
136
137
138 typedef enum
139 {
140 FILETYPE_UNKNOWN,
141 FILETYPE_HOMEBANK,
142 FILETYPE_OFX,
143 FILETYPE_QIF,
144 FILETYPE_CSV_HB,
145 // FILETYPE_AMIGA_HB,
146 NUM_FILETYPE
147 } HbFileType;
148
149
150 /* ---- icon size as defined into gtkiconfactory.c ---- */
151 /* GTK_ICON_SIZE_MENU 16
152 * GTK_ICON_SIZE_BUTTON 20
153 * GTK_ICON_SIZE_SMALL_TOOLBAR 18
154 * GTK_ICON_SIZE_LARGE_TOOLBAR 24 (default for toolbar)
155 * GTK_ICON_SIZE_DND 32
156 * GTK_ICON_SIZE_DIALOG 48
157 */
158
159
160 /* -------- named icons (Standard Icon Name) -------- */
161
162
163 //obsolete, as since since gtk3.10 : no more icons for dialogs and menu
164 #define ICONNAME_SAVE_AS "document-save-as" //obsolete
165 #define ICONNAME_REVERT "document-revert" //obsolete
166 #define ICONNAME_PROPERTIES "document-properties" //obsolete
167 #define ICONNAME_CLOSE "window-close" //obsolete
168 #define ICONNAME_QUIT "application-exit" //obsolete
169 #define ICONNAME_HELP "help-browser" //obsolete
170 #define ICONNAME_ABOUT "help-about" //obsolete
171 #define ICONNAME_PREFERENCES "preferences-system" //obsolete
172
173
174 //#define ICONNAME_FIND "edit-find" //unused
175 //#define ICONNAME_CLEAR "edit-clear" //unused
176 //#define ICONNAME_HB_SCHED_SKIP "media-skip-forward"
177 //#define ICONNAME_HB_SCHED_POST "media-playback-start"
178
179 //in 5.2 no themeable icon to keep a consistent iconset
180
181 #define ICONNAME_WARNING "dialog-warning"
182 #define ICONNAME_ERROR "dialog-error"
183 #define ICONNAME_INFO "dialog-information"
184
185
186 #define ICONNAME_FOLDER "folder-symbolic"
187 #define ICONNAME_EMBLEM_OK "emblem-ok-symbolic"
188 #define ICONNAME_EMBLEM_SYSTEM "emblem-system-symbolic"
189 #define ICONNAME_WINDOW_CLOSE "window-close-symbolic"
190 #define ICONNAME_LIST_ADD "list-add-symbolic"
191 #define ICONNAME_LIST_REMOVE "list-remove-symbolic"
192 #define ICONNAME_LIST_REMOVE_ALL "list-remove-all-symbolic"
193 #define ICONNAME_CHANGES_PREVENT "changes-prevent-symbolic"
194 #define ICONNAME_SYSTEM_SEARCH "system-search-symbolic"
195
196 // custom or gnome not found
197 #define ICONNAME_HB_BUTTON_MENU "open-menu-symbolic"
198 #define ICONNAME_HB_BUTTON_COLLAPSE "list-collapse-all-symbolic"
199 #define ICONNAME_HB_BUTTON_EXPAND "list-expand-all-symbolic"
200 #define ICONNAME_HB_BUTTON_SPLIT "edit-split-symbolic"
201 #define ICONNAME_HB_TOGGLE_SIGN "toggle-sign-symbolic"
202
203
204 /* -------- named icons (Custom to homebank) -------- */
205
206
207 #define ICONNAME_HB_CURRENCY "hb-currency"
208 #define ICONNAME_HB_ACCOUNT "hb-account"
209 #define ICONNAME_HB_ARCHIVE "hb-archive"
210 #define ICONNAME_HB_ASSIGN "hb-assign"
211 #define ICONNAME_HB_BUDGET "hb-budget"
212 #define ICONNAME_HB_CATEGORY "hb-category"
213 #define ICONNAME_HB_PAYEE "hb-payee"
214 #define ICONNAME_HB_OPE_SHOW "hb-ope-show" //? "view-register
215 #define ICONNAME_HB_REP_STATS "hb-rep-stats"
216 #define ICONNAME_HB_REP_TIME "hb-rep-time"
217 #define ICONNAME_HB_REP_BALANCE "hb-rep-balance"
218 #define ICONNAME_HB_REP_BUDGET "hb-rep-budget"
219 #define ICONNAME_HB_REP_CAR "hb-rep-vehicle"
220
221 #define ICONNAME_HB_VIEW_LIST "hb-view-list" //"view-list-text"
222 #define ICONNAME_HB_VIEW_BAR "hb-view-bar" //"view-chart-bar"
223 #define ICONNAME_HB_VIEW_COLUMN "hb-view-column" //"view-chart-column"
224 #define ICONNAME_HB_VIEW_LINE "hb-view-line" //"view-chart-line"
225 #define ICONNAME_HB_VIEW_STACK "hb-view-stack" //"view-chart-stack"
226 #define ICONNAME_HB_VIEW_PIE "hb-view-pie" //"view-chart-pie"
227 #define ICONNAME_HB_VIEW_DONUT "hb-view-donut" //"view-chart-donut"
228 #define ICONNAME_HB_SHOW_LEGEND "hb-legend" //"view-legend"
229 #define ICONNAME_HB_SHOW_RATE "hb-rate" // obsolete ?
230 #define ICONNAME_HB_REFRESH "hb-view-refresh" //"view-refresh"
231 #define ICONNAME_HB_FILTER "hb-filter" //"edit-filter"
232
233 #define ICONNAME_HB_FILE_NEW "hb-document-new" //document-new
234 #define ICONNAME_HB_FILE_OPEN "hb-document-open" //document-open
235 #define ICONNAME_HB_FILE_SAVE "hb-document-save" //document-save
236 //#define ICONNAME_PRINT "document-print"
237 #define ICONNAME_HB_FILE_IMPORT "hb-file-import" //document-import
238 #define ICONNAME_HB_FILE_EXPORT "hb-file-export" //document-export
239 #define ICONNAME_HB_FILE_VALID "hb-file-valid"
240 #define ICONNAME_HB_FILE_INVALID "hb-file-invalid"
241
242 #define ICONNAME_HB_OPE_AUTO "hb-ope-auto" //?
243 #define ICONNAME_HB_OPE_BUDGET "hb-ope-budget" //?
244 #define ICONNAME_HB_OPE_ADD "hb-ope-add" //? "edit-add"
245 #define ICONNAME_HB_OPE_HERIT "hb-ope-herit" //? "edit-clone"
246 #define ICONNAME_HB_OPE_EDIT "hb-ope-edit" //
247 #define ICONNAME_HB_OPE_MULTIEDIT "hb-ope-multiedit" //
248 #define ICONNAME_HB_OPE_DELETE "hb-ope-delete" //? "edit-delete"
249 #define ICONNAME_CONVERT "hb-ope-convert" // obsolete ?
250 #define ICONNAME_HB_ASSIGN_RUN "hb-assign-run"
251
252 #define ICONNAME_HB_OPE_NEW "hb-ope-new"
253 // edit is defined above
254 #define ICONNAME_HB_OPE_REMIND "hb-ope-remind"
255 #define ICONNAME_HB_OPE_SIMILAR "hb-ope-similar"
256
257 #define ICONNAME_HB_OPE_CLEARED "hb-ope-cleared"
258 #define ICONNAME_HB_OPE_RECONCILED "hb-ope-reconciled"
259 #define ICONNAME_HB_OPE_FUTURE "hb-ope-future"
260
261
262 /*
263 ** Global application datas
264 */
265 struct HomeBank
266 {
267 // hbfile storage
268 GHashTable *h_cur; //currencies
269 GHashTable *h_acc; //accounts
270 GHashTable *h_pay; //payees
271 GHashTable *h_cat; //categories
272 GHashTable *h_tag; //tags
273 GHashTable *h_rul; //assign rules
274
275 GHashTable *h_memo; //memo/description
276
277 GList *arc_list; //archives
278
279 //#1419304 we keep the deleted txn to a stack trash
280 GTrashStack *txn_stk;
281
282 // hbfile (saved properties)
283 gchar *owner;
284 gshort auto_smode;
285 gshort auto_weekday;
286 gshort auto_nbdays;
287
288 guint32 vehicle_category;
289 guint32 kcur; // base currency
290
291 // hbfile (unsaved properties)
292 guint changes_count;
293 gboolean hbfile_is_new;
294 gboolean hbfile_is_bak;
295 gchar *xhb_filepath;
296 gboolean xhb_hasrevert; //file has backup (*.xhb~) used for revert menu sensitivity
297 guint64 xhb_timemodified;
298
299 // really global stuffs
300 gboolean first_run;
301 guint32 today; //today's date
302 gint define_off; //>0 when a stat, account window is opened
303 gboolean minor;
304
305 GtkWidget *mainwindow; //should be global to access attached window data
306 GtkWidget *alltxnwindow; //window to mutex all txn show
307 GtkIconTheme *icontheme;
308 //GdkPixbuf *lst_pixbuf[NUM_LST_PIXBUF];
309 //gint lst_pixbuf_maxwidth;
310
311 };
312
313 gint homebank_alienfile_recognize(gchar *filename);
314 gchar *homebank_filepath_with_extention(gchar *path, gchar *extension);
315 gchar *homebank_filename_without_extention(gchar *path);
316 void homebank_file_ensure_xhb(gchar *filename);
317 void homebank_backup_current_file(void);
318 gboolean homebank_util_url_show (const gchar *url);
319 gchar *homebank_lastopenedfiles_load(void);
320 gboolean homebank_lastopenedfiles_save(void);
321
322
323 void homebank_window_set_icon_from_file(GtkWindow *window, gchar *filename);
324
325 const gchar *homebank_app_get_config_dir (void);
326 const gchar *homebank_app_get_images_dir (void);
327 const gchar *homebank_app_get_pixmaps_dir (void);
328 const gchar *homebank_app_get_locale_dir (void);
329 const gchar *homebank_app_get_help_dir (void);
330 const gchar *homebank_app_get_datas_dir (void);
331 guint32 homebank_app_date_get_julian(void);
332
333 /* - - - - obsolete things - - - - */
334
335 /*
336 typedef struct _budget Budget;
337
338 struct _budget
339 {
340 guint key;
341 gushort flags;
342 guint cat_key;
343 guint year;
344 gdouble value[13];
345 };
346 */
347
348 /*
349 struct _investment
350 {
351 guint date;
352 gdouble buy_amount;
353 gdouble curr_amount;
354 gdouble commission;
355 guint number;
356 guint account;
357 gchar *name;
358 gchar *symbol;
359 gchar *note;
360 };
361 */
362
363 #endif
This page took 0.049769 seconds and 4 git commands to generate.