libvaladoc@PACKAGE_SUFFIX@_la_SOURCES = \
libvaladoc.vala.stamp \
$(libvaladoc_la_VALASOURCES:.vala=.c) \
+ gvc-compat.c \
$(NULL)
valadoc@PACKAGE_SUFFIX@.vapi valadoc.h: libvaladoc.vala.stamp
* Florian Brosch <flo.brosch@gmail.com>
*/
+[CCode (cname = "valadoc_compat_gvc_init")]
+extern void valadoc_gvc_init ();
public class Valadoc.Charts.Chart : Api.Visitor {
protected Gvc.Context context;
protected Factory factory;
static construct {
- #if !WITH_CGRAPH
- Gvc.init ();
- #endif
+ valadoc_gvc_init ();
}
public Chart (Factory factory, Api.Node node) {
* Florian Brosch <flo.brosch@gmail.com>
*/
+[CCode (cname = "valadoc_compat_gvc_graph_create_node")]
+extern Gvc.Node valadoc_gvc_graph_create_node (Gvc.Graph graph, string name);
public abstract class Valadoc.Charts.Factory : Object {
protected Gvc.Node create_type (Gvc.Graph graph, Api.Node item) {
-#if WITH_CGRAPH
- return graph.create_node (item.get_full_name (), 1);
-#else
- return graph.create_node (item.get_full_name ());
-#endif
+ return valadoc_gvc_graph_create_node (graph, item.get_full_name ());
}
public abstract Gvc.Graph create_graph (Api.Node item);
* Florian Brosch <flo.brosch@gmail.com>
*/
-
+[CCode (cname = "valadoc_compat_gvc_graph_new")]
+extern Gvc.Graph valadoc_gvc_graph_new (string name);
public class Valadoc.Charts.SimpleFactory : Charts.Factory {
protected virtual Gvc.Node configure_type (Gvc.Node node, Api.Node item) {
}
public override Gvc.Graph create_graph (Api.Node item) {
-#if WITH_CGRAPH
- var graph = new Gvc.Graph (item.get_full_name (), Gvc.Agdirected, 0);
-#else
- var graph = new Gvc.Graph (item.get_full_name (), Gvc.GraphKind.AGDIGRAPH);
-#endif
- return graph;
+ return valadoc_gvc_graph_new (item.get_full_name ());
}
public override Gvc.Context create_context (Gvc.Graph graph) {
--- /dev/null
+/* gvc-compat.c
+ *
+ * Copyright (C) 2017 Rico Tzschichholz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Rico Tzschichholz <ricotz@ubuntu.com>
+ */
+
+#include <gvc.h>
+
+/* Compat-layer for Graphviz with/without cgraph support */
+
+void
+valadoc_compat_gvc_init ()
+{
+#ifndef WITH_CGRAPH
+ aginit ();
+#endif
+}
+
+Agnode_t*
+valadoc_compat_gvc_graph_create_node (Agraph_t* graph, const char *name)
+{
+#ifdef WITH_CGRAPH
+ return agnode (graph, (char*) name, TRUE);
+#else
+ return agnode (graph, (char*) name);
+#endif
+}
+
+Agraph_t*
+valadoc_compat_gvc_graph_new (const char *name)
+{
+#ifdef WITH_CGRAPH
+ return agopen ((char*) name, Agdirected, NULL);
+#else
+ return agopen ((char*) name, AGDIGRAPH);
+#endif
+}