Re: Client side usage of PersistStream



Hi Christian,

Am Die, 2003-06-17 um 00.13 schrieb Christian Glodt:
> I've been looking for an example of client side
> usage of the PersistStream interface. Specifically,
> I want to feed a local file to a Control in the easiest
> possible way. I've tried PersistFile, which works fine,
> but not all Controls support PersistFile anymore as its
> deprecated.

No, the PersistFile interface is not deprecated. Only the use of
BonoboPersistFile for implementing PersistFile in a component is
discouraged. Same for BonoboPersistStream.

> I'm currently blocked on the part where I need to
> instantiate a Bonobo_Stream which I can pass to
> Bonobo_PersistStream_load(). I've read somewhere that
> GnomeVFS can create such a stream, but I didn't find
> out how.

To get a (read-only) Stream, do 
stream = bonobo_get_object (moniker, "IDL:Bonobo/Stream:1.0", &ev);

where moniker is "file:<<path to your file>>" for local files, or
"vfs:<<vfs-uri>>" for gnome-vfs, or some other fancy moniker.

But you really want:

control = bonobo_get_object (moniker, "IDL:Bonobo/Control:1.0", &ev);

which will return a control with the file loaded. It will use whatever
PersistFoo the control implements.

> I'd be very grateful for any explanations or pointers
> to sources I can study to see how this can be done.

Nautilus can use PersistStream:
nautilus/components/adapter/nautilus-adapter-stream-load-strategy.c
in nautilus_adapter_stream_load_strategy_load_location

And in gpdf a test uses PersistStream:
gpdf/xpdf/tests/test-pdf-loading.cc, in load_via_bonobo_stream.

HTH,
	Martin
-- 
The goal is clean code that works. (Ron Jeffries)




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