From 6d996af704841a65e6c0484d61d34c25360d721e Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sat, 27 Sep 2014 22:21:50 +0200 Subject: [PATCH] Add an image_size parameter to ag_chart_create_svg() This is required so we can generate a fixed size image, e.g. for the chart preview. --- src/ag-chart.c | 22 +++++++++++++++++++--- src/ag-chart.h | 1 + src/ag-window.c | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/ag-chart.c b/src/ag-chart.c index b59cfb7..f743dd1 100644 --- a/src/ag-chart.c +++ b/src/ag-chart.c @@ -1417,6 +1417,7 @@ ag_chart_create_svg(AgChart *chart, gsize *length, gboolean rendering, AgDisplayTheme *theme, + guint image_size, GError **err) { xmlDocPtr doc = create_save_doc(chart), @@ -1762,9 +1763,15 @@ ag_chart_create_svg(AgChart *chart, params[3] = g_strdup_printf("\"%s\"", css); g_free(css); params[4] = "chart-size"; - params[5] = g_strdup_printf("%d", AG_CHART_DEFAULT_RING_SIZE); params[6] = "image-size"; - params[7] = "0"; + + if (image_size == 0) { + params[5] = g_strdup_printf("%d", AG_CHART_DEFAULT_RING_SIZE); + params[7] = g_strdup("0"); + } else { + params[5] = g_strdup("0"); + params[7] = g_strdup_printf("%d", image_size); + } params[8] = "icon-size"; params[9] = g_strdup_printf("%d", AG_CHART_DEFAULT_ICON_SIZE); @@ -1781,6 +1788,7 @@ ag_chart_create_svg(AgChart *chart, xmlFreeDoc(doc); g_free(params[3]); g_free(params[5]); + g_free(params[7]); g_free(params[9]); g_free(params); @@ -1819,7 +1827,14 @@ ag_chart_export_svg_to_file(AgChart *chart, gchar *svg; gsize length; - if ((svg = ag_chart_create_svg(chart, &length, TRUE, theme, err)) == NULL) { + if ((svg = ag_chart_create_svg( + chart, + &length, + TRUE, + theme, + 0, + err + )) == NULL) { return; } @@ -1854,6 +1869,7 @@ ag_chart_export_jpg_to_file(AgChart *chart, &svg_length, TRUE, theme, + 0, err )) == NULL) { return; diff --git a/src/ag-chart.h b/src/ag-chart.h index 440369a..3d15273 100644 --- a/src/ag-chart.h +++ b/src/ag-chart.h @@ -120,6 +120,7 @@ gchar *ag_chart_create_svg(AgChart *chart, gsize *length, gboolean rendering, AgDisplayTheme *theme, + guint image_size, GError **err); GList *ag_chart_get_planets(AgChart *chart); diff --git a/src/ag-window.c b/src/ag-window.c index 66352ed..107e4b8 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -532,6 +532,7 @@ ag_window_redraw_chart(AgWindow *window) &length, FALSE, NULL, + 0, &err );