Re: libgnome: User level



Colm Smyth wrote:
>IMO you can also solve this with stackable databases, as used in
bonobo-config.

Not really.  Stackable databases (as used also in GConf ;) are not the
solution to the problem below; each database in the stack has an
identical namespace.

Sorry, I meant stackable databases as used in bonobo-config.
The configuration context I described below provides a list of
base addresses that define a logically stacked namespace
that may be resolved within a single database or across multiple
(stacked or composed) databases.
 
So please let me explain the concept I use in bonobo-config. It is quite easy and part of the ConfigDatabase interface:
        /** 
         * addDatabase:
         * 
         * The added database will be used to lookup default values.
         */
        void            addDatabase (in ConfigDatabase default_db, 
                                     in string path)
                raises (BackendFailed);
That is all you need. Maybe it is best to use the user_level as example. The user level is a global configuration key, but some application wants to implement there own meaning. So we have two keys:

/global/shared/settings/user_level

/application/gnumeric/shared/user_level

The application uses the following code to access the database:

defaultdb = bonobo_get_object ("config:/global/shared/settings", "Bonobo/ConfigDatabase");

db = bonobo_get_object ("config:/application/gnumeric", "Bonobo/ConfigDatabase");

Bonobo_ConfigDatabase_addDatabase (db, defaultdb, "shared");
You can now get/set the user_level with:
bonobo_pbclient_get_long (db, "/shared/user_level", NULL);

bonobo_pbclient_set_long (db, "/shared/user_level",  1, NULL);
I think this is a nice solution to your problem.

- Dietmar
 



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