diff --git a/src/FileDialog.c b/src/FileDialog.c index 4293c5a641..066fc32035 100644 --- a/src/FileDialog.c +++ b/src/FileDialog.c @@ -38,8 +38,8 @@ // static short module = MOD_GUI; /** GLOBALS *********************************************************/ -Session *current_session = NULL; -AccountGroup *topgroup = NULL; /* the current top of the heriarchy */ +static Session *current_session = NULL; +static AccountGroup *topgroup = NULL; /* the current top of the heriarchy */ /********************************************************************\ * fileMenubarCB -- handles file menubar choices * @@ -499,5 +499,35 @@ gncFileQuit (void) topgroup = NULL; } + +/* ======================================================== */ + +AccountGroup * +gncGetCurrentGroup (void) +{ + AccountGroup *grp; + grp = xaccSessionGetGroup (current_session); + if (grp) return grp; + + /* If we are here, then no session has yet been started ... */ + grp = topgroup; + if (grp) return grp; + + /* if we are here, then topgroup not yet initialized ... */ + xaccLogEnable(); + topgroup = xaccMallocAccountGroup(); + + return topgroup; +} +#if 0 +/* ======================================================== */ +/* whats this for ???? */ + +gnc_main_window_get_session(gncUIWidget w) +{ + return(current_session); +} + +#endif /********************* END OF FILE **********************************/ diff --git a/src/FileDialog.h b/src/FileDialog.h index a73f4a6de0..c97265abfc 100644 --- a/src/FileDialog.h +++ b/src/FileDialog.h @@ -86,6 +86,10 @@ * The user WILL NOT BE PROMPTED to confirm this action, or do do * any kind of saving beforehand. * + * The gncGetCurrentGroup() routine will return the account group associated + * with the current session. It will always return a non-null value + * (barring system catastrophe such as out of memory). + * * HISTORY: * Derived from Rob Clark's original MainWindow.c code, Dec 1998 */ @@ -126,6 +130,11 @@ void gncFileOpenFile (const char *); void gncFileQuerySave (void); void gncFileQuit (void); -extern Session *current_session; +AccountGroup *gncGetCurrentGroup (void); + +/* ??? why is this needed ??? */ +/* +Session *gnc_main_window_get_session(gncUIWidget w); +*/ #endif /* __GNC_FILE_DIALOG_H__ */ diff --git a/src/MainWindow.h b/src/MainWindow.h index a667825417..0626caf845 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -29,7 +29,6 @@ #include "config.h" #include "ui-callbacks.h" #include "gnc-common.h" -#include "Session.h" /** GLOBALS *********************************************************/ typedef enum { @@ -46,6 +45,5 @@ typedef enum { void mainWindow(); void gnc_show_help(const gncHelpTypes t); -Session *gnc_main_window_get_session(gncUIWidget w); #endif