Bill Gribble's patch to add gtkhtml support, key-value pairs,

and g-wrapping of the query api.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2545 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-07-08 12:35:12 +00:00
parent 4b013b67dd
commit 79ee7381ad
55 changed files with 1351 additions and 480 deletions

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -63,8 +63,8 @@
/* If configure found libXpm, then use it */
#define HAVE_XPM
/* Use the new XmHTML widdget instead of the old htmlw widget */
#define HAVE_LIBXMHTML 1
/* Use the new gtkhtml widget instead of the old xmhtml widget */
#define HAVE_LIBGTKHTML 1
/* use gnomeprint if it's available */
#undef HAVE_LIBGNOMEPRINT

View File

@ -78,6 +78,9 @@
/* If configure found libXpm, then use it */
#define HAVE_XPM
/* Use the new gtkhtml widget instead of the old xmhtml widget */
#define HAVE_LIBGTKHTML 1
/* use gnomeprint if it's available */
#undef HAVE_LIBGNOMEPRINT

170
configure vendored
View File

@ -5296,7 +5296,7 @@ if test "${with_imlib+set}" = set; then
fi
# the XmHTML widget needs libz, libjpeg, and libpng.
# the gtkhtml widget needs libz, libjpeg, and libpng.
# it also uses #ifdef's not #if's so DONT #def to zero.
echo $ac_n "checking for deflateEnd in -lz""... $ac_c" 1>&6
echo "configure:5303: checking for deflateEnd in -lz" >&5
@ -5482,108 +5482,12 @@ EOF
fi
### -------------------------------------------------------------------------
## gtk-xmhtml
# if gtk-xmhtml header or library not found, gnome builds are disabled
# make gnome will run make gnome.disabled which echoes a warning message
## XXX - need to do this because gtk-xmhtml requires glibconfig.h
## and I don't want CPPFLAGS permanently altered.
## If there's a better way to tackle this please let me know!
OLDCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS `$GNOME_CONFIG_BIN --cflags gnome`"
# gnome targets if all goes well
# XXX - should we shift these to the rest of the gnome configuration
# section?
GNOME_TARGET="gnome.real"
GNOME_STATIC_TARGET="gnome.static.real"
#AC_CHECK_HEADER might work, but I'm not sure it uses CPPFLAGS
# this guarantees it - it works. Promise!!
echo $ac_n "checking gtk-xmhtml/gtk-xmhtml.h""... $ac_c" 1>&6
echo "configure:5509: checking gtk-xmhtml/gtk-xmhtml.h" >&5
cat > conftest.$ac_ext <<EOF
#line 5511 "configure"
#include "confdefs.h"
#include <gtk-xmhtml/gtk-xmhtml.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:5516: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
{ echo "configure: error: Cannot find gtk-xmhtml.h. See the README for more info." 1>&2; exit 1; }
fi
rm -f conftest*
#undo damage to CPPFLAGS
CPPFLAGS="$OLDCPPFLAGS"
### --------------------------------------------------------------------------
EXTRALIBS=`$GNOME_CONFIG_BIN --libs gtkxmhtml`
#check for gtkxmhtml, export library link to variable GTK_XMHTML
echo $ac_n "checking for gtk_xmhtml_new in -lgtkxmhtml""... $ac_c" 1>&6
echo "configure:5539: checking for gtk_xmhtml_new in -lgtkxmhtml" >&5
ac_lib_var=`echo gtkxmhtml'_'gtk_xmhtml_new | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lgtkxmhtml $EXTRALIBS $LIBS"
cat > conftest.$ac_ext <<EOF
#line 5547 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char gtk_xmhtml_new();
int main() {
gtk_xmhtml_new()
; return 0; }
EOF
if { (eval echo configure:5558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
GTK_XMHTML="gtkxmhtml"
else
echo "$ac_t""no" 1>&6
{ echo "configure: error: Cannot find libgtkxmhtml. See the README for more info." 1>&2; exit 1; }
fi
### --------------------------------------------------------------------------
EXTRALIBS=`$GNOME_CONFIG_BIN --libs xml`
#check for libxml
echo $ac_n "checking for xmlDefaultSAXHandlerInit in -lxml""... $ac_c" 1>&6
echo "configure:5587: checking for xmlDefaultSAXHandlerInit in -lxml" >&5
echo "configure:5491: checking for xmlDefaultSAXHandlerInit in -lxml" >&5
ac_lib_var=`echo xml'_'xmlDefaultSAXHandlerInit | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -5591,7 +5495,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lxml $EXTRALIBS $LIBS"
cat > conftest.$ac_ext <<EOF
#line 5595 "configure"
#line 5499 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -5602,7 +5506,7 @@ int main() {
xmlDefaultSAXHandlerInit()
; return 0; }
EOF
if { (eval echo configure:5606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:5510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -5630,7 +5534,7 @@ EXTRALIBS=`$GNOME_CONFIG_BIN --libs print`
# check for gnome-print and enable it via HAVE_LIBGNOMEPRINT
# if found
echo $ac_n "checking for gnome_print_context_new in -lgnomeprint""... $ac_c" 1>&6
echo "configure:5634: checking for gnome_print_context_new in -lgnomeprint" >&5
echo "configure:5538: checking for gnome_print_context_new in -lgnomeprint" >&5
ac_lib_var=`echo gnomeprint'_'gnome_print_context_new | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -5638,7 +5542,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lgnomeprint $EXTRALIBS $LIBS"
cat > conftest.$ac_ext <<EOF
#line 5642 "configure"
#line 5546 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -5649,7 +5553,7 @@ int main() {
gnome_print_context_new()
; return 0; }
EOF
if { (eval echo configure:5653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:5557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -5673,6 +5577,55 @@ else
echo "$ac_t""no" 1>&6
fi
### --------------------------------------------------------------------------
EXTRALIBS=`$GNOME_CONFIG_BIN --libs gtkhtml`
# check for gtkhtml and enable it via HAVE_LIBGTKHTML
# if found
echo $ac_n "checking for gtk_html_new in -lgtkhtml""... $ac_c" 1>&6
echo "configure:5587: checking for gtk_html_new in -lgtkhtml" >&5
ac_lib_var=`echo gtkhtml'_'gtk_html_new | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lgtkhtml $EXTRALIBS $LIBS"
cat > conftest.$ac_ext <<EOF
#line 5595 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char gtk_html_new();
int main() {
gtk_html_new()
; return 0; }
EOF
if { (eval echo configure:5606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
GNOMEBUILDLIBS="${GNOMEBUILDLIBS} gtkhtml"
cat >> confdefs.h <<\EOF
#define HAVE_LIBGTKHTML 1
EOF
else
echo "$ac_t""no" 1>&6
fi
@ -5688,7 +5641,7 @@ cat >> confdefs.h <<\EOF
EOF
GNOMEBUILDLIBS="gnomeui gnome gtkxmhtml xml ${GNOMEBUILDLIBS}"
GNOMEBUILDLIBS="gnomeui gnome xml ${GNOMEBUILDLIBS}"
if test "${GNOME_CONFIG_BIN}"x != GNOME_CONFIG_NOT_FOUNDx
then
@ -5709,7 +5662,7 @@ G_WRAP_LINK_ARGS=""
# Extract the first word of "g-wrap-config", so it can be a program name with args.
set dummy g-wrap-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:5713: checking for $ac_word" >&5
echo "configure:5666: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_G_WRAP_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -5753,7 +5706,7 @@ fi
# Extract the first word of "g-wrap", so it can be a program name with args.
set dummy g-wrap; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:5757: checking for $ac_word" >&5
echo "configure:5710: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_G_WRAP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -5811,7 +5764,7 @@ GUILE_LINK_ARGS=""
# Extract the first word of "guile-config", so it can be a program name with args.
set dummy guile-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:5815: checking for $ac_word" >&5
echo "configure:5768: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GUILE_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -5855,7 +5808,7 @@ fi
# Extract the first word of "guile", so it can be a program name with args.
set dummy guile; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:5859: checking for $ac_word" >&5
echo "configure:5812: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_GUILE'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -6141,7 +6094,6 @@ s%@X_CFLAGS@%$X_CFLAGS%g
s%@X_PRE_LIBS@%$X_PRE_LIBS%g
s%@X_LIBS@%$X_LIBS%g
s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
s%@GTK_XMHTML@%$GTK_XMHTML%g
s%@GNOME_TARGET@%$GNOME_TARGET%g
s%@GNOME_STATIC_TARGET@%$GNOME_STATIC_TARGET%g
s%@GNOME_CFLAGS@%$GNOME_CFLAGS%g

View File

@ -264,7 +264,7 @@ AC_ARG_WITH( imlib,
[ --with-imlib=PATH specify where to look for imlib includes and libs],
X_LIBS="${X_LIBS} -L$with_imlib/lib" X_CFLAGS="$X_CFLAGS -I$with_imlib/include" )
# the XmHTML widget needs libz, libjpeg, and libpng.
# the gtkhtml widget needs libz, libjpeg, and libpng.
# it also uses #ifdef's not #if's so DONT #def to zero.
AC_CHECK_LIB(z, deflateEnd,
AC_DEFINE(HAVE_ZLIB,1))
@ -284,48 +284,6 @@ AC_CHECK_LIB(Xpm, XpmReadFileToXpmImage,
AC_MSG_ERROR([Cannot find required Xpm library]),
$X_PRE_LIBS -lX11 $X_LIBS $X_EXTRA_LIBS)
### -------------------------------------------------------------------------
## gtk-xmhtml
# if gtk-xmhtml header or library not found, gnome builds are disabled
# make gnome will run make gnome.disabled which echoes a warning message
## XXX - need to do this because gtk-xmhtml requires glibconfig.h
## and I don't want CPPFLAGS permanently altered.
## If there's a better way to tackle this please let me know!
OLDCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS `$GNOME_CONFIG_BIN --cflags gnome`"
# gnome targets if all goes well
# XXX - should we shift these to the rest of the gnome configuration
# section?
GNOME_TARGET="gnome.real"
GNOME_STATIC_TARGET="gnome.static.real"
#AC_CHECK_HEADER might work, but I'm not sure it uses CPPFLAGS
# this guarantees it - it works. Promise!!
AC_MSG_CHECKING([gtk-xmhtml/gtk-xmhtml.h])
AC_TRY_CPP([#include <gtk-xmhtml/gtk-xmhtml.h>],
AC_MSG_RESULT(yes),
AC_MSG_ERROR([Cannot find gtk-xmhtml.h. See the README for more info.]))
#undo damage to CPPFLAGS
CPPFLAGS="$OLDCPPFLAGS"
### --------------------------------------------------------------------------
EXTRALIBS=`$GNOME_CONFIG_BIN --libs gtkxmhtml`
#check for gtkxmhtml, export library link to variable GTK_XMHTML
AC_CHECK_LIB(gtkxmhtml, gtk_xmhtml_new,
GTK_XMHTML="gtkxmhtml",
AC_MSG_ERROR([Cannot find libgtkxmhtml. See the README for more info.]),
$EXTRALIBS)
AC_SUBST(GTK_XMHTML)
### --------------------------------------------------------------------------
EXTRALIBS=`$GNOME_CONFIG_BIN --libs xml`
@ -345,6 +303,16 @@ AC_CHECK_LIB(gnomeprint, gnome_print_context_new,
AC_DEFINE(HAVE_LIBGNOMEPRINT),
,
$EXTRALIBS)
### --------------------------------------------------------------------------
EXTRALIBS=`$GNOME_CONFIG_BIN --libs gtkhtml`
# check for gtkhtml and enable it via HAVE_LIBGTKHTML
# if found
AC_CHECK_LIB(gtkhtml, gtk_html_new,
GNOMEBUILDLIBS="${GNOMEBUILDLIBS} gtkhtml"
AC_DEFINE(HAVE_LIBGTKHTML),
,
$EXTRALIBS)
AC_SUBST(GNOME_TARGET)
AC_SUBST(GNOME_STATIC_TARGET)
@ -357,7 +325,7 @@ AC_SUBST(GNOME_STATIC_TARGET)
GNOME=1
AC_DEFINE(GNOME)
GNOMEBUILDLIBS="gnomeui gnome gtkxmhtml xml ${GNOMEBUILDLIBS}"
GNOMEBUILDLIBS="gnomeui gnome xml ${GNOMEBUILDLIBS}"
if test "${GNOME_CONFIG_BIN}"x != GNOME_CONFIG_NOT_FOUNDx
then

1
debian/Makefile.in vendored
View File

@ -84,7 +84,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -221,6 +221,41 @@ xaccAccountCommitEdit (Account *acc)
acc->open = 0;
}
/********************************************************************
* xaccAccountGetSlot
********************************************************************/
kvp_value *
xaccAccountGetSlot(Account * account, const char * key) {
if(!account || !key || !(account->kvp_data)) {
return NULL;
}
else {
return kvp_frame_get_slot(account->kvp_data, key);
}
}
/********************************************************************
* xaccAccountSetSlot
********************************************************************/
void
xaccAccountSetSlot(Account * account, const char * key,
const kvp_value * value) {
if(!account || !key || !value) {
return;
}
else {
if(!account->kvp_data) {
account->kvp_data = kvp_frame_new();
}
kvp_frame_set_slot(account->kvp_data, key, value);
}
}
/********************************************************************\
\********************************************************************/

View File

@ -28,6 +28,7 @@
#include "config.h"
#include "AccInfo.h"
#include "Transaction.h"
#include "kvp_frame.h"
#include "GNCId.h"
@ -50,6 +51,10 @@ void xaccFreeAccount( Account * );
void xaccAccountBeginEdit (Account *, int defer);
void xaccAccountCommitEdit (Account *);
kvp_value * xaccAccountGetSlot(Account * account, const char * key);
void xaccAccountSetSlot(Account * account, const char * key,
const kvp_value * value);
/*
* The xaccAccountGetGUID() subroutine will return the
* globally unique id associated with that account.

View File

@ -43,6 +43,7 @@
#define __XACC_ACCOUNT_P_H__
#include "config.h"
#include "kvp_frame.h"
#include "AccInfo.h"
#include "GNCId.h"
#include "Transaction.h"
@ -83,6 +84,11 @@ struct _account {
*/
char *notes;
/* kvp_data is a key-value pair database for storing simple
* "extra" information in splits, transactions, and accounts.
* it's NULL until accessed. */
kvp_frame * kvp_data;
/* The type field is the account type, picked from the enumerated
* list that includes BANK, STOCK, CREDIT, INCOME, etc. Its
* intended use is to be a hint to the GUI as to how to display

View File

@ -24,7 +24,8 @@ libgncengine_la_SOURCES = \
util.c \
GNCId.c \
guid.c \
md5.c
md5.c \
kvp_frame.c
libgncengine_la_LDFLAGS = -version-info 1:1:1
@ -53,7 +54,8 @@ noinst_HEADERS = \
gnc-common.h \
guid.h \
md5.h \
util.h
util.h \
kvp_frame.h
EXTRA_DIST = \
.cvsignore \

View File

@ -83,7 +83,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@
@ -124,12 +123,12 @@ SUBDIRS = sql
lib_LTLIBRARIES = libgncengine.la
# Build hell from main.c and libhello.la
libgncengine_la_SOURCES = AccInfo.c Account.c Backend.c DateUtils.c FileIO.c Group.c LedgerUtils.c Query.c Queue.c Scrub.c Session.c Transaction.c TransLog.c date.c util.c GNCId.c guid.c md5.c
libgncengine_la_SOURCES = AccInfo.c Account.c Backend.c DateUtils.c FileIO.c Group.c LedgerUtils.c Query.c Queue.c Scrub.c Session.c Transaction.c TransLog.c date.c util.c GNCId.c guid.c md5.c kvp_frame.c
libgncengine_la_LDFLAGS = -version-info 1:1:1
noinst_HEADERS = AccInfo.h AccInfoP.h Account.h AccountP.h BackendP.h DateUtils.h FileIO.h FileIOP.h GNCId.h GNCIdP.h Group.h GroupP.h LedgerUtils.h Query.h Queue.h Scrub.h Session.h TransLog.h Transaction.h TransactionP.h date.h gnc-common.h guid.h md5.h util.h
noinst_HEADERS = AccInfo.h AccInfoP.h Account.h AccountP.h BackendP.h DateUtils.h FileIO.h FileIOP.h GNCId.h GNCIdP.h Group.h GroupP.h LedgerUtils.h Query.h Queue.h Scrub.h Session.h TransLog.h Transaction.h TransactionP.h date.h gnc-common.h guid.h md5.h util.h kvp_frame.h
EXTRA_DIST = .cvsignore README.query-api design.txt extensions.txt
@ -155,7 +154,8 @@ X_PRE_LIBS = @X_PRE_LIBS@
libgncengine_la_LIBADD =
libgncengine_la_OBJECTS = AccInfo.lo Account.lo Backend.lo DateUtils.lo \
FileIO.lo Group.lo LedgerUtils.lo Query.lo Queue.lo Scrub.lo Session.lo \
Transaction.lo TransLog.lo date.lo util.lo GNCId.lo guid.lo md5.lo
Transaction.lo TransLog.lo date.lo util.lo GNCId.lo guid.lo md5.lo \
kvp_frame.lo
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
@ -173,7 +173,7 @@ DEP_FILES = .deps/AccInfo.P .deps/Account.P .deps/Backend.P \
.deps/DateUtils.P .deps/FileIO.P .deps/GNCId.P .deps/Group.P \
.deps/LedgerUtils.P .deps/Query.P .deps/Queue.P .deps/Scrub.P \
.deps/Session.P .deps/TransLog.P .deps/Transaction.P .deps/date.P \
.deps/guid.P .deps/md5.P .deps/util.P
.deps/guid.P .deps/kvp_frame.P .deps/md5.P .deps/util.P
SOURCES = $(libgncengine_la_SOURCES)
OBJECTS = $(libgncengine_la_OBJECTS)

View File

@ -108,6 +108,8 @@ xaccInitSplit(Split * split)
split->cost_basis = 0.0;
split->ticket = 0;
split->kvp_data = NULL;
xaccGUIDNew(&split->guid);
xaccStoreEntity(split, &split->guid, GNC_ID_SPLIT);
}
@ -193,6 +195,37 @@ xaccFreeSplit( Split *split )
_free(split);
}
/********************************************************************
* xaccSplitGetSlot
********************************************************************/
kvp_value *
xaccSplitGetSlot(Split * split, const char * key) {
if(!split || !key || !(split->kvp_data)) {
return NULL;
}
else {
return kvp_frame_get_slot(split->kvp_data, key);
}
}
/********************************************************************
* xaccSplitSetSlot
********************************************************************/
void
xaccSplitSetSlot(Split * split, const char * key, const kvp_value * value) {
if(!split || !key || !value) {
return;
}
else {
if(!split->kvp_data) {
split->kvp_data = kvp_frame_new();
}
kvp_frame_set_slot(split->kvp_data, key, value);
}
}
/********************************************************************\
\********************************************************************/
@ -410,6 +443,8 @@ xaccInitTransaction( Transaction * trans )
trans->open = 0;
trans->orig = NULL;
trans->kvp_data = NULL;
xaccGUIDNew(&trans->guid);
xaccStoreEntity(trans, &trans->guid, GNC_ID_TRANS);
}
@ -526,6 +561,38 @@ xaccFreeTransaction( Transaction *trans )
LEAVE ("addr=%p\n", trans);
}
/********************************************************************
* xaccTransGetSlot
********************************************************************/
kvp_value *
xaccTransGetSlot(Transaction * trans, const char * key) {
if(!trans || !key || !(trans->kvp_data)) {
return NULL;
}
else {
return kvp_frame_get_slot(trans->kvp_data, key);
}
}
/********************************************************************
* xaccTransSetSlot
********************************************************************/
void
xaccTransSetSlot(Transaction * trans, const char * key,
const kvp_value * value) {
if(!trans || !key || !value) {
return;
}
else {
if(!trans->kvp_data) {
trans->kvp_data = kvp_frame_new();
}
kvp_frame_set_slot(trans->kvp_data, key, value);
}
}
/********************************************************************\
\********************************************************************/

View File

@ -30,6 +30,7 @@
#include <time.h>
#include "gnc-common.h"
#include "kvp_frame.h"
#include "GNCId.h"
@ -159,6 +160,16 @@ gncBoolean xaccTransIsOpen (Transaction *trans);
const GUID * xaccTransGetGUID (Transaction *trans);
Transaction * xaccTransLookup (const GUID *guid);
/* xaccTransGetSlot and xaccTransSetSlot reference the kvp_data
* field of the transaction. kvp_data is used to store arbitrary
* strings, numbers, and structures which aren't "official" members
* of the transaction structure. */
kvp_value * xaccTransGetSlot(Transaction * trans, const char * key);
void xaccTransSetSlot(Transaction * trans, const char * key,
const kvp_value * value);
/* Convert a day, month, and year to a Timespec */
Timespec gnc_dmy2timespec(int day, int month, int year);
@ -312,6 +323,16 @@ double xaccTransGetImbalance (Transaction * trans);
Split * xaccMallocSplit (void);
void xaccInitSplit (Split *); /* clears a split struct */
/* xaccSplitGetSlot and xaccSplitSetSlot reference the kvp_data field
* of the split. kvp_data is used to store arbitrary strings,
* numbers, and structures which aren't "official" members of the
* split structure. */
kvp_value * xaccSplitGetSlot(Split * split, const char * key);
void xaccSplitSetSlot(Split * split, const char * key,
const kvp_value * value);
/*
* The xaccSplitGetGUID() subroutine will return the
* globally unique id associated with that split.

View File

@ -2,6 +2,7 @@
* TransactionP.h -- defines transaction for xacc (X-Accountant) *
* Copyright (C) 1997 Robin D. Clark *
* Copyright (C) 1997, 1998, 1999, 2000 Linas Vepstas *
* Copyright (C) 2000 Bill Gribble *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@ -45,8 +46,10 @@
#define __XACC_TRANSACTION_P_H__
#include <time.h>
#include <glib.h>
#include "config.h"
#include "kvp_frame.h"
#include "Transaction.h" /* for typedefs */
#include "GNCId.h"
@ -99,6 +102,11 @@ struct _split
*/
char * docref;
/* kvp_data is a key-value pair database for storing simple
* "extra" information in splits, transactions, and accounts.
* it's NULL until accessed. */
kvp_frame * kvp_data;
/* The reconciled field ...
*/
char reconciled;
@ -158,6 +166,11 @@ struct _transaction
*/
char * docref;
/* kvp_data is a key-value pair database for storing simple
* "extra" information in splits, transactions, and accounts.
* it's NULL until accessed. */
kvp_frame * kvp_data;
Split **splits; /* list of splits, null terminated */
/* marker is used to track the progress of transaction traversals.

View File

@ -22,7 +22,7 @@
\********************************************************************/
#ifndef __GUID__
#define __GUID__ 1
#define __GUID__
#ifdef HAVE_CONFIG_H
# include <config.h>

526
src/engine/kvp_frame.c Normal file
View File

@ -0,0 +1,526 @@
/********************************************************************
* kvp_frame.h -- a key-value frame system for gnucash. *
* Copyright (C) 2000 Bill Gribble *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
********************************************************************/
#include "kvp_frame.h"
#include "guid.h"
#include <string.h>
#include <glib.h>
struct _kvp_frame {
GHashTable * hash;
};
struct _kvp_list {
GList * list;
};
struct _kvp_value_int64 {
kvp_value_t type;
gint64 value;
};
struct _kvp_value_float64 {
kvp_value_t type;
double value;
};
struct _kvp_value_string {
kvp_value_t type;
char * value;
};
struct _kvp_value_guid {
kvp_value_t type;
GUID * value;
};
struct _kvp_value_binary {
kvp_value_t type;
void * value;
int datasize;
};
struct _kvp_value_frame {
kvp_value_t type;
kvp_frame * value;
};
struct _kvp_value_list {
kvp_value_t type;
kvp_list * value;
};
union _kvp_value {
kvp_value_t type;
struct _kvp_value_int64 int64;
struct _kvp_value_float64 float64;
struct _kvp_value_string str;
struct _kvp_value_guid guid;
struct _kvp_value_binary binary;
struct _kvp_value_list list;
struct _kvp_value_frame frame;
};
/********************************************************************
* kvp_frame functions
********************************************************************/
static guint
kvp_hash_func(gconstpointer v) {
return g_str_hash(v);
}
static gint
kvp_comp_func(gconstpointer v, gconstpointer v2) {
return g_str_equal(v, v2);
}
kvp_frame *
kvp_frame_new() {
kvp_frame * retval = g_new0(kvp_frame, 1);
retval->hash = g_hash_table_new(&kvp_hash_func,
&kvp_comp_func);
return retval;
}
static void
kvp_frame_delete_worker(gpointer key, gpointer value, gpointer user_data) {
kvp_value_delete((kvp_value *)value);
}
void
kvp_frame_delete(kvp_frame * frame) {
/* free any allocated resource for frame or its children */
g_hash_table_foreach(frame->hash, & kvp_frame_delete_worker,
(gpointer)frame);
/* delete the hash table */
g_hash_table_destroy(frame->hash);
frame->hash = NULL;
g_free(frame);
}
static void
kvp_frame_copy_worker(gpointer key, gpointer value, gpointer user_data) {
kvp_frame * dest = (kvp_frame *)user_data;
g_hash_table_freeze(dest->hash);
g_hash_table_insert(dest->hash,
(gpointer)strdup(key),
(gpointer)kvp_value_copy(value));
g_hash_table_thaw(dest->hash);
}
kvp_frame *
kvp_frame_copy(const kvp_frame * frame) {
kvp_frame * retval = kvp_frame_new();
g_hash_table_foreach(frame->hash,
& kvp_frame_copy_worker,
(gpointer)retval);
return retval;
}
void
kvp_frame_set_slot(kvp_frame * frame, const char * slot,
const kvp_value * value) {
g_hash_table_freeze(frame->hash);
g_hash_table_insert(frame->hash,
(gpointer)strdup(slot),
(gpointer)kvp_value_copy(value));
g_hash_table_thaw(frame->hash);
}
kvp_value *
kvp_frame_get_slot(kvp_frame * frame, const char * slot) {
return (kvp_value *)g_hash_table_lookup(frame->hash, slot);
}
/********************************************************************
* kvp_list functions
********************************************************************/
kvp_list *
kvp_list_new() {
kvp_list * retval = g_new0(kvp_list, 1);
retval->list = NULL;
return retval;
}
static void
kvp_list_delete_worker(gpointer datum, gpointer user_data) {
kvp_value * val = (kvp_value *)datum;
kvp_value_delete(val);
}
void
kvp_list_delete(kvp_list * list) {
if(list) {
if(list->list) {
/* delete the data in the list */
g_list_foreach(list->list, & kvp_list_delete_worker, NULL);
/* free the backbone */
g_list_free(list->list);
}
g_free(list);
}
}
kvp_list *
kvp_list_copy(const kvp_list * list) {
kvp_list * retval = kvp_list_new();
GList * lptr;
if(!list) return retval;
/* duplicate the backbone of the list (this duplicates the POINTERS
* to the values; we need to deep-copy the values separately) */
retval->list = g_list_copy(list->list);
/* this step deep-copies the values */
for(lptr = retval->list; lptr; lptr = lptr->next) {
lptr->data = kvp_value_copy(lptr->data);
}
return retval;
}
int
kvp_list_null_p(const kvp_list * list) {
return (!list || (list->list == NULL));
}
kvp_value *
kvp_list_car(kvp_list * list) {
if(!list || (list->list == NULL)) {
return NULL;
}
else {
return (kvp_value *)(list->list->data);
}
}
kvp_list *
kvp_list_cdr(kvp_list * list) {
kvp_list * retval;
if(!list || (list->list == NULL)) {
return NULL;
}
else {
retval = kvp_list_new();
retval->list = list->list->next;
return retval;
}
}
/* cons semantics are "hand over": you give it pointers to
* your objects and the list handles them after that. */
kvp_list *
kvp_list_cons(kvp_value * car, kvp_list * cdr) {
kvp_list * retval;
if(!car || !cdr) {
return NULL;
}
else {
retval = kvp_list_new();
retval->list = g_list_prepend( cdr->list, (gpointer)car);
cdr->list = NULL;
kvp_list_delete(cdr);
return retval;
}
}
kvp_list *
kvp_list_1(kvp_value * value) {
kvp_list * retval = kvp_list_new();
retval = kvp_list_cons(value, retval);
return retval;
}
kvp_list *
kvp_list_2(kvp_value * value1, kvp_value * value2) {
kvp_list * retval = kvp_list_new();
retval = kvp_list_cons(value2, retval);
retval = kvp_list_cons(value1, retval);
return retval;
}
kvp_list *
kvp_list_3(kvp_value * value1, kvp_value * value2,
kvp_value * value3) {
kvp_list * retval = kvp_list_new();
retval = kvp_list_cons(value3, retval);
retval = kvp_list_cons(value2, retval);
retval = kvp_list_cons(value1, retval);
return retval;
}
kvp_list *
kvp_list_4(kvp_value * value1, kvp_value * value2,
kvp_value * value3, kvp_value * value4) {
kvp_list * retval = kvp_list_new();
retval = kvp_list_cons(value4, retval);
retval = kvp_list_cons(value3, retval);
retval = kvp_list_cons(value2, retval);
retval = kvp_list_cons(value1, retval);
return retval;
}
kvp_list *
kvp_list_5(kvp_value * value1, kvp_value * value2,
kvp_value * value3, kvp_value * value4,
kvp_value * value5) {
kvp_list * retval = kvp_list_new();
retval = kvp_list_cons(value5, retval);
retval = kvp_list_cons(value4, retval);
retval = kvp_list_cons(value3, retval);
retval = kvp_list_cons(value2, retval);
retval = kvp_list_cons(value1, retval);
return retval;
}
/********************************************************************
* kvp_value functions
********************************************************************/
kvp_value *
kvp_value_new() {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_NONE;
return retval;
}
kvp_value *
kvp_value_new_int64(gint64 value) {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_INT64;
retval->int64.value = value;
return retval;
}
kvp_value *
kvp_value_new_float64(double value) {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_FLOAT64;
retval->float64.value = value;
return retval;
}
kvp_value *
kvp_value_new_string(const char * value) {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_STRING;
retval->str.value = strdup(value);
return retval;
}
kvp_value *
kvp_value_new_guid(const GUID * value) {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_GUID;
retval->guid.value = g_new0(GUID, 1);
memcpy(retval->guid.value, value, sizeof(GUID));
return retval;
}
kvp_value *
kvp_value_new_binary(const void * value, int datasize) {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_BINARY;
retval->binary.value = g_new0(char, datasize);
retval->binary.datasize = datasize;
memcpy(retval->binary.value, value, datasize);
return retval;
}
kvp_value *
kvp_value_new_list(const kvp_list * value) {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_LIST;
retval->list.value = kvp_list_copy(value);
return retval;
}
kvp_value *
kvp_value_new_frame(const kvp_frame * value) {
kvp_value * retval = g_new0(kvp_value, 1);
retval->type = KVP_TYPE_FRAME;
retval->frame.value = kvp_frame_copy(value);
return retval;
}
void
kvp_value_delete(kvp_value * value) {
if(!value) return;
switch(value->type) {
case KVP_TYPE_STRING:
g_free(value->str.value);
break;
case KVP_TYPE_GUID:
g_free(value->guid.value);
break;
case KVP_TYPE_BINARY:
g_free(value->binary.value);
break;
case KVP_TYPE_LIST:
kvp_list_delete(value->list.value);
break;
case KVP_TYPE_FRAME:
kvp_frame_delete(value->frame.value);
break;
case KVP_TYPE_NONE:
case KVP_TYPE_INT64:
case KVP_TYPE_FLOAT64:
default:
}
g_free(value);
}
kvp_value_t
kvp_value_get_type(const kvp_value * value) {
return value->type;
}
gint64
kvp_value_get_int64(const kvp_value * value) {
if(value->type == KVP_TYPE_INT64) {
return value->int64.value;
}
else {
return 0;
}
}
double
kvp_value_get_float64(const kvp_value * value) {
if(value->type == KVP_TYPE_FLOAT64) {
return value->float64.value;
}
else {
return 0.0;
}
}
char *
kvp_value_get_string(const kvp_value * value) {
if(value->type == KVP_TYPE_STRING) {
return value->str.value;
}
else {
return NULL;
}
}
GUID *
kvp_value_get_guid(const kvp_value * value) {
if(value->type == KVP_TYPE_GUID) {
return value->guid.value;
}
else {
return NULL;
}
}
void *
kvp_value_get_binary(const kvp_value * value, int * size_return) {
if(value->type == KVP_TYPE_BINARY) {
*size_return = value->binary.datasize;
return value->binary.value;
}
else {
*size_return = 0;
return NULL;
}
}
kvp_list *
kvp_value_get_list(const kvp_value * value) {
if(value->type == KVP_TYPE_LIST) {
return value->list.value;
}
else {
return NULL;
}
}
kvp_frame *
kvp_value_get_frame(const kvp_value * value) {
if(value->type == KVP_TYPE_FRAME) {
return value->frame.value;
}
else {
return NULL;
}
}
kvp_value *
kvp_value_copy(const kvp_value * value) {
if(!value) return NULL;
switch(value->type) {
case KVP_TYPE_INT64:
return kvp_value_new_int64(value->int64.value);
break;
case KVP_TYPE_FLOAT64:
return kvp_value_new_float64(value->float64.value);
break;
case KVP_TYPE_STRING:
return kvp_value_new_string(value->str.value);
break;
case KVP_TYPE_GUID:
return kvp_value_new_guid(value->guid.value);
break;
case KVP_TYPE_BINARY:
return kvp_value_new_binary(value->binary.value,
value->binary.datasize);
break;
case KVP_TYPE_LIST:
return kvp_value_new_list(value->list.value);
break;
case KVP_TYPE_FRAME:
return kvp_value_new_frame(value->frame.value);
break;
case KVP_TYPE_NONE:
return kvp_value_new();
break;
}
return NULL;
}

95
src/engine/kvp_frame.h Normal file
View File

@ -0,0 +1,95 @@
/********************************************************************\
* kvp_frame.h -- a key-value frame system for gnucash.
* Copyright (C) 2000 Bill Gribble *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
#ifndef __KVP_FRAME_H__
#define __KVP_FRAME_H__
#include <sys/types.h>
#include <guid.h>
#include <glib.h>
/* a kvp_frame is a set of associations between character strings
* (keys) and kvp_value structures. A kvp_value is a union with
* possible types enumerated in the kvp_value_t enum.
*
* Pointers passed as arguments into set_slot and get_slot are the
* responsibility of the caller. Pointers returned by get_slot are
* the responsibility of the caller (they point to newly-allocated
* structures which are deep value copies of those in the frame).
*
* kvp_frame_delete and kvp_value_delete are deep (recursive) deletes.
* kvp_frame_copy and kvp_value_copy are deep value copies. */
typedef enum { KVP_TYPE_NONE,
KVP_TYPE_INT64, KVP_TYPE_FLOAT64,
KVP_TYPE_STRING, KVP_TYPE_GUID, KVP_TYPE_BINARY,
KVP_TYPE_LIST, KVP_TYPE_FRAME } kvp_value_t;
typedef struct _kvp_frame kvp_frame;
typedef struct _kvp_list kvp_list;
typedef union _kvp_value kvp_value;
/* kvp_frame functions */
kvp_frame * kvp_frame_new();
void kvp_frame_delete(kvp_frame * frame);
kvp_frame * kvp_frame_copy(const kvp_frame * frame);
void kvp_frame_set_slot(kvp_frame * frame,
const char * key, const kvp_value * value);
kvp_value * kvp_frame_get_slot(kvp_frame * frame,
const char * key);
kvp_value * kvp_value_new();
void kvp_value_delete(kvp_value * value);
kvp_value * kvp_value_copy(const kvp_value * value);
/* kvp_list functions */
kvp_list * kvp_list_new();
void kvp_list_delete(kvp_list * list);
kvp_list * kvp_list_copy(const kvp_list * list);
int kvp_list_null_p(const kvp_list * list);
kvp_value * kvp_list_car(kvp_list * list);
kvp_list * kvp_list_cdr(kvp_list * list);
kvp_list * kvp_list_cons(kvp_value * car, kvp_list * cdr);
/* value constructors (copying for pointer args) */
kvp_value * kvp_value_new_int64(gint64 value);
kvp_value * kvp_value_new_float64(double value);
kvp_value * kvp_value_new_string(const char * value);
kvp_value * kvp_value_new_guid(const GUID * guid);
kvp_value * kvp_value_new_binary(const void * data, int datasize);
kvp_value * kvp_value_new_list(const kvp_list * value);
kvp_value * kvp_value_new_frame(const kvp_frame * value);
/* value accessors (NON-copying for frames/lists/guids/binary) */
kvp_value_t kvp_value_get_type(const kvp_value * val);
gint64 kvp_value_get_int64(const kvp_value * val);
double kvp_value_get_float64(const kvp_value * val);
char * kvp_value_get_string(const kvp_value * val);
GUID * kvp_value_get_guid(const kvp_value * val);
void * kvp_value_get_binary(const kvp_value * val, int * size_return);
kvp_list * kvp_value_get_list(const kvp_value * val);
kvp_frame * kvp_value_get_frame(const kvp_value * val);
#endif

View File

@ -84,7 +84,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -234,6 +234,7 @@ gnc_ui_print_dialog_ok_cb(GtkWidget * widget, gpointer user_data) {
}
else {
gnc_print_session_print(pcd->session);
gnc_print_session_done(pcd->session);
gnc_ui_print_dialog_destroy(pcd);
}
}
@ -276,6 +277,9 @@ gnc_print_session_create() {
void
gnc_print_session_destroy(PrintSession * ps) {
gtk_object_unref(GTK_OBJECT(ps->meta));
if(ps->printer)
gtk_object_unref(GTK_OBJECT(ps->printer));
gtk_object_unref(GTK_OBJECT(ps->default_font));
g_free(ps->paper);
@ -315,6 +319,8 @@ gnc_print_session_print(PrintSession * ps) {
pc = gnome_print_context_new(ps->printer);
gnome_print_meta_render_from_object(GNOME_PRINT_CONTEXT(pc),
GNOME_PRINT_META(ps->meta));
gnome_print_context_close(pc);
gtk_object_unref(GTK_OBJECT(pc));
}
#else

View File

@ -27,6 +27,8 @@
#include <stdlib.h>
#include <guile/gh.h>
#include <gnome.h>
#include <gtk/gtk.h>
#include <gtkhtml/gtkhtml.h>
#include "gnome-top-level.h"
#include "window-main.h"
@ -71,8 +73,8 @@ static void gnc_configure_register_borders(void);
static void gnc_configure_reverse_balance_cb(void *);
static void gnc_configure_reverse_balance(void);
static void gnc_configure_sr_label_callbacks();
static void gnc_configure_auto_raise_cb(void *);
static void gnc_configure_auto_raise(void);
static void gnc_configure_auto_raise_cb(void * foo) { }
static void gnc_configure_auto_raise(void) { }
static void gnc_configure_auto_decimal_cb(void *);
static void gnc_configure_auto_decimal(void);
static void gnc_configure_register_font_cb(void *);
@ -80,7 +82,6 @@ static void gnc_configure_register_font(void);
static void gnc_configure_register_hint_font_cb(void *);
static void gnc_configure_register_hint_font(void);
/** GLOBALS *********************************************************/
/* This static indicates the debugging module that this .o belongs to. */
static short module = MOD_GUI;
@ -147,7 +148,12 @@ gnucash_ui_init()
{
gnome_init("GnuCash", NULL, fake_argc, fake_argv);
gnome_is_initialized = TRUE;
/* initialization required for gtkhtml */
gdk_rgb_init ();
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
gtk_widget_set_default_visual (gdk_rgb_get_visual ());
app = gnome_app_new("GnuCash", "GnuCash");
gnc_options_init();
@ -646,37 +652,6 @@ gnc_configure_register_borders(void)
gnucash_style_set_register_borders (reg_borders);
}
/* gnc_configure_auto_raise_cb
* Callback called when options change - sets
* auto-raise status of combocell class
*
* Args: Nothing
* Returns: Nothing
*/
static void
gnc_configure_auto_raise_cb(void *data)
{
gnc_configure_auto_raise();
}
/* gnc_configure_auto_raise
* sets combocell auto raise status
*
* Args: Nothing
* Returns: Nothing
*/
static void
gnc_configure_auto_raise(void)
{
gncBoolean auto_pop;
auto_pop = gnc_lookup_boolean_option("Register",
"Auto-Raise Lists",
GNC_T);
xaccComboCellSetAutoPop(auto_pop);
}
/* gnc_configure_reverse_balance_cb
* Callback called when options change - sets
* reverse balance info for the callback

View File

@ -109,36 +109,35 @@ help_data_set_text(HelpData *help_data, const gchar *text)
static HTMLData *
helpAnchorCB(XmHTMLAnchorCallbackStruct *acbs, HTMLUserData user_data)
helpAnchorCB(URLType url_type, char * location, char * label,
HTMLUserData user_data)
{
HelpData *user = user_data;
HTMLData *html_data;
HelpData *help_data;
switch(acbs->url_type)
{
switch(url_type) {
/* a local file with a possible jump to label */
case ANCHOR_FILE_LOCAL:
help_data = help_data_new();
help_data_set_file(help_data, acbs->href);
help_data_set_title(help_data, user->title);
case URL_TYPE_FILE:
help_data = help_data_new();
help_data_set_file(help_data, location);
help_data_set_title(help_data, user->title);
html_data = gnc_html_data_new(user->title, help_data,
help_data_destroy,
NULL, 0);
html_data = gnc_html_data_new(user->title, help_data,
help_data_destroy,
NULL, 0);
return html_data;
break;
return html_data;
/* other types use gnome_url_show */
case ANCHOR_FTP:
case ANCHOR_HTTP:
case ANCHOR_MAILTO:
case ANCHOR_UNKNOWN:
default:
gnome_url_show(acbs->href);
break;
/* other types use gnc_url_show */
default:
gnc_url_show(url_type, location, label);
return NULL;
break;
}
g_warning("What's going on?\n");
return NULL;
}
@ -173,8 +172,9 @@ helpJumpCB(HTMLUserData user_data, char **set_text, char **set_label)
}
/* if text to display wasn't specified, use the truncated name to read */
if (text == NULL)
text = gncReadFile(help_data->htmlfile);
if (text == NULL) {
gncReadFile(help_data->htmlfile, &text);
}
if (text != NULL)
{

View File

@ -4,6 +4,7 @@
* Copyright (C) 1998 Linas Vepstas <linas@linas.org> *
* Copyright (C) 1999 Jeremy Collins ( gtk-xmhtml port ) *
* Copyright (C) 2000 Linas Vepstas *
* Copyright (C) 2000 Bill Gribble <grib@billgribble.com> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@ -23,19 +24,26 @@
* Boston, MA 02111-1307, USA gnu@gnu.org *
\********************************************************************/
#include "config.h"
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <gtk/gtk.h>
#include <gtkhtml/gtkhtml.h>
#include <gnome.h>
#include <regex.h>
#include "top-level.h"
#include "gnucash.h"
#include "messages.h"
#include "window-html.h"
#include "dialog-utils.h"
#include "global-options.h"
#include "messages.h"
#include "print-session.h"
#include "File.h"
#include "util.h"
static short module = MOD_HTML;
/********************************************************************\
* HTML History functions *
@ -312,40 +320,96 @@ historyDestroy(HTMLHistory *history)
struct _HTMLWindow
{
GtkWidget *window;
GtkWidget *htmlwidget;
GtkWidget * window;
GtkWidget * scroller;
GtkWidget * htmlwidget;
GtkWidget *forward;
GtkWidget *back;
GtkWidget * forward;
GtkWidget * back;
GtkWidget *toolbar;
SCM toolbar_change_callback_id;
GtkWidget * dock;
HTMLHistory *history;
SCM toolbar_change_callback_id;
HTMLAnchorCB anchor_cb;
HTMLJumpCB jump_cb;
char * null_text;
char * null_label;
HTMLHistory * history;
HTMLAnchorCB anchor_cb;
HTMLJumpCB jump_cb;
};
/** PROTOTYPES ******************************************************/
static void htmlBackCB(GtkWidget *widget, gpointer data);
static void htmlFwdCB(GtkWidget *widget, gpointer data);
static void htmlAnchorCB(GtkWidget *widget,
XmHTMLAnchorCallbackStruct *acbs,
gpointer data);
static void htmlPrintCB(GtkWidget * widget, gpointer data);
static void htmlAnchorCB(GtkHTML * html, const gchar * url, gpointer data);
static void htmlUrlCB(GtkHTML * html, char * url,
GtkHTMLStream * handle, gpointer data);
static gboolean htmlKeyCB(GtkWidget *widget, GdkEventKey *event,
gpointer user_data);
static void closeHtmlWinCB(GtkWidget *widget, gpointer data);
static void destroyHtmlWinCB(GtkWidget *widget, gpointer data);
static XmImageInfo * htmlReadImageProc(GtkWidget *widget, String file,
gpointer data);
static void htmlSetButtonStates(HTMLWindow *hw);
/********************************************************************\
* gnc_html_window_new *
* g_malloc and initialize HTMLWindow structure *
* *
* Args: anchor_cb - callback for new html pages *
* jump_cb - callback for html text *
* Return: g_malloc'd initialized HTMLWindow structure *
\********************************************************************/
HTMLWindow *
gnc_html_window_new(HTMLAnchorCB anchor_cb, HTMLJumpCB jump_cb)
{
HTMLWindow *hw;
hw = g_new0(HTMLWindow, 1);
hw->history = historyNew();
hw->anchor_cb = anchor_cb;
hw->jump_cb = jump_cb;
hw->null_text = NULL;
return hw;
}
/********************************************************************\
* gnc_html_window_destroy *
* destroy an HTMLWindow structure *
* *
* Args: hw - the htmlwindow structure to destroy *
* Return: none *
\********************************************************************/
void
gnc_html_window_destroy(HTMLWindow * hw)
{
if (hw == NULL)
return;
if (hw->window != NULL)
gtk_widget_destroy(hw->window);
else
{
historyDestroy(hw->history);
g_free(hw);
}
}
/********************************************************************\
* gnc_html_window_user_data *
* return the current user data for the window *
@ -353,8 +417,9 @@ static void htmlSetButtonStates(HTMLWindow *hw);
* Args: none *
* Return: user data for the window *
\********************************************************************/
HTMLUserData
gnc_html_window_user_data(HTMLWindow *hw)
gnc_html_window_user_data(HTMLWindow * hw)
{
if (hw == NULL)
return NULL;
@ -370,6 +435,7 @@ gnc_html_window_user_data(HTMLWindow *hw)
* Args: none *
* Return: gtk window for html window *
\********************************************************************/
GtkWidget *
gnc_html_window_get_window(HTMLWindow *hw)
{
@ -379,60 +445,13 @@ gnc_html_window_get_window(HTMLWindow *hw)
return hw->window;
}
/********************************************************************\
* gnc_html_window_new *
* g_malloc and initialize HTMLWindow structure *
* *
* Args: anchor_cb - callback for new html pages *
* jump_cb - callback for html text *
* Return: g_malloc'd initialized HTMLWindow structure *
\********************************************************************/
HTMLWindow *
gnc_html_window_new(HTMLAnchorCB anchor_cb, HTMLJumpCB jump_cb)
{
HTMLWindow *hw;
hw = g_new0(HTMLWindow, 1);
hw->history = historyNew();
hw->anchor_cb = anchor_cb;
hw->jump_cb = jump_cb;
return hw;
}
/********************************************************************\
* gnc_html_window_destroy *
* destroy an HTMLWindow structure *
* *
* Args: hw - the htmlwindow structure to destroy *
* Return: none *
\********************************************************************/
void
gnc_html_window_destroy(HTMLWindow *hw)
{
if (hw == NULL)
return;
if (hw->window != NULL)
gtk_widget_destroy(hw->window);
else
{
historyDestroy(hw->history);
g_free(hw);
}
}
static void
gnc_html_window_fill_toolbar(HTMLWindow *hw)
html_window_fill_toolbar(HTMLWindow *hw)
{
GnomeUIInfo *toolbar_info;
gint num_start, num_end;
GList *children, *node;
GtkWidget *dock_item;
GtkWidget *toolbar;
HTMLData *data;
gint i;
@ -460,6 +479,17 @@ gnc_html_window_fill_toolbar(HTMLWindow *hw)
GnomeUIInfo toolbar_end[] =
{
GNOMEUIINFO_SEPARATOR,
{ GNOME_APP_UI_ITEM,
PRINT_STR,
"Print HTML Window",
htmlPrintCB, hw,
NULL,
GNOME_APP_PIXMAP_STOCK,
GNOME_STOCK_PIXMAP_PRINT,
0, 0, NULL
},
GNOMEUIINFO_SEPARATOR,
{ GNOME_APP_UI_ITEM,
CLOSE_STR,
TOOLTIP_CLOSE_HTML,
@ -476,16 +506,23 @@ gnc_html_window_fill_toolbar(HTMLWindow *hw)
if (data == NULL)
return;
if (hw->toolbar == NULL)
if (hw->dock == NULL)
return;
node = children = gtk_container_children(GTK_CONTAINER(hw->toolbar));
while (node != NULL)
{
gtk_container_remove(GTK_CONTAINER(hw->toolbar), GTK_WIDGET(node->data));
node = node->next;
}
g_list_free(children);
dock_item = GTK_WIDGET(gnome_dock_get_item_by_name(GNOME_DOCK(hw->dock),
"toolbar", NULL, NULL,
NULL, NULL));
if (dock_item == NULL)
return;
toolbar = gnome_dock_item_get_child(GNOME_DOCK_ITEM(dock_item));
if (toolbar != NULL)
gtk_container_remove(GTK_CONTAINER(dock_item), toolbar);
toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
gtk_container_set_border_width(GTK_CONTAINER(toolbar), 2);
gtk_container_add(GTK_CONTAINER(dock_item), toolbar);
gtk_widget_show(toolbar);
num_start = sizeof(toolbar_start) / sizeof(GnomeUIInfo);
num_end = sizeof(toolbar_end) / sizeof(GnomeUIInfo);
@ -502,7 +539,7 @@ gnc_html_window_fill_toolbar(HTMLWindow *hw)
for (i = 0; i < num_end; i++)
toolbar_info[i + num_start + data->num_user_buttons] = toolbar_end[i];
gnome_app_fill_toolbar(GTK_TOOLBAR(hw->toolbar), toolbar_info, NULL);
gnome_app_fill_toolbar(GTK_TOOLBAR(toolbar), toolbar_info, NULL);
hw->back = toolbar_info[0].widget;
hw->forward = toolbar_info[1].widget;
@ -512,14 +549,25 @@ gnc_html_window_fill_toolbar(HTMLWindow *hw)
static void
gnc_html_toolbar_change_cb(void *data)
html_toolbar_change_cb(void *data)
{
HTMLWindow *hw = data;
GtkToolbarStyle tbstyle;
GnomeDockItem *dock_item;
GtkWidget *toolbar;
tbstyle = gnc_get_toolbar_style();
gtk_toolbar_set_style(GTK_TOOLBAR(hw->toolbar), tbstyle);
dock_item = gnome_dock_get_item_by_name(GNOME_DOCK(hw->dock), "toolbar",
NULL, NULL, NULL, NULL);
if (dock_item == NULL)
return;
toolbar = gnome_dock_item_get_child(dock_item);
if (toolbar == NULL)
return;
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), tbstyle);
}
@ -559,11 +607,13 @@ htmlWindow(GtkWidget *parent,
/************ CREATE HTML WINDOW HERE *****************/
{
GtkWidget *window;
GtkWidget *html;
GtkWidget *dock;
GtkWidget *dock_item;
GtkWidget *toolbar;
GtkWidget * window;
GtkWidget * html;
GtkWidget * dock;
GtkWidget * dock_item;
GtkWidget * toolbar;
GtkWidget * scroll;
GtkWidget * frame;
SCM id;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@ -573,42 +623,56 @@ htmlWindow(GtkWidget *parent,
dock = gnome_dock_new();
gtk_container_add(GTK_CONTAINER(window), dock);
hw->dock = dock;
dock_item = gnome_dock_item_new("toolbar", GNOME_DOCK_ITEM_BEH_EXCLUSIVE);
toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);
gtk_container_set_border_width(GTK_CONTAINER(toolbar), 2);
gtk_container_add(GTK_CONTAINER(dock_item), toolbar);
hw->toolbar = toolbar;
id = gnc_register_option_change_callback(gnc_html_toolbar_change_cb, hw,
"General", "Toolbar Buttons");
hw->toolbar_change_callback_id = id;
gnome_dock_add_item (GNOME_DOCK(dock), GNOME_DOCK_ITEM(dock_item),
GNOME_DOCK_TOP, 0, 0, 0, TRUE);
html = gtk_xmhtml_new();
id = gnc_register_option_change_callback(html_toolbar_change_cb, hw,
"General", "Toolbar Buttons");
hw->toolbar_change_callback_id = id;
frame = gtk_frame_new(NULL);
scroll = gtk_scrolled_window_new(NULL, NULL);
html = gtk_html_new();
hw->htmlwidget = html;
gnome_dock_set_client_area(GNOME_DOCK(dock), html);
gtk_xmhtml_set_image_procs(GTK_XMHTML(html), htmlReadImageProc,
NULL, NULL, NULL);
hw->scroller = scroll;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gnc_html_load(hw);
gtk_signal_connect (GTK_OBJECT(html), "url_requested",
GTK_SIGNAL_FUNC (htmlUrlCB),
(gpointer)hw);
gtk_signal_connect(GTK_OBJECT(hw->htmlwidget), "activate",
GTK_SIGNAL_FUNC(htmlAnchorCB), hw);
gtk_signal_connect (GTK_OBJECT(html), "link_clicked",
GTK_SIGNAL_FUNC (htmlAnchorCB),
(gpointer)hw);
gtk_signal_connect (GTK_OBJECT(html), "key_press_event",
GTK_SIGNAL_FUNC(htmlKeyCB), hw);
gtk_signal_connect(GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(destroyHtmlWinCB), hwp);
gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
GTK_SIGNAL_FUNC(htmlKeyCB), hw);
gtk_container_add(GTK_CONTAINER(frame), scroll);
gtk_container_add(GTK_CONTAINER(scroll), html);
gtk_html_load_empty(GTK_HTML(html));
gnome_dock_set_client_area(GNOME_DOCK(dock), frame);
gtk_widget_realize(GTK_WIDGET(html));
gtk_widget_show_all(window);
gnc_html_load(hw);
}
gnc_html_toolbar_change_cb(hw);
html_toolbar_change_cb(hw);
htmlSetButtonStates(hw);
}
@ -652,16 +716,15 @@ htmlSetButtonStates(HTMLWindow *hw)
static gboolean
htmlKeyCB(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
HTMLWindow *hw = (HTMLWindow *) data;
GtkXmHTML *html = GTK_XMHTML(hw->htmlwidget);
GtkAdjustment *vadj, *hadj;
gfloat v_value, h_value;
HTMLWindow * hw = (HTMLWindow *) data;
vadj = GTK_ADJUSTMENT(html->vsba);
hadj = GTK_ADJUSTMENT(html->hsba);
GtkAdjustment * vadj =
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(hw->scroller));
GtkAdjustment * hadj =
gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(hw->scroller));
v_value = vadj->value;
h_value = hadj->value;
gfloat v_value = vadj->value;
gfloat h_value = hadj->value;
switch (event->keyval)
{
@ -756,6 +819,15 @@ htmlFwdCB(GtkWidget *widget, gpointer data)
htmlSetButtonStates(hw);
}
/********************************************************************\
* htmlPrintCB
* callback for printing from toolbar button
\********************************************************************/
static void
htmlPrintCB(GtkWidget * widget, gpointer data) {
HTMLWindow * hw = (HTMLWindow *)data;
gnc_html_print(hw);
}
/********************************************************************\
* closeHtmlWinCB - callback for closing html window *
@ -783,7 +855,7 @@ closeHtmlWinCB(GtkWidget *widget, gpointer data)
static void
destroyHtmlWinCB(GtkWidget *widget, gpointer data)
{
HTMLWindow **hwp = (HTMLWindow **) data;
HTMLWindow **hwp = data;
HTMLWindow *hw = *hwp;
/* Delete the history: */
@ -796,49 +868,190 @@ destroyHtmlWinCB(GtkWidget *widget, gpointer data)
g_free(hw);
*hwp = NULL;
DEBUG("HTML window destroyed.\n");
}
/********************************************************************\
* htmlAnchorCB - called when user clicks on html anchor tag *
* *
* Args: widget - the html widget that called us *
* acbs - callback structure *
* data - html window structure *
* Return: none *
* the URL needs to be processed and the user callback called. *
\********************************************************************/
static void
htmlAnchorCB(GtkWidget *widget, XmHTMLAnchorCallbackStruct *acbs,
gpointer data)
{
HTMLWindow *hw = (HTMLWindow *) data;
HTMLData *html_data;
htmlAnchorCB(GtkHTML * html, const gchar * url, gpointer data) {
HTMLWindow * hw = (HTMLWindow *)data;
HTMLData * html_data;
char * url_location;
char * url_label;
int url_type;
/* printf("in htmlAnchorCB: url='%s'\n", url); */
if (acbs->reason != XmCR_ACTIVATE) return;
url_type = gnc_html_parse_url(hw, url, &url_location, &url_label);
switch(acbs->url_type)
{
/* a named anchor on a page that is already displayed */
case ANCHOR_JUMP:
XmHTMLAnchorScrollToName(widget, acbs->href);
break;
switch(url_type) {
case URL_TYPE_JUMP:
gtk_html_jump_to_anchor(html, url_label);
g_free(url_location);
g_free(url_label);
break;
default:
if (hw->anchor_cb == NULL)
return;
default:
if (hw->anchor_cb == NULL) {
g_free(url_location);
g_free(url_label);
return;
}
html_data = (hw->anchor_cb)(url_type, url_location, url_label,
historyUserData(hw->history));
g_free(url_location);
g_free(url_label);
html_data = (hw->anchor_cb)(acbs, historyUserData(hw->history));
if (html_data == NULL)
return;
if (html_data == NULL)
return;
historyInsert(hw->history, html_data);
gnc_html_load(hw);
break;
}
}
historyInsert(hw->history, html_data);
gnc_html_load(hw);
break;
/********************************************************************\
* htmlUrlCB - called by the GtkHTML widget when a URL needs to be *
* loaded. At this point, the StreamHandle is already open. *
\********************************************************************/
static void
htmlUrlCB(GtkHTML * html, char * url, GtkHTMLStream * handle,
gpointer user_data) {
HTMLWindow * hw = (HTMLWindow *)user_data;
char * text=NULL;
char * location=NULL;
char * label=NULL;
int fsize;
URLType type;
if(!url) return;
if(!strcmp(url, "")) {
gtk_html_write(GTK_HTML(hw->htmlwidget), handle,
hw->null_text, (hw->null_text ?
strlen(hw->null_text) : 0));
gtk_html_end(GTK_HTML(hw->htmlwidget), handle, GTK_HTML_STREAM_OK);
if(hw->null_label) {
gtk_html_jump_to_anchor(GTK_HTML(hw->htmlwidget),
hw->null_label);
}
}
else {
type = gnc_html_parse_url(hw, url, &location, &label);
fsize = gncReadFile(location, &text);
if(text == NULL) {
gtk_html_end(html, handle, GTK_HTML_STREAM_OK);
}
else {
gtk_html_write(GTK_HTML(hw->htmlwidget), handle,
text, fsize);
gtk_html_end(GTK_HTML(hw->htmlwidget), handle, GTK_HTML_STREAM_OK);
if(label) {
gtk_html_jump_to_anchor(GTK_HTML(hw->htmlwidget), label);
}
g_free(text);
}
}
}
/********************************************************************\
* gnc_html_parse_url
* this takes a URL and the HTMLWindow context and determines the
* protocol type, location, and possible anchor name from the URL.
\********************************************************************/
URLType
gnc_html_parse_url(HTMLWindow * html, const gchar * url,
char ** url_location, char ** url_label) {
char uri_rexp[] = "^(([^:]*):)?([^#]+)?(#(.*))?$";
regex_t compiled;
regmatch_t match[6];
char * protocol=NULL, * path=NULL, * label=NULL;
int found_protocol=0, found_path=0, found_label=0;
URLType retval;
regcomp(&compiled, uri_rexp, REG_EXTENDED);
if(!regexec(&compiled, url, 6, match, 0)) {
if(match[2].rm_so != -1) {
protocol = g_new0(char, match[2].rm_eo - match[2].rm_so + 1);
strncpy(protocol, url + match[2].rm_so,
match[2].rm_eo - match[2].rm_so);
protocol[match[2].rm_eo - match[2].rm_so] = 0;
found_protocol = 1;
}
if(match[3].rm_so != -1) {
path = g_new0(char, match[3].rm_eo - match[3].rm_so + 1);
strncpy(path, url+match[3].rm_so,
match[3].rm_eo - match[3].rm_so);
path[match[3].rm_eo - match[3].rm_so] = 0;
found_path = 1;
}
if(match[5].rm_so != -1) {
label = g_new0(char, match[5].rm_eo - match[5].rm_so + 1);
strncpy(label, url+match[5].rm_so,
match[5].rm_eo - match[5].rm_so);
label[match[5].rm_eo - match[5].rm_so] = 0;
found_label = 1;
}
}
htmlSetButtonStates(hw);
if(found_protocol) {
if(!strcmp(protocol, "file")) {
retval = URL_TYPE_FILE;
}
else if(!strcmp(protocol, "http")) {
retval = URL_TYPE_HTTP;
}
else if(!strcmp(protocol, "ftp")) {
retval = URL_TYPE_FTP;
}
else if(!strcmp(protocol, "https")) {
retval = URL_TYPE_SECURE;
}
else {
retval = URL_TYPE_OTHER;
}
}
else if(found_label && !found_path) {
retval = URL_TYPE_JUMP;
}
else {
retval = URL_TYPE_FILE; /* FIXME BG */
}
g_free(protocol);
switch(retval) {
case URL_TYPE_FILE:
*url_location = path;
break;
case URL_TYPE_JUMP:
*url_location = NULL;
g_free(path);
break;
case URL_TYPE_OTHER:
default:
* url_location = path;
break;
}
* url_label = label;
return retval;
}
@ -851,9 +1064,9 @@ htmlAnchorCB(GtkWidget *widget, XmHTMLAnchorCallbackStruct *acbs,
void
gnc_html_load(HTMLWindow *hw)
{
HTMLData *data;
char *label = NULL;
char *text = NULL;
HTMLData * data;
GtkHTMLStream * handle;
char * text=NULL, * label=NULL;
if (hw == NULL)
return;
@ -863,52 +1076,66 @@ gnc_html_load(HTMLWindow *hw)
data = historyData(hw->history);
gtk_window_set_title(GTK_WINDOW(hw->window), data->title);
gnc_html_window_fill_toolbar(hw);
html_window_fill_toolbar(hw);
htmlSetButtonStates(hw);
(hw->jump_cb)(data->user_data, &text, &label);
(hw->jump_cb)(data->user_data, &hw->null_text, &hw->null_label);
if (text == NULL)
{
text = "";
label = NULL;
}
gtk_xmhtml_source(GTK_XMHTML(hw->htmlwidget), text);
if (label != NULL)
XmHTMLAnchorScrollToName(hw->htmlwidget, label);
else
XmHTMLTextScrollToLine(hw->htmlwidget, 0);
handle = gtk_html_begin(GTK_HTML(hw->htmlwidget));
htmlUrlCB(GTK_HTML(hw->htmlwidget), "", handle, (gpointer)hw);
}
void
gnc_url_show(URLType type, char * location, char * label) {
char * full_url;
char proto_tag[8];
/********************************************************************\
* htmlReadImageProc - callback function for the html widget *
* used to find an image file *
* *
* Args: widget - the html widget *
* file - the name of the image file to read *
* data - some data, not used *
* Return: none *
\********************************************************************/
static XmImageInfo *
htmlReadImageProc (GtkWidget *widget, String file, gpointer data)
{
char *filename;
XmImageInfo *retval = NULL;
switch(type) {
case URL_TYPE_FILE:
case URL_TYPE_JUMP:
strcpy(proto_tag, "file:");
break;
case URL_TYPE_HTTP:
strcpy(proto_tag, "http:");
break;
case URL_TYPE_FTP:
strcpy(proto_tag, "ftp:");
break;
case URL_TYPE_SECURE:
strcpy(proto_tag, "https:");
break;
default:
strcpy(proto_tag, "");
}
/* construct absolute path -- twiddle the relative path we received */
filename = gncFindFile(file);
full_url = g_new0(char,
(proto_tag ? strlen(proto_tag) : 0) +
(location ? strlen(location) : 0) +
(label ? strlen(label) : 0) + 1);
strcpy(full_url, proto_tag);
if(location) strcat(full_url, location);
if(label) strcat(full_url, label);
/* use the default proc for the hard work */
retval = XmHTMLImageDefaultProc(widget, filename, NULL, 0);
if (filename != NULL)
free(filename);
return retval;
gnome_url_show(full_url);
}
/* ----------------------- END OF FILE --------------------- */
/********************************************************************
* gnc_html_print : print an html window
********************************************************************/
void
gnc_html_print(HTMLWindow * hw) {
PrintSession * ps = gnc_print_session_create();
gtk_html_print(GTK_HTML(hw->htmlwidget),
GNOME_PRINT_CONTEXT(ps->meta));
gnc_print_session_done(ps);
gnc_ui_print_dialog_create(ps);
}

View File

@ -4,6 +4,8 @@
* Copyright (C) 1998 Linas Vepstas *
* Copyright (C) 1999 Jeremy Collins ( gtk-xmhtml port ) *
* Copyright (C) 2000 Linas Vepstas <linas@linas.org> *
* Copyright (C) 2000 Bill Gribble <grib@billgribble.com> *
* (gtkhtml port) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@ -27,39 +29,45 @@
#define __WINDOW_HTML_H__
#include <gnome.h>
#include <gtk-xmhtml/gtk-xmhtml.h>
#include <gtkhtml/gtkhtml.h>
typedef struct _HTMLWindow HTMLWindow;
typedef struct _HTMLData HTMLData;
typedef void * HTMLUserData;
typedef struct _HTMLData HTMLData;
typedef void * HTMLUserData;
typedef enum { URL_TYPE_FILE, URL_TYPE_JUMP,
URL_TYPE_HTTP, URL_TYPE_FTP,
URL_TYPE_SECURE, URL_TYPE_OTHER } URLType;
typedef void (*HTMLDestroyUserDataFunc)(HTMLUserData);
typedef HTMLData* (*HTMLAnchorCB)(XmHTMLAnchorCallbackStruct *acbs,
HTMLUserData user_data);
typedef HTMLData * (*HTMLAnchorCB)(URLType url_type, char * location,
char * label, HTMLUserData user_data);
typedef void (*HTMLJumpCB)(HTMLUserData user_data,
char **text, char **label);
typedef void (*HTMLJumpCB)(HTMLUserData user_data, char ** location,
char ** label);
HTMLData * gnc_html_data_new(const char * title,
HTMLUserData user_data,
HTMLDestroyUserDataFunc destroy,
GnomeUIInfo * user_buttons,
int num_user_buttons);
HTMLWindow * gnc_html_window_new(HTMLAnchorCB anchor_cb, HTMLJumpCB jump_cb);
void gnc_html_window_destroy(HTMLWindow *hw);
void gnc_html_load(HTMLWindow *hw);
void gnc_html_print(HTMLWindow * hw);
URLType gnc_html_parse_url(HTMLWindow * html, const gchar * url,
char ** location, char ** label);
HTMLUserData gnc_html_window_user_data(HTMLWindow *hw);
GtkWidget * gnc_html_window_get_window(HTMLWindow *hw);
GtkWidget * gnc_html_window_get_window(HTMLWindow *hw);
HTMLWindow * gnc_html_window_new(HTMLAnchorCB anchor_cb, HTMLJumpCB jump_cb);
void gnc_html_window_destroy(HTMLWindow *hw);
void htmlWindow(GtkWidget * parent, HTMLWindow ** hwp, HTMLData * data);
HTMLData * gnc_html_data_new(const char *title, HTMLUserData user_data,
HTMLDestroyUserDataFunc destroy,
GnomeUIInfo *user_buttons,
int num_user_buttons);
void htmlWindow(GtkWidget *parent,
HTMLWindow **hwp,
HTMLData *data);
void gnc_html_load(HTMLWindow *hw);
/* for showing URLS with an external browser */
void gnc_url_show(URLType type, char * location, char * label);
#endif

View File

@ -177,21 +177,16 @@ report_data_set_guile_options(ReportData *report_data, const SCM guile_options)
static HTMLData *
reportAnchorCB(XmHTMLAnchorCallbackStruct *acbs,
reportAnchorCB(URLType url_type, char * location, char * label,
HTMLUserData user_data)
{
switch(acbs->url_type)
{
case ANCHOR_FILE_LOCAL:
case ANCHOR_FTP:
case ANCHOR_HTTP:
case ANCHOR_MAILTO:
case ANCHOR_UNKNOWN:
default:
gnome_url_show(acbs->href);
break;
/* this isn't called for "jump to anchor" clicks. That's */
/* handled internally in the HTML widget. */
switch(url_type) {
default:
gnc_url_show(url_type, location, label);
break;
}
return NULL;
}

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -23,32 +23,32 @@
date-format
custom-info)))
(define (print-check-format? self)
(eq? (simple-obj-type self) 'print-check-format))
(define print-check-format?
(record-predicate <print-check-format>))
(define (print-check-format:format self)
(simple-obj-getter self <print-check-format> 'format))
(define print-check-format:format
(simple-obj-getter <print-check-format> 'format))
(define (print-check-format:set-format! self value)
(simple-obj-setter self <print-check-format> 'format value))
(define print-check-format:set-format!
(simple-obj-setter <print-check-format> 'format))
(define (print-check-format:position self)
(simple-obj-getter self <print-check-format> 'position))
(define print-check-format:position
(simple-obj-getter <print-check-format> 'position))
(define (print-check-format:set-position! self value)
(simple-obj-setter self <print-check-format> 'position value))
(define print-check-format:set-position!
(simple-obj-setter <print-check-format> 'position))
(define (print-check-format:date-format self)
(simple-obj-getter self <print-check-format> 'date-format))
(define print-check-format:date-format
(simple-obj-getter <print-check-format> 'date-format))
(define (print-check-format:set-date-format! self value)
(simple-obj-setter self <print-check-format> 'date-format value))
(define print-check-format:set-date-format!
(simple-obj-setter <print-check-format> 'date-format))
(define (print-check-format:custom-info self)
(simple-obj-getter self <print-check-format> 'custom-info))
(define print-check-format:custom-info
(simple-obj-getter <print-check-format> 'custom-info))
(define (print-check-format:set-custom-info! self value)
(simple-obj-setter self <print-check-format> 'custom-info value))
(define print-check-format:set-custom-info!
(simple-obj-setter <print-check-format> 'custom-info))
(define (make-print-check-format fmt pos dateformat cust)
(let ((retval (make-simple-obj <print-check-format>)))

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@

View File

@ -81,7 +81,6 @@ GNOME_CONFIG_BIN = @GNOME_CONFIG_BIN@
GNOME_LIBS = @GNOME_LIBS@
GNOME_STATIC_TARGET = @GNOME_STATIC_TARGET@
GNOME_TARGET = @GNOME_TARGET@
GTK_XMHTML = @GTK_XMHTML@
GT_NO = @GT_NO@
GT_YES = @GT_YES@
GUILE = @GUILE@