Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/ChangeLog,v
retrieving revision 1.133
diff -u -p -r1.133 ChangeLog
--- ChangeLog	29 Apr 2003 23:35:30 -0000	1.133
+++ ChangeLog	24 May 2003 11:13:05 -0000
@@ -1,3 +1,24 @@
+2003-05-24  Gustavo J. A. M. Carneiro  <gustavo@users.sourceforge.net>
+
+	* configure.in: Check if libbonobo >= 2.3.1, in which case we
+	define PYBONOBO_CPP_FLAGS="-DPYBONOBO_HAVE_FOREIGN_OBJECT".
+
+	* examples/bonobo/unknown.py: Example program of how to create a
+	custom BonoboObject in python and a aggregate to an exiting
+	C-based BonoboObject.
+
+	* bonobo/__init__.py: Define class UnknownBaseImpl, a helper class
+	to facilitate implementation of custom BonoboObjects in python.
+	[credit on this goes to James Henstridge and Johan Dahlin]
+
+	* bonobo/bonobo.override: Include bonobo-foreign-object.h
+
+	* bonobo/bonobo.defs (bonobo_foreign_object_new): Declare
+	BonoboForeignObject constructor.
+
+	* bonobo/bonobo-types.defs (ForeignObject): Declare
+	BonoboForeignObject type.
+
 2003-04-29  Johan Dahlin  <jdahlin@async.com.br>
 
 	* gnome/vfsmodule.c: Add exceptions
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/configure.in,v
retrieving revision 1.48
diff -u -p -r1.48 configure.in
--- configure.in	23 Mar 2003 06:25:56 -0000	1.48
+++ configure.in	24 May 2003 11:13:05 -0000
@@ -235,6 +235,19 @@ AM_CONDITIONAL(BUILD_BONOBO, $have_pyorb
 if test -n "$export_dynamic"; then
   BONOBO_LIBS=`echo $BONOBO_LIBS | sed -e "s/$export_dynamic//"`
 fi
+dnl Check if libbonobo version is >= 2.3.1
+if $have_pyorbit && $build_bonobo; then
+   AC_MSG_CHECKING([if libbonobo supports foreign objects])
+   if test -z `pkg-config libbonobo-2.0 >= 2.3.1 2>&1`; then
+	PYBONOBO_CPP_FLAGS="-DPYBONOBO_HAVE_FOREIGN_OBJECT"
+	AC_MSG_RESULT(yes);
+   else
+	PYBONOBO_CPP_FLAGS=""
+	AC_MSG_RESULT(no);
+   fi
+fi
+AC_SUBST(PYBONOBO_CPP_FLAGS)
+
 
 dnl should we build the bonobo.ui module?
 build_bonoboui=false
Index: bonobo/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/bonobo/Makefile.am,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile.am
--- bonobo/Makefile.am	25 Feb 2003 14:29:50 -0000	1.16
+++ bonobo/Makefile.am	24 May 2003 11:13:06 -0000
@@ -43,7 +43,7 @@ activationmodule_la_LDFLAGS = -module -a
 activationmodule_la_LIBADD = $(BONOBO_ACTIVATION_LIBS)
 activationmodule_la_SOURCES = activationmodule.c
 
-_bonobomodule_la_CFLAGS = $(BONOBO_CFLAGS)
+_bonobomodule_la_CFLAGS = $(BONOBO_CFLAGS) $(PYBONOBO_CPP_FLAGS)
 _bonobomodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_bonobo
 _bonobomodule_la_LIBADD = $(BONOBO_LIBS)
 _bonobomodule_la_SOURCES = bonobomodule.c bonobo-arg.c
@@ -71,6 +71,6 @@ bonoboui.c: bonoboui.defs bonoboui-types
 	    --register ../gnome/canvas.defs \
 	    --register bonobo-types.defs \
 	    --override $*.override \
-	    --prefix py$* $*.defs) > gen-$*.c \
+	    --prefix py$* $(PYBONOBO_CPP_FLAGS) $*.defs ) > gen-$*.c \
 	&& cp gen-$*.c $*.c \
 	&& rm -f gen-$*.c
Index: bonobo/__init__.py
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/bonobo/__init__.py,v
retrieving revision 1.5
diff -u -p -r1.5 __init__.py
--- bonobo/__init__.py	1 Nov 2002 02:25:49 -0000	1.5
+++ bonobo/__init__.py	24 May 2003 11:13:06 -0000
@@ -10,3 +10,17 @@ del ORBit
 import activation
 
 from _bonobo import *
+
+class UnknownBaseImpl(object):
+    def __init__(self):
+        self.__bobj = ForeignObject(self._this())
+    def get_bonobo_object(self):
+        return self.__bobj
+    def ref(self):
+        self.__bobj.ref()
+    def unref(self):
+        self.__bobj.unref()
+    def queryInterface(self, repoid):
+        return self.__bobj.query_local_interface(repoid).corba_objref()
+
+
Index: bonobo/bonobo-types.defs
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/bonobo/bonobo-types.defs,v
retrieving revision 1.6
diff -u -p -r1.6 bonobo-types.defs
--- bonobo/bonobo-types.defs	26 Jan 2003 19:37:44 -0000	1.6
+++ bonobo/bonobo-types.defs	24 May 2003 11:13:06 -0000
@@ -23,6 +23,15 @@
   (gtype-id "BONOBO_TYPE_ITEM_HANDLER")
 )
 
+(ifdef 'PYBONOBO_HAVE_FOREIGN_OBJECT
+  (define-object ForeignObject
+    (in-module "Bonobo")
+    (parent "BonoboObject")
+    (c-name "BonoboForeignObject")
+    (gtype-id "BONOBO_TYPE_FOREIGN_OBJECT")
+  )
+)
+
 (define-object Listener
   (in-module "Bonobo")
   (parent "BonoboObject")
Index: bonobo/bonobo.defs
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/bonobo/bonobo.defs,v
retrieving revision 1.6
diff -u -p -r1.6 bonobo.defs
--- bonobo/bonobo.defs	26 Jan 2003 19:37:44 -0000	1.6
+++ bonobo/bonobo.defs	24 May 2003 11:13:07 -0000
@@ -2376,4 +2376,15 @@
   )
 )
 
+;; From bonobo-foreign-object.h
+(ifdef 'PYBONOBO_HAVE_FOREIGN_OBJECT
+  (define-function bonobo_foreign_object_new
+    (c-name "bonobo_foreign_object_new")
+    (is-constructor-of BonoboForeignObject)
+    (return-type "BonoboObject*")
+    (parameters
+     '("CORBA_Object" "corba_objref")
+    )
+  )
+)
 
Index: bonobo/bonobo.override
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/bonobo/bonobo.override,v
retrieving revision 1.14
diff -u -p -r1.14 bonobo.override
--- bonobo/bonobo.override	26 Jan 2003 19:37:44 -0000	1.14
+++ bonobo/bonobo.override	24 May 2003 11:13:07 -0000
@@ -9,6 +9,10 @@ headers
 #include <libbonobo.h>
 #include <bonobo/bonobo-persist-client.h>
 #include <bonobo/bonobo-item-handler.h>
+#ifdef PYBONOBO_HAVE_FOREIGN_OBJECT
+# include <bonobo/bonobo-foreign-object.h>
+#endif
+
 %%
 modulename bonobo
 %%
