Move mdi g-wrapping into gnome-utils module.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5720 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-10-25 00:09:04 +00:00
parent e9e50593aa
commit d37d5d1e04
7 changed files with 121 additions and 33 deletions

View File

@ -1,6 +1,6 @@
SUBDIRS = . test
pkglib_LTLIBRARIES = libgncmod-gnome-utils.la
pkglib_LTLIBRARIES = libgncmod-gnome-utils.la libgw-gnome-utils.la
CFLAGS = \
@CFLAGS@ \
@ -81,6 +81,12 @@ libgncmod_gnome_utils_la_LIBADD = \
${GUPPI_LIBS} \
${GLIB_LIBS}
libgw_gnome_utils_la_SOURCES = gw-gnome-utils.c
libgw_gnome_utils_la_LDFLAGS = -module
gwmoddir = ${GNC_GWRAP_LIBDIR}
gwmod_DATA = gw-gnome-utils.scm gw-gnome-utils-spec.scm
gladedir = $(GNC_GLADE_DIR)
glade_DATA = \
commodity.glade
@ -88,7 +94,8 @@ glade_DATA = \
EXTRA_DIST = \
.cvsignore \
gnc-dir.h.in \
${glade_DATA}
${glade_DATA} \
${gwmod_DATA}
dialog-utils.c: gnc-dir.h
@ -110,3 +117,21 @@ BUILT_SOURCES = gnc-dir.h
# by all means, let us know...
dist-hook:
rm ${distdir}/gnc-dir.h
.scm-links:
rm -f gnucash g-wrapped
ln -sf . gnucash
ln -sf . g-wrapped
touch .scm-links
gw-gnome-utils.scm gw-gnome-utils.c gw-gnome-utils.h: .scm-links gw-gnome-utils-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-gnome-utils-spec.scm\") \
(gw:generate-module \"gw-gnome-utils\")"
BUILT_SOURCES = gw-gnome-utils.scm gw-gnome-utils.c gw-gnome-utils.h
CLEANFILES = gw-gnome-utils.scm gw-gnome-utils.c gw-gnome-utils.h \
gw-gnome-utils.html gnucash g-wrapped .scm-links

View File

@ -32,6 +32,14 @@ gnc_module_description(void) {
return g_strdup("Utilities for using Gnome/Gtk with GnuCash");
}
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) {
/* load the engine (we depend on it) */
@ -54,6 +62,9 @@ gnc_module_init(int refcount) {
return FALSE;
}
/* publish g-wrapped bindings */
lmod("(g-wrapped gw-gnome-utils)");
return TRUE;
}

View File

@ -0,0 +1,80 @@
(define-module (g-wrapped gw-gnome-utils-spec))
(use-modules (g-wrap))
(use-modules (g-wrapped gw-engine-spec))
(debug-set! maxdepth 100000)
(debug-set! stack 2000000)
(let ((mod (gw:new-module "gw-gnome-utils")))
(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-set-guile-module! mod '(g-wrapped gw-gnome-utils))
(gw:module-set-declarations-ccodegen!
mod
(lambda (client-only?)
(list
"#include <gnc-mdi-utils.h>\n"
)))
(let ((nnt (gw:wrap-non-native-type
mod
'<gnc:mdi-info*>
"GNCMDIInfo*" "const GNCMDIInfo*")))
#t)
(gw:wrap-function
mod
'gnc:mdi-has-apps?
'<gw:bool>
"gnc_mdi_has_apps"
'()
"Return true if there are gnc mdi app windows open.")
(gw:wrap-function
mod
'gnc:mdi-get-current
'<gnc:mdi-info*>
"gnc_mdi_get_current"
'()
"Return the main window data structure for the application.")
(gw:wrap-function
mod
'gnc:mdi-save
'<gw:void>
"gnc_mdi_save" '((<gnc:mdi-info*> mi)
((<gw:m-chars-caller-owned>) bookname))
"Save the MDI window configuration for the specified book")
(gw:wrap-function
mod
'gnc:mdi-restore
'<gw:void>
"gnc_mdi_restore" '((<gnc:mdi-info*> mi)
((<gw:m-chars-caller-owned> gw:const) bookname))
"Restore MDI window configuration for the specified book")
)

View File

@ -130,13 +130,6 @@ gnucash_ui_is_terminating(void)
return gnome_is_terminating;
}
static gboolean
gnc_ui_can_cancel_save (void)
{
return gnc_main_window_can_cancel_save (gnc_mdi_get_current ());
}
static const char* gnc_scheme_remaining_var = "gnc:*command-line-remaining*";
static char**
@ -543,7 +536,7 @@ gnucash_ui_init(void)
gnc_ui_commodity_set_help_callback (gnc_commodity_help_cb);
gnc_file_set_can_cancel_callback (gnc_ui_can_cancel_save);
gnc_file_set_can_cancel_callback (gnc_mdi_has_apps);
gnc_options_dialog_set_global_help_cb (gnc_global_options_help_cb, NULL);

View File

@ -192,22 +192,6 @@ gnc_main_window_create_child(const gchar * configstring) {
* gnc_main_window_can_*()
********************************************************************/
gboolean
gnc_main_window_can_save (GNCMDIInfo * wind)
{
if (!wind) return FALSE;
return gnc_mdi_has_apps ();
}
gboolean
gnc_main_window_can_cancel_save (GNCMDIInfo *wind)
{
if (!wind) return FALSE;
return gnc_mdi_has_apps ();
}
static gboolean
gnc_main_window_can_restore_cb (const char * filename)
{

View File

@ -24,12 +24,8 @@
#ifndef WINDOW_MAIN_H
#define WINDOW_MAIN_H
#include <glib.h>
#include "gnc-mdi-utils.h"
GNCMDIInfo * gnc_main_window_new (void);
gboolean gnc_main_window_can_save (GNCMDIInfo * wind);
gboolean gnc_main_window_can_cancel_save (GNCMDIInfo *wind);
GNCMDIInfo * gnc_main_window_new (void);
#endif

View File

@ -128,8 +128,7 @@ the account instead of opening a register.") #f))
(if (not save-file?) (gnc:warn (_ "Can't save window state")))
(if (and save-file? conf-file-name
(gnc:main-window-can-save? (gnc:mdi-get-current)))
(if (and save-file? conf-file-name (gnc:mdi-has-apps?))
(let ((book-path (build-path (getenv "HOME") ".gnucash" "books"
conf-file-name)))
(with-output-to-port (open-output-file book-path)