2
* Copyright (C) 2007, 2008 Mark Lee <avant-wn@lazymalevolence.com>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
19
* Author : Mark Lee <avant-wn@lazymalevolence.com>
22
#ifndef _LIBAWN_AWN_CONFIG_CLIENT_H
23
#define _LIBAWN_AWN_CONFIG_CLIENT_H
26
#include <glib-object.h>
31
* An opaque structure that facilitates having multiple configuration backends
34
typedef struct _AwnConfigClient AwnConfigClient;
36
#define AWN_TYPE_CONFIG_CLIENT (awn_config_client_get_type ())
39
* @obj: The variable/value to cast
41
* Casts a variable/value to be an #AwnConfigClient.
43
#define AWN_CONFIG_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_CONFIG_CLIENT, AwnConfigClient))
46
* AwnConfigClientValue:
47
* @bool_val: The boolean value of the entry, if the entry is defined as taking
49
* @float_val: The float value of the entry, if the entry is defined as taking
51
* @int_val: The integer value of the entry, if the entry is defined as taking
53
* @str_val: The string value of the entry, if the entry is defined as taking
55
* @list_val: The list value of the entry, if the entry is defined as taking
58
* A union used to store a configuration value when it has changed and has
59
* notify callbacks associated with it.
67
} AwnConfigClientValue;
70
* AwnConfigClientNotifyEntry:
71
* @client: The client associated with the entry.
72
* @group: The group name of the entry.
73
* @key: The key name of the entry.
74
* @value: The new value of the entry.
76
* The structure used to transport data to the notification functions of
77
* a configuration entry.
80
AwnConfigClient *client;
83
AwnConfigClientValue value;
84
} AwnConfigClientNotifyEntry;
87
* AwnConfigClientNotifyFunc:
88
* @entry: The metadata about the new entry value.
89
* @data: Extra data passed to the callback, as defined in the call
90
* to awn_config_client_notify_add().
92
* The callback template for configuration change notification functions.
94
typedef void (*AwnConfigClientNotifyFunc) (AwnConfigClientNotifyEntry *entry, gpointer data);
97
* AWN_CONFIG_CLIENT_DEFAULT_GROUP:
99
* In the #GKeyFile backend, the group name with which "top-level" configuration
100
* entries are associated.
102
#define AWN_CONFIG_CLIENT_DEFAULT_GROUP "DEFAULT"
105
* AwnConfigValueType:
106
* @AWN_CONFIG_VALUE_TYPE_NULL: Indicates that the configuration value type
108
* @AWN_CONFIG_VALUE_TYPE_BOOL: Indicates that the configuration value type
110
* @AWN_CONFIG_VALUE_TYPE_FLOAT: Indicates that the configuration value type
112
* @AWN_CONFIG_VALUE_TYPE_INT: Indicates that the configuration value type
114
* @AWN_CONFIG_VALUE_TYPE_STRING: Indicates that the configuration value type
116
* @AWN_CONFIG_VALUE_TYPE_LIST_BOOL: Indicates that the configuration value
117
* type is list whose items are booleans.
118
* @AWN_CONFIG_VALUE_TYPE_LIST_FLOAT: Indicates that the configuration value
119
* type is list whose items are floats.
120
* @AWN_CONFIG_VALUE_TYPE_LIST_INT: Indicates that the configuration value
121
* type is list whose items are integers.
122
* @AWN_CONFIG_VALUE_TYPE_LIST_STRING: Indicates that the configuration value
123
* type is list whose items are strings.
125
* Indicates the value type of a particular configuration entry.
128
AWN_CONFIG_VALUE_TYPE_NULL = -1,
129
AWN_CONFIG_VALUE_TYPE_BOOL,
130
AWN_CONFIG_VALUE_TYPE_FLOAT,
131
AWN_CONFIG_VALUE_TYPE_INT,
132
AWN_CONFIG_VALUE_TYPE_STRING,
133
AWN_CONFIG_VALUE_TYPE_LIST_BOOL,
134
AWN_CONFIG_VALUE_TYPE_LIST_FLOAT,
135
AWN_CONFIG_VALUE_TYPE_LIST_INT,
136
AWN_CONFIG_VALUE_TYPE_LIST_STRING
137
} AwnConfigValueType;
141
* @AWN_CONFIG_CLIENT_LIST_TYPE_BOOL: Indicates that the list value type
143
* @AWN_CONFIG_CLIENT_LIST_TYPE_FLOAT: Indicates that the list value type
145
* @AWN_CONFIG_CLIENT_LIST_TYPE_INT: Indicates that the list value type
147
* @AWN_CONFIG_CLIENT_LIST_TYPE_STRING: Indicates that the list value type
150
* Indicates the value type of every item in a configuration entry of
154
AWN_CONFIG_CLIENT_LIST_TYPE_BOOL,
155
AWN_CONFIG_CLIENT_LIST_TYPE_FLOAT,
156
AWN_CONFIG_CLIENT_LIST_TYPE_INT,
157
AWN_CONFIG_CLIENT_LIST_TYPE_STRING
160
GType awn_config_client_get_type (void);
162
AwnConfigClient *awn_config_client_new ();
163
AwnConfigClient *awn_config_client_new_for_applet (gchar *name, gchar *uid);
165
void awn_config_client_clear (AwnConfigClient *client, GError **err);
167
void awn_config_client_ensure_group (AwnConfigClient *client, const gchar *group);
169
void awn_config_client_notify_add (AwnConfigClient *client, const gchar *group,
170
const gchar *key, AwnConfigClientNotifyFunc callback,
172
gboolean awn_config_client_entry_exists (AwnConfigClient *client, const gchar *group,
174
void awn_config_client_load_defaults_from_schema (AwnConfigClient *client, GError **err);
176
int awn_config_client_key_lock_open (const gchar *group, const gchar *key);
177
int awn_config_client_key_lock (int fd, int operation);
178
int awn_config_client_key_lock_close (int fd);
180
AwnConfigValueType awn_config_client_get_value_type (AwnConfigClient *client, const gchar *group,
181
const gchar *key, GError **err);
183
gboolean awn_config_client_get_bool (AwnConfigClient *client, const gchar *group,
184
const gchar *key, GError **err);
185
void awn_config_client_set_bool (AwnConfigClient *client, const gchar *group,
186
const gchar *key, gboolean value, GError **err);
187
gfloat awn_config_client_get_float (AwnConfigClient *client, const gchar *group,
188
const gchar *key, GError **err);
189
void awn_config_client_set_float (AwnConfigClient *client, const gchar *group,
190
const gchar *key, gfloat value, GError **err);
191
gint awn_config_client_get_int (AwnConfigClient *client, const gchar *group,
192
const gchar *key, GError **err);
193
void awn_config_client_set_int (AwnConfigClient *client, const gchar *group,
194
const gchar *key, gint value, GError **err);
195
gchar *awn_config_client_get_string (AwnConfigClient *client, const gchar *group,
196
const gchar *key, GError **err);
197
void awn_config_client_set_string (AwnConfigClient *client, const gchar *group,
198
const gchar *key, gchar *value, GError **err);
199
GSList *awn_config_client_get_list (AwnConfigClient *client, const gchar *group,
200
const gchar *key, AwnConfigListType list_type,
202
void awn_config_client_set_list (AwnConfigClient *client, const gchar *group,
203
const gchar *key, AwnConfigListType list_type,
204
GSList *value, GError **err);
205
void awn_config_client_free (AwnConfigClient *client);
207
#endif /* _LIBAWN_AWN_CONFIG_CLIENT_H */
208
/* vim: set noet ts=8 sw=8 sts=8 : */