? bonobo/.t.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/ChangeLog,v
retrieving revision 1.132
diff -u -p -u -p -r1.132 ChangeLog
--- ChangeLog	23 Mar 2003 06:25:56 -0000	1.132
+++ ChangeLog	15 Apr 2003 22:32:50 -0000
@@ -1,3 +1,21 @@
+2003-04-15  Gustavo J. A. M. Carneiro  <gustavo@users.sourceforge.net>
+
+	* 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-03-23  James Henstridge  <james@daa.com.au>
 
 	* setup.py (MICRO_VERSION): same here.
Index: bonobo/__init__.py
===================================================================
RCS file: /cvs/gnome/gnome-python/gnome-python/bonobo/__init__.py,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 __init__.py
--- bonobo/__init__.py	1 Nov 2002 02:25:49 -0000	1.5
+++ bonobo/__init__.py	15 Apr 2003 22:32:50 -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 -u -p -r1.6 bonobo-types.defs
--- bonobo/bonobo-types.defs	26 Jan 2003 19:37:44 -0000	1.6
+++ bonobo/bonobo-types.defs	15 Apr 2003 22:32:51 -0000
@@ -9,6 +9,13 @@
   (gtype-id "BONOBO_TYPE_OBJECT")
 )
 
+(define-object ForeignObject
+  (in-module "Bonobo")
+  (parent "BonoboObject")
+  (c-name "BonoboForeignObject")
+  (gtype-id "BONOBO_TYPE_FOREIGN_OBJECT")
+)
+
 (define-object GenericFactory
   (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 -u -p -r1.6 bonobo.defs
--- bonobo/bonobo.defs	26 Jan 2003 19:37:44 -0000	1.6
+++ bonobo/bonobo.defs	15 Apr 2003 22:32:52 -0000
@@ -2376,4 +2376,13 @@
   )
 )
 
+;; From bonobo-foreign-object.h
+(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 -u -p -r1.14 bonobo.override
--- bonobo/bonobo.override	26 Jan 2003 19:37:44 -0000	1.14
+++ bonobo/bonobo.override	15 Apr 2003 22:32:52 -0000
@@ -9,6 +9,9 @@ headers
 #include <libbonobo.h>
 #include <bonobo/bonobo-persist-client.h>
 #include <bonobo/bonobo-item-handler.h>
+#include <bonobo/bonobo-foreign-object.h>
+
+
 %%
 modulename bonobo
 %%
Index: examples/bonobo/unknown.py
===================================================================
RCS file: examples/bonobo/unknown.py
diff -N examples/bonobo/unknown.py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ examples/bonobo/unknown.py	15 Apr 2003 22:32:53 -0000
@@ -0,0 +1,35 @@
+#! /usr/bin/env python
+
+import pygtk
+pygtk.require("2.0")
+
+import bonobo
+import Bonobo
+import Bonobo__POA
+import CORBA, sys
+
+orb = CORBA.ORB_init(sys.argv)
+bonobo.activate()
+
+class PersistStream(Bonobo__POA.PersistStream, bonobo.UnknownBaseImpl):
+    def __init__(self):
+        bonobo.UnknownBaseImpl.__init__(self)
+    # implementations of methods/attributes of "Interface" go here
+
+    def load(self, content_type):
+	print "PersistStream::load(content_type='%s')" % content_type
+
+    def save(self, content_type):
+	print "PersistStream::save(content_type='%s')" % content_type
+
+
+ps = PersistStream()
+
+def foo(*args):
+    print args
+
+listener = bonobo.Listener(foo)
+listener.add_interface(ps.get_bonobo_object())
+
+print listener.corba_objref().queryInterface("IDL:Bonobo/PersistStream:1.0")
+
