dia r4110 - in trunk: . app bindings lib objects/UML plug-ins/cairo plug-ins/python tests



Author: hans
Date: Sun Aug 10 18:03:34 2008
New Revision: 4110
URL: http://svn.gnome.org/viewvc/dia?rev=4110&view=rev

Log:
2008-08-10  Hans Breuer  <hans breuer org>

	* configure.in : one more step to build bindings on Linux
	* lib/libdia.[hc] : renamed to dialib.[hc] to avoid confusion with 
	libdia.la (libdia.lo)
	* lib/Makefile.am app/app_procs.c bindings/dia-extra.cpp
	  plug-ins/python/diamodule.c tests/test-objects.c
	  tests/test-boundingbox.c : adapted to name change

	* objects/UML/Makefile.am plug-ins/cairo/Makefile.am : add
	$(module)_la_LIBADD = $(OTHER_LIBS) $(top_builddir)/lib/libdia.la

	* bindings/dia.swig : don't crash on passing None to do_export()
	* bindings/Makefile.am bindings/test.py : now work start to work
	on Linux, too.

	* plug-ins/python/pydiadoc.py plug-ins/python/otypes.py : don't 
	assume there is always a display. In the bindings non-interactive
	test case there is not
	



Added:
   trunk/lib/dialib.c
      - copied, changed from r4107, /trunk/lib/libdia.c
   trunk/lib/dialib.h
      - copied unchanged from r4107, /trunk/lib/libdia.h
   trunk/lib/lib_dia.
      - copied unchanged from r4105, /trunk/lib/libdia.c
Removed:
   trunk/lib/libdia.c
   trunk/lib/libdia.h
Modified:
   trunk/ChangeLog
   trunk/app/app_procs.c
   trunk/bindings/Makefile.am
   trunk/bindings/dia-extra.cpp
   trunk/bindings/dia.swig
   trunk/bindings/test.py
   trunk/configure.in
   trunk/lib/Makefile.am
   trunk/objects/UML/Makefile.am
   trunk/plug-ins/cairo/Makefile.am
   trunk/plug-ins/python/diamodule.c
   trunk/plug-ins/python/otypes.py
   trunk/plug-ins/python/pydiadoc.py
   trunk/tests/test-boundingbox.c
   trunk/tests/test-objects.c

Modified: trunk/app/app_procs.c
==============================================================================
--- trunk/app/app_procs.c	(original)
+++ trunk/app/app_procs.c	Sun Aug 10 18:03:34 2008
@@ -74,7 +74,7 @@
 #include "sheets.h"
 #include "exit_dialog.h"
 #include "newgroup.h"
-#include "libdia.h"
+#include "dialib.h"
 
 static gboolean
 handle_initial_diagram(const char *input_file_name, 

Modified: trunk/bindings/Makefile.am
==============================================================================
--- trunk/bindings/Makefile.am	(original)
+++ trunk/bindings/Makefile.am	Sun Aug 10 18:03:34 2008
@@ -49,11 +49,16 @@
 	$(PYTHON_EXTRA_SOURCE)
 
 _dia_la_CPPFLAGS = $(PYTHON_INCLUDES) -I$(top_srcdir)/lib
-_dia_la_LDFLAGS = -export-dynamic -module -avoid-version
+_dia_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_dia
 ## must link ../lib/libdia.la but don't know how;(
-_dia_la_LIBADD = $(PYTHON_LIBS) $(GTK_LIBS)
+_dia_la_LIBADD = $(PYTHON_LIBS) $(GTK_LIBS) $(top_builddir)/lib/libdia.la
+
+# trial and error adaption from pygimp;)
+#_diadir = $(libdir)/lib
+#_dia_LTLIBRARIES = $(top_builddir)/lib/libdia.la
 
 INCLUDES = \
+	$(DEBUG_FLAGS) \
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/lib \
 	$(GTK_CFLAGS) \

Modified: trunk/bindings/dia-extra.cpp
==============================================================================
--- trunk/bindings/dia-extra.cpp	(original)
+++ trunk/bindings/dia-extra.cpp	Sun Aug 10 18:03:34 2008
@@ -31,7 +31,7 @@
 #include "properties.h"
 #include "object.h"
 #include "plug-ins.h"
-#include "libdia.h"
+#include "dialib.h"
 
 /*!
  * 

Modified: trunk/bindings/dia.swig
==============================================================================
--- trunk/bindings/dia.swig	(original)
+++ trunk/bindings/dia.swig	Sun Aug 10 18:03:34 2008
@@ -295,8 +295,11 @@
 // NOTE: although renamed above we need to use the old name here
 %extend _DiaExportFilter {
   // don't use 'export' as this produces nothing w/o warning
-  void do_export (dia::DiagramData *dia, const gchar *filename) {
-    self->export_func (dia->Self(), filename, filename, self->user_data);
+  void do_export (dia::DiagramData *dia, const gchar *filename) {
+    if (dia)
+      self->export_func (dia->Self(), filename, filename, self->user_data);
+    else
+      g_warning ( "%s no data", G_STRFUNC);
   }
 };
 
@@ -365,5 +368,5 @@
 def new (s) :
     return Diagram()
 def active_display () :
-    return Display()
+    return None
 %}

Modified: trunk/bindings/test.py
==============================================================================
--- trunk/bindings/test.py	(original)
+++ trunk/bindings/test.py	Sun Aug 10 18:03:34 2008
@@ -1,18 +1,20 @@
 import os, sys
 
+# a global object to make it changeable by main()
+format_extensions = ["svg", "png"]
+
 if sys.platform == "win32" :
 	print "Adjusting PATH ..."
 	sys.path.insert(0, r'd:\graph\dia2\python')
 	sys.path.insert(0, r'd:\graph\dia2\bin')
 	sys.path.insert(0, r'..\plug-ins\python')
+	format_extensions.prepend ("wmf")
 else : # sorry only Linux and win32 tested ;)
 	sys.path.insert (0, os.getcwd() + "/.libs")
 	sys.path.insert(0, r'../plug-ins/python')
 
 import dia
 
-# a global object to make it changeable by main()
-format_extensions = ["wmf", "svg", "png"]
 
 def Dump () :
 	print dir(dia)
@@ -27,9 +29,11 @@
 if sys.platform == "win32" :
 	os.environ["DIA_LIB_PATH"] = r"d:\graph\dia2\dia"
 else :
-	print "FIXME: trouble with dynamic loading on '%s', no plug-ins" % (sys.platform,)
-	#base_path = os.getcwd() + "/.."
-	#os.environ["DIA_LIB_PATH"] = base_path + "/objects//:" + base_path + "/plug-ins//"
+	print "FIXME: trouble with dynamic loading on '%s'?" % (sys.platform,)
+	base_path = os.getcwd() + "/.."
+	os.environ["DIA_LIB_PATH"] = base_path + "/objects//:" + base_path + "/plug-ins//"
+	os.environ["DIA_SHAPE_PATH"] = base_path + "/shapes//"
+	os.environ["DIA_XSLT_PATH"] = base_path + "/plug-ins/xslt"
 
 try :
 	dia.register_plugins()
@@ -71,7 +75,9 @@
 	data = dia.DiagramData()
 
 	import pydiadoc
-	data = pydiadoc.autodoc_cb (data, 0)
+	res = pydiadoc.autodoc_cb (data, 1)
+	if res :
+		data = res
 	Export ("pydiadoc", data)
 
 def Dox () :
@@ -87,7 +93,9 @@
 	data = dia.DiagramData()
 
 	import otypes
-	data = otypes.otypes_cb (data, 0)
+	res = otypes.otypes_cb (data, 0)
+	if res :
+		data = res
 	Export ("otypes", data)
 
 def AObj () :
@@ -130,7 +138,7 @@
 	except AttributeError, s :
 		print "Expected except", s, r.top, r.left
 
-for arg in sys.argv :
+for arg in sys.argv[1:] :
 	if '--dump' == arg : Dump ()
 	elif '--import' == arg : Import ()
 	elif '--gx' == arg : Gx ()

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Sun Aug 10 18:03:34 2008
@@ -466,7 +466,7 @@
 dnl Handling of Python bindings with SWIG
 with_swig=no
 AC_ARG_WITH(swig,
-[  --with-swig          generate python bindings with swig],,with_swig=no)
+[  --with-swig          generate python bindings with swig],with_swig=yes,with_swig=no)
 
 if test "x$with_swig" != xno; then
   AC_PROG_SWIG(1.3.31)

Modified: trunk/lib/Makefile.am
==============================================================================
--- trunk/lib/Makefile.am	(original)
+++ trunk/lib/Makefile.am	Sun Aug 10 18:03:34 2008
@@ -162,8 +162,8 @@
 		prefs.h \
 	        newgroup.c \
 	        newgroup.h \
-		libdia.c \
-		libdia.h \
+		dialib.c \
+		dialib.h \
 		\
 		diacellrendererproperty.c \
 		diacellrendererproperty.h \
@@ -175,7 +175,7 @@
 #		render.h \
 #		render.c 
 
-libdia_la_LDFLAGS = -avoid-version
+libdia_la_LDFLAGS = -avoid-version --export-dynamic
 libdia_la_LIBADD = $(GTK_LIBS)
 
 AM_CPPFLAGS = \
@@ -212,3 +212,4 @@
 
 
 EXTRA_DIST = libdia.def makefile.msc diamarshal.list
+

Copied: trunk/lib/dialib.c (from r4107, /trunk/lib/libdia.c)
==============================================================================
--- /trunk/lib/libdia.c	(original)
+++ trunk/lib/dialib.c	Sun Aug 10 18:03:34 2008
@@ -26,7 +26,7 @@
 
 #include <libxml/xmlerror.h>
 
-#include "libdia.h"
+#include "dialib.h"
 #include "message.h"
 #include "utils.h"
 #include "dia_image.h"
@@ -113,3 +113,4 @@
 
   object_registry_init();
 }
+

Modified: trunk/objects/UML/Makefile.am
==============================================================================
--- trunk/objects/UML/Makefile.am	(original)
+++ trunk/objects/UML/Makefile.am	Sun Aug 10 18:03:34 2008
@@ -39,6 +39,7 @@
 			umlformalparameter.c
 
 libuml_objects_la_LDFLAGS = -export-dynamic -module -avoid-version
+libuml_objects_la_LIBADD = $(CAIRO_LIBS) $(top_builddir)/lib/libdia.la
 
 INCLUDES = -I$(top_srcdir)/intl -I$(srcdir)/../../lib \
 	$(DEBUG_FLAGS) $(GTK_CFLAGS) $(GNOME_CFLAGS) $(PANGOFT2_CFLAGS) $(UNICODE_CFLAGS)

Modified: trunk/plug-ins/cairo/Makefile.am
==============================================================================
--- trunk/plug-ins/cairo/Makefile.am	(original)
+++ trunk/plug-ins/cairo/Makefile.am	Sun Aug 10 18:03:34 2008
@@ -14,7 +14,6 @@
 libcairo_filter_la_SOURCES = $(plugin_sources)
 
 libcairo_filter_la_LDFLAGS = -export-dynamic -module -avoid-version
-
-libcairo_filter_la_LIBADD = $(CAIRO_LIBS)
+libcairo_filter_la_LIBADD = $(CAIRO_LIBS) $(top_builddir)/lib/libdia.la
 
 INCLUDES = -I$(srcdir)/../../lib $(GTK_CFLAGS) $(DEBUG_FLAGS) $(CAIRO_CFLAGS)

Modified: trunk/plug-ins/python/diamodule.c
==============================================================================
--- trunk/plug-ins/python/diamodule.c	(original)
+++ trunk/plug-ins/python/diamodule.c	Sun Aug 10 18:03:34 2008
@@ -39,7 +39,7 @@
 #include "pydia-text.h"
 #include "pydia-paperinfo.h"
 
-#include "lib/libdia.h"
+#include "lib/dialib.h"
 #include "lib/object.h"
 #include "lib/group.h"
 #include "app/diagram.h"

Modified: trunk/plug-ins/python/otypes.py
==============================================================================
--- trunk/plug-ins/python/otypes.py	(original)
+++ trunk/plug-ins/python/otypes.py	Sun Aug 10 18:03:34 2008
@@ -32,8 +32,12 @@
 
 def otypes_cb(data, flags) :
 
-	diagram = dia.new("Object Types.dia")
-	layer = diagram.data.active_layer
+	if dia.active_display () :
+		diagram = dia.new("Object Types.dia")
+		layer = diagram.data.active_layer
+	else : # non-interactive
+		diagram = None
+		layer = data.active_layer
 
 	otypes = dia.registered_types()
 	keys = otypes.keys()
@@ -74,6 +78,7 @@
 
 	for sp in packages.keys() :
 		pkg = packages[sp]
+		print "Package", sp
 		op, h1, h2 = dtp.create(0.0, cy + 1.0)
 		op.properties["name"] = sp
 		layer.add_object(op)
@@ -168,9 +173,13 @@
 		op.move_handle(h,(maxx + 1.0, maxy + 1.0), 0, 0)
 		cy = maxy + 2.0
 		maxx = 0 # every package a new size
-	diagram.display()
-	diagram.update_extents()
-	diagram.flush()
+	print "Size:", cx, cy
+	layer.update_extents ()
+	data.update_extents ()
+	if diagram :
+		diagram.display()
+		diagram.update_extents()
+		diagram.flush()
 
 dia.register_action ("HelpOtypes", "Dia Object Types",
                      "/ToolboxMenu/Help/HelpExtensionStart", 

Modified: trunk/plug-ins/python/pydiadoc.py
==============================================================================
--- trunk/plug-ins/python/pydiadoc.py	(original)
+++ trunk/plug-ins/python/pydiadoc.py	Sun Aug 10 18:03:34 2008
@@ -45,17 +45,23 @@
 			y += height
 
 def autodoc_cb (data, flags) :
-	diagram = dia.new("PyDiaObjects.dia")
-	# passed in data is not necessary valid - we are called from the Toolbox menu
-	data = diagram.data
+	if dia.active_display () :
+		diagram = dia.new("PyDiaObjects.dia")
+		# passed in data is not necessary valid - we are called from the Toolbox menu
+		data = diagram.data
+		display = diagram.display()
+	else :
+		diagram = None
+		display = None
 	layer = data.active_layer
-	display = diagram.display()
 
 	oType = dia.get_object_type ("UML - Class")		
 	
 	theDir = dir(dia)
 	# for reflection we need some objects ...
-	theObjects = [diagram, data, layer, display, oType]
+	theObjects = [data, layer, oType]
+	if diagram : theObjects.append (diagram)
+	if display : theObjects.append (display)
 	# add some objects with interesting properties
 	#theObjects.append(dia.DiaImage())
 	once = 1
@@ -95,6 +101,7 @@
 		is_a = eval("type(dia." + s + ") is types.BuiltinMethodType")
 		if is_a :
 			theGlobals.append((s,doc))
+			#print s, doc
 			continue
 		o, h1, h2 = oType.create (0,0) # p.x, p.y
 		if doc :
@@ -110,10 +117,15 @@
 			# ... attributes
 			attributes = []
 			for m in dir(t) :
+				if m[:2] == "__" :
+					continue
 				#print s + "." + m
 				#tm = eval("t." + m)
 				#print tm
-				is_m = eval("type(t." + m + ") is types.BuiltinMethodType")
+				try :
+					is_m = eval("type(t." + m + ") is types.BuiltinMethodType")
+				except IndexError :
+					is_m = None
 				doc = ""
 				try :
 					doc = eval("t." + m + ".__doc__")
@@ -138,8 +150,10 @@
 	# all objects got there bounding box, distribute them
 	distribute_objects (layer.objects)
 
-	diagram.update_extents()
-	diagram.flush()
+	data.update_extents ()
+	if diagram and display :
+		diagram.update_extents()
+		diagram.flush()
 
 dia.register_action ("HelpPydia", "PyDia Docs", 
                        "/ToolboxMenu/Help/HelpExtensionStart", 

Modified: trunk/tests/test-boundingbox.c
==============================================================================
--- trunk/tests/test-boundingbox.c	(original)
+++ trunk/tests/test-boundingbox.c	Sun Aug 10 18:03:34 2008
@@ -31,7 +31,7 @@
 #if GLIB_CHECK_VERSION(2,16,0)
 #include <glib/gtestutils.h>
 #endif
-#include "libdia.h"
+#include "dialib.h"
 
 /*
  * To test DiaObject bounding boxes a nice approach would be to implment a BoundingboxRenderer

Modified: trunk/tests/test-objects.c
==============================================================================
--- trunk/tests/test-objects.c	(original)
+++ trunk/tests/test-objects.c	Sun Aug 10 18:03:34 2008
@@ -34,7 +34,7 @@
 
 #include "object.h"
 #include "plug-ins.h"
-#include "libdia.h"
+#include "dialib.h"
 
 /* allows to select specific objects for testing */
 static gchar *_type_name = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]