More work on refresh.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3362 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-12-28 09:46:04 +00:00
parent c231521073
commit 0b425bc6c8
3 changed files with 62 additions and 24 deletions

View File

@ -32,16 +32,20 @@
#include "Group.h"
#include "TransLog.h"
#include "file-history.h"
#include "gnc-component-manager.h"
#include "gnc-engine-util.h"
#include "gnc-event.h"
#include "gnc-ui.h"
#include "messages.h"
/** GLOBALS *********************************************************/
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_GUI;
/** GLOBALS *********************************************************/
static GNCBook *current_book = NULL;
/* ======================================================== */
static const char *
@ -161,7 +165,9 @@ gncFileNew (void)
xaccGroupWindowDestroy (group);
/* close any ongoing file sessions, and free the accounts.
* disable logging so we don't get all that junk. */
* disable logging and events so we don't get all that junk. */
gnc_engine_suspend_events ();
xaccLogDisable();
gnc_book_destroy (book);
current_book = NULL;
@ -169,6 +175,9 @@ gncFileNew (void)
/* start a new book */
gncGetCurrentBook ();
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
}
/* ======================================================== */
@ -265,9 +274,11 @@ gncPostFileOpen (const char * filename)
/* but first, check to make sure we've got a book going. */
new_book = gnc_book_new ();
/* disable logging while we move over to the new set of accounts to
* edit; the mass deletetion of accounts and transactions during
* switchover is not something we want to keep in a journal. */
/* disable logging and events while moving over to the new set of
* accounts; the mass deletetion of accounts and transactions during
* switchover is not something we want to keep in a journal. */
gnc_engine_suspend_events ();
gnc_set_busy_cursor (NULL);
xaccLogDisable ();
new_group = NULL;
@ -307,7 +318,7 @@ gncPostFileOpen (const char * filename)
{
gnc_book_destroy (new_book);
/* well, no matter what, I think its a good idea to have a
/* well, no matter what, I think it's a good idea to have a
* topgroup around. For example, early in the gnucash startup
* sequence, the user opens a file; if this open fails for any
* reason, we don't want to leave them high & dry without a
@ -315,7 +326,11 @@ gncPostFileOpen (const char * filename)
* happen. */
gncGetCurrentBook ();
free (newfile);
g_free (newfile);
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
return;
}
@ -330,11 +345,14 @@ gncPostFileOpen (const char * filename)
xaccLogEnable();
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
/* --------------- END CORE SESSION CODE -------------- */
/* clean up old stuff, and then we're outta here. */
gnc_history_add_file (newfile);
free (newfile);
g_free (newfile);
/* run a file-opened hook. For now, the main thing it will do
* is notice if legacy currencies are being imported. */
@ -483,7 +501,7 @@ gncFileSaveAs (void)
oldfile = gnc_book_get_file_path (book);
if (oldfile && (strcmp(oldfile, newfile) == 0))
{
free (newfile);
g_free (newfile);
gncFileSave ();
return;
}
@ -511,7 +529,7 @@ gncFileSaveAs (void)
gnc_book_destroy (new_book);
xaccLogEnable ();
free (newfile);
g_free (newfile);
gnc_refresh_main_window();
return;
@ -541,7 +559,10 @@ gncFileSaveAs (void)
/* if user says cancel, we should break out */
if (!result)
{
g_free (newfile);
return;
}
/* Whoa-ok. Blow away the previous file. Do not disable
* logging. We want to capture the old file in the log, just in
@ -553,8 +574,7 @@ gncFileSaveAs (void)
gnc_book_set_group (new_book, group);
gncFileSave ();
free (newfile);
gnc_refresh_main_window();
g_free (newfile);
}
/* ======================================================== */
@ -566,12 +586,18 @@ gncFileQuit (void)
book = gncGetCurrentBook ();
/* disable logging; the mass deletetion of accounts and transactions
* during shutdown is not something we want to keep in a journal. */
/* disable logging and events; the mass deletetion of accounts and
* transactions during shutdown is not something we want to keep in
* a journal. */
gnc_engine_suspend_events ();
xaccLogDisable();
gnc_book_destroy (book);
current_book = NULL;
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
}
/* ======================================================== */

View File

@ -587,31 +587,39 @@ xaccResolveFilePath (const char * filefrag)
/* check for an absolute file path */
if ('/' == *filefrag)
return strdup (filefrag);
return g_strdup (filefrag);
/* get conservative on the length so that sprintf(getpid()) works ... */
/* strlen ("/.LCK") + sprintf (%x%d) */
namelen = strlen (filefrag) + 25;
for (i=-2; 1 ; i++)
for (i = -2; TRUE ; i++)
{
switch (i)
{
case -2:
/* try to find a file by this name in the cwd ... */
path = getcwd (pathbuf, PATH_MAX);
if (!path) continue;
if (!path)
continue;
len = strlen (path) + namelen;
if (PATH_MAX <= len) continue;
if (PATH_MAX <= len)
continue;
strcat (path, "/");
break;
case -1:
/* look for something in $HOME/.gnucash/data */
path = getenv ("HOME");
if (!path) continue;
if (!path)
continue;
len = strlen (path) + namelen + 20;
if (PATH_MAX <= len) continue;
if (PATH_MAX <= len)
continue;
strcpy (pathbuf, path);
strcat (pathbuf, "/.gnucash/data/");
path = pathbuf;
@ -623,7 +631,9 @@ xaccResolveFilePath (const char * filefrag)
if (path)
{
len = strlen (path) + namelen;
if (PATH_MAX <= len) continue;
if (PATH_MAX <= len)
continue;
strcpy (pathbuf, path);
path = pathbuf;
}
@ -638,7 +648,7 @@ xaccResolveFilePath (const char * filefrag)
strcat (path, filefrag);
rc = stat (path, &statbuf);
if ((!rc) && (S_ISREG(statbuf.st_mode)))
return (strdup (path));
return (g_strdup (path));
}
/* make sure that the gnucash home dir exists. */
@ -662,7 +672,7 @@ xaccResolveFilePath (const char * filefrag)
strcpy (pathbuf, path);
strcat (pathbuf, "/.gnucash/data/");
strcat (pathbuf, filefrag);
return (strdup (pathbuf));
return (g_strdup (pathbuf));
}
}
@ -676,7 +686,7 @@ xaccResolveFilePath (const char * filefrag)
{
strcat (path, "/");
strcat (path, filefrag);
return (strdup (path));
return (g_strdup (path));
}
}

View File

@ -740,9 +740,11 @@ gnc_ui_filemenu_cb(GtkWidget *widget, gpointer menuItem)
break;
case FMB_SAVE:
gncFileSave();
gnc_refresh_main_window_title();
break;
case FMB_SAVEAS:
gncFileSaveAs();
gnc_refresh_main_window_title();
break;
case FMB_IMPORT:
gncFileQIFImport();