2001-05-10 Dave Peticolas <dave@krondo.com>

* src/scm/main-window.scm ((gnc:main-window-book-open-handler
	book-url)): restore the main window even if we can't get a
	conf-file-name.

	* src/scm/main.scm (gnc:load-account-file): if we have a file to
	open, only run book-opened-hook if file open returns false.

	* src/FileDialog.c (gncPostFileOpen): once book-closed-hook has
	been run, run book-opened-hook if opening the file fails for some
	reason.

	* src/guile/gnc.gwp: update ui-open-file api.

	* src/gnome/top-level.c (gnucash_ui_open_file): return TRUE/FALSE
	for success/failure. use gboolean instead of int for boolean
	returns.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4161 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-05-10 22:55:08 +00:00
parent d2aaaf20dc
commit f7eb603ace
7 changed files with 59 additions and 30 deletions

View File

@ -1,3 +1,22 @@
2001-05-10 Dave Peticolas <dave@krondo.com>
* src/scm/main-window.scm ((gnc:main-window-book-open-handler
book-url)): restore the main window even if we can't get a
conf-file-name.
* src/scm/main.scm (gnc:load-account-file): if we have a file to
open, only run book-opened-hook if file open returns false.
* src/FileDialog.c (gncPostFileOpen): once book-closed-hook has
been run, run book-opened-hook if opening the file fails for some
reason.
* src/guile/gnc.gwp: update ui-open-file api.
* src/gnome/top-level.c (gnucash_ui_open_file): return TRUE/FALSE
for success/failure. use gboolean instead of int for boolean
returns.
2001-05-10 Bill Gribble <grib@billgribble.com>
* src/gnome/dialog-column-view.c: change handling of component

View File

@ -305,7 +305,7 @@ gncFileQuerySave (void)
/* ======================================================== */
/* private utilities for file open; done in two stages */
static void
static gboolean
gncPostFileOpen (const char * filename)
{
GNCBook *new_book;
@ -314,13 +314,13 @@ gncPostFileOpen (const char * filename)
char * newfile;
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
if (!filename) return;
if (!filename) return FALSE;
newfile = xaccResolveURL (filename);
if (!newfile)
{
show_book_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
return;
return FALSE;
}
/* disable events while moving over to the new set of accounts;
@ -419,14 +419,18 @@ gncPostFileOpen (const char * filename)
* reason, we don't want to leave them high & dry without a
* topgroup, because if the user continues, then bad things will
* happen. */
gncGetCurrentBook ();
current_book = gncGetCurrentBook ();
g_free (newfile);
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
return;
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
gh_eval_str("gnc:*book-opened-hook*"),
gh_str02scm(gnc_book_get_url(current_book)));
return FALSE;
}
/* if we got to here, then we've successfully gotten a new session */
@ -446,37 +450,42 @@ gncPostFileOpen (const char * filename)
gnc_engine_resume_events ();
gnc_gui_refresh_all ();
return TRUE;
}
/* ======================================================== */
void
gboolean
gncFileOpen (void)
{
const char * newfile;
gboolean result;
if (!gncFileQuerySave ())
return;
return FALSE;
newfile = fileBox(_("Open"), NULL, gnc_history_get_last());
gncPostFileOpen (newfile);
result = gncPostFileOpen (newfile);
/* This dialogue can show up early in the startup process. If the
* user fails to pick a file (by e.g. hitting the cancel button), we
* might be left with a null topgroup, which leads to nastiness when
* user goes to create their very first account. So create one. */
gncGetCurrentBook ();
return result;
}
void
gboolean
gncFileOpenFile (const char * newfile)
{
if (!newfile) return;
if (!newfile) return FALSE;
if (!gncFileQuerySave ())
return;
return FALSE;
gncPostFileOpen (newfile);
return gncPostFileOpen (newfile);
}
/* ======================================================== */

View File

@ -125,12 +125,12 @@
#include "gnc-book.h"
void gncFileNew (void);
void gncFileOpen (void);
gboolean gncFileOpen (void);
void gncFileQIFImport (void);
void gncFileSave (void);
void gncFileSaveAs (void);
void gncFileOpenFile (const char *);
gboolean gncFileOpenFile (const char *filename);
gboolean gncFileQuerySave (void);

View File

@ -123,7 +123,7 @@ static SCM register_hint_font_callback_id = SCM_UNDEFINED;
/* ============================================================== */
int
gboolean
gnucash_ui_is_running(void)
{
return gnome_is_running;
@ -131,7 +131,7 @@ gnucash_ui_is_running(void)
/* ============================================================== */
int
gboolean
gnucash_ui_is_terminating(void)
{
return gnome_is_terminating;
@ -467,11 +467,10 @@ gnc_ui_main(void)
/* ============================================================== */
int
gboolean
gnucash_ui_open_file(const char name[])
{
gncFileOpenFile(name);
return 1;
return gncFileOpenFile(name);
}
/* ============================================================== */

View File

@ -23,12 +23,14 @@
#ifndef __TOP_LEVEL_H__
#define __TOP_LEVEL_H__
#include <glib.h>
#include "window-main.h"
int gnucash_ui_is_running(void);
int gnucash_ui_is_terminating(void);
gboolean gnucash_ui_is_running(void);
gboolean gnucash_ui_is_terminating(void);
int gnucash_ui_init(void);
int gnucash_ui_open_file(const char * name);
gboolean gnucash_ui_open_file(const char * name);
int gnucash_ui_select_file(void);
GNCMainInfo * gnc_ui_get_data(void);

View File

@ -170,9 +170,8 @@ the account instead of opening a register.") #f))
(let ((conf-file-name (gnc:html-encode-string book-url))
(dead-reports '()))
(if conf-file-name
(begin
(try-load conf-file-name)
(gnc:main-window-restore (gnc:get-ui-data) book-url)))))
(try-load conf-file-name))
(gnc:main-window-restore (gnc:get-ui-data) book-url)))
(gnc:hook-add-dangler gnc:*book-opened-hook*
gnc:main-window-book-open-handler)

View File

@ -109,7 +109,8 @@
(define (gnc:load-account-file)
(let ((file (gnc:account-file-to-load)))
(if file
(gnc:ui-open-file file)
(and (not (gnc:ui-open-file file))
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))))
(define (gnc:main)