Chapter 10. The GNOME Persistence Interfaces

Table of Contents
Introduction
The persistence interfaces
Bonobo persistence example

Introduction

Nowadays, a document (such as an AbiWord word-processing document) may contain things like GIMP-pictures, Gnumeric-spreadsheets etcetera. In the previous chapter, we saw how compound files (stream/stores) can be used to store heterogenous content. However, this still leaves a problem: how do we know how to save all these objects? We cannot 'simply' add code to support file operations for every possible embeddable component; this would bloat our code tremendously, and be outdated as soon as somebody writes a new component.

There must be a better solution. And indeed, there is. Instead of dealing with the saving and loading (persistence) of containees (components) ourselves, this task is delegated to the components: we make them responsible for their own persistence.

Every component that wants to support storing its state to some persistent medium (such as a disk file), must support one or more of the following Bonobo interfaces:

These interfaces are defined in the 'gnome-persist.idl' IDL file. By supporting these interfaces, a component says it knows how to deal with persistence: it knows how to store its state as well as how to retrieve it. Depending on the type of component and its specific needs, it can support on or more of these interfaces. Note that this supports persistence for a complete hierarchy of components (like a Guppi-component in a Gnumeric-spreadsheet in a AbiWord-document) quite nicely: every container simply delegates persistence to its containees.

In this chapter we will describe these interfaces, and show how to use them.