diff options
author | Gary Kramlich <grim@reaperworld.com> | 2016-08-19 23:51:13 -0500 |
---|---|---|
committer | Gary Kramlich <grim@reaperworld.com> | 2016-08-19 23:51:13 -0500 |
commit | 3f8d53ecbebc78e40a57bec2fe14c941b2b3a199 (patch) | |
tree | be33c3f66ca9986142fded8c412b9ad13eee3ce9 /libpurple/prefs.h | |
parent | 3f871f44e7d153d8be3be86fe50bee43438a8e94 (diff) | |
download | pidgin-3f8d53ecbebc78e40a57bec2fe14c941b2b3a199.tar.gz |
Fix prefs for stuff that was broken in the merge
Diffstat (limited to 'libpurple/prefs.h')
-rw-r--r-- | libpurple/prefs.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/libpurple/prefs.h b/libpurple/prefs.h index 1b98beabdc..8174f2c7bc 100644 --- a/libpurple/prefs.h +++ b/libpurple/prefs.h @@ -74,8 +74,106 @@ typedef enum typedef void (*PurplePrefCallback) (const char *name, PurplePrefType type, gconstpointer val, gpointer data); +/** + * Opaque type to carry callback information + * + * @since 2.11.0 + */ +typedef struct _PurplePrefCallbackData PurplePrefCallbackData; + +/** @copydoc _PurplePrefsUiOps */ +typedef struct _PurplePrefsUiOps PurplePrefsUiOps; + +/** + * Prefs UI operations. This allows overriding the prefs.xml storage with + * anything else. + * + * Unless specified otherwise, each entry provides an implementation for the + * corresponding purple_prefs_* method, and disables the prefs.xml code for it. + * This means that to do anything useful, all the methods must be implemented. + * + * @since 2.11.0 + */ +struct _PurplePrefsUiOps +{ + void (*add_none)(const char *name); + void (*add_bool)(const char *name, gboolean value); + void (*add_int)(const char *name, int value); + void (*add_string)(const char *name, const char *value); + void (*add_string_list)(const char *name, GList *value); + + void (*set_bool)(const char *name, gboolean value); + void (*set_int)(const char *name, int value); + void (*set_string)(const char *name, const char *value); + void (*set_string_list)(const char *name, GList *value); + + gboolean (*get_bool)(const char *name); + int (*get_int)(const char *name); + const char *(*get_string)(const char *name); + GList *(*get_string_list)(const char *name); + + PurplePrefType (*get_type)(const char *name); + GList *(*get_children_names)(const char *name); + + gboolean (*exists)(const char *name); + void (*remove)(const char *name); + + void (*rename)(const char *oldname, const char *newname); + void (*rename_boolean_toggle)(const char *oldname, const char *newname); + + gboolean (*load)(void); + void (*save)(void); + void (*schedule_save)(void); + + /** + * Called when a callback is added to a preference. The UI must keep + * track of it and call #purple_prefs_trigger_callback_object with the + * data attribute. + * + * @param name The preference name. + * @param data The object to be passed when triggering the callback + * @return A pointer to a ui_data object. + * */ + void *(*connect_callback)(const char *name, PurplePrefCallbackData *data); + + /** + * Called when a callback is removed from a preference. The ui_data + * object is the one returned from connect_callback. + * + * @param name The preference name + * @param ui_data The object that was returned from the + * connect_callback UI OP. + * */ + void (*disconnect_callback)(const char *name, void *ui_data); + + void (*_purple_reserved1)(void); + void (*_purple_reserved2)(void); + void (*_purple_reserved3)(void); + void (*_purple_reserved4)(void); +}; + G_BEGIN_DECLS +/****************************************************************************** + * UI Registration Functions + *****************************************************************************/ + +/** + * Sets the UI operations structure to be used for preferences. + * + * @param ops The UI operations structure. + * @since 2.11.0 + */ +void purple_prefs_set_ui_ops(PurplePrefsUiOps *ops); + +/** + * Returns the UI operations structure used for preferences. + * + * @return The UI operations structure in use. + * @since 2.11.0 + */ +PurplePrefsUiOps *purple_prefs_get_ui_ops(void); + /**************************************************************************/ /* Prefs API Preferences are named according to a directory-like structure. @@ -394,6 +492,14 @@ void purple_prefs_disconnect_by_handle(void *handle); void purple_prefs_trigger_callback(const char *name); /** + * Trigger callbacks as if the pref changed, taking a #PurplePrefCallbackData + * instead of a name + * + * @since 2.11.0 + */ +void purple_prefs_trigger_callback_object(PurplePrefCallbackData *data); + +/** * purple_prefs_load: * * Read preferences |