4
>BonoboPersistFile</TITLE
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
10
TITLE="Libbonobo Reference Manual"
11
HREF="index.html"><LINK
13
TITLE="Libbonobo API Reference Manual"
17
HREF="libbonobo-bonobo-object.html"><LINK
19
TITLE="BonoboPersistStream"
20
HREF="libbonobo-bonobo-persist-stream.html"></HEAD
43
>Libbonobo Reference Manual</FONT
52
HREF="libbonobo-bonobo-object.html"
57
><<< Previous Page</B
106
HREF="libbonobo-bonobo-persist-stream.html"
111
>Next Page >>></B
120
NAME="LIBBONOBO-BONOBO-PERSIST-FILE"
121
>BonoboPersistFile</A
130
>BonoboPersistFile -- Interface for anything that can save / load itself from a file.</DIV
132
CLASS="REFSYNOPSISDIV"
150
HREF="libbonobo-bonobo-persist-file.html#BONOBO-PERSIST-FILE-TYPE-CAPS"
151
>BONOBO_PERSIST_FILE_TYPE</A
154
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEPRIVATE"
155
>BonoboPersistFilePrivate</A
158
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
159
>BonoboPersistFile</A
162
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
163
>*BonoboPersistFileIOFn</A
165
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
166
>BonoboPersistFile</A
168
const CORBA_char *filename,
169
CORBA_Environment *ev,
172
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILECLASS"
173
>BonoboPersistFileClass</A
176
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
177
>BonoboPersistFile</A
179
HREF="libbonobo-bonobo-persist-file.html#BONOBO-PERSIST-FILE-NEW"
180
>bonobo_persist_file_new</A
182
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
183
>BonoboPersistFileIOFn</A
186
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
187
>BonoboPersistFileIOFn</A
190
HREF=../glib/glib-basic-types.html#GCHAR
194
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
195
>BonoboPersistFile</A
197
HREF="libbonobo-bonobo-persist-file.html#BONOBO-PERSIST-FILE-CONSTRUCT"
198
>bonobo_persist_file_construct</A
201
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
202
>BonoboPersistFile</A
205
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
206
>BonoboPersistFileIOFn</A
209
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
210
>BonoboPersistFileIOFn</A
213
HREF=../glib/glib-basic-types.html#GCHAR
215
void *closure); </PRE
228
>The PersistFile interface is a useful interface for Bonoboizing
229
legacy applications, however, for new / correct applications it
230
is far preferable to implement the <A
231
HREF="libbonobo-bonobo-persist-stream.html#BONOBOPERSISTSTREAM"
232
>BonoboPersistStream</A
234
since this will not only result in a nice clean to your application
235
architecture, but also allow the transparent use of local, remote,
236
and synthetic streams.</P
238
>This interface works by connecting callbacks to the methods, in
239
a pretty deprecated fashion, it is probably better nowadays to
240
simply sub-class the BonoboXObject and override the epv methods.
241
Either way, after all the caveats here is an example use:
249
>Example 1. Persist file implementation</B
259
CLASS="PROGRAMLISTING"
261
load_from_file (BonoboPersistFile *pf,
262
const CORBA_char *filename,
263
CORBA_Environment *ev,
266
EogImageData *image_data = closure;
268
g_warning ("Load from '<TT
273
return 0; /* Return 0 on success */
277
save_to_file (BonoboPersistFile *pf,
278
const CORBA_char *filename,
279
CORBA_Environment *ev,
282
EogImageData *image_data = closure;
284
g_warning ("Save to '<TT
289
return 0; /* Return 0 on success */
297
Having implemented the callbacks we then have to register them
298
and aggregate the interface to our object:
306
>Example 2. Aggregating a new PersistFile</B
316
CLASS="PROGRAMLISTING"
318
eog_image_data_construct (EogImageData *image_data)
320
BonoboObject *retval;
321
BonoboPersistFile *file;
323
file = bonobo_persist_file_new (
324
load_from_file, save_to_file, image_data);
327
bonobo_object_unref (BONOBO_OBJECT (image_data));
331
bonobo_object_add_interface (BONOBO_OBJECT (image_data),
332
BONOBO_OBJECT (file));
342
Note again, that you should be writing a BonoboPersistStream
343
interface, however if you have already done this you might like
344
to just have hooks through so that old apps can use the PersistFile
353
>Example 3. Chaining to a PersistStream implementation</B
363
CLASS="PROGRAMLISTING"
365
load_from_file (BonoboPersistFile *pf,
366
const CORBA_char *filename,
367
CORBA_Environment *ev,
370
Bonobo_PersistStream ps = closure;
371
BonoboStream *stream;
373
stream = bonobo_stream_open (
375
filename, Bonobo_STORAGE_READ,
381
.. extract content type from file ...
383
Bonobo_PersistStream_load (ps, type, ev);
385
return 0; /* Return 0 on success */
389
save_to_file (BonoboPersistFile *pf,
390
const CORBA_char *filename,
391
CORBA_Environment *ev,
394
Bonobo_PersistStream ps = closure;
395
BonoboStream *stream;
397
stream = bonobo_stream_open (
399
filename, Bonobo_STORAGE_WRITE | Bonobo_STORAGE_CREATE,
400
S_IRUSR | S_IWUSR | S_IRGRP);
405
.. work out content type we want to save ...
407
Bonobo_PersistStream_save (ps, type, ev);
409
return 0; /* Return 0 on success */
417
The mime type data can be extracted from gnome-vfs or gnome-mime.</P
433
NAME="BONOBO-PERSIST-FILE-TYPE-CAPS"
435
>BONOBO_PERSIST_FILE_TYPE</H3
444
CLASS="PROGRAMLISTING"
445
>#define BONOBO_PERSIST_FILE_TYPE BONOBO_TYPE_PERSIST_FILE /* deprecated, you should use BONOBO_TYPE_PERSIST_FILE */</PRE
459
NAME="BONOBOPERSISTFILEPRIVATE"
461
>struct BonoboPersistFilePrivate</H3
470
CLASS="PROGRAMLISTING"
471
>struct BonoboPersistFilePrivate;</PRE
485
NAME="BONOBOPERSISTFILE"
487
>struct BonoboPersistFile</H3
496
CLASS="PROGRAMLISTING"
497
>struct BonoboPersistFile {
498
BonoboPersist persist;
503
* For the sample routines, NULL if we use the ::save and ::load
504
* methods from the class
506
BonoboPersistFileIOFn save_fn;
507
BonoboPersistFileIOFn load_fn;
510
BonoboPersistFilePrivate *priv;
525
NAME="BONOBOPERSISTFILEIOFN"
527
>BonoboPersistFileIOFn ()</H3
536
CLASS="PROGRAMLISTING"
537
>int (*BonoboPersistFileIOFn) (<A
538
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
539
>BonoboPersistFile</A
541
const CORBA_char *filename,
542
CORBA_Environment *ev,
550
CLASS="INFORMALTABLE"
660
NAME="BONOBOPERSISTFILECLASS"
662
>BonoboPersistFileClass</H3
671
CLASS="PROGRAMLISTING"
673
BonoboPersistClass parent_class;
675
POA_Bonobo_PersistFile__epv epv;
678
int (*load) (BonoboPersistFile *ps,
679
const CORBA_char *filename,
680
CORBA_Environment *ev);
682
int (*save) (BonoboPersistFile *ps,
683
const CORBA_char *filename,
684
CORBA_Environment *ev);
686
char *(*get_current_file) (BonoboPersistFile *ps,
687
CORBA_Environment *ev);
689
} BonoboPersistFileClass;</PRE
703
NAME="BONOBO-PERSIST-FILE-NEW"
705
>bonobo_persist_file_new ()</H3
714
CLASS="PROGRAMLISTING"
716
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
717
>BonoboPersistFile</A
718
>* bonobo_persist_file_new (<A
719
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
720
>BonoboPersistFileIOFn</A
723
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
724
>BonoboPersistFileIOFn</A
727
HREF=../glib/glib-basic-types.html#GCHAR
734
>Creates a BonoboPersistFile object. The <TT
745
parameters might be NULL. If this is the case, the load and save
746
operations are performed by the class load and save methods</P
750
CLASS="INFORMALTABLE"
779
> Loading routine</TD
813
> OAF IID of the object this interface is aggregated to</TD
830
> Data passed to IO routines.</TD
860
NAME="BONOBO-PERSIST-FILE-CONSTRUCT"
862
>bonobo_persist_file_construct ()</H3
871
CLASS="PROGRAMLISTING"
873
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
874
>BonoboPersistFile</A
875
>* bonobo_persist_file_construct
877
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILE"
878
>BonoboPersistFile</A
881
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
882
>BonoboPersistFileIOFn</A
885
HREF="libbonobo-bonobo-persist-file.html#BONOBOPERSISTFILEIOFN"
886
>BonoboPersistFileIOFn</A
889
HREF=../glib/glib-basic-types.html#GCHAR
896
>Initializes the BonoboPersistFile object. The <TT
907
parameters might be NULL. If this is the case, the load and save
908
operations are performed by the class load and save methods</P
912
CLASS="INFORMALTABLE"
958
> Loading routine</TD
992
> OAF IID of the object this interface is aggregated to</TD
1009
> Data passed to IO routines.</TD
1042
HREF="libbonobo-bonobo-persist-stream.html#BONOBOPERSISTSTREAM"
1043
>BonoboPersistStream</A
1045
HREF="libbonobo-bonobo-persist.html#BONOBOPERSIST"
1052
CLEAR="all"><BR><TABLE
1064
HREF="libbonobo-bonobo-object.html"
1069
><<< Previous Page</B
1118
HREF="libbonobo-bonobo-persist-stream.html"
1123
>Next Page >>></B
1146
>BonoboPersistStream</B
b'\\ No newline at end of file'