1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2017 Maxime DOYEN
4 * This file is part of HomeBank.
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.
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.
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/>.
23 #include "dsp_mainwindow.h"
24 #include "hb-preferences.h"
33 #define APPLICATION_NAME "HomeBank"
35 /****************************************************************************/
37 /****************************************************************************/
46 /* our global datas */
47 struct HomeBank
*GLOBALS
;
48 struct Preferences
*PREFS
;
51 /* installation paths */
52 static gchar
*config_dir
= NULL
;
53 static gchar
*images_dir
= NULL
;
54 static gchar
*pixmaps_dir
= NULL
;
55 static gchar
*locale_dir
= NULL
;
56 static gchar
*help_dir
= NULL
;
57 static gchar
*datas_dir
= NULL
;
58 static gchar
*pkglib_dir
= NULL
;
61 //#define MARKUP_STRING "<span size='small'>%s</span>"
64 /* Application arguments */
65 static gboolean arg_version
= FALSE
;
66 static gchar
**files
= NULL
;
68 static GOptionEntry option_entries
[] =
70 { "version", '\0', 0, G_OPTION_ARG_NONE
, &arg_version
,
71 N_("Output version information and exit"), NULL
},
73 { G_OPTION_REMAINING
, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY
, &files
,
81 ** try to determine the file type (if supported for import by homebank)
85 gint
homebank_alienfile_recognize(gchar
*filename
)
88 gint i
, retval
= FILETYPE_UNKNOW
;
92 static gint csvtype
[7] = {
103 DB( g_print("\n[homebank] alienfile_recognize\n") );
106 io
= g_io_channel_new_file(filename
, "r", NULL
);
109 g_io_channel_set_encoding(io
, NULL
, NULL
); /* set to binary mode */
113 if( retval
!= FILETYPE_UNKNOW
)
116 io_stat
= g_io_channel_read_line(io
, &tmpstr
, NULL
, NULL
, &err
);
117 if( io_stat
== G_IO_STATUS_EOF
)
119 if( io_stat
== G_IO_STATUS_ERROR
)
121 DB (g_print(" + ERROR %s\n",err
->message
));
124 if( io_stat
== G_IO_STATUS_NORMAL
)
126 if( *tmpstr
!= '\0' )
128 DB( g_print(" line %d: '%s' retval=%d\n", i
, tmpstr
, retval
) );
130 /* native homebank file */
131 if( g_str_has_prefix(tmpstr
, "<homebank v="))
133 DB( g_print(" type is HomeBank\n") );
134 retval
= FILETYPE_HOMEBANK
;
139 if( g_str_has_prefix(tmpstr
, "!Type") ||
140 g_str_has_prefix(tmpstr
, "!type") ||
141 g_str_has_prefix(tmpstr
, "!Option") ||
142 g_str_has_prefix(tmpstr
, "!option") ||
143 g_str_has_prefix(tmpstr
, "!Account") ||
144 g_str_has_prefix(tmpstr
, "!account")
147 DB( g_print(" type is QIF\n") );
148 retval
= FILETYPE_QIF
;
153 if( g_strstr_len(tmpstr
, 10, "OFX") != NULL
)
155 DB( g_print(" type is OFX\n") );
156 retval
= FILETYPE_OFX
;
159 /* is it csv homebank ? */
163 gboolean isvalid
= FALSE
;
165 hb_string_strip_crlf(tmpstr
);
166 str_array
= hb_csv_row_get(tmpstr
, ";", 8);
167 isvalid
= hb_csv_row_valid(str_array
, 8, csvtype
);
169 DB( g_print(" hbcsv %d\n", isvalid
) );
171 if( isvalid
== TRUE
)
173 DB( g_print(" type is CSV homebank\n") );
174 retval
= FILETYPE_CSV_HB
;
177 g_strfreev (str_array
);
183 g_io_channel_unref (io
);
190 /* = = = = = = = = = = = = = = = = = = = = */
194 ** ensure the filename ends with '.xhb'
196 void homebank_file_ensure_xhb(gchar
*filename
)
198 DB( g_print("\n[homebank] file_ensure_xhb\n") );
199 filename
= (filename
== NULL
) ? g_strdup(GLOBALS
->xhb_filepath
) : filename
;
200 if( g_str_has_suffix (filename
, ".xhb") == FALSE
)
204 newfilename
= hb_util_filename_new_with_extension(filename
, "xhb");
205 hbfile_change_filepath(newfilename
);
206 DB( g_print(" - changed to: '%s'\n", GLOBALS
->xhb_filepath
) );
211 hbfile_change_filepath(filename
);
216 static gboolean
homebank_copy_file(gchar
*srcfile
, gchar
*dstfile
)
220 //GError *error = NULL;
221 gboolean retval
= FALSE
;
223 if (g_file_get_contents (srcfile
, &buffer
, &length
, NULL
))
225 if(g_file_set_contents(dstfile
, buffer
, length
, NULL
))
235 void homebank_backup_current_file(void)
239 DB( g_print("\n[homebank] backup_current_file\n") );
241 bakfilename
= hb_util_filename_new_with_extension (GLOBALS
->xhb_filepath
, "xhb~");
242 if( g_file_test(bakfilename
, G_FILE_TEST_EXISTS
) )
244 DB( g_print(" - delete existing: '%s'\n", bakfilename
) );
245 g_remove(bakfilename
);
248 DB( g_print(" - copy '%s' => '%s'\n", GLOBALS
->xhb_filepath
, bakfilename
) );
250 //#512046 copy file not to broke potential links
251 //retval = g_rename(pathname, newname);
252 homebank_copy_file (GLOBALS
->xhb_filepath
, bakfilename
);
257 /* = = = = = = = = = = = = = = = = = = = = */
265 homebank_util_url_show_win32 (const gchar
*url
)
271 retval
= ShellExecuteA (NULL
, "open", url
, NULL
, NULL
, SW_NORMAL
);
273 if (retval
< 0 || retval
> 32)
276 errmsg
= g_win32_error_message(retval
);
277 DB( g_print ("%s\n", errmsg
) );
286 homebank_util_url_show_unix (const gchar
*url
)
291 retval
= gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (GLOBALS
->mainwindow
)), url
, GDK_CURRENT_TIME
, &err
);
295 ui_dialog_msg_infoerror(GTK_WINDOW(GLOBALS
->mainwindow
), GTK_MESSAGE_ERROR
,
297 _("Could not display the URL '%s'"),
304 g_print ("%s\n", err
->message
);
314 homebank_util_url_show (const gchar
*url
)
322 return homebank_util_url_show_win32 (url
);
324 return homebank_util_url_show_unix (url
);
329 /* = = = = = = = = = = = = = = = = = = = = */
330 /* lastopenedfiles */
333 ** load lastopenedfiles from homedir/.homebank
335 gboolean
homebank_lastopenedfiles_load(void)
338 gboolean retval
= FALSE
;
339 gchar
*group
, *filename
, *lastfilename
;
341 DB( g_print("\n[homebank] lastopenedfiles load\n") );
343 keyfile
= g_key_file_new();
347 filename
= g_build_filename(homebank_app_get_config_dir(), "lastopenedfiles", NULL
);
349 DB( g_print(" - filename: %s\n", filename
) );
351 if(g_key_file_load_from_file (keyfile
, filename
, G_KEY_FILE_NONE
, NULL
))
355 DB( g_print(" - load keyfile ok\n") );
357 if(g_key_file_has_key(keyfile
, group
, "LastOpenedFile", NULL
))
359 DB( g_print(" - keyfile has key ok\n") );
361 lastfilename
= g_key_file_get_string (keyfile
, group
, "LastOpenedFile", NULL
);
363 DB( g_print(" - lastfile loaded: %s\n", lastfilename
) );
365 if (g_file_test (lastfilename
, G_FILE_TEST_EXISTS
) != FALSE
)
367 DB( g_print(" - file exists\n") );
369 hbfile_change_filepath(lastfilename
);
376 g_key_file_free (keyfile
);
379 DB( g_print(" - return: %d\n", retval
) );
386 ** save lastopenedfiles to homedir/.homebank (HB_DATA_PATH)
388 gboolean
homebank_lastopenedfiles_save(void)
391 gboolean retval
= FALSE
;
392 gchar
*group
, *filename
;
395 DB( g_print("\n[homebank] lastopenedfiles save\n") );
397 if( GLOBALS
->xhb_filepath
!= NULL
)
399 keyfile
= g_key_file_new();
402 DB( g_print(" - saving '%s'\n", GLOBALS
->xhb_filepath
) );
405 g_key_file_set_string (keyfile
, group
, "LastOpenedFile", GLOBALS
->xhb_filepath
);
407 gchar
*contents
= g_key_file_to_data( keyfile
, &length
, NULL
);
409 //DB( g_print(" keyfile:\n%s\nlen=%d\n", contents, length) );
411 filename
= g_build_filename(homebank_app_get_config_dir(), "lastopenedfiles", NULL
);
412 g_file_set_contents(filename
, contents
, length
, NULL
);
416 g_key_file_free (keyfile
);
425 /* = = = = = = = = = = = = = = = = = = = = */
428 static GtkCssProvider
*provider
;
431 homebank_theme_changed (GtkSettings
*settings
, GParamSpec
*pspec
, gpointer data
)
434 if (pspec
== NULL
|| g_str_equal (pspec
->name
, "gtk-theme-name"))
439 g_object_get (settings
, "gtk-theme-name", &theme
, NULL
);
440 screen
= gdk_screen_get_default ();
442 DB( g_print("theme %s\n", theme
) );
444 if (g_str_equal (theme
, "gtk-win32"))
446 if (provider
== NULL
)
450 filename
= g_build_filename(homebank_app_get_datas_dir(), "homebank-gtk-win32.css", NULL
);
451 DB( g_print("tweak file %s\n", filename
) );
453 if( g_file_test(filename
, G_FILE_TEST_EXISTS
) )
455 provider
= gtk_css_provider_new ();
456 gtk_css_provider_load_from_path (provider
, filename
, NULL
);
463 DB( g_print(" assign provider %p to screen %p\n", provider
, screen
) );
465 gtk_style_context_add_provider_for_screen (screen
,
466 GTK_STYLE_PROVIDER (provider
),
467 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
);
470 else if (provider
!= NULL
)
472 gtk_style_context_remove_provider_for_screen (screen
,
473 GTK_STYLE_PROVIDER (provider
));
474 g_clear_object (&provider
);
482 homebank_setup_theme_extensions (void)
484 GtkSettings
*settings
;
486 settings
= gtk_settings_get_default ();
488 g_signal_connect (settings
, "notify", G_CALLBACK (homebank_theme_changed
), NULL
);
489 homebank_theme_changed (settings
, NULL
, NULL
);
495 homebank_icon_theme_setup()
497 DB( g_print("\n[homebank] icon_theme_setup\n") );
499 GLOBALS
->icontheme
= gtk_icon_theme_get_default();
501 DB( g_print(" - prepend theme search path: %s\n", homebank_app_get_pixmaps_dir()) );
502 gtk_icon_theme_prepend_search_path (GLOBALS
->icontheme
, homebank_app_get_pixmaps_dir());
503 //DB( g_print(" - append theme search path: %s\n", homebank_app_get_pixmaps_dir()) );
504 //gtk_icon_theme_append_search_path (GLOBALS->icontheme, homebank_app_get_pixmaps_dir());
508 GtkIconTheme
*ic
= gtk_icon_theme_get_default();
512 DB( g_print(" - get default icon theme\n") );
514 gtk_icon_theme_get_search_path(ic
, &paths
, NULL
);
515 for(i
=0;i
<g_strv_length(paths
);i
++)
517 g_print(" - path %d: %s\n", i
, paths
[i
]);
529 homebank_app_get_config_dir (void)
535 homebank_app_get_images_dir (void)
541 homebank_app_get_pixmaps_dir (void)
547 homebank_app_get_locale_dir (void)
553 homebank_app_get_help_dir (void)
559 homebank_app_get_datas_dir (void)
565 homebank_app_get_pkglib_dir (void)
571 /* build package paths at runtime */
573 build_package_paths (void)
575 DB( g_print("\n[homebank] build_package_paths\n") );
580 prefix
= g_win32_get_package_installation_directory_of_module (NULL
);
581 locale_dir
= g_build_filename (prefix
, "share", "locale", NULL
);
582 images_dir
= g_build_filename (prefix
, "share", PACKAGE
, "images", NULL
);
583 pixmaps_dir
= g_build_filename (prefix
, "share", PACKAGE
, "icons", NULL
);
584 help_dir
= g_build_filename (prefix
, "share", PACKAGE
, "help", NULL
);
585 datas_dir
= g_build_filename (prefix
, "share", PACKAGE
, "datas", NULL
);
586 pkglib_dir
= g_build_filename (prefix
, "lib", PACKAGE
, NULL
);
588 DB( g_print(" - app is portable under windows\n") );
589 config_dir
= g_build_filename(prefix
, "config", NULL
);
591 config_dir
= g_build_filename(g_get_user_config_dir(), HB_DATA_PATH
, NULL
);
595 locale_dir
= g_build_filename (DATA_DIR
, "locale", NULL
);
596 images_dir
= g_build_filename (SHARE_DIR
, "images", NULL
);
597 pixmaps_dir
= g_build_filename (DATA_DIR
, PACKAGE
, "icons", NULL
);
598 help_dir
= g_build_filename (DATA_DIR
, PACKAGE
, "help", NULL
);
599 datas_dir
= g_build_filename (DATA_DIR
, PACKAGE
, "datas", NULL
);
600 pkglib_dir
= g_build_filename (PKGLIB_DIR
, NULL
);
601 config_dir
= g_build_filename(g_get_user_config_dir(), HB_DATA_PATH
, NULL
);
603 //#870023 Ubuntu packages the help files in "/usr/share/doc/homebank-data/help/" for some strange reason
604 if(! g_file_test(help_dir
, (G_FILE_TEST_EXISTS
| G_FILE_TEST_IS_DIR
)))
607 help_dir
= g_build_filename ("/usr", "share", "doc", "homebank-data", "help", NULL
);
611 DB( g_print(" - config_dir : %s\n", config_dir
) );
612 DB( g_print(" - images_dir : %s\n", images_dir
) );
613 DB( g_print(" - pixmaps_dir: %s\n", pixmaps_dir
) );
614 DB( g_print(" - locale_dir : %s\n", locale_dir
) );
615 DB( g_print(" - help_dir : %s\n", help_dir
) );
616 DB( g_print(" - datas_dir : %s\n", datas_dir
) );
617 DB( g_print(" - pkglib_dir : %s\n", pkglib_dir
) );
622 guint32
homebank_app_date_get_julian(void)
625 //init global default value
627 g_date_set_time_t(date
, time(NULL
));
628 GLOBALS
->today
= g_date_get_julian(date
);
630 return GLOBALS
->today
;
634 static gboolean
homebank_check_app_dir_migrate_file(gchar
*srcdir
, gchar
*dstdir
, gchar
*filename
)
640 //GError *error = NULL;
641 gboolean retval
= FALSE
;
643 DB( g_print("\n[homebank] check_app_dir_migrate_file\n") );
645 srcpath
= g_build_filename(srcdir
, filename
, NULL
);
646 dstpath
= g_build_filename(dstdir
, filename
, NULL
);
648 if (g_file_get_contents (srcpath
, &buffer
, &length
, NULL
))
650 if(g_file_set_contents(dstpath
, buffer
, length
, NULL
))
652 //g_print("sould delete %s\n", srcpath);
665 * check/create user home directory for .homebank (HB_DATA_PATH) directory
667 static void homebank_check_app_dir()
670 const gchar
*configdir
;
673 DB( g_print("\n[homebank] check_app_dir\n") );
675 /* check if <userdir>/.config exist */
677 configdir
= g_get_user_config_dir();
678 DB( g_print(" - check '%s' exists\n", configdir
) );
679 if(!g_file_test(configdir
, G_FILE_TEST_IS_DIR
))
681 DB( g_print(" - creating dir\n") );
682 g_mkdir(configdir
, 0755);
686 /* check for XDG .config/homebank */
687 configdir
= homebank_app_get_config_dir();
688 DB( g_print(" - config_dir is: '%s'\n", configdir
) );
689 exists
= g_file_test(configdir
, G_FILE_TEST_IS_DIR
);
692 /* just update folder security */
693 DB( g_print(" - chmod 0700\n") );
694 g_chmod(configdir
, 0700);
695 GLOBALS
->first_run
= FALSE
;
699 /* create the config dir */
700 DB( g_print(" - create config_dir\n") );
701 g_mkdir(configdir
, 0755);
702 g_chmod(configdir
, 0700);
704 /* any old homedir configuration out there ? */
705 homedir
= g_build_filename(g_get_home_dir (), ".homebank", NULL
);
706 DB( g_print(" - homedir is: '%s'\n", homedir
) );
708 exists
= g_file_test(homedir
, G_FILE_TEST_IS_DIR
);
712 /* we must do the migration properly */
713 DB( g_print(" - migrate old 2 files\n") );
714 f1
= homebank_check_app_dir_migrate_file(homedir
, config_dir
, "preferences");
715 f2
= homebank_check_app_dir_migrate_file(homedir
, config_dir
, "lastopenedfiles");
718 DB( g_print(" - removing old dir\n") );
723 GLOBALS
->first_run
= TRUE
;
730 ** application cleanup: icons, GList, memory
732 static void homebank_cleanup()
735 DB( g_print("\n[homebank] cleanup\n") );
737 //v3.4 save windows size/position
738 homebank_pref_save();
740 hbfile_cleanup(TRUE
);
742 /* free our global datas */
745 homebank_pref_free();
756 g_free (pixmaps_dir
);
766 ** application setup: icons, GList, memory
768 static gboolean
homebank_setup()
771 DB( g_print("\n[homebank] setup\n") );
773 GLOBALS
= g_malloc0(sizeof(struct HomeBank
));
774 if(!GLOBALS
) return FALSE
;
775 PREFS
= g_malloc0(sizeof(struct Preferences
));
776 if(!PREFS
) return FALSE
;
778 // check homedir for .homebank dir
779 homebank_check_app_dir();
781 homebank_pref_setdefault();
782 homebank_pref_load();
786 homebank_icon_theme_setup();
789 homebank_setup_theme_extensions();
792 homebank_app_date_get_julian();
797 g_print(" - user_name: %s\n", g_get_user_name ());
798 g_print(" - real_name: %s\n", g_get_real_name ());
799 g_print(" - user_cache_dir: %s\n", g_get_user_cache_dir());
800 g_print(" - user_data_dir: %s\n", g_get_user_data_dir ());
801 g_print(" - user_config_dir: %s\n", g_get_user_config_dir ());
802 //g_print(" - system_data_dirs: %s\n", g_get_system_data_dirs ());
803 //g_print(" - system_config_dirs: %s\n", g_get_system_config_dirs ());
805 g_print(" - home_dir: %s\n", g_get_home_dir ());
806 g_print(" - tmp_dir: %s\n", g_get_tmp_dir ());
807 g_print(" - current_dir: %s\n", g_get_current_dir ());
815 /* = = = = = = = = = = = = = = = = = = = = */
819 homebank_construct_splash()
822 GtkWidget
*frame
, *vbox
, *image
;
823 //gchar *ver_string, *markup, *version;
826 DB( g_print("\n[homebank_construct_splash]\n") );
828 window
= gtk_window_new(GTK_WINDOW_POPUP
); //TOPLEVEL DONT WORK
829 gtk_window_set_type_hint (GTK_WINDOW (window
), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN
);
830 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window
), TRUE
);
832 gtk_window_set_title (GTK_WINDOW (window
), "HomeBank");
833 gtk_window_set_position (GTK_WINDOW (window
), GTK_WIN_POS_CENTER
);
835 pathfilename
= g_build_filename(homebank_app_get_images_dir(), "splash.png", NULL
);
836 image
= gtk_image_new_from_file((const gchar
*)pathfilename
);
837 g_free(pathfilename
);
839 frame
= gtk_frame_new (NULL
);
840 gtk_frame_set_shadow_type (GTK_FRAME (frame
), GTK_SHADOW_OUT
);
841 gtk_container_add (GTK_CONTAINER (window
), frame
);
843 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, 0);
844 gtk_container_add (GTK_CONTAINER (frame
), vbox
);
847 ver_string = g_strdup_printf(_("Version: HomeBank-%s"), VERSION);
849 version = gtk_label_new(NULL);
850 markup = g_markup_printf_escaped(MARKUP_STRING, ver_string);
851 gtk_label_set_markup(GTK_LABEL(version), markup);
856 gtk_box_pack_start (GTK_BOX (vbox
), image
, FALSE
, FALSE
, 0);
857 //gtk_box_pack_start (GTK_BOX (vbox), version, FALSE, FALSE, 0);
863 homebank_init_i18n (void)
865 /* We may change the locale later if the user specifies a language
866 * in the gimprc file. Here we are just initializing the locale
867 * according to the environment variables and set up the paths to
868 * the message catalogs.
871 setlocale (LC_ALL
, "");
873 bindtextdomain (GETTEXT_PACKAGE
, homebank_app_get_locale_dir ());
874 //#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
875 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
878 textdomain (GETTEXT_PACKAGE
);
881 gchar *wl = g_win32_getlocale ();
882 DB( g_print(" - win32 locale is '%s'\n", wl) );
890 main (int argc
, char *argv
[], char *env
[])
892 GOptionContext
*option_context
;
893 GOptionGroup
*option_group
;
894 GError
*error
= NULL
;
896 GtkWidget
*splash
= NULL
;
899 DB( g_print("\n--------------------------------" ) );
900 DB( g_print("\nhomebank starting...\n" ) );
902 build_package_paths();
904 homebank_init_i18n ();
906 /* Set up option groups */
907 option_context
= g_option_context_new (NULL
);
909 //g_option_context_set_summary (option_context, _(""));
911 option_group
= g_option_group_new ("homebank",
912 N_("HomeBank options"),
913 N_("HomeBank options"),
915 g_option_group_add_entries (option_group
, option_entries
);
916 g_option_context_set_main_group (option_context
, option_group
);
917 g_option_group_set_translation_domain (option_group
, GETTEXT_PACKAGE
);
919 /* Add Gtk option group */
920 g_option_context_add_group (option_context
, gtk_get_option_group (FALSE
));
922 /* Parse command line */
923 if (!g_option_context_parse (option_context
, &argc
, &argv
, &error
))
925 g_option_context_free (option_context
);
929 g_print ("%s\n", error
->message
);
930 g_error_free (error
);
933 g_print ("An unknown error occurred\n");
938 g_option_context_free (option_context
);
939 option_context
= NULL
;
941 if (arg_version
!= FALSE
)
943 /* Print version information and exit */
944 g_print ("%s\n", PACKAGE
" " VERSION
);
948 /* Pass NULL here since we parsed the gtk+ args already...
949 * from this point all we need a DISPLAY variable to be set.
951 gtk_init (NULL
, NULL
);
953 //todo: sanity check gtk version here ?
955 g_set_application_name (APPLICATION_NAME
);
957 if( homebank_setup() )
959 /* change the locale if a language is specified */
960 language_init (PREFS
->language
);
962 DB( g_print(" - loading plugins\n") );
963 ext_init(&argc
, &argv
, &env
);
966 for (it
= PREFS
->ext_whitelist
; it
; it
= g_list_next(it
)) {
967 ext_load_plugin(it
->data
);
970 gchar
** plugins
= ext_list_plugins();
972 for (plugins_it
= plugins
; *plugins_it
; ++plugins_it
) {
973 gboolean loaded
= ext_is_plugin_loaded(*plugins_it
);
974 g_print("found plugin: %s, loaded: %d\n", *plugins_it
, loaded
);
978 if( PREFS
->showsplash
== TRUE
)
980 splash
= homebank_construct_splash();
981 gtk_window_set_auto_startup_notification (FALSE
);
982 gtk_widget_show_all (splash
);
983 gtk_window_set_auto_startup_notification (TRUE
);
985 // make sure splash is up
986 while (gtk_events_pending ())
987 gtk_main_iteration ();
990 gtk_window_set_default_icon_name ("homebank");
992 DB( g_print(" - creating window\n" ) );
994 mainwin
= (GtkWidget
*)create_hbfile_window (NULL
);
996 GValue mainwin_val
= G_VALUE_INIT
;
997 ext_hook("create_main_window", EXT_OBJECT(&mainwin_val
, mainwin
), NULL
);
1002 //todo: pause on splash
1003 if( PREFS
->showsplash
== TRUE
)
1005 //g_usleep( G_USEC_PER_SEC * 1 );
1006 gtk_widget_hide(splash
);
1007 gtk_widget_destroy(splash
);
1011 #if HB_UNSTABLE == TRUE
1012 /* GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(mainwin),
1013 GTK_DIALOG_DESTROY_WITH_PARENT,
1014 GTK_MESSAGE_WARNING,
1016 "This is a beta version of HomeBank (UNSTABLE)"
1019 gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
1020 "DO NOT USE with important files or do a backup first.\n"
1021 "This kind of release is for <b>TESTING ONLY</b>.\n"
1022 "<u>It may be buggy, crash, or lose your data</u>.\n\n"
1024 "For unstable bugs report, questions, suggestions:\n"
1025 " - <b>DO NOT USE LaunchPad</b>\n"
1026 " - direct email to: <homebank@free.fr>\n\n"
1031 gtk_dialog_run (GTK_DIALOG (dialog));
1032 gtk_widget_destroy (dialog);*/
1035 if(GLOBALS
->first_run
)
1037 ui_mainwindow_action_help_welcome();
1041 while (gtk_events_pending ()) /* make sure splash is gone */
1042 gtk_main_iteration ();
1045 DB( g_print(" - open last file ?\n" ) );
1048 /* load 1st file specified on commandline */
1049 openlast
= PREFS
->loadlast
;
1052 if (g_file_test (files
[0], G_FILE_TEST_EXISTS
) != FALSE
)
1054 DB( g_print(" - should load %s\n", files
[0] ) );
1055 hbfile_change_filepath(g_strdup(files
[0]));
1056 ui_mainwindow_open_internal(mainwin
, NULL
);
1061 g_warning (_("Unable to open '%s', the file does not exist.\n"), files
[0]);
1068 DB( g_print(" - GLOBALS->xhb_filepath: '%s'\n", GLOBALS
->xhb_filepath
) );
1072 if( homebank_lastopenedfiles_load() == TRUE
)
1073 ui_mainwindow_open_internal(mainwin
, NULL
);
1076 /* -- hack to generate a big file -- */
1079 /* update the mainwin display */
1080 ui_mainwindow_update(mainwin
, GINT_TO_POINTER(UF_TITLE
+UF_SENSITIVE
+UF_BALANCE
+UF_VISUAL
));
1082 ext_hook("enter_main_loop", NULL
);
1084 DB( g_print(" - gtk_main()\n" ) );
1088 ext_hook("exit_main_loop", NULL
);
1091 DB( g_print(" - unloading plugins\n") );
1099 return EXIT_SUCCESS
;
1103 /* In case we build this as a windowed application */
1106 #define _stdcall __attribute__((stdcall))
1110 WinMain (struct HINSTANCE__
*hInstance
,
1111 struct HINSTANCE__
*hPrevInstance
,
1115 return main (__argc
, __argv
);