summaryrefslogtreecommitdiff
blob: b9242275d3a00614fdb66e2d3be84075dbe1353b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From 071bd53b80621cf2bf3cea9ef2a97c5b3fc56ee6 Mon Sep 17 00:00:00 2001
From: Vivien Malerba <malerba@gnome-db.org>
Date: Tue, 30 Apr 2013 20:51:04 +0200
Subject: [PATCH] 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
+			}
 		}
 	}
 
-- 
1.8.3.2