File libgda-old-graphviz.patch of Package libgda

From 071bd53b80621cf2bf3cea9ef2a97c5b3fc56ee6 Mon Sep 17 00:00:00 2001
From: Vivien Malerba <malerba@gnome-db.org>
Date: Tue, 30 Apr 2013 18:51:04 +0000
Subject: Allow compiling even with old Graphviz API

cf changes made in commit #cc5d429567e21ec62bf61b7e3b54348af11965b9
---
Index: libgda-5.1.2/configure.ac
===================================================================
--- libgda-5.1.2.orig/configure.ac
+++ libgda-5.1.2/configure.ac
@@ -250,6 +250,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
 fi
 
Index: libgda-5.1.2/tools/browser/canvas/browser-canvas.c
===================================================================
--- libgda-5.1.2.orig/tools/browser/canvas/browser-canvas.c
+++ libgda-5.1.2/tools/browser/canvas/browser-canvas.c
@@ -851,6 +851,7 @@ browser_canvas_perform_auto_layout (Brow
 	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 (Brow
         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 (Brow
 		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 (Brow
 			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
+			}
 		}
 	}
openSUSE Build Service is sponsored by