To work with my system Fiesty libgoffice-0-3 0.3.5-1ubuntu1 I needed to
change src/gnome-utils/gnc-html-graph-gog.c to use cairo.
Attached is a patch I've wrapped these with HAVE_CAIRO. I've not
attepted any automake foo the set HAVE_CAIRO.
Index: src/gnome-utils/gnc-html-graph-gog.c
===================================================================
--- src/gnome-utils/gnc-html-graph-gog.c (revision 15675)
+++ src/gnome-utils/gnc-html-graph-gog.c (working copy)
@@ -35,7 +35,12 @@
#include <goffice/goffice.h>
#include <goffice/graph/gog-graph.h>
#include <goffice/graph/gog-object.h>
+#define WITH_CAIRO
+#ifdef WITH_CAIRO
+#include <goffice/graph/gog-renderer-cairo.h>
+#else
#include <goffice/graph/gog-renderer-pixbuf.h>
+#endif
#include <goffice/graph/gog-renderer-gnome-print.h>
#include <goffice/graph/gog-style.h>
#include <goffice/graph/gog-styled-object.h>
@@ -43,7 +48,9 @@
#include <goffice/graph/gog-series.h>
#include <goffice/utils/go-color.h>
#include <goffice/graph/gog-data-set.h>
+#if 0
#include <goffice/graph/gog-renderer-svg.h>
+#endif
#include <goffice/data/go-data-simple.h>
#include <goffice/app/go-plugin.h>
#include <goffice/app/go-plugin-loader-module.h>
@@ -159,10 +166,56 @@
return retval;
}
+#ifdef WITH_CAIRO
static void
-add_pixbuf_graph_widget( GtkHTMLEmbedded *eb, GogObject *graph )
+add_cairo_graph_widget ( GtkHTMLEmbedded *eb, GogObject *graph )
{
GtkWidget *widget;
+ GogRendererCairo *cairo_renderer;
+ GdkPixbuf *buf;
+ gboolean update_status;
+
+ // Note that this shouldn't be necessary as per discussion with Jody...
+ // ... but it is because we don't embed in a control which passes the
+ // update requests back to the graph widget, a-la the foo-canvas that
+ // gnumeric uses. We probably _should_ do something like that, though.
+ gog_object_update (GOG_OBJECT (graph));
+
+#if 0
+ // example SVG use. Also, nice for debugging.
+ {
+ GsfOutput *mem;
+ gboolean output;
+
+ mem = gsf_output_memory_new();
+ output = gog_graph_export_to_svg( graph, mem, eb->width, eb->height, 1. );
+ printf( "svg: [%s]\n", (guchar*)gsf_output_memory_get_bytes( GSF_OUTPUT_MEMORY(mem) ) );
+ }
+#endif // 0
+
+ cairo_renderer = GOG_RENDERER_CAIRO (g_object_new (GOG_RENDERER_CAIRO_TYPE,
+ "model", graph,
+ NULL));
+ update_status = gog_renderer_cairo_update (cairo_renderer,
+ eb->width, eb->height, 1.0);
+ buf = gog_renderer_cairo_get_pixbuf (cairo_renderer);
+ widget = gtk_image_new_from_pixbuf (buf);
+ gtk_widget_set_size_request (widget, eb->width, eb->height);
+ gtk_widget_show_all (widget);
+ gtk_container_add (GTK_CONTAINER (eb), widget);
+
+ // blindly copied from gnc-html-guppi.c..
+ gtk_widget_set_size_request (GTK_WIDGET (eb), eb->width, eb->height);
+
+ g_object_set_data_full (G_OBJECT (eb), "graph", graph, g_object_unref);
+ g_signal_connect (G_OBJECT (eb), "draw_print",
+ G_CALLBACK (draw_print_cb), NULL);
+}
+#else
+static void
+add_pixbuf_graph_widget ( GtkHTMLEmbedded *eb, GogObject *graph )
+{
+ GtkWidget *widget;
GogRendererPixbuf *pixbuf_renderer;
GdkPixbuf *buf;
gboolean update_status;
@@ -203,6 +256,7 @@
g_signal_connect (G_OBJECT (eb), "draw_print",
G_CALLBACK (draw_print_cb), NULL);
}
+#endif
static gboolean
create_basic_plot_elements(const char *plot_type_name,
@@ -359,7 +413,11 @@
// fixme: colors
set_chart_titles_from_hash(chart, eb);
+#ifdef WITH_CAIRO
+ add_cairo_graph_widget (eb, graph);
+#else
add_pixbuf_graph_widget (eb, graph);
+#endif
return TRUE;
}
@@ -494,7 +552,11 @@
// we need to do this twice for the barchart... :p
gog_object_update (GOG_OBJECT (graph));
+#ifdef WITH_CAIRO
+ add_cairo_graph_widget (eb, graph);
+#else
add_pixbuf_graph_widget (eb, graph);
+#endif
g_debug("barchart rendered.");
return TRUE;
@@ -546,7 +608,11 @@
// And twice for the scatter, too... :p
gog_object_update(GOG_OBJECT(graph));
+#ifdef WITH_CAIRO
+ add_cairo_graph_widget (eb, graph);
+#else
add_pixbuf_graph_widget (eb, graph);
+#endif
return TRUE;
}
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel