Re: Client side usage of PersistStream
Christian Glodt <[email protected]> 17 Jun 2003 09:44:07 +0200
| Newsgroups | gmane.comp.gnome.components |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 2003-06-17 at 01:08, Martin Kretzschmar wrote: > 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. Yes, but unfortunately some components only support PersistFile and others only PersistStream. To support these "corner case" components I need to be able to talk both Stream and File at my end. > > 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. Great, I was hoping it would be that easy. > 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. Actually, that's what I'm currently doing. But due to specific constraints on my project (http://www.nongnu.org/moz-bonobo/), I can't rely on this function. The name of the file I need to open is mangled, and GnomeVFS sometimes fails to recognize its mime type because of this. Incidently, I know the exact mime type of the file. So, I instantiate a control supporting that mime type and then feed it the file via PersistFile or Persist- Stream. > > 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 Thanks, this helps me a lot. Cheers, Christian Glodt