new API


Over time people have had various valid complaints about the gconf
API, some of the ones I can think of quickly:

 - to distinguish an unset key, you have to use gconf_client_get_value() not 
 - the notification callback takes some silly arguments that are hard to remember
 - gconf_client_get_default() returns a new reference count
 - every function takes a GError
 - explicitly managing the cache preload and clear isn't something 
   people understand and doesn't usually happen
 - changesets are perhaps overkill

A simpler API might be something like the appended. I'm not working on
this right now and am not convinced that the cleanups this API offers
are worth the confusion of yet another API. (Certainly if we added this API, 
GConfClient and GConfEngine would be deprecated.)

However, if anyone has insights or opinions, please feel free to comment.
At some point we'll have to decide on this.

Details of the API:

 - get_int() would return TRUE if a value was set for the int
 - caching would be automatic, just based on keeping the last 
   N items or based on time or something like that
 - gconf_prefs_notify() gets the values for the keys and calls 
   the MonitorFunc for them
 - errors are just sent to some default handler or ignored
 - conceivably, pop_transaction() could return an error
   so you can see if the transaction failed

I haven't put a lot of thought into this yet but wanted to get my
notes so far in the archives.


typedef struct GConfPrefs GConfPrefs;

typedef void (* GConfMonitorFunc) (GConfPrefs *prefs,
                                   const char *changed_key,
                                   GConfEntry *new_entry,
                                   void       *data);

GConfPrefs* gconf_prefs_get_default      (void);
void        gconf_prefs_push_transaction (GConfPrefs        *prefs);
void        gconf_prefs_pop_transaction  (GConfPrefs        *prefs);
void        gconf_prefs_push_prefix      (GConfPrefs        *prefs);
void        gconf_prefs_pop_prefix       (GConfPrefs        *prefs);
void        gconf_prefs_set_int          (GConfPrefs        *prefs,
                                          const char        *key,
                                          int                value);
gboolean    gconf_prefs_get_int          (GConfPrefs        *prefs,
                                          const char        *key,
                                          int               *valuep);
void        gconf_prefs_notify           (GConfPrefs        *prefs,
                                          const char       **keys,
                                          int                n_keys);
void        gconf_prefs_add_monitor      (GConfPrefs        *prefs,
                                          const char
                                          GConfMonitorFunc   func,
                                          void              *data,
void        gconf_prefs_remove_monitor   (GConfPrefs        *prefs,
                                          const char
                                          GConfMonitorFunc   func,
                                          void              *data);

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