mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Rob Browning's initialization updates
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1004 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bdce64c4ab
commit
e22a15dfbc
148
src/gnome/main.c
148
src/gnome/main.c
@ -206,31 +206,67 @@ foreach_split_in_group(AccountGroup *g, void (*f)(Split *)) {
|
||||
#endif
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnome_main *
|
||||
* called after the guile engine is up and running *
|
||||
* sets up the top level widget *
|
||||
* and calls the mainWindow() function which creates the main *
|
||||
* window. *
|
||||
* *
|
||||
* Args: argc, the number of command line arguments, and argv, *
|
||||
* the array of command line args *
|
||||
* Return: *
|
||||
* Global: topgroup - the data from the datafile *
|
||||
* datafile - the name of the user's datafile *
|
||||
\********************************************************************/
|
||||
static int
|
||||
gnome_main(int argc, char *argv[])
|
||||
int
|
||||
gnucash_ui_open_file(const char name[]) {
|
||||
|
||||
if( name == NULL ) return 0;
|
||||
|
||||
/* FIXME: this is a memory leak (very small). */
|
||||
datafile = name;
|
||||
|
||||
/* load the accounts data from datafile*/
|
||||
topgroup = xaccReadAccountGroup (datafile);
|
||||
|
||||
if ( topgroup == NULL )
|
||||
{
|
||||
SCM datafile_scm = gh_lookup("gnucash:datafile-tmp_");
|
||||
if(datafile_scm != SCM_BOOL_F)
|
||||
{
|
||||
datafile = gh_scm2newstr(datafile_scm, NULL);
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
|
||||
dialog = gtk_dialog_new ();
|
||||
|
||||
button = gtk_button_new_with_label ( "Ok" );
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show ( button );
|
||||
|
||||
label = gtk_label_new (" \nInvalid filename \nNew file started.\n ");
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE,
|
||||
TRUE, 0);
|
||||
gtk_widget_show ( label );
|
||||
gtk_widget_show ( dialog );
|
||||
|
||||
topgroup = xaccMallocAccountGroup();
|
||||
}
|
||||
|
||||
/* argc and argv have been cleared by guile at this point */
|
||||
gnome_init("GnuCash", NULL, argc, argv, 0, &argc);
|
||||
/* Create main window */
|
||||
xaccAccountGroupMarkSaved(topgroup);
|
||||
main_window_init(topgroup);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gnucash_ui_select_file() {
|
||||
|
||||
/* Connect the cancel_button to kill the app */
|
||||
filebox_quit =
|
||||
gtk_signal_connect_object
|
||||
(GTK_OBJECT (GTK_FILE_SELECTION (filebox)->cancel_button),
|
||||
"clicked", (GtkSignalFunc)gtk_exit, NULL );
|
||||
|
||||
gtk_widget_show ( filebox );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gnucash_lowlev_app_init()
|
||||
{
|
||||
int fake_argc = 1;
|
||||
char *fake_argv[] = {"gnucash"};
|
||||
|
||||
gnome_init("GnuCash", NULL, fake_argc, fake_argv, 0, NULL);
|
||||
prepare_app();
|
||||
|
||||
{
|
||||
@ -266,49 +302,27 @@ gnome_main(int argc, char *argv[])
|
||||
(GTK_OBJECT (GTK_FILE_SELECTION (import_filebox)->ok_button),
|
||||
"clicked", (GtkSignalFunc) import_ok_sel, import_filebox );
|
||||
|
||||
/* read in the filename (should be the first arg after all
|
||||
* the X11 stuff */
|
||||
if( datafile != NULL ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* load the accounts data from datafile*/
|
||||
topgroup = xaccReadAccountGroup (datafile);
|
||||
/********************************************************************\
|
||||
* gnome_main *
|
||||
* called after the guile engine is up and running *
|
||||
* sets up the top level widget *
|
||||
* and calls the mainWindow() function which creates the main *
|
||||
* window. *
|
||||
* *
|
||||
* Args: argc, the number of command line arguments, and argv, *
|
||||
* the array of command line args *
|
||||
* Return: *
|
||||
* Global: topgroup - the data from the datafile *
|
||||
* datafile - the name of the user's datafile *
|
||||
\********************************************************************/
|
||||
|
||||
if ( topgroup == NULL )
|
||||
int
|
||||
gnucash_lowlev_app_main()
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
|
||||
dialog = gtk_dialog_new ();
|
||||
|
||||
button = gtk_button_new_with_label ( "Ok" );
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show ( button );
|
||||
|
||||
label = gtk_label_new (" \nInvalid filename \nNew file started.\n ");
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE,
|
||||
TRUE, 0);
|
||||
gtk_widget_show ( label );
|
||||
gtk_widget_show ( dialog );
|
||||
|
||||
topgroup = xaccMallocAccountGroup();
|
||||
}
|
||||
/* Create main window */
|
||||
xaccAccountGroupMarkSaved(topgroup);
|
||||
main_window_init(topgroup);
|
||||
} else {
|
||||
/* Filebox code here */
|
||||
/* Connect the cancel_button to also kill the app */
|
||||
filebox_quit =
|
||||
gtk_signal_connect_object
|
||||
(GTK_OBJECT (GTK_FILE_SELECTION (filebox)->cancel_button),
|
||||
"clicked", (GtkSignalFunc)gtk_exit, NULL );
|
||||
|
||||
gtk_widget_show ( filebox );
|
||||
}
|
||||
|
||||
/* Enter event loop */
|
||||
/* Enter gnome event loop */
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
@ -327,7 +341,7 @@ gnome_main(int argc, char *argv[])
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
gnucash_main(argc, argv, gnome_main);
|
||||
gnucash_main(argc, argv);
|
||||
/* This will never return. */
|
||||
|
||||
assert(0); /* Just to be anal */
|
||||
@ -346,13 +360,3 @@ prepare_app()
|
||||
}
|
||||
|
||||
/****************** END OF FILE **********************/
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
tab-width: 2
|
||||
indent-tabs-mode: nil
|
||||
mode: c
|
||||
c-indentation-style: gnu
|
||||
eval: (c-set-offset 'substatement-open 0)
|
||||
End:
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user