[libgda] Allow compiling even with old Graphviz API
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Allow compiling even with old Graphviz API
- Date: Tue, 30 Apr 2013 19:09:48 +0000 (UTC)
commit 071bd53b80621cf2bf3cea9ef2a97c5b3fc56ee6
Author: Vivien Malerba <malerba gnome-db org>
Date: Tue Apr 30 20:51:04 2013 +0200
Allow compiling even with old Graphviz API
cf changes made in commit #cc5d429567e21ec62bf61b7e3b54348af11965b9
configure.ac | 19 +++++++++++++++++++
tools/browser/canvas/browser-canvas.c | 23 +++++++++++++++++++++--
2 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0a61cef..84aad65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -251,6 +251,25 @@ then
AC_MSG_ERROR([Graphviz support requested but not found.])
fi
have_graphviz=no])
+ if test "x$have_graphviz" = "xyes"
+ then
+ dnl test if new API is supported
+ AC_MSG_CHECKING([whether Graphviz's new API is supported])
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+#include <gvc.h>
+int main() {
+ Agraph_t *graph;
+ graph = agopen ("BrowserCanvasLayout", Agdirected, NULL);
+ return 0;
+}
+])],
+ graphviz_new_api=yes, graphviz_new_api=no)
+
+ AC_MSG_RESULT($graphviz_new_api)
+ if test "$graphviz_new_api" = "yes"; then
+ AC_DEFINE(GRAPHVIZ_NEW_API,[1],[define if Graphviz's new API is available])
+ fi
+ fi
fi
PKG_CHECK_MODULES(GLADE, "gladeui-2.0", [
diff --git a/tools/browser/canvas/browser-canvas.c b/tools/browser/canvas/browser-canvas.c
index b228fd3..e173c1b 100644
--- a/tools/browser/canvas/browser-canvas.c
+++ b/tools/browser/canvas/browser-canvas.c
@@ -851,6 +851,7 @@ browser_canvas_perform_auto_layout (BrowserCanvas *canvas, gboolean animate, Bro
if (!gvc)
gvc = gvContext ();
+#ifdef GRAPHVIZ_NEW_API
graph = agopen ("BrowserCanvasLayout", Agdirected, NULL);
agnode (graph, "shape", "box");
agset (graph, "height", ".1");
@@ -858,6 +859,15 @@ browser_canvas_perform_auto_layout (BrowserCanvas *canvas, gboolean animate, Bro
agset (graph, "fixedsize", "true");
agset (graph, "pack", "true");
agset (graph, "packmode", "node");
+#else
+ graph = agopen ("BrowserCanvasLayout", AGRAPH);
+ agnodeattr (graph, "shape", "box");
+ agnodeattr (graph, "height", ".1");
+ agnodeattr (graph, "width", ".1");
+ agnodeattr (graph, "fixedsize", "true");
+ agnodeattr (graph, "pack", "true");
+ agnodeattr (graph, "packmode", "node");
+#endif
if (class->get_layout_items)
@@ -885,7 +895,11 @@ browser_canvas_perform_auto_layout (BrowserCanvas *canvas, gboolean animate, Bro
nodes_list = g_slist_prepend (nodes_list, nl);
tmp = g_strdup_printf ("%p", item);
+#ifdef GRAPHVIZ_NEW_API
node = agnode (graph, tmp, 0);
+#else
+ node = agnode (graph, tmp);
+#endif
nl->node = node;
g_hash_table_insert (nodes_hash, item, node);
@@ -928,8 +942,13 @@ browser_canvas_perform_auto_layout (BrowserCanvas *canvas, gboolean animate, Bro
Agnode_t *from_node, *to_node;
from_node = (Agnode_t*) g_hash_table_lookup (nodes_hash, from);
to_node = (Agnode_t*) g_hash_table_lookup (nodes_hash, to);
- if (from_node && to_node)
- agedge (graph, from_node, to_node, "", 0);
+ if (from_node && to_node) {
+#ifdef GRAPHVIZ_NEW_API
+ agedge (graph, from_node, to_node, "", 0);
+#else
+ agedge (graph, from_node, to_node);
+#endif
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]