1 /* SPDX-License-Identifier: Zlib */
2 
3 #ifndef GIRARA_SETTINGS_H
4 #define GIRARA_SETTINGS_H
5 
6 #include "types.h"
7 #include "macros.h"
8 
9 /**
10  * Adds an additional entry in the settings list
11  *
12  * @param session The used girara session
13  * @param name The name of the setting
14  * @param value The value of the setting
15  * @param type The type of the setting
16  * @param init_only Will only available on initialization
17  * @param description Description of the setting
18  * @param callback Function that is called when the setting changes
19  * @param data Arbitrary data that can be used by callbacks
20  * @return TRUE No error occurred
21  * @return FALSE An error occurred
22  */
23 bool girara_setting_add(girara_session_t* session, const char* name,
24     const void* value, girara_setting_type_t type, bool init_only,
25     const char* description, girara_setting_callback_t callback, void* data) GIRARA_VISIBLE;
26 
27 /**
28  * Sets the value of a setting
29  *
30  * @param session The used girara session
31  * @param name The name of the setting
32  * @param value The new value of the setting
33  * @return TRUE No error occurred
34  * @return FALSE An error occurred
35  */
36 bool girara_setting_set(girara_session_t* session, const char* name, const void* value) GIRARA_VISIBLE;
37 
38 /**
39  * Retrieve the value of a setting. If the setting is a string, the value stored
40  * in dest has to be deallocated with g_free.
41  * @param session The used girara session
42  * @param name The name of the setting
43  * @param dest A pointer to the destination of the result.
44  * @return true if the setting exists, false otherwise.
45  */
46 bool girara_setting_get(girara_session_t* session, const char* name, void* dest) GIRARA_VISIBLE;
47 
48 /**
49  * Find a setting.
50  *
51  * @param session The girara session
52  * @param name name of the setting
53  * @return the setting or NULL if it doesn't exist
54  */
55 girara_setting_t* girara_setting_find(girara_session_t* session, const char* name) GIRARA_VISIBLE;
56 
57 /**
58  * Get the setting's name.
59  *
60  * @param setting The setting
61  * @return the setting's name
62  */
63 const char* girara_setting_get_name(const girara_setting_t* setting) GIRARA_VISIBLE;
64 
65 /**
66  * Get the setting's value. If the setting is a string, the value stored
67  * in dest has to be deallocated with g_free.
68  *
69  * @param setting The setting
70  * @param dest A pointer to the destination of the result.
71  * @return true if the setting exists, false otherwise.
72  */
73 bool girara_setting_get_value(girara_setting_t* setting, void* dest) GIRARA_VISIBLE;
74 
75 /**
76  * Get the setting's value.
77  *
78  * @param setting The setting
79  * @return the value
80  */
81 girara_setting_type_t girara_setting_get_type(girara_setting_t* setting) GIRARA_VISIBLE;
82 
83 /**
84  * Set the setting's value. If session is NULL, the setting's callback won't be
85  * called.
86  *
87  * @param session The girara session
88  * @param setting The setting
89  * @param value The new value
90  */
91 void girara_setting_set_value(girara_session_t* session,
92     girara_setting_t* setting, const void* value) GIRARA_VISIBLE;
93 
94 #endif
95