~ubuntu-branches/ubuntu/oneiric/avant-window-navigator/oneiric

« back to all changes in this revision

Viewing changes to libawn/awn-config-client.h

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2008-05-24 14:42:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080524144201-r3v8e4g2hv2q1i9x
Tags: 0.2.6-6
* debian/patches/04-fix-colormap.patch
 - Fix crash in awn-manager if colormap == None. Thanks Emme for the 
   patch. (Closes: #482030) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2007, 2008 Mark Lee <avant-wn@lazymalevolence.com>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 *
 
19
 *  Author : Mark Lee <avant-wn@lazymalevolence.com>
 
20
 */
 
21
 
 
22
#ifndef _LIBAWN_AWN_CONFIG_CLIENT_H
 
23
#define _LIBAWN_AWN_CONFIG_CLIENT_H
 
24
 
 
25
#include <glib.h>
 
26
#include <glib-object.h>
 
27
 
 
28
/**
 
29
 * AwnConfigClient:
 
30
 *
 
31
 * An opaque structure that facilitates having multiple configuration backends
 
32
 * available to Awn.
 
33
 */
 
34
typedef struct _AwnConfigClient AwnConfigClient;
 
35
 
 
36
#define AWN_TYPE_CONFIG_CLIENT (awn_config_client_get_type ())
 
37
/**
 
38
 * AWN_CONFIG_CLIENT:
 
39
 * @obj: The variable/value to cast
 
40
 *
 
41
 * Casts a variable/value to be an #AwnConfigClient.
 
42
 */
 
43
#define AWN_CONFIG_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_CONFIG_CLIENT, AwnConfigClient))
 
44
 
 
45
/**
 
46
 * AwnConfigClientValue:
 
47
 * @bool_val: The boolean value of the entry, if the entry is defined as taking
 
48
 * a boolean value.
 
49
 * @float_val: The float value of the entry, if the entry is defined as taking
 
50
 * a float value.
 
51
 * @int_val: The integer value of the entry, if the entry is defined as taking
 
52
 * an integer value.
 
53
 * @str_val: The string value of the entry, if the entry is defined as taking
 
54
 * a string value.
 
55
 * @list_val: The list value of the entry, if the entry is defined as taking
 
56
 * a list value.
 
57
 *
 
58
 * A union used to store a configuration value when it has changed and has
 
59
 * notify callbacks associated with it.
 
60
 */
 
61
typedef union {
 
62
        gboolean bool_val;
 
63
        gfloat float_val;
 
64
        gint int_val;
 
65
        gchar *str_val;
 
66
        GSList *list_val;
 
67
} AwnConfigClientValue;
 
68
 
 
69
/**
 
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.
 
75
 *
 
76
 * The structure used to transport data to the notification functions of
 
77
 * a configuration entry.
 
78
 */
 
79
typedef struct {
 
80
        AwnConfigClient *client;
 
81
        gchar *group;
 
82
        gchar *key;
 
83
        AwnConfigClientValue value;
 
84
} AwnConfigClientNotifyEntry;
 
85
 
 
86
/**
 
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().
 
91
 *
 
92
 * The callback template for configuration change notification functions.
 
93
 */
 
94
typedef void (*AwnConfigClientNotifyFunc) (AwnConfigClientNotifyEntry *entry, gpointer data);
 
95
 
 
96
/**
 
97
 * AWN_CONFIG_CLIENT_DEFAULT_GROUP:
 
98
 *
 
99
 * In the #GKeyFile backend, the group name with which "top-level" configuration
 
100
 * entries are associated.
 
101
 */
 
102
#define AWN_CONFIG_CLIENT_DEFAULT_GROUP "DEFAULT"
 
103
 
 
104
/**
 
105
 * AwnConfigValueType:
 
106
 * @AWN_CONFIG_VALUE_TYPE_NULL: Indicates that the configuration value type
 
107
 * is unknown.
 
108
 * @AWN_CONFIG_VALUE_TYPE_BOOL: Indicates that the configuration value type
 
109
 * is boolean.
 
110
 * @AWN_CONFIG_VALUE_TYPE_FLOAT: Indicates that the configuration value type
 
111
 * is float.
 
112
 * @AWN_CONFIG_VALUE_TYPE_INT: Indicates that the configuration value type
 
113
 * is integer.
 
114
 * @AWN_CONFIG_VALUE_TYPE_STRING: Indicates that the configuration value type
 
115
 * is string.
 
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.
 
124
 *
 
125
 * Indicates the value type of a particular configuration entry.
 
126
 */
 
127
typedef enum {
 
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;
 
138
 
 
139
/**
 
140
 * AwnConfigListType:
 
141
 * @AWN_CONFIG_CLIENT_LIST_TYPE_BOOL: Indicates that the list value type
 
142
 * is boolean.
 
143
 * @AWN_CONFIG_CLIENT_LIST_TYPE_FLOAT: Indicates that the list value type
 
144
 * is float.
 
145
 * @AWN_CONFIG_CLIENT_LIST_TYPE_INT: Indicates that the list value type
 
146
 * is integer.
 
147
 * @AWN_CONFIG_CLIENT_LIST_TYPE_STRING: Indicates that the list value type
 
148
 * is string.
 
149
 *
 
150
 * Indicates the value type of every item in a configuration entry of
 
151
 * type "list".
 
152
 */
 
153
typedef enum {
 
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
 
158
} AwnConfigListType;
 
159
 
 
160
GType              awn_config_client_get_type                  (void);
 
161
 
 
162
AwnConfigClient   *awn_config_client_new                       ();
 
163
AwnConfigClient   *awn_config_client_new_for_applet            (gchar *name, gchar *uid);
 
164
 
 
165
void               awn_config_client_clear                     (AwnConfigClient *client, GError **err);
 
166
 
 
167
void               awn_config_client_ensure_group              (AwnConfigClient *client, const gchar *group);
 
168
 
 
169
void               awn_config_client_notify_add                (AwnConfigClient *client, const gchar *group,
 
170
                                                                const gchar *key, AwnConfigClientNotifyFunc callback,
 
171
                                                                gpointer data);
 
172
gboolean           awn_config_client_entry_exists              (AwnConfigClient *client, const gchar *group,
 
173
                                                                const gchar *key);
 
174
void               awn_config_client_load_defaults_from_schema (AwnConfigClient *client, GError **err);
 
175
 
 
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);
 
179
 
 
180
AwnConfigValueType awn_config_client_get_value_type            (AwnConfigClient *client, const gchar *group,
 
181
                                                                const gchar *key, GError **err);
 
182
 
 
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,
 
201
                                                                GError **err);
 
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);
 
206
 
 
207
#endif /* _LIBAWN_AWN_CONFIG_CLIENT_H */
 
208
/* vim: set noet ts=8 sw=8 sts=8 : */