Untable app-file and app-file-gnome dependencies.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5738 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-10-29 08:14:42 +00:00
parent f2ca55fc3f
commit 0622d2bc06
7 changed files with 180 additions and 32 deletions

View File

@ -24,5 +24,15 @@
void gnc_file_init (void);
#endif
typedef void (*GNCHistoryAddFileFunc) (const char *filename);
typedef const char * (*GNCHistoryGetLastFunc) (void);
typedef const char * (*GNCFileDialogFunc) (const char * title,
const char * filter,
const char * default_name);
void gnc_file_set_handlers (GNCHistoryAddFileFunc history_add_file_func,
GNCHistoryGetLastFunc history_get_last_func,
GNCFileDialogFunc file_dialog_func);
#endif

View File

@ -50,6 +50,21 @@ static short module = MOD_GUI;
static GNCSession * current_session = NULL;
static GNCCanCancelSaveCB can_cancel_cb = NULL;
static GNCHistoryAddFileFunc history_add_file_func = NULL;
static GNCHistoryGetLastFunc history_get_last_func = NULL;
static GNCFileDialogFunc file_dialog_func = NULL;
void
gnc_file_set_handlers (GNCHistoryAddFileFunc history_add_file_func_in,
GNCHistoryGetLastFunc history_get_last_func_in,
GNCFileDialogFunc file_dialog_func_in)
{
history_add_file_func = history_add_file_func_in;
history_get_last_func = history_get_last_func_in;
file_dialog_func = file_dialog_func_in;
}
static GNCSession *
gnc_get_current_session_internal (void)
@ -223,17 +238,21 @@ static void
gnc_add_history (GNCSession * session)
{
char *url;
char *file;
if (!session) return;
if (!history_add_file_func) return;
url = xaccResolveURL (gnc_session_get_url (session));
if (!url)
return;
if (strncmp (url, "file:", 5) == 0)
gnc_history_add_file (url + 5);
file = url + 5;
else
gnc_history_add_file (url);
file = url;
history_add_file_func (file);
g_free (url);
}
@ -477,12 +496,20 @@ gboolean
gnc_file_open (void)
{
const char * newfile;
const char * last;
gboolean result;
if (!gnc_file_query_save ())
return FALSE;
newfile = gnc_file_dialog (_("Open"), NULL, gnc_history_get_last ());
if (!file_dialog_func)
{
PWARN ("no file dialog function");
return FALSE;
}
last = history_get_last_func ? history_get_last_func () : NULL;
newfile = file_dialog_func (_("Open"), NULL, last);
result = gnc_post_file_open (newfile);
/* This dialogue can show up early in the startup process. If the
@ -570,7 +597,14 @@ gnc_file_save_as (void)
GNCBackendError io_err = ERR_BACKEND_NO_ERR;
ENTER(" ");
filename = gnc_file_dialog (_("Save"), "*.gnc", NULL);
if (!file_dialog_func)
{
PWARN ("no file dialog func");
return;
}
filename = file_dialog_func (_("Save"), "*.gnc", NULL);
if (!filename) return;
/* Check to see if the user specified the same file as the current

View File

@ -4,3 +4,8 @@ Makefile.in
*.la
.deps
.libs
.scm-links
gw-app-file-gnome.c
gw-app-file-gnome.scm
gw-app-file-gnome.h
gw-app-file-gnome.html

View File

@ -1,6 +1,6 @@
SUBDIRS = . #test
pkglib_LTLIBRARIES = libgncmod-app-file-gnome.la
pkglib_LTLIBRARIES = libgncmod-app-file-gnome.la libgw-app-file-gnome.la
AM_CFLAGS = \
-I${top_srcdir}/src/gnc-module \
@ -32,3 +32,32 @@ libgncmod_app_file_gnome_la_LIBADD = \
${GNOMEUI_LIBS} \
${GNOME_LIBDIR} \
${GLIB_LIBS}
libgw_app_file_gnome_la_SOURCES = gw-app-file-gnome.c
libgw_app_file_gnome_la_LDFLAGS = -module
gwmoddir = ${GNC_GWRAP_LIBDIR}
gwmod_DATA = gw-app-file-gnome-spec.scm gw-app-file-gnome.scm
noinst_DATA = .scm-links
EXTRA_DIST = \
${gwmod_DATA}
.scm-links:
rm -f gnucash g-wrapped
ln -sf . gnucash
ln -sf . g-wrapped
touch .scm-links
gw-app-file-gnome.scm gw-app-file-gnome.c gw-app-file-gnome.h: .scm-links gw-app-file-gnome-spec.scm
FLAVOR=gnome guile -c \
"(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
(set! %load-path (cons \"${PWD}\" %load-path)) \
(set! %load-path (cons \"${top_srcdir}/src/engine\" %load-path)) \
(primitive-load \"./gw-app-file-gnome-spec.scm\") \
(gw:generate-module \"gw-app-file-gnome\")"
BUILT_SOURCES = gw-app-file-gnome.scm gw-app-file-gnome.c gw-app-file-gnome.h
CLEANFILES = gw-app-file-gnome.scm gw-app-file-gnome.c gw-app-file-gnome.h \
gw-app-file-gnome.html gnucash g-wrapped .scm-links

View File

@ -11,7 +11,9 @@
#include <libguile/strports.h>
#include <libguile/modules.h>
#include "gnc-file-dialog.h"
#include "gnc-file-p.h"
#include "gnc-file-history.h"
#include "gnc-module.h"
#include "gnc-module-api.h"
@ -24,26 +26,48 @@ int gnc_module_revision = 0;
int gnc_module_age = 0;
char *
gnc_module_path(void) {
gnc_module_path(void)
{
return g_strdup("gnucash/app-file/gnome");
}
char *
gnc_module_description(void) {
gnc_module_description(void)
{
return g_strdup("Application level file interface for Gnome");
}
static void
lmod(char * mn)
{
char * form = g_strdup_printf("(use-modules %s)\n", mn);
gh_eval_str(form);
g_free(form);
}
int
gnc_module_init(int refcount) {
gnc_module_init(int refcount)
{
/* load the calculation module (we depend on it) */
if(!gnc_module_load("gnucash/app-file", 0)) {
return FALSE;
}
lmod ("(g-wrapped gw-app-file-gnome)");
if (refcount == 0)
gnc_file_set_handlers (gnc_history_add_file,
gnc_history_get_last,
gnc_file_dialog);
return TRUE;
}
int
gnc_module_end(int refcount) {
gnc_module_end(int refcount)
{
if (refcount == 0)
gnc_file_set_handlers (NULL, NULL, NULL);
return TRUE;
}

View File

@ -0,0 +1,67 @@
;;; -*-scheme-*-
(use-modules (g-wrap))
(debug-set! maxdepth 100000)
(debug-set! stack 2000000)
(define-module (g-wrapped gw-app-file-gnome-spec)
:use-module (g-wrap))
(use-modules (g-wrapped gw-engine-spec))
(use-modules (g-wrapped gw-glib-spec))
(let ((mod (gw:new-module "gw-app-file-gnome")))
(define (standard-c-call-gen result func-call-code)
(list (gw:result-get-c-name result) " = " func-call-code ";\n"))
(define (add-standard-result-handlers! type c->scm-converter)
(define (standard-pre-handler result)
(let* ((ret-type-name (gw:result-get-proper-c-type-name result))
(ret-var-name (gw:result-get-c-name result)))
(list "{\n"
" " ret-type-name " " ret-var-name ";\n")))
(gw:type-set-pre-call-result-ccodegen! type standard-pre-handler)
(gw:type-set-post-call-result-ccodegen!
type
(lambda (result)
(let* ((scm-name (gw:result-get-scm-name result))
(c-name (gw:result-get-c-name result)))
(list
(c->scm-converter scm-name c-name)
" }\n")))))
(gw:module-depends-on mod "gw-runtime")
(gw:module-depends-on mod "gw-engine")
(gw:module-depends-on mod "gw-glib")
(gw:module-set-guile-module! mod '(g-wrapped gw-app-file-gnome))
(gw:module-set-declarations-ccodegen!
mod
(lambda (client-only?)
(list
"#include <gnc-file-dialog.h>\n"
"#include <gnc-file-history.h>\n")))
(gw:wrap-function
mod
'gnc:history-get-last
'(<gw:m-chars-callee-owned> gw:const)
"gnc_history_get_last"
'()
"Get the last file opened by the user.")
(gw:wrap-function
mod
'gnc:file-selection-dialog
'(<gw:m-chars-callee-owned> gw:const)
"gnc_file_dialog"
'(((<gw:m-chars-caller-owned> gw:const) title)
((<gw:m-chars-caller-owned> gw:const) filter)
((<gw:m-chars-caller-owned> gw:const) default))
"Lets the user select a file. Dialog has given title, filter,
or default name. Either filter, default, or both should be NULL.")
)

View File

@ -42,9 +42,7 @@
mod
(lambda (client-only?)
(list
"#include <gnc-file.h>\n"
"#include <gnc-file-dialog.h>\n"
"#include <gnc-file-history.h>\n")))
"#include <gnc-file.h>\n")))
(gw:wrap-function
@ -71,23 +69,4 @@ if they say 'Yes'. The return is false if the user says 'Cancel'.")
"gnc_file_open_file"
'(((<gw:m-chars-caller-owned> gw:const) filename))
"Open filename.")
(gw:wrap-function
mod
'gnc:history-get-last
'(<gw:m-chars-callee-owned> gw:const)
"gnc_history_get_last"
'()
"Get the last file opened by the user.")
(gw:wrap-function
mod
'gnc:file-selection-dialog
'(<gw:m-chars-callee-owned> gw:const)
"gnc_file_dialog"
'(((<gw:m-chars-caller-owned> gw:const) title)
((<gw:m-chars-caller-owned> gw:const) filter)
((<gw:m-chars-caller-owned> gw:const) default))
"Lets the user select a file. Dialog has given title, filter,
or default name. Either filter, default, or both should be NULL.")
)