Bill Gribble's patch.

* src/scm/report/stylesheet-{plain,fancy}.scm: add a new boolean
	option to disable hyperlinks in reports.  This will make it nicer
	to have a "printing" style sheet that disables links when you want
	to print.  (if you change a report's style sheet, click "Reload"
	to see it take effect.  this needs to be fixed)

	* src/gnome/gnc-html-embedded.c: add support for URLsa attached to
	double clicks of pie slices, bar chart bars, and legend entries of
	guppi graphs.  Still need to do this for scatter chart.

	* src/scm/html-{piechart,barchart}.scm: add API for callbacks.
	Not totally finished with barchart yet.

	* src/scm/qif-import/qif-to-gnc.scm: check for currency and type
	mismatches between QIF-imported and existing GNC accounts.  If
	there's a name conflict, rename the new account with a unique name
	and a description indicating there was a conflict.  This should
	fix several reports of crashes for multi-currency users.

	* src/scm/report-utilities.scm: back out my previous breakage of
	gnc:amount->string

	* src/scm/report.scm: Thanks to the guile mailing list for
	pointing my at this odd bit of code needed to print backtraces on
	guile exceptions while still running.  You need to run with
	--debug to get the trace.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3559 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-01-30 23:56:33 +00:00
parent 53be5478e1
commit 690584073e
11 changed files with 625 additions and 73 deletions

View File

@ -1,3 +1,32 @@
2001-01-30 Bill Gribble <grib@billgribble.com>
* src/scm/report/stylesheet-{plain,fancy}.scm: add a new boolean
option to disable hyperlinks in reports. This will make it nicer
to have a "printing" style sheet that disables links when you want
to print. (if you change a report's style sheet, click "Reload"
to see it take effect. this needs to be fixed)
* src/gnome/gnc-html-embedded.c: add support for URLsa attached to
double clicks of pie slices, bar chart bars, and legend entries of
guppi graphs. Still need to do this for scatter chart.
* src/scm/html-{piechart,barchart}.scm: add API for callbacks.
Not totally finished with barchart yet.
* src/scm/qif-import/qif-to-gnc.scm: check for currency and type
mismatches between QIF-imported and existing GNC accounts. If
there's a name conflict, rename the new account with a unique name
and a description indicating there was a conflict. This should
fix several reports of crashes for multi-currency users.
* src/scm/report-utilities.scm: back out my previous breakage of
gnc:amount->string
* src/scm/report.scm: Thanks to the guile mailing list for
pointing my at this odd bit of code needed to print backtraces on
guile exceptions while still running. You need to run with
--debug to get the trace.
2001-01-26 Bill Gribble <grib@billgribble.com>
* src/gnome/gnc-gpg.{c,h}: if Linas can add useless prototype

View File

@ -22,8 +22,21 @@ the whole pie.
value="teeny tiny small medium large huge">
<param name=colors
value="red blue orange green purple goldenrod">
<param name=slice_urls_1
value="gnc-help:xacc-regwin.html label1 #label2 #label3 #label4 #label5 #label6">
THIS IS ALT TEXT
</object>
<p id="label1">This is the first pie segment.</p>
<p id="label2">This is the second pie segment.</p>
<p id="label3">This is the third pie segment.</p>
<p id="label4">This is the fourth pie segment.</p>
<p id="label5">This is the fifth pie segment.</p>
<p id="label6">This is the sixth pie segment.</p>
</body>

View File

@ -24,8 +24,9 @@
#include <gnome.h>
#include <glib.h>
#include <guile/gh.h>
#ifdef USE_GUPPI
/* #include <libguppi/guppi-memory.h> */
#include <libguppitank/guppi-tank.h>
#endif
@ -102,25 +103,163 @@ free_strings(char ** strings, int nstrings) {
#ifdef USE_GUPPI
struct guppi_chart_data {
GtkWidget * widget;
GuppiObject * guppiobject;
gnc_html * parent;
GPtrArray * data_1_callbacks;
GPtrArray * data_2_callbacks;
GPtrArray * data_3_callbacks;
GPtrArray * legend_1_callbacks;
GPtrArray * legend_2_callbacks;
GPtrArray * legend_3_callbacks;
};
static struct guppi_chart_data *
gnc_guppi_chart_data_new(void) {
struct guppi_chart_data * rv = g_new0(struct guppi_chart_data, 1);
rv->widget = NULL;
rv->guppiobject = NULL;
return rv;
}
static void
gnc_guppi_chart_data_destroy(struct guppi_chart_data * d) {
g_free(d);
}
/* callbacks for button double-click on a pie slice, barchart bar, or
* legend element. generic_callback is used by all of them. */
static void
guppi_generic_callback(gnc_html * html, GPtrArray * array, gint index) {
URLType type;
char * location = NULL;
char * label = NULL;
char * url = g_ptr_array_index(array, index);
if(!url) return;
type = gnc_html_parse_url(html, url, &location, &label);
gnc_html_show_url(html, type, location, label, 0);
g_free(location);
g_free(label);
return;
}
static void
guppi_slice_1_callback(gint slice, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->data_1_callbacks,
slice);
}
static void
guppi_slice_2_callback(gint slice, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->data_2_callbacks,
slice);
}
static void
guppi_slice_3_callback(gint slice, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->data_3_callbacks,
slice);
}
static void
guppi_legend_1_callback(gint item, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->legend_1_callbacks,
item);
}
static void
guppi_legend_2_callback(gint item, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->legend_2_callbacks,
item);
}
static void
guppi_legend_3_callback(gint item, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->legend_3_callbacks,
item);
}
static void
guppi_bar_1_callback(gint row, gint col, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->data_1_callbacks,
(col*row) + col);
}
static void
guppi_bar_2_callback(gint row, gint col, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->data_1_callbacks,
(col*row) + col);
}
static void
guppi_bar_3_callback(gint row, gint col, gpointer user_data) {
struct guppi_chart_data * chart = user_data;
guppi_generic_callback(chart->parent,
chart->data_1_callbacks,
(col*row) + col);
}
static GPtrArray *
convert_string_array(char ** strings, int nstrings) {
GPtrArray * retval = g_ptr_array_new();
int i;
/* g_ptr_array_set_size(retval, nstrings); */
for(i=0; i < nstrings; i++) {
g_ptr_array_add(retval, strings[i]);
}
return retval;
}
/********************************************************************
* gnc_html_embedded_piechart
* create a Guppi piechart from an HTML <object> block
********************************************************************/
GtkWidget *
gnc_html_embedded_piechart(int w, int h, GHashTable * params) {
gnc_html_embedded_piechart(gnc_html * parent, int w, int h,
GHashTable * params) {
struct guppi_chart_data * chart = gnc_guppi_chart_data_new();
GuppiObject * piechart = NULL;
GuppiObject * title = NULL;
GtkWidget * rv;
GtkArg arglist[5];
GtkArg arglist[17];
int argind=0;
char * param;
int datasize;
double * data=NULL;
char ** labels=NULL;
char ** colors=NULL;
char ** callbacks=NULL;
char * gtitle;
chart->parent = parent;
if((param = g_hash_table_lookup(params, "datasize")) != NULL) {
sscanf(param, "%d", &datasize);
arglist[argind].name = "data_size";
@ -149,6 +288,90 @@ gnc_html_embedded_piechart(int w, int h, GHashTable * params) {
GTK_VALUE_POINTER(arglist[argind]) = colors;
argind++;
}
if((param = g_hash_table_lookup(params, "slice_urls_1")) != NULL) {
arglist[argind].name = "slice_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_slice_1_callback;
argind++;
arglist[argind].name = "slice_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datasize);
chart->data_1_callbacks = convert_string_array(callbacks, datasize);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "slice_urls_2")) != NULL) {
arglist[argind].name = "slice_callback2";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_slice_2_callback;
argind++;
arglist[argind].name = "slice_callback2_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datasize);
chart->data_2_callbacks = convert_string_array(callbacks, datasize);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "slice_urls_3")) != NULL) {
arglist[argind].name = "slice_callback3";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_slice_3_callback;
argind++;
arglist[argind].name = "slice_callback3_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datasize);
chart->data_3_callbacks = convert_string_array(callbacks, datasize);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "legend_urls_1")) != NULL) {
arglist[argind].name = "legend_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_slice_1_callback;
argind++;
arglist[argind].name = "legend_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datasize);
chart->legend_1_callbacks = convert_string_array(callbacks, datasize);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "legend_urls_2")) != NULL) {
arglist[argind].name = "legend_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_legend_2_callback;
argind++;
arglist[argind].name = "legend_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datasize);
chart->legend_2_callbacks = convert_string_array(callbacks, datasize);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "legend_urls_3")) != NULL) {
arglist[argind].name = "legend_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_legend_3_callback;
argind++;
arglist[argind].name = "legend_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datasize);
chart->legend_3_callbacks = convert_string_array(callbacks, datasize);
g_free(callbacks);
}
piechart = guppi_object_newv("pie", w, h,
argind, arglist);
@ -161,23 +384,27 @@ gnc_html_embedded_piechart(int w, int h, GHashTable * params) {
"subtitle"),
"subobject", piechart,
"on_top", TRUE, NULL);
rv = guppi_object_build_widget(title);
gtk_object_set_user_data(GTK_OBJECT(rv), (gpointer)title);
chart->widget = guppi_object_build_widget(title);
chart->guppiobject = title;
}
else {
rv = guppi_object_build_widget(piechart);
gtk_object_set_user_data(GTK_OBJECT(rv), (gpointer)piechart);
chart->widget = guppi_object_build_widget(piechart);
chart->guppiobject = piechart;
}
}
else {
rv = NULL;
gnc_guppi_chart_data_destroy(chart);
chart = NULL;
}
g_free(data);
free_strings(labels, datasize);
free_strings(colors, datasize);
return rv;
if(chart)
return chart->widget;
else
return NULL;
}
@ -187,13 +414,13 @@ gnc_html_embedded_piechart(int w, int h, GHashTable * params) {
********************************************************************/
GtkWidget *
gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
gnc_html_embedded_barchart(gnc_html * parent,
int w, int h, GHashTable * params) {
struct guppi_chart_data * chart = gnc_guppi_chart_data_new();
GuppiObject * barchart = NULL;
GuppiObject * title = NULL;
GtkArg arglist[9];
GtkArg arglist[21];
int argind=0;
GtkWidget * rv;
char * param;
int datarows=0;
int datacols=0;
@ -202,6 +429,7 @@ gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
char ** col_labels=NULL;
char ** row_labels=NULL;
char ** col_colors=NULL;
char ** callbacks=NULL;
char * gtitle = NULL;
if((param = g_hash_table_lookup(params, "data_rows")) != NULL) {
@ -225,6 +453,7 @@ gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
GTK_VALUE_POINTER(arglist[argind]) = data;
argind++;
}
#if 0
if((param = g_hash_table_lookup(params, "x_axis_label")) != NULL) {
arglist[argind].name = "x_axis_label";
@ -239,6 +468,7 @@ gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
argind++;
}
#endif
if((param = g_hash_table_lookup(params, "col_labels")) != NULL) {
col_labels = read_strings(param, datacols);
arglist[argind].name = "column_labels";
@ -267,6 +497,97 @@ gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
GTK_VALUE_BOOL(arglist[argind]) = rotate;
argind++;
}
if((param = g_hash_table_lookup(params, "bar_urls_1")) != NULL) {
arglist[argind].name = "bar_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_bar_1_callback;
argind++;
arglist[argind].name = "bar_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datarows*datacols);
chart->data_1_callbacks = convert_string_array(callbacks,
datarows*datacols);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "bar_urls_2")) != NULL) {
arglist[argind].name = "bar_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_bar_2_callback;
argind++;
arglist[argind].name = "bar_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datarows*datacols);
chart->data_2_callbacks = convert_string_array(callbacks,
datarows*datacols);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "bar_urls_3")) != NULL) {
arglist[argind].name = "bar_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_bar_3_callback;
argind++;
arglist[argind].name = "bar_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datarows*datacols);
chart->data_3_callbacks = convert_string_array(callbacks,
datarows*datacols);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "legend_urls_1")) != NULL) {
arglist[argind].name = "legend_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_slice_1_callback;
argind++;
arglist[argind].name = "legend_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datarows*datacols);
chart->legend_1_callbacks = convert_string_array(callbacks,
datarows*datacols);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "legend_urls_2")) != NULL) {
arglist[argind].name = "legend_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_legend_2_callback;
argind++;
arglist[argind].name = "legend_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datarows*datacols);
chart->legend_2_callbacks = convert_string_array(callbacks,
datarows*datacols);
g_free(callbacks);
}
if((param = g_hash_table_lookup(params, "legend_urls_3")) != NULL) {
arglist[argind].name = "legend_callback1";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = &guppi_legend_3_callback;
argind++;
arglist[argind].name = "legend_callback1_data";
arglist[argind].type = GTK_TYPE_POINTER;
GTK_VALUE_POINTER(arglist[argind]) = chart;
argind++;
callbacks = read_strings(param, datarows*datacols);
chart->legend_3_callbacks = convert_string_array(callbacks,
datarows*datacols);
g_free(callbacks);
}
barchart = guppi_object_newv("barchart", w, h,
argind, arglist);
@ -280,16 +601,17 @@ gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
"subobject", barchart,
"on_top", TRUE, NULL);
rv = guppi_object_build_widget(title);
gtk_object_set_user_data(GTK_OBJECT(rv), (gpointer)title);
chart->widget = guppi_object_build_widget(title);
chart->guppiobject = title;
}
else {
rv = guppi_object_build_widget(barchart);
gtk_object_set_user_data(GTK_OBJECT(rv), (gpointer)barchart);
chart->widget = guppi_object_build_widget(barchart);
chart->guppiobject = barchart;
}
}
else {
rv = NULL;
gnc_guppi_chart_data_destroy(chart);
chart = NULL;
}
g_free(data);
@ -297,7 +619,10 @@ gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
free_strings(row_labels, datarows);
free_strings(col_colors, datacols);
return rv;
if(chart)
return chart->widget;
else
return NULL;
}
@ -307,11 +632,11 @@ gnc_html_embedded_barchart(int w, int h, GHashTable * params) {
********************************************************************/
GtkWidget *
gnc_html_embedded_scatter(int w, int h, GHashTable * params) {
gnc_html_embedded_scatter(gnc_html * parent,
int w, int h, GHashTable * params) {
struct guppi_chart_data * chart = gnc_guppi_chart_data_new();
GuppiObject * scatter = NULL;
GuppiObject * title = NULL;
GtkWidget * rv;
GtkArg arglist[8];
int argind=0;
char * param;
@ -368,7 +693,6 @@ gnc_html_embedded_scatter(int w, int h, GHashTable * params) {
argind++;
}
scatter = guppi_object_newv("scatter", w, h,
argind, arglist);
@ -380,22 +704,27 @@ gnc_html_embedded_scatter(int w, int h, GHashTable * params) {
"subtitle"),
"subobject", scatter,
"on_top", TRUE, NULL);
rv = guppi_object_build_widget(title);
gtk_object_set_user_data(GTK_OBJECT(rv), (gpointer)title);
chart->widget = guppi_object_build_widget(title);
chart->guppiobject = title;
}
else {
rv = guppi_object_build_widget(scatter);
gtk_object_set_user_data(GTK_OBJECT(rv), (gpointer)scatter);
chart->widget = guppi_object_build_widget(scatter);
chart->guppiobject = scatter;
}
}
else {
rv = NULL;
gnc_guppi_chart_data_destroy(chart);
chart = NULL;
}
g_free(x_data);
g_free(y_data);
return rv;
if(chart)
return chart->widget;
else
return NULL;
}
#endif /* USE_GUPPI */
/********************************************************************
@ -421,8 +750,10 @@ set_bools(char * indices, gboolean * array, int num) {
}
}
GtkWidget *
gnc_html_embedded_account_tree(int w, int h, GHashTable * params) {
gnc_html_embedded_account_tree(gnc_html * parent,
int w, int h, GHashTable * params) {
AccountViewInfo info;
GtkWidget * tree = gnc_mainwin_account_tree_new();
char * param;

View File

@ -24,10 +24,15 @@
#define __GNC_HTML_EMBEDDED_H__
#include <gnome.h>
#include "gnc-html.h"
GtkWidget * gnc_html_embedded_piechart(gint w, gint h, GHashTable * params);
GtkWidget * gnc_html_embedded_barchart(gint w, gint h, GHashTable * params);
GtkWidget * gnc_html_embedded_scatter(gint w, gint h, GHashTable * params);
GtkWidget * gnc_html_embedded_account_tree(gint w, gint h, GHashTable * prms);
GtkWidget * gnc_html_embedded_piechart(gnc_html * parent,
gint w, gint h, GHashTable * params);
GtkWidget * gnc_html_embedded_barchart(gnc_html * parent,
gint w, gint h, GHashTable * params);
GtkWidget * gnc_html_embedded_scatter(gnc_html * parent,
gint w, gint h, GHashTable * params);
GtkWidget * gnc_html_embedded_account_tree(gnc_html * parent,
gint w, gint h, GHashTable * prms);
#endif

View File

@ -316,7 +316,10 @@ ghttp_check_callback(gpointer data) {
GList * current;
ghttp_status status;
struct request_info * req;
URLType type;
char * location = NULL;
char * label = NULL;
/* walk the request list to deal with any complete requests */
for(current = html->requests; current; current = current->next) {
req = current->data;
@ -348,6 +351,11 @@ ghttp_check_callback(gpointer data) {
ghttp_get_body(req->request),
ghttp_get_body_len(req->request));
gtk_html_end(GTK_HTML(html->html), req->handle, GTK_HTML_STREAM_OK);
type = gnc_html_parse_url(html, req->uri, &location, &label);
if(label) {
gtk_html_jump_to_anchor(GTK_HTML(html->html), label);
}
}
else {
gtk_html_write(GTK_HTML(html->html), req->handle, error_404,
@ -466,7 +474,9 @@ gnc_html_load_to_stream(gnc_html * html, GtkHTMLStream * handle,
gtk_html_end(GTK_HTML(html->html), handle, GTK_HTML_STREAM_ERROR);
}
g_free(fdata);
if(label) {
gtk_html_jump_to_anchor(GTK_HTML(html->html), label);
}
break;
case URL_TYPE_HTTP:
@ -496,6 +506,9 @@ gnc_html_load_to_stream(gnc_html * html, GtkHTMLStream * handle,
free(fdata);
fdata = NULL;
fsize = 0;
if(label) {
gtk_html_jump_to_anchor(GTK_HTML(html->html), label);
}
}
else {
gtk_html_write(GTK_HTML(html->html), handle, error_404,
@ -613,11 +626,12 @@ static int
gnc_html_object_requested_cb(GtkHTML * html, GtkHTMLEmbedded * eb,
gpointer data) {
GtkWidget * widg = NULL;
gnc_html * gnchtml = data;
int retval = FALSE;
if(!strcmp(eb->classid, "gnc-guppi-pie")) {
#ifdef USE_GUPPI
widg = gnc_html_embedded_piechart(eb->width, eb->height,
widg = gnc_html_embedded_piechart(gnchtml, eb->width, eb->height,
eb->params);
#endif /* USE_GUPPI */
if(widg) {
@ -632,7 +646,7 @@ gnc_html_object_requested_cb(GtkHTML * html, GtkHTMLEmbedded * eb,
}
else if(!strcmp(eb->classid, "gnc-guppi-bar")) {
#ifdef USE_GUPPI
widg = gnc_html_embedded_barchart(eb->width, eb->height,
widg = gnc_html_embedded_barchart(gnchtml, eb->width, eb->height,
eb->params);
#endif /* USE_GUPPI */
if(widg) {
@ -647,7 +661,7 @@ gnc_html_object_requested_cb(GtkHTML * html, GtkHTMLEmbedded * eb,
}
else if(!strcmp(eb->classid, "gnc-guppi-scatter")) {
#ifdef USE_GUPPI
widg = gnc_html_embedded_scatter(eb->width, eb->height,
widg = gnc_html_embedded_scatter(gnchtml, eb->width, eb->height,
eb->params);
#endif /* USE_GUPPI */
if(widg) {
@ -661,7 +675,7 @@ gnc_html_object_requested_cb(GtkHTML * html, GtkHTMLEmbedded * eb,
}
}
else if(!strcmp(eb->classid, "gnc-account-tree")) {
widg = gnc_html_embedded_account_tree(eb->width, eb->height,
widg = gnc_html_embedded_account_tree(gnchtml, eb->width, eb->height,
eb->params);
if(widg) {
gtk_widget_show_all(widg);

View File

@ -25,7 +25,12 @@
(define <html-piechart>
(make-record-type "<html-piechart>"
'(width height title subtitle data colors labels)))
'(width height title subtitle data colors labels
button-1-slice-urls button-2-slice-urls
button-3-slice-urls
button-1-legend-urls button-2-legend-urls
button-3-legend-urls)))
(define gnc:html-piechart?
(record-predicate <html-piechart>))
@ -84,6 +89,42 @@
(define gnc:html-piechart-set-subtitle!
(record-modifier <html-piechart> 'subtitle))
(define gnc:html-piechart-button-1-slice-urls
(record-accessor <html-piechart> 'button-1-slice-urls))
(define gnc:html-piechart-set-button-1-slice-urls!
(record-modifier <html-piechart> 'button-1-slice-urls))
(define gnc:html-piechart-button-2-slice-urls
(record-accessor <html-piechart> 'button-2-slice-urls))
(define gnc:html-piechart-set-button-2-slice-urls!
(record-modifier <html-piechart> 'button-2-slice-urls))
(define gnc:html-piechart-button-3-slice-urls
(record-accessor <html-piechart> 'button-3-slice-urls))
(define gnc:html-piechart-set-button-3-slice-urls!
(record-modifier <html-piechart> 'button-3-slice-urls))
(define gnc:html-piechart-button-1-legend-urls
(record-accessor <html-piechart> 'button-1-legend-urls))
(define gnc:html-piechart-set-button-1-legend-urls!
(record-modifier <html-piechart> 'button-1-legend-urls))
(define gnc:html-piechart-button-2-legend-urls
(record-accessor <html-piechart> 'button-2-legend-urls))
(define gnc:html-piechart-set-button-2-legend-urls!
(record-modifier <html-piechart> 'button-2-legend-urls))
(define gnc:html-piechart-button-3-legend-urls
(record-accessor <html-piechart> 'button-3-legend-urls))
(define gnc:html-piechart-set-button-3-legend-urls!
(record-modifier <html-piechart> 'button-3-legend-urls))
(define (gnc:html-piechart-render piechart doc)
(define (ensure-positive-numbers nlist)
(map
@ -123,6 +164,24 @@
(lambda ()
(let ((title (gnc:html-piechart-title piechart))
(subtitle (gnc:html-piechart-subtitle piechart))
(url-1
(catenate-escaped-strings
(gnc:html-piechart-button-1-slice-urls piechart)))
(url-2
(catenate-escaped-strings
(gnc:html-piechart-button-2-slice--urls piechart)))
(url-3
(catenate-escaped-strings
(gnc:html-piechart-button-3-slice--urls piechart)))
(legend-1
(catenate-escaped-strings
(gnc:html-piechart-button-1-legend-urls piechart)))
(legend-2
(catenate-escaped-strings
(gnc:html-piechart-button-2-legend-urls piechart)))
(legend-3
(catenate-escaped-strings
(gnc:html-piechart-button-3-legend-urls piechart)))
(data
(ensure-positive-numbers (gnc:html-piechart-data piechart)))
(labels
@ -168,6 +227,36 @@
(display " <param name=\"labels\" value=\"")
(display labels)
(display "\">\n")))
(if url-1
(begin
(display " <param name=\"slice_urls_1\" value=\"")
(display url-1)
(display "\">\n")))
(if url-2
(begin
(display " <param name=\"slice_urls_2\" value=\"")
(display url-2)
(display "\">\n")))
(if url-3
(begin
(display " <param name=\"slice_urls_3\" value=\"")
(display url-3)
(display "\">\n")))
(if legend-1
(begin
(display " <param name=\"legend_urls_1\" value=\"")
(display legend-1)
(display "\">\n")))
(if legend-2
(begin
(display " <param name=\"legend_urls_2\" value=\"")
(display legend-2)
(display "\">\n")))
(if legend-3
(begin
(display " <param name=\"legend_urls_3\" value=\"")
(display legend-3)
(display "\">\n")))
(display "Unable to display pie chart\n")
(display "</object>"))
" ")))))

View File

@ -27,15 +27,53 @@
(existing-account (hash-ref gnc-acct-hash gnc-name))
(same-gnc-account
(gnc:get-account-from-full-name acct-group gnc-name separator))
(make-new-acct #f))
(allowed-types
(qif-map-entry:allowed-types acct-info))
(make-new-acct #f)
(incompatible-acct #f))
(if (or (not same-gnc-account)
(and same-gnc-account
(not (string=?
(gnc:account-get-full-name same-gnc-account)
gnc-name))))
(set! make-new-acct #t))
(define (make-unique-name-variant long-name short-name)
(if (gnc:get-account-from-full-name acct-group long-name separator)
(let loop ((count 2))
(let ((test-name
(string-append long-name (sprintf #f " %a" count))))
(if (gnc:get-account-from-full-name
acct-group test-name separator)
(loop (+ 1 count))
test-name)))
short-name))
;; just because we found an account doesn't mean we can use it.
;; if the name is in use but the currency, security, or type are
;; incompatible, we need to create a new account with a modified
;; name.
(if same-gnc-account
(if (and (gnc:commodity-equiv?
currency (gnc:account-get-currency same-gnc-account))
(gnc:commodity-equiv?
security (gnc:account-get-security same-gnc-account))
(list? allowed-types)
(memq (gnc:account-get-type same-gnc-account)
allowed-types))
(begin
;; everything is ok, so we can just use the same
;; account. Make sure we make the same type.
(set! make-new-acct #f)
(set! incompatible-acct #f)
(set! allowed-types
(list (gnc:account-get-type same-gnc-account))))
(begin
;; there's an existing account with that name, so we
;; have to make a new acct with different properties and
;; something to indicate that it's different
(set! make-new-acct #t)
(set! incompatible-acct #t)))
(begin
;; otherwise, there is no existing account with the same
;; name.
(set! make-new-acct #t)
(set! incompatible-acct #f)))
(if existing-account
existing-account
(let ((new-acct (gnc:malloc-account))
@ -44,12 +82,13 @@
(acct-name #f)
(last-colon #f))
(set! last-colon (string-rindex gnc-name separator))
(gnc:account-begin-edit new-acct)
;; if this is a copy of an existing gnc account,
;; copy the account properties
(if (not make-new-acct)
;; if this is a copy of an existing gnc account, copy the
;; account properties. For incompatible existing accts,
;; we'll do something different later.
(if same-gnc-account
(begin
(gnc:account-set-name
new-acct (gnc:account-get-name same-gnc-account))
@ -96,7 +135,18 @@
(gnc:account-set-currency new-acct currency)
(gnc:account-set-security new-acct security)
;; set the account type FIXME !!
;; if it's an incompatible account, set the
;; name to be unique, and a description that
;; hints what's happening
(if incompatible-acct
(let ((new-name (make-unique-name-variant
gnc-name acct-name)))
(gnc:account-set-name new-acct new-name)
(gnc:account-set-description
new-acct
(_ "QIF import: Name conflict with another account."))))
;; set the account type. this could be smarter.
(if (qif-map-entry:allowed-types acct-info)
(gnc:account-set-type
new-acct (car (qif-map-entry:allowed-types acct-info))))))
@ -473,8 +523,8 @@
((cgshort cgshortx cgmid cgmidx cglong cglongx intinc intincx
div divx miscinc miscincx xin rtrncap rtrncapx)
(gnc:split-set-value gnc-near-split split-amt)
(gnc:split-set-share-amount gnc-near-split split-amt)
(gnc:split-set-value gnc-near-split xtn-amt)
(gnc:split-set-share-amount gnc-near-split xtn-amt)
(gnc:split-set-value gnc-far-split (n- xtn-amt))
(gnc:split-set-share-amount gnc-far-split (n- xtn-amt)))
@ -485,20 +535,13 @@
(gnc:split-set-share-amount gnc-far-split xtn-amt))
((shrsin)
;; for shrsin, the near account is the security account.
;; we'll need to set the share-price after a little
;; trickery post-adding-to-account
;; getting rid of the old equity-acct-per-stock trick.
;; you must now have a cash value for the stock.
;; you must now have a cash/basis value for the stock.
(gnc:split-set-share-amount gnc-near-split num-shares)
(gnc:split-set-value gnc-near-split split-amt)
(gnc:split-set-value gnc-far-split (n- xtn-amt))
(gnc:split-set-share-amount gnc-far-split (n- xtn-amt)))
;;; (gnc:split-set-share-amount gnc-near-split num-shares)
;;; (gnc:split-set-value gnc-far-split num-shares))
((shrsout)
;; shrsout is like shrsin
(gnc:split-set-share-amount gnc-near-split (n- num-shares))

View File

@ -21,7 +21,7 @@
(gnc:depend "engine-utilities.scm")
(define (gnc:amount->string amount info)
(gnc:amount->string-helper (exact->inexact amount) info))
(d-gnc:amount->string-helper (exact->inexact amount) info))
(define (gnc:commodity-amount->string amount info)
(gnc:amount->string-helper amount info))

View File

@ -191,17 +191,21 @@
(define (gnc:report-run id)
(define (dumper key . args)
(let ((stack (make-stack #t dumper)))
(display-backtrace stack (current-error-port))
(apply display-error stack (current-error-port) args)
(throw 'ignore)))
(catch
#t
(lambda () (gnc:report-run-unsafe id))
'ignore
(lambda ()
(lazy-catch #t
(lambda () (gnc:report-run-unsafe id))
dumper))
(lambda (key . args)
(if (gnc:debugging?)
(begin
(display (gnc:error->string key args))
(newline)))
#f)))
(define (gnc:report-run-unsafe id)
(let ((report (gnc:find-report id)))
(if report

View File

@ -52,6 +52,12 @@
(_ "Show preparer info") "c"
(_ "Name of organization or company")
#f))
(opt-register
(gnc:make-simple-boolean-option
(_ "General")
(_ "Enable Links") "c"
(_ "Enable hyperlinks in reports")
#t))
(opt-register
(gnc:make-pixmap-option
@ -124,6 +130,7 @@
(preparer (opt-val (_ "General") (_ "Preparer")))
(prepared-for (opt-val (_ "General") (_ "Prepared for")))
(show-preparer? (opt-val (_ "General") (_ "Show preparer info")))
(links? (opt-val (_ "General") (_ "Enable Links")))
(bgcolor (color-val (_ "Colors") (_ "Background Color")))
(textcolor (color-val (_ "Colors") (_ "Text Color")))
(linkcolor (color-val (_ "Colors") (_ "Link Color")))
@ -153,6 +160,11 @@
'attribute (list "cellspacing" spacing)
'attribute (list "cellpadding" padding))
;; don't surround marked-up links with <a> </a>
(if (not links?)
(gnc:html-document-set-style!
ssdoc "a" 'tag ""))
(let ((t (gnc:make-html-table)))
;; we don't want a bevel for this table, but we don't want
;; that to propagate

View File

@ -44,6 +44,11 @@
(_ "General")
(_ "Background Pixmap") "b" (_ "Background tile for reports.")
""))
(opt-register
(gnc:make-simple-boolean-option
(_ "General")
(_ "Enable Links") "c" (_ "Enable hyperlinks in reports.")
#t))
(opt-register
(gnc:make-number-range-option
(_ "Tables")
@ -73,6 +78,7 @@
(_ "General")
(_ "Background Color"))))
(bgpixmap (opt-val (_ "General") (_ "Background Pixmap")))
(links? (opt-val (_ "General") (_ "Enable Links")))
(spacing (opt-val (_ "Tables") (_ "Table cell spacing")))
(padding (opt-val (_ "Tables") (_ "Table cell padding")))
(border (opt-val (_ "Tables") (_ "Table border width"))))
@ -93,7 +99,13 @@
'attribute (list "border" border)
'attribute (list "cellspacing" spacing)
'attribute (list "cellpadding" padding))
;; don't surround marked-up links with <a> </a>
(if (not links?)
(gnc:html-document-set-style!
ssdoc "a"
'tag ""))
(let ((title (gnc:html-document-title doc)))
(if title
(gnc:html-document-add-object!