1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2019 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/>.
24 #include "dsp-mainwindow.h"
25 #include "hb-preferences.h"
33 #define APPLICATION_NAME "HomeBank"
36 /****************************************************************************/
38 /****************************************************************************/
47 /* our global datas */
48 struct HomeBank
*GLOBALS
;
49 struct Preferences
*PREFS
;
52 /* installation paths */
53 static gchar
*config_dir
= NULL
;
54 static gchar
*images_dir
= NULL
;
55 static gchar
*pixmaps_dir
= NULL
;
56 static gchar
*locale_dir
= NULL
;
57 static gchar
*help_dir
= NULL
;
58 static gchar
*datas_dir
= NULL
;
59 static gchar
*pkglib_dir
= NULL
;
62 //#define MARKUP_STRING "<span size='small'>%s</span>"
65 /* Application arguments */
66 static gboolean arg_version
= FALSE
;
67 static gchar
**files
= NULL
;
69 static GOptionEntry option_entries
[] =
71 { "version", '\0', 0, G_OPTION_ARG_NONE
, &arg_version
,
72 N_("Output version information and exit"), NULL
},
74 { G_OPTION_REMAINING
, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY
, &files
,
82 /* = = = = = = = = = = = = = = = = = = = = */
86 ** ensure the filename ends with '.xhb'
88 void homebank_file_ensure_xhb(gchar
*filename
)
90 DB( g_print("\n[homebank] file_ensure_xhb\n") );
91 filename
= (filename
== NULL
) ? g_strdup(GLOBALS
->xhb_filepath
) : filename
;
92 if( g_str_has_suffix (filename
, ".xhb") == FALSE
)
96 newfilename
= hb_filename_new_with_extension(filename
, "xhb");
97 hbfile_change_filepath(newfilename
);
98 DB( g_print(" - changed to: '%s'\n", GLOBALS
->xhb_filepath
) );
103 hbfile_change_filepath(filename
);
108 static gboolean
homebank_file_copy(gchar
*srcfile
, gchar
*dstfile
)
112 //GError *error = NULL;
113 gboolean retval
= FALSE
;
115 DB( g_print("\n[homebank] file copy\n") );
117 if (g_file_get_contents (srcfile
, &buffer
, &length
, NULL
))
119 if(g_file_set_contents(dstfile
, buffer
, length
, NULL
))
126 DB( g_print(" - copied '%s' => '%s' :: %d\n", srcfile
, dstfile
, retval
) );
131 static gboolean
homebank_file_delete_existing(gchar
*filepath
)
133 gboolean retval
= FALSE
;
135 DB( g_print("\n[homebank] file delete existing\n") );
137 if( g_file_test(filepath
, G_FILE_TEST_EXISTS
) )
139 DB( g_print(" - deleting: '%s'\n", filepath
) );
145 DB( g_print(" - cannot delete: '%s'\n", filepath
) );
152 void homebank_backup_current_file(void)
158 DB( g_print("\n[homebank] backup_current_file\n") );
160 //do normal linux backup file
161 DB( g_print(" normal backup with ~\n") );
162 bakfilename
= hb_filename_new_with_extension (GLOBALS
->xhb_filepath
, "xhb~");
163 homebank_file_delete_existing(bakfilename
);
164 //#512046 copy file not to broke potential links
165 //retval = g_rename(pathname, newname);
166 homebank_file_copy (GLOBALS
->xhb_filepath
, bakfilename
);
169 //do safe backup according to user preferences
170 DB( g_print(" user pref backup\n") );
171 if( PREFS
->bak_is_automatic
== TRUE
)
173 bakfilename
= hb_filename_new_for_backup(GLOBALS
->xhb_filepath
);
174 if( g_file_test(bakfilename
, G_FILE_TEST_EXISTS
) == FALSE
)
176 homebank_file_copy (GLOBALS
->xhb_filepath
, bakfilename
);
180 //delete any offscale backup
181 DB( g_print(" clean old backup\n") );
182 array
= hb_filename_backup_list(GLOBALS
->xhb_filepath
);
184 DB( g_print(" found %d match\n", array
->len
) );
186 gchar
*dirname
= g_path_get_dirname(GLOBALS
->xhb_filepath
);
188 for(i
=0;i
<(gint
)array
->len
;i
++)
190 gchar
*offscalefilename
= g_ptr_array_index(array
, i
);
192 DB( g_print(" %d : '%s'\n", i
, offscalefilename
) );
193 if( i
>= PREFS
->bak_max_num_copies
)
195 gchar
*bakdelfilepath
= g_build_filename(dirname
, offscalefilename
, NULL
);
197 DB( g_print(" - should delete '%s'\n", bakdelfilepath
) );
199 homebank_file_delete_existing(bakdelfilepath
);
201 g_free(bakdelfilepath
);
204 g_ptr_array_free(array
, TRUE
);
212 /* = = = = = = = = = = = = = = = = = = = = */
220 homebank_util_url_show_win32 (const gchar
*url
)
226 retval
= ShellExecuteA (NULL
, "open", url
, NULL
, NULL
, SW_NORMAL
);
228 if (retval
< 0 || retval
> 32)
231 errmsg
= g_win32_error_message(retval
);
232 DB( g_print ("%s\n", errmsg
) );
241 homebank_util_url_show_unix (const gchar
*url
)
246 retval
= gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (GLOBALS
->mainwindow
)), url
, GDK_CURRENT_TIME
, &err
);
250 ui_dialog_msg_infoerror(GTK_WINDOW(GLOBALS
->mainwindow
), GTK_MESSAGE_ERROR
,
252 _("Could not display the URL '%s'"),
259 g_print ("%s\n", err
->message
);
269 homebank_util_url_show (const gchar
*url
)
277 return homebank_util_url_show_win32 (url
);
279 return homebank_util_url_show_unix (url
);
284 /* = = = = = = = = = = = = = = = = = = = = */
285 /* lastopenedfiles */
288 ** load lastopenedfiles from homedir/.homebank
290 gchar
*homebank_lastopenedfiles_load(void)
293 gchar
*group
, *filename
, *tmpfilename
;
294 gchar
*lastfilename
= NULL
;
295 GError
*error
= NULL
;
297 DB( g_print("\n[homebank] lastopenedfiles load\n") );
299 keyfile
= g_key_file_new();
302 filename
= g_build_filename(homebank_app_get_config_dir(), "lastopenedfiles", NULL
);
303 if(g_key_file_load_from_file (keyfile
, filename
, G_KEY_FILE_NONE
, &error
))
307 if(g_key_file_has_key(keyfile
, group
, "LastOpenedFile", NULL
))
309 tmpfilename
= g_key_file_get_string (keyfile
, group
, "LastOpenedFile", NULL
);
311 if (g_file_test (tmpfilename
, G_FILE_TEST_EXISTS
) != FALSE
)
313 lastfilename
= tmpfilename
;
320 g_print("failed: %s\n", error
->message
);
321 g_error_free (error
);
325 g_key_file_free (keyfile
);
333 ** save lastopenedfiles to homedir/.homebank (HB_DATA_PATH)
335 gboolean
homebank_lastopenedfiles_save(void)
338 gboolean retval
= FALSE
;
339 gchar
*group
, *filename
;
341 GError
*error
= NULL
;
343 DB( g_print("\n[homebank] lastopenedfiles save\n") );
345 if( GLOBALS
->xhb_filepath
!= NULL
)
347 //don't save bakup files
348 if( hbfile_file_isbackup(GLOBALS
->xhb_filepath
) == FALSE
)
350 keyfile
= g_key_file_new();
353 DB( g_print(" - saving '%s'\n", GLOBALS
->xhb_filepath
) );
356 g_key_file_set_string (keyfile
, group
, "LastOpenedFile", GLOBALS
->xhb_filepath
);
358 gchar
*contents
= g_key_file_to_data( keyfile
, &length
, NULL
);
360 //DB( g_print(" keyfile:\n%s\nlen=%d\n", contents, length) );
362 filename
= g_build_filename(homebank_app_get_config_dir(), "lastopenedfiles", NULL
);
364 g_file_set_contents(filename
, contents
, length
, &error
);
369 g_print("failed: %s\n", error
->message
);
370 g_error_free (error
);
374 g_key_file_free (keyfile
);
384 /* = = = = = = = = = = = = = = = = = = = = */
387 static GtkCssProvider
*provider
;
390 homebank_theme_changed (GtkSettings
*settings
, GParamSpec
*pspec
, gpointer data
)
393 if (pspec
== NULL
|| g_str_equal (pspec
->name
, "gtk-theme-name"))
398 g_object_get (settings
, "gtk-theme-name", &theme
, NULL
);
399 screen
= gdk_screen_get_default ();
401 DB( g_print("theme %s\n", theme
) );
403 if (g_str_equal (theme
, "gtk-win32"))
405 if (provider
== NULL
)
409 filename
= g_build_filename(homebank_app_get_datas_dir(), "homebank-gtk-win32.css", NULL
);
410 DB( g_print("tweak file %s\n", filename
) );
412 if( g_file_test(filename
, G_FILE_TEST_EXISTS
) )
414 provider
= gtk_css_provider_new ();
415 gtk_css_provider_load_from_path (provider
, filename
, NULL
);
422 DB( g_print(" assign provider %p to screen %p\n", provider
, screen
) );
424 gtk_style_context_add_provider_for_screen (screen
,
425 GTK_STYLE_PROVIDER (provider
),
426 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
);
429 else if (provider
!= NULL
)
431 gtk_style_context_remove_provider_for_screen (screen
,
432 GTK_STYLE_PROVIDER (provider
));
433 g_clear_object (&provider
);
441 homebank_setup_theme_extensions (void)
443 GtkSettings
*settings
;
445 settings
= gtk_settings_get_default ();
447 g_signal_connect (settings
, "notify", G_CALLBACK (homebank_theme_changed
), NULL
);
448 homebank_theme_changed (settings
, NULL
, NULL
);
454 homebank_icon_theme_setup()
456 DB( g_print("\n[homebank] icon_theme_setup\n") );
458 GLOBALS
->icontheme
= gtk_icon_theme_get_default();
460 DB( g_print(" - prepend theme search path: %s\n", homebank_app_get_pixmaps_dir()) );
461 gtk_icon_theme_prepend_search_path (GLOBALS
->icontheme
, homebank_app_get_pixmaps_dir());
462 //DB( g_print(" - append theme search path: %s\n", homebank_app_get_pixmaps_dir()) );
463 //gtk_icon_theme_append_search_path (GLOBALS->icontheme, homebank_app_get_pixmaps_dir());
467 GtkIconTheme
*ic
= gtk_icon_theme_get_default();
471 DB( g_print(" - get default icon theme\n") );
473 gtk_icon_theme_get_search_path(ic
, &paths
, NULL
);
474 for(i
=0;i
<g_strv_length(paths
);i
++)
476 g_print(" - path %d: %s\n", i
, paths
[i
]);
488 homebank_app_get_config_dir (void)
494 homebank_app_get_images_dir (void)
500 homebank_app_get_pixmaps_dir (void)
506 homebank_app_get_locale_dir (void)
512 homebank_app_get_help_dir (void)
518 homebank_app_get_datas_dir (void)
524 homebank_app_get_pkglib_dir (void)
530 /* build package paths at runtime */
532 build_package_paths (void)
534 DB( g_print("\n[homebank] build_package_paths\n") );
539 prefix
= g_win32_get_package_installation_directory_of_module (NULL
);
540 locale_dir
= g_build_filename (prefix
, "share", "locale", NULL
);
541 images_dir
= g_build_filename (prefix
, "share", PACKAGE
, "images", NULL
);
542 pixmaps_dir
= g_build_filename (prefix
, "share", PACKAGE
, "icons", NULL
);
543 help_dir
= g_build_filename (prefix
, "share", PACKAGE
, "help", NULL
);
544 datas_dir
= g_build_filename (prefix
, "share", PACKAGE
, "datas", NULL
);
545 pkglib_dir
= g_build_filename (prefix
, "lib", PACKAGE
, NULL
);
547 DB( g_print(" - app is portable under windows\n") );
548 config_dir
= g_build_filename(prefix
, "config", NULL
);
550 config_dir
= g_build_filename(g_get_user_config_dir(), HB_DATA_PATH
, NULL
);
554 locale_dir
= g_build_filename (DATA_DIR
, "locale", NULL
);
555 images_dir
= g_build_filename (SHARE_DIR
, "images", NULL
);
556 pixmaps_dir
= g_build_filename (DATA_DIR
, PACKAGE
, "icons", NULL
);
557 help_dir
= g_build_filename (DATA_DIR
, PACKAGE
, "help", NULL
);
558 datas_dir
= g_build_filename (DATA_DIR
, PACKAGE
, "datas", NULL
);
559 pkglib_dir
= g_build_filename (PKGLIB_DIR
, NULL
);
560 config_dir
= g_build_filename(g_get_user_config_dir(), HB_DATA_PATH
, NULL
);
562 //#870023 Ubuntu packages the help files in "/usr/share/doc/homebank-data/help/" for some strange reason
563 if(! g_file_test(help_dir
, (G_FILE_TEST_EXISTS
| G_FILE_TEST_IS_DIR
)))
566 help_dir
= g_build_filename ("/usr", "share", "doc", "homebank-data", "help", NULL
);
570 DB( g_print(" - config_dir : %s\n", config_dir
) );
571 DB( g_print(" - images_dir : %s\n", images_dir
) );
572 DB( g_print(" - pixmaps_dir: %s\n", pixmaps_dir
) );
573 DB( g_print(" - locale_dir : %s\n", locale_dir
) );
574 DB( g_print(" - help_dir : %s\n", help_dir
) );
575 DB( g_print(" - datas_dir : %s\n", datas_dir
) );
576 DB( g_print(" - pkglib_dir : %s\n", pkglib_dir
) );
581 guint32
homebank_app_date_get_julian(void)
584 //init global default value
586 g_date_set_time_t(date
, time(NULL
));
587 GLOBALS
->today
= g_date_get_julian(date
);
589 return GLOBALS
->today
;
593 static gboolean
homebank_check_app_dir_migrate_file(gchar
*srcdir
, gchar
*dstdir
, gchar
*filename
)
599 //GError *error = NULL;
600 gboolean retval
= FALSE
;
602 DB( g_print("\n[homebank] check_app_dir_migrate_file\n") );
604 srcpath
= g_build_filename(srcdir
, filename
, NULL
);
605 dstpath
= g_build_filename(dstdir
, filename
, NULL
);
607 if (g_file_get_contents (srcpath
, &buffer
, &length
, NULL
))
609 if(g_file_set_contents(dstpath
, buffer
, length
, NULL
))
611 //g_print("sould delete %s\n", srcpath);
624 * check/create user home directory for .homebank (HB_DATA_PATH) directory
626 static void homebank_check_app_dir()
629 const gchar
*configdir
;
632 DB( g_print("\n[homebank] check_app_dir\n") );
634 /* check if <userdir>/.config exist */
636 configdir
= g_get_user_config_dir();
637 DB( g_print(" - check '%s' exists\n", configdir
) );
638 if(!g_file_test(configdir
, G_FILE_TEST_IS_DIR
))
640 DB( g_print(" - creating dir\n") );
641 g_mkdir(configdir
, 0755);
645 /* check for XDG .config/homebank */
646 configdir
= homebank_app_get_config_dir();
647 DB( g_print(" - config_dir is: '%s'\n", configdir
) );
648 exists
= g_file_test(configdir
, G_FILE_TEST_IS_DIR
);
651 /* just update folder security */
652 DB( g_print(" - chmod 0700\n") );
653 g_chmod(configdir
, 0700);
654 GLOBALS
->first_run
= FALSE
;
658 /* create the config dir */
659 DB( g_print(" - create config_dir\n") );
660 g_mkdir(configdir
, 0755);
661 g_chmod(configdir
, 0700);
663 /* any old homedir configuration out there ? */
664 homedir
= g_build_filename(g_get_home_dir (), ".homebank", NULL
);
665 DB( g_print(" - homedir is: '%s'\n", homedir
) );
667 exists
= g_file_test(homedir
, G_FILE_TEST_IS_DIR
);
671 /* we must do the migration properly */
672 DB( g_print(" - migrate old 2 files\n") );
673 f1
= homebank_check_app_dir_migrate_file(homedir
, config_dir
, "preferences");
674 f2
= homebank_check_app_dir_migrate_file(homedir
, config_dir
, "lastopenedfiles");
677 DB( g_print(" - removing old dir\n") );
682 GLOBALS
->first_run
= TRUE
;
689 ** application cleanup: icons, GList, memory
691 static void homebank_cleanup()
694 DB( g_print("\n[homebank] cleanup\n") );
696 //v3.4 save windows size/position
697 homebank_pref_save();
699 hbfile_cleanup(TRUE
);
701 /* free our global datas */
704 homebank_pref_free();
715 g_free (pixmaps_dir
);
725 ** application setup: icons, GList, memory
727 static gboolean
homebank_setup()
730 DB( g_print("\n[homebank] setup\n") );
732 GLOBALS
= g_malloc0(sizeof(struct HomeBank
));
733 if(!GLOBALS
) return FALSE
;
734 PREFS
= g_malloc0(sizeof(struct Preferences
));
735 if(!PREFS
) return FALSE
;
737 // check homedir for .homebank dir
738 homebank_check_app_dir();
740 homebank_pref_setdefault();
741 homebank_pref_load();
745 homebank_icon_theme_setup();
748 homebank_setup_theme_extensions();
751 homebank_app_date_get_julian();
756 g_print(" - user_name: %s\n", g_get_user_name ());
757 g_print(" - real_name: %s\n", g_get_real_name ());
758 g_print(" - user_cache_dir: %s\n", g_get_user_cache_dir());
759 g_print(" - user_data_dir: %s\n", g_get_user_data_dir ());
760 g_print(" - user_config_dir: %s\n", g_get_user_config_dir ());
761 //g_print(" - system_data_dirs: %s\n", g_get_system_data_dirs ());
762 //g_print(" - system_config_dirs: %s\n", g_get_system_config_dirs ());
764 g_print(" - home_dir: %s\n", g_get_home_dir ());
765 g_print(" - tmp_dir: %s\n", g_get_tmp_dir ());
766 g_print(" - current_dir: %s\n", g_get_current_dir ());
774 /* = = = = = = = = = = = = = = = = = = = = */
778 homebank_construct_splash()
781 GtkWidget
*frame
, *vbox
, *image
;
782 //gchar *ver_string, *markup, *version;
785 DB( g_print("\n[homebank_construct_splash]\n") );
787 window
= gtk_window_new(GTK_WINDOW_POPUP
); //TOPLEVEL DONT WORK
788 gtk_window_set_type_hint (GTK_WINDOW (window
), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN
);
789 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window
), TRUE
);
791 gtk_window_set_title (GTK_WINDOW (window
), "HomeBank");
792 gtk_window_set_position (GTK_WINDOW (window
), GTK_WIN_POS_CENTER
);
794 pathfilename
= g_build_filename(homebank_app_get_images_dir(), "splash.png", NULL
);
795 image
= gtk_image_new_from_file((const gchar
*)pathfilename
);
796 g_free(pathfilename
);
798 frame
= gtk_frame_new (NULL
);
799 gtk_frame_set_shadow_type (GTK_FRAME (frame
), GTK_SHADOW_OUT
);
800 gtk_container_add (GTK_CONTAINER (window
), frame
);
802 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, 0);
803 gtk_container_add (GTK_CONTAINER (frame
), vbox
);
806 ver_string = g_strdup_printf(_("Version: HomeBank-%s"), VERSION);
808 version = gtk_label_new(NULL);
809 markup = g_markup_printf_escaped(MARKUP_STRING, ver_string);
810 gtk_label_set_markup(GTK_LABEL(version), markup);
815 gtk_box_pack_start (GTK_BOX (vbox
), image
, FALSE
, FALSE
, 0);
816 //gtk_box_pack_start (GTK_BOX (vbox), version, FALSE, FALSE, 0);
822 homebank_init_i18n (void)
824 /* We may change the locale later if the user specifies a language
825 * in the gimprc file. Here we are just initializing the locale
826 * according to the environment variables and set up the paths to
827 * the message catalogs.
830 setlocale (LC_ALL
, "");
832 bindtextdomain (GETTEXT_PACKAGE
, homebank_app_get_locale_dir ());
833 //#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
834 bind_textdomain_codeset (GETTEXT_PACKAGE
, "UTF-8");
837 textdomain (GETTEXT_PACKAGE
);
840 gchar *wl = g_win32_getlocale ();
841 DB( g_print(" - win32 locale is '%s'\n", wl) );
849 main (int argc
, char *argv
[], char *env
[])
851 GOptionContext
*option_context
;
852 GOptionGroup
*option_group
;
853 GError
*error
= NULL
;
855 GtkWidget
*splash
= NULL
;
858 DB( g_print("\n--------------------------------" ) );
859 DB( g_print("\nhomebank starting...\n" ) );
861 build_package_paths();
863 homebank_init_i18n ();
865 /* Set up option groups */
866 option_context
= g_option_context_new (NULL
);
868 //g_option_context_set_summary (option_context, _(""));
870 option_group
= g_option_group_new ("homebank",
871 N_("HomeBank options"),
872 N_("HomeBank options"),
874 g_option_group_add_entries (option_group
, option_entries
);
875 g_option_context_set_main_group (option_context
, option_group
);
876 g_option_group_set_translation_domain (option_group
, GETTEXT_PACKAGE
);
878 /* Add Gtk option group */
879 g_option_context_add_group (option_context
, gtk_get_option_group (FALSE
));
881 /* Parse command line */
882 if (!g_option_context_parse (option_context
, &argc
, &argv
, &error
))
884 g_option_context_free (option_context
);
888 g_print ("%s\n", error
->message
);
889 g_error_free (error
);
892 g_print ("An unknown error occurred\n");
897 g_option_context_free (option_context
);
898 option_context
= NULL
;
900 if (arg_version
!= FALSE
)
902 /* Print version information and exit */
903 g_print ("%s\n", PACKAGE
" " VERSION
);
907 /* Pass NULL here since we parsed the gtk+ args already...
908 * from this point all we need a DISPLAY variable to be set.
910 gtk_init (NULL
, NULL
);
912 //todo: sanity check gtk version here ?
914 g_set_application_name (APPLICATION_NAME
);
916 if( homebank_setup() )
918 /* change the locale if a language is specified */
919 language_init (PREFS
->language
);
921 DB( g_print(" - loading plugins\n") );
922 ext_init(&argc
, &argv
, &env
);
925 for (it
= PREFS
->ext_whitelist
; it
; it
= g_list_next(it
)) {
926 ext_load_plugin(it
->data
);
929 gchar
** plugins
= ext_list_plugins();
931 for (plugins_it
= plugins
; *plugins_it
; ++plugins_it
) {
932 gboolean loaded
= ext_is_plugin_loaded(*plugins_it
);
933 g_print("found plugin: %s, loaded: %d\n", *plugins_it
, loaded
);
937 if( PREFS
->showsplash
== TRUE
)
939 splash
= homebank_construct_splash();
940 gtk_window_set_auto_startup_notification (FALSE
);
941 gtk_widget_show_all (splash
);
942 gtk_window_set_auto_startup_notification (TRUE
);
944 // make sure splash is up
945 while (gtk_events_pending ())
946 gtk_main_iteration ();
949 gtk_window_set_default_icon_name ("homebank");
951 DB( g_print(" - creating window\n" ) );
953 mainwin
= (GtkWidget
*)create_hbfile_window (NULL
);
955 GValue mainwin_val
= G_VALUE_INIT
;
956 ext_hook("create_main_window", EXT_OBJECT(&mainwin_val
, mainwin
), NULL
);
961 //todo: pause on splash
962 if( PREFS
->showsplash
== TRUE
)
964 //g_usleep( G_USEC_PER_SEC * 1 );
965 gtk_widget_hide(splash
);
966 gtk_widget_destroy(splash
);
970 #if HB_UNSTABLE == TRUE
971 /* GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(mainwin),
972 GTK_DIALOG_DESTROY_WITH_PARENT,
975 "This is a beta version of HomeBank (UNSTABLE)"
978 gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
979 "DO NOT USE with important files or do a backup first.\n"
980 "This kind of release is for <b>TESTING ONLY</b>.\n"
981 "<u>It may be buggy, crash, or lose your data</u>.\n\n"
983 "For unstable bugs report, questions, suggestions:\n"
984 " - <b>DO NOT USE LaunchPad</b>\n"
985 " - direct email to: <homebank@free.fr>\n\n"
990 gtk_dialog_run (GTK_DIALOG (dialog));
991 gtk_widget_destroy (dialog);*/
994 if(GLOBALS
->first_run
)
996 ui_mainwindow_action_help_welcome();
1000 while (gtk_events_pending ()) /* make sure splash is gone */
1001 gtk_main_iteration ();
1004 DB( g_print(" - open last file ?\n" ) );
1007 /* load 1st file specified on commandline */
1008 openlast
= PREFS
->loadlast
;
1011 if (g_file_test (files
[0], G_FILE_TEST_EXISTS
) != FALSE
)
1013 DB( g_print(" - should load %s\n", files
[0] ) );
1014 hbfile_change_filepath(g_strdup(files
[0]));
1015 ui_mainwindow_open_internal(mainwin
, NULL
);
1020 g_warning (_("Unable to open '%s', the file does not exist.\n"), files
[0]);
1027 DB( g_print(" - GLOBALS->xhb_filepath: '%s'\n", GLOBALS
->xhb_filepath
) );
1031 gchar
*lastfilepath
;
1033 lastfilepath
= homebank_lastopenedfiles_load();
1034 if( lastfilepath
!= NULL
)
1036 //#1710955 test for backup open
1037 if( hbfile_file_isbackup(lastfilepath
) )
1039 if( ui_mainwindow_open_backup_check_confirm(lastfilepath
) == TRUE
)
1041 GLOBALS
->hbfile_is_bak
= TRUE
;
1045 g_free(lastfilepath
);
1050 hbfile_change_filepath(lastfilepath
);
1051 ui_mainwindow_open_internal(mainwin
, NULL
);
1056 /* -- hack to generate a big file -- */
1059 /* update the mainwin display */
1060 ui_mainwindow_update(mainwin
, GINT_TO_POINTER(UF_TITLE
+UF_SENSITIVE
+UF_BALANCE
+UF_VISUAL
));
1062 ext_hook("enter_main_loop", NULL
);
1064 DB( g_print(" - gtk_main()\n" ) );
1067 ext_hook("exit_main_loop", NULL
);
1069 DB( g_print(" - call destroy mainwin\n" ) );
1070 gtk_widget_destroy(mainwin
);
1073 DB( g_print(" - unloading plugins\n") );
1081 return EXIT_SUCCESS
;
1085 /* In case we build this as a windows application */
1088 #define _stdcall __attribute__((stdcall))
1092 WinMain (struct HINSTANCE__
*hInstance
,
1093 struct HINSTANCE__
*hPrevInstance
,
1097 return main (__argc
, __argv
);