Re: Problem Querying Bonobo_Unknown



Le lun 09/02/2004 à 14:30, Stephane K. a écrit :
> Michael Meeks wrote:
> 
> >Hi Andrew,
> >
> >On Thu, 2004-02-05 at 20:59 +1100, Andrew Burton wrote:
> >  
> >
> >>For some reason, I cannot get pstream to work with the
> >>Bonobo_Unknown_queryInterface call. If I use Bonobo_PersistFile instead,
> >>    
> >>
> >
> >	So the EOG control isn't implementing PersistStream - which is a shame;
> >of course, it's harder - but then it's often more flexible / efficient /
> >powerful so ... ;->
> >
> >	Of course - it'd be really nice if someone hacked up a generic
> >PersistFile -> PersistStream adaptor that worked via a /tmp file such
> >that this was hidden from users.
> >
> >	HTH,
> >
> >		Michael.
> >
> >  
> >
> Hey people,
> 
> anybody knows why the docs of bonobo 2.2 file persiststream and persist 
> file as deprecated? What else should we use then?
> 

The bonobo_persist_stream_new function is deprecated, not the
BonoboPersistStream interface. The same is true for BonoboPersistFile.
For a BonoboPersistStream, you should derive a class from BonoboPersist.
I use the following code:

#define PERSIST_STREAM_TYPE         (persist_stream_get_type ())
#define PERSIST_STREAM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o),
PERSIST_STREAM_TYPE, PersistStream))
#define PERSIST_STREAM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k),
PERSIST_STREAM_TYPE, PersistStreamClass))
#define PERSIST_STREAM_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
PERSIST_STREAM_TYPE))
#define PERSIST_STREAM_IS_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k),
PERSIST_STREAM_TYPE))
#define PERSIST_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
PERSIST_STREAM_TYPE, PersistStreamClass))

typedef struct {
	BonoboPersist parent;
	/* put your data here if any */
} PersistStream;

typedef struct {
	BonoboPersistClass parent_class;

	POA_Bonobo_PersistStream__epv epv;
} PersistStreamClass;

GType persist_stream_get_type (void);

static void on_load(gpointer p, Bonobo_Stream stream, const
Bonobo_Persist_ContentType type, CORBA_Environment  *ev)
{
/* code for loading*/
}

static void on_save(gpointer p, Bonobo_Stream stream, const
Bonobo_Persist_ContentType type, CORBA_Environment  *ev)
{
/* code for saving */
}

static PersistStream* persist_stream_new()
{
	PersistStream* ps = (PersistStream*) g_object_new (PERSIST_STREAM_TYPE,
NULL);
	return ps;
}

static void persist_stream_init(PersistStream *ps)
{
}

static void persist_stream_class_init(PersistStreamClass *klass)
{
	POA_Bonobo_PersistStream__epv* epv = &(klass->epv);
	epv->load = (void(*)(void*, CORBA_Object_type*, const CORBA_char*,
CORBA_Environment*)) on_load;
	epv->save = (void(*)(void*, CORBA_Object_type*, const CORBA_char*,
CORBA_Environment*)) on_save;
}

 BONOBO_TYPE_FUNC_FULL (
	PersistStream,                /* Glib class name */
	Bonobo_PersistStream,  /* CORBA interface name */
	BONOBO_TYPE_PERSIST,  /* parent type */
	persist_stream);     /* local prefix ie. 'echo'_class_init */

Then, you add the interface to your object:

PersistStreamps = persist_stream_new();
bonobo_object_add_interface(object, ps);

These lines come from GChemPaint-0.4.0 (file src/gchempaint-bonobo.cc)

Attachment: signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=



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