Outsource chart pixbuf creation to ag_chart_get_pixbuf()

This commit is contained in:
Gergely Polonkai 2014-09-28 00:38:56 +02:00
parent a02c584d7d
commit 54a93e05d6
2 changed files with 38 additions and 12 deletions

View File

@ -1892,16 +1892,15 @@ ag_chart_export_svg_to_file(AgChart *chart,
); );
} }
void GdkPixbuf *
ag_chart_export_jpg_to_file(AgChart *chart, ag_chart_get_pixbuf(AgChart *chart,
GFile *file, guint image_size,
AgDisplayTheme *theme, guint icon_size,
GError **err) AgDisplayTheme *theme,
GError **err)
{ {
gchar *svg, gchar *svg;
*jpg; gsize svg_length;
gsize svg_length,
jpg_length;
RsvgHandle *svg_handle; RsvgHandle *svg_handle;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
@ -1910,10 +1909,11 @@ ag_chart_export_jpg_to_file(AgChart *chart,
&svg_length, &svg_length,
TRUE, TRUE,
theme, theme,
0, 0, image_size,
icon_size,
err err
)) == NULL) { )) == NULL) {
return; return NULL;
} }
if ((svg_handle = rsvg_handle_new_from_data( if ((svg_handle = rsvg_handle_new_from_data(
@ -1923,7 +1923,7 @@ ag_chart_export_jpg_to_file(AgChart *chart,
)) == NULL) { )) == NULL) {
g_free(svg); g_free(svg);
return; return NULL;
} }
g_free(svg); g_free(svg);
@ -1935,6 +1935,25 @@ ag_chart_export_jpg_to_file(AgChart *chart,
_("Unknown rendering error") _("Unknown rendering error")
); );
return NULL;
}
return pixbuf;
}
void
ag_chart_export_jpg_to_file(AgChart *chart,
GFile *file,
AgDisplayTheme *theme,
GError **err)
{
gchar *jpg;
gsize jpg_length;
GdkPixbuf *pixbuf;
pixbuf = ag_chart_get_pixbuf(chart, 0, 0, theme, err);
if (pixbuf == NULL) {
return; return;
} }

View File

@ -22,6 +22,7 @@
#include <glib-object.h> #include <glib-object.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <swe-glib.h> #include <swe-glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "ag-db.h" #include "ag-db.h"
#include "ag-display-theme.h" #include "ag-display-theme.h"
@ -140,6 +141,12 @@ const gchar *ag_chart_get_note(AgChart *chart);
AgDbChartSave *ag_chart_get_db_save(AgChart *chart, gint db_id); AgDbChartSave *ag_chart_get_db_save(AgChart *chart, gint db_id);
GdkPixbuf *ag_chart_get_pixbuf(AgChart *chart,
guint image_size,
guint icon_size,
AgDisplayTheme *theme,
GError **err);
#define AG_CHART_ERROR (ag_chart_error_quark()) #define AG_CHART_ERROR (ag_chart_error_quark())
GQuark ag_chart_error_quark(void); GQuark ag_chart_error_quark(void);