MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //usr/share/gtk-doc/html/libbonobo/libbonobo-bonobo-persist-file.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>BonoboPersistFile</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="Libbonobo Reference Manual">
<link rel="up" href="persist.html" title="Persistency">
<link rel="prev" href="libbonobo-bonobo-persist.html" title="BonoboPersist">
<link rel="next" href="libbonobo-bonobo-persist-stream.html" title="BonoboPersistStream">
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="general.html" title="General">
<link rel="chapter" href="factories.html" title="Objects, Factories, Reference Counting">
<link rel="chapter" href="property-bags.html" title="Property Bags, Events, Listeners">
<link rel="chapter" href="monikers.html" title="Monikers">
<link rel="chapter" href="streams.html" title="Storages and Streams">
<link rel="chapter" href="persist.html" title="Persistency">
<link rel="chapter" href="misc.html" title="Miscellaneous">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="libbonobo-bonobo-persist.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="persist.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">Libbonobo Reference Manual</th>
<td><a accesskey="n" href="libbonobo-bonobo-persist-stream.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2782062" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2782285" class="shortcut">Description</a>
                  &#160;|&#160;
                  <a href="#id2782246" class="shortcut">Object Hierarchy</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="libbonobo-bonobo-persist-file"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2782062"></a><span class="refentrytitle">BonoboPersistFile</span>
</h2>
<p>BonoboPersistFile &#8212; Interface for anything that can save / load itself from a file.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<a name="BonoboPersistFile"></a><pre class="synopsis">



            <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile-struct">BonoboPersistFile</a>;
int         (<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">*BonoboPersistFileIOFn</a>)        (<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a> *pf,
                                             const CORBA_char *uri,
                                             CORBA_Environment *ev,
                                             void *closure);
            <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileClass">BonoboPersistFileClass</a>;
<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a>* <a href="libbonobo-bonobo-persist-file.html#bonobo-persist-file-new">bonobo_persist_file_new</a>  (<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> load_fn,
                                             <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> save_fn,
                                             const <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"
>gchar</a> *iid,
                                             void *closure);
<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a>* <a href="libbonobo-bonobo-persist-file.html#bonobo-persist-file-construct">bonobo_persist_file_construct</a>
                                            (<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a> *pf,
                                             <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> load_fn,
                                             <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> save_fn,
                                             const <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"
>gchar</a> *iid,
                                             void *closure);


</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2782246"></a><h2>Object Hierarchy</h2>
<pre class="synopsis">

  <a
href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject"
>GObject</a>
   +----<a href="libbonobo-bonobo-object.html#BonoboObject">BonoboObject</a>
         +----<a href="libbonobo-bonobo-persist.html#BonoboPersist">BonoboPersist</a>
               +----BonoboPersistFile
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2782285"></a><h2>Description</h2>
<p>
The PersistFile interface is a useful interface for Bonoboizing
legacy applications, however, for new / correct applications it
is far preferable to implement the <a href="libbonobo-bonobo-persist-stream.html#BonoboPersistStream"><span class="type">BonoboPersistStream</span></a> interface,
since this will not only result in a nice clean to your application
architecture, but also allow the transparent use of local, remote,
and synthetic streams.
</p>
<p>
This interface works by connecting callbacks to the methods, in
a pretty deprecated fashion, it is probably better nowadays to
simply sub-class the BonoboXObject and override the epv methods.
Either way, after all the caveats here is an example use:
  </p>
<div class="example">
<a name="id2782319"></a><p class="title"><b>Example&#160;1.&#160;Persist file implementation</b></p>
<pre class="programlisting">
static gint
load_from_file (BonoboPersistFile *pf,
                const CORBA_char  *filename,
		CORBA_Environment *ev,
                void              *closure)
{
	EogImageData *image_data = closure;

	g_warning ("Load from '<code class="literal">s</code>'", filename);

	return 0; /* Return 0 on success */
}

static gint
save_to_file (BonoboPersistFile *pf,
              const CORBA_char  *filename,
              CORBA_Environment *ev,
              void              *closure)
{
	EogImageData *image_data = closure;

	g_warning ("Save to '<code class="literal">s</code>'", filename);

	return 0; /* Return 0 on success */
}
    </pre>
</div>
<p>
Having implemented the callbacks we then have to register them
and aggregate the interface to our object:
  </p>
<div class="example">
<a name="id2782362"></a><p class="title"><b>Example&#160;2.&#160;Aggregating a new PersistFile</b></p>
<pre class="programlisting">
EogImageData *
eog_image_data_construct (EogImageData *image_data)
{
	BonoboObject        *retval;
	BonoboPersistFile   *file;

	file = bonobo_persist_file_new (
		load_from_file, save_to_file, image_data);

	if (file == NULL) {
		bonobo_object_unref (BONOBO_OBJECT (image_data));
		return NULL;
	}

	bonobo_object_add_interface (BONOBO_OBJECT (image_data),
				     BONOBO_OBJECT (file));

	return image_data;
}
    </pre>
</div>
<p>
Note again, that you should be writing a BonoboPersistStream
interface, however if you have already done this you might like
to just have hooks through so that old apps can use the PersistFile
interface:
  </p>
<div class="example">
<a name="id2782386"></a><p class="title"><b>Example&#160;3.&#160;Chaining to a <span class="type">PersistStream</span> implementation</b></p>
<pre class="programlisting">
static gint
load_from_file (BonoboPersistFile *pf,
                const CORBA_char  *filename,
		CORBA_Environment *ev,
                void              *closure)
{
	Bonobo_PersistStream ps = closure;
	BonoboStream *stream;
	
	stream = bonobo_stream_open (
		BONOBO_IO_DRIVER_FS,
		filename, Bonobo_STORAGE_READ,
		0);

	if (!stream)
		return 0;

	.. extract content type from file ...

	Bonobo_PersistStream_load (ps, type, ev);

	return 0; /* Return 0 on success */
}

static gint
save_to_file (BonoboPersistFile *pf,
              const CORBA_char  *filename,
              CORBA_Environment *ev,
              void              *closure)
{
	Bonobo_PersistStream ps = closure;
	BonoboStream *stream;
	
	stream = bonobo_stream_open (
		BONOBO_IO_DRIVER_FS,
		filename, Bonobo_STORAGE_WRITE | Bonobo_STORAGE_CREATE,
		S_IRUSR | S_IWUSR | S_IRGRP);

	if (!stream)
		return 0;

	.. work out content type we want to save ...

	Bonobo_PersistStream_save (ps, type, ev);

	return 0; /* Return 0 on success */
}
     </pre>
</div>
<p>
  The mime type data can be extracted from gnome-vfs or gnome-mime.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2782429"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2782439"></a><h3>
<a name="BonoboPersistFile-struct"></a>BonoboPersistFile</h3>
<a class="indexterm" name="id2782453"></a><pre class="programlisting">typedef struct _BonoboPersistFile BonoboPersistFile;</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">BonoboPersistFile</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2782481"></a><h3>
<a name="BonoboPersistFileIOFn"></a>BonoboPersistFileIOFn ()</h3>
<a class="indexterm" name="id2782496"></a><pre class="programlisting">int         (*BonoboPersistFileIOFn)        (<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a> *pf,
                                             const CORBA_char *uri,
                                             CORBA_Environment *ev,
                                             void *closure);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">BonoboPersistFileIOFn</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>pf</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>uri</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>ev</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>closure</code></em>&#160;:</span></td>
<td>
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td>


</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2782628"></a><h3>
<a name="BonoboPersistFileClass"></a>BonoboPersistFileClass</h3>
<a class="indexterm" name="id2782643"></a><pre class="programlisting">typedef struct {
	BonoboPersistClass parent_class;

	POA_Bonobo_PersistFile__epv epv;

	/* methods */
	int   (*load)             (BonoboPersistFile *ps,
				   const CORBA_char  *uri,
				   CORBA_Environment *ev);

	int   (*save)             (BonoboPersistFile *ps,
				   const CORBA_char  *uri,
				   CORBA_Environment *ev);

	char *(*get_current_file) (BonoboPersistFile *ps,
				   CORBA_Environment *ev);
} BonoboPersistFileClass;
</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">BonoboPersistFileClass</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2782678"></a><h3>
<a name="bonobo-persist-file-new"></a>bonobo_persist_file_new ()</h3>
<a class="indexterm" name="id2782693"></a><pre class="programlisting"><a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a>* bonobo_persist_file_new  (<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> load_fn,
                                             <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> save_fn,
                                             const <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"
>gchar</a> *iid,
                                             void *closure);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">bonobo_persist_file_new</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
Creates a BonoboPersistFile object.  The <em class="parameter"><code>load_fn</code></em> and <em class="parameter"><code>save_fn</code></em>
parameters might be NULL.  If this is the case, the load and save 
operations are performed by the class load and save methods</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>load_fn</code></em>&#160;:</span></td>
<td> Loading routine
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>save_fn</code></em>&#160;:</span></td>
<td> Saving routine
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>iid</code></em>&#160;:</span></td>
<td> OAF IID of the object this interface is aggregated to
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>closure</code></em>&#160;:</span></td>
<td> Data passed to IO routines.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> the <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile"><span class="type">BonoboPersistFile</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2782856"></a><h3>
<a name="bonobo-persist-file-construct"></a>bonobo_persist_file_construct ()</h3>
<a class="indexterm" name="id2782872"></a><pre class="programlisting"><a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a>* bonobo_persist_file_construct
                                            (<a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile">BonoboPersistFile</a> *pf,
                                             <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> load_fn,
                                             <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFileIOFn">BonoboPersistFileIOFn</a> save_fn,
                                             const <a
href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"
>gchar</a> *iid,
                                             void *closure);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">bonobo_persist_file_construct</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
Initializes the BonoboPersistFile object.  The <em class="parameter"><code>load_fn</code></em> and <em class="parameter"><code>save_fn</code></em>
parameters might be NULL.  If this is the case, the load and save 
operations are performed by the class load and save methods</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>pf</code></em>&#160;:</span></td>
<td> A BonoboPersistFile
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>load_fn</code></em>&#160;:</span></td>
<td> Loading routine
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>save_fn</code></em>&#160;:</span></td>
<td> Saving routine
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>iid</code></em>&#160;:</span></td>
<td> OAF IID of the object this interface is aggregated to
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>closure</code></em>&#160;:</span></td>
<td> Data passed to IO routines.
</td>
</tr>
<tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
<td> the <a href="libbonobo-bonobo-persist-file.html#BonoboPersistFile"><span class="type">BonoboPersistFile</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2783059"></a><h2>See Also</h2>
<p>
<a href="libbonobo-bonobo-persist-stream.html#BonoboPersistStream"><span class="type">BonoboPersistStream</span></a>, <a href="libbonobo-bonobo-persist.html#BonoboPersist"><span class="type">BonoboPersist</span></a>
</p>
</div>
</div>
</body>
</html>