mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
d2aaaf20dc
commit
f7eb603ace
19
ChangeLog
19
ChangeLog
@ -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>
|
2001-05-10 Bill Gribble <grib@billgribble.com>
|
||||||
|
|
||||||
* src/gnome/dialog-column-view.c: change handling of component
|
* src/gnome/dialog-column-view.c: change handling of component
|
||||||
|
@ -305,7 +305,7 @@ gncFileQuerySave (void)
|
|||||||
/* ======================================================== */
|
/* ======================================================== */
|
||||||
/* private utilities for file open; done in two stages */
|
/* private utilities for file open; done in two stages */
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
gncPostFileOpen (const char * filename)
|
gncPostFileOpen (const char * filename)
|
||||||
{
|
{
|
||||||
GNCBook *new_book;
|
GNCBook *new_book;
|
||||||
@ -314,13 +314,13 @@ gncPostFileOpen (const char * filename)
|
|||||||
char * newfile;
|
char * newfile;
|
||||||
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
|
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
|
||||||
|
|
||||||
if (!filename) return;
|
if (!filename) return FALSE;
|
||||||
|
|
||||||
newfile = xaccResolveURL (filename);
|
newfile = xaccResolveURL (filename);
|
||||||
if (!newfile)
|
if (!newfile)
|
||||||
{
|
{
|
||||||
show_book_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
|
show_book_error (ERR_FILEIO_FILE_NOT_FOUND, filename);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disable events while moving over to the new set of accounts;
|
/* disable events while moving over to the new set of accounts;
|
||||||
@ -336,7 +336,7 @@ gncPostFileOpen (const char * filename)
|
|||||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
||||||
gh_eval_str("gnc:*book-closed-hook*"),
|
gh_eval_str("gnc:*book-closed-hook*"),
|
||||||
gh_str02scm(gnc_book_get_url(current_book)));
|
gh_str02scm(gnc_book_get_url(current_book)));
|
||||||
|
|
||||||
gnc_book_destroy (current_book);
|
gnc_book_destroy (current_book);
|
||||||
current_book = NULL;
|
current_book = NULL;
|
||||||
|
|
||||||
@ -419,24 +419,28 @@ gncPostFileOpen (const char * filename)
|
|||||||
* reason, we don't want to leave them high & dry without a
|
* reason, we don't want to leave them high & dry without a
|
||||||
* topgroup, because if the user continues, then bad things will
|
* topgroup, because if the user continues, then bad things will
|
||||||
* happen. */
|
* happen. */
|
||||||
gncGetCurrentBook ();
|
current_book = gncGetCurrentBook ();
|
||||||
|
|
||||||
g_free (newfile);
|
g_free (newfile);
|
||||||
|
|
||||||
gnc_engine_resume_events ();
|
gnc_engine_resume_events ();
|
||||||
gnc_gui_refresh_all ();
|
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 */
|
/* if we got to here, then we've successfully gotten a new session */
|
||||||
/* close up the old file session (if any) */
|
/* close up the old file session (if any) */
|
||||||
current_book = new_book;
|
current_book = new_book;
|
||||||
|
|
||||||
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
gh_call2(gh_eval_str("gnc:hook-run-danglers"),
|
||||||
gh_eval_str("gnc:*book-opened-hook*"),
|
gh_eval_str("gnc:*book-opened-hook*"),
|
||||||
gh_str02scm(gnc_book_get_url(current_book)));
|
gh_str02scm(gnc_book_get_url(current_book)));
|
||||||
|
|
||||||
/* --------------- END CORE SESSION CODE -------------- */
|
/* --------------- END CORE SESSION CODE -------------- */
|
||||||
|
|
||||||
/* clean up old stuff, and then we're outta here. */
|
/* clean up old stuff, and then we're outta here. */
|
||||||
@ -446,37 +450,42 @@ gncPostFileOpen (const char * filename)
|
|||||||
|
|
||||||
gnc_engine_resume_events ();
|
gnc_engine_resume_events ();
|
||||||
gnc_gui_refresh_all ();
|
gnc_gui_refresh_all ();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================== */
|
/* ======================================================== */
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
gncFileOpen (void)
|
gncFileOpen (void)
|
||||||
{
|
{
|
||||||
const char * newfile;
|
const char * newfile;
|
||||||
|
gboolean result;
|
||||||
|
|
||||||
if (!gncFileQuerySave ())
|
if (!gncFileQuerySave ())
|
||||||
return;
|
return FALSE;
|
||||||
|
|
||||||
newfile = fileBox(_("Open"), NULL, gnc_history_get_last());
|
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
|
/* 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
|
* 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
|
* might be left with a null topgroup, which leads to nastiness when
|
||||||
* user goes to create their very first account. So create one. */
|
* user goes to create their very first account. So create one. */
|
||||||
gncGetCurrentBook ();
|
gncGetCurrentBook ();
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
gboolean
|
||||||
gncFileOpenFile (const char * newfile)
|
gncFileOpenFile (const char * newfile)
|
||||||
{
|
{
|
||||||
if (!newfile) return;
|
if (!newfile) return FALSE;
|
||||||
|
|
||||||
if (!gncFileQuerySave ())
|
if (!gncFileQuerySave ())
|
||||||
return;
|
return FALSE;
|
||||||
|
|
||||||
gncPostFileOpen (newfile);
|
return gncPostFileOpen (newfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======================================================== */
|
/* ======================================================== */
|
||||||
|
@ -125,12 +125,12 @@
|
|||||||
#include "gnc-book.h"
|
#include "gnc-book.h"
|
||||||
|
|
||||||
void gncFileNew (void);
|
void gncFileNew (void);
|
||||||
void gncFileOpen (void);
|
gboolean gncFileOpen (void);
|
||||||
void gncFileQIFImport (void);
|
void gncFileQIFImport (void);
|
||||||
void gncFileSave (void);
|
void gncFileSave (void);
|
||||||
void gncFileSaveAs (void);
|
void gncFileSaveAs (void);
|
||||||
|
|
||||||
void gncFileOpenFile (const char *);
|
gboolean gncFileOpenFile (const char *filename);
|
||||||
|
|
||||||
gboolean gncFileQuerySave (void);
|
gboolean gncFileQuerySave (void);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ static SCM register_hint_font_callback_id = SCM_UNDEFINED;
|
|||||||
|
|
||||||
/* ============================================================== */
|
/* ============================================================== */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
gnucash_ui_is_running(void)
|
gnucash_ui_is_running(void)
|
||||||
{
|
{
|
||||||
return gnome_is_running;
|
return gnome_is_running;
|
||||||
@ -131,7 +131,7 @@ gnucash_ui_is_running(void)
|
|||||||
|
|
||||||
/* ============================================================== */
|
/* ============================================================== */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
gnucash_ui_is_terminating(void)
|
gnucash_ui_is_terminating(void)
|
||||||
{
|
{
|
||||||
return gnome_is_terminating;
|
return gnome_is_terminating;
|
||||||
@ -467,11 +467,10 @@ gnc_ui_main(void)
|
|||||||
|
|
||||||
/* ============================================================== */
|
/* ============================================================== */
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
gnucash_ui_open_file(const char name[])
|
gnucash_ui_open_file(const char name[])
|
||||||
{
|
{
|
||||||
gncFileOpenFile(name);
|
return gncFileOpenFile(name);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================== */
|
/* ============================================================== */
|
||||||
|
@ -23,12 +23,14 @@
|
|||||||
#ifndef __TOP_LEVEL_H__
|
#ifndef __TOP_LEVEL_H__
|
||||||
#define __TOP_LEVEL_H__
|
#define __TOP_LEVEL_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "window-main.h"
|
#include "window-main.h"
|
||||||
|
|
||||||
int gnucash_ui_is_running(void);
|
gboolean gnucash_ui_is_running(void);
|
||||||
int gnucash_ui_is_terminating(void);
|
gboolean gnucash_ui_is_terminating(void);
|
||||||
int gnucash_ui_init(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);
|
int gnucash_ui_select_file(void);
|
||||||
|
|
||||||
GNCMainInfo * gnc_ui_get_data(void);
|
GNCMainInfo * gnc_ui_get_data(void);
|
||||||
|
@ -170,9 +170,8 @@ the account instead of opening a register.") #f))
|
|||||||
(let ((conf-file-name (gnc:html-encode-string book-url))
|
(let ((conf-file-name (gnc:html-encode-string book-url))
|
||||||
(dead-reports '()))
|
(dead-reports '()))
|
||||||
(if conf-file-name
|
(if conf-file-name
|
||||||
(begin
|
(try-load conf-file-name))
|
||||||
(try-load conf-file-name)
|
(gnc:main-window-restore (gnc:get-ui-data) book-url)))
|
||||||
(gnc:main-window-restore (gnc:get-ui-data) book-url)))))
|
|
||||||
|
|
||||||
(gnc:hook-add-dangler gnc:*book-opened-hook*
|
(gnc:hook-add-dangler gnc:*book-opened-hook*
|
||||||
gnc:main-window-book-open-handler)
|
gnc:main-window-book-open-handler)
|
||||||
|
@ -108,8 +108,9 @@
|
|||||||
|
|
||||||
(define (gnc:load-account-file)
|
(define (gnc:load-account-file)
|
||||||
(let ((file (gnc:account-file-to-load)))
|
(let ((file (gnc:account-file-to-load)))
|
||||||
(if file
|
(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))))
|
(gnc:hook-run-danglers gnc:*book-opened-hook* #f))))
|
||||||
|
|
||||||
(define (gnc:main)
|
(define (gnc:main)
|
||||||
|
Loading…
Reference in New Issue
Block a user