Add support for monitors "All" to span panel over all monitors.
[lxde/lxpanel.git] / src / conf.h
CommitLineData
0260eac5
AG
1/*
2 * Copyright (c) 2014 LxDE Developers, see the file AUTHORS for details.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19/* This is a config file parser with API similar to one used by libconfig
20 for convenience but contents of the file is the own config format
21 therefore it is much more restricted than libconfig is.
22 Strings cannot be numeric and are not quoted (similarly to INI file format).
23 Groups cannot be inside other group but only inside an anonymous list.
24 That anonymous list is the only list type which is supported and there
25 can be only one anonymous member in any group. */
26
27#ifndef __CONF_H__
28#define __CONF_H__ 1
29
30#include <glib.h>
31#include <stdio.h>
32
33G_BEGIN_DECLS
34
35typedef struct _config_setting_t config_setting_t;
36typedef struct _PanelConf PanelConf;
37
38typedef enum
39{
40 PANEL_CONF_TYPE_GROUP,
41 PANEL_CONF_TYPE_INT,
42 PANEL_CONF_TYPE_STRING,
43 PANEL_CONF_TYPE_LIST
44} PanelConfType;
45
17fab6e5 46typedef void (*PanelConfSaveHook)(const config_setting_t * setting, FILE * f, gpointer user_data);
0260eac5
AG
47
48PanelConf *config_new(void);
49void config_destroy(PanelConf * config);
50gboolean config_read_file(PanelConf * config, const char * filename);
51gboolean config_write_file(PanelConf * config, const char * filename);
52char * config_setting_to_string(const config_setting_t * setting);
53
54config_setting_t * config_root_setting(const PanelConf * config);
55config_setting_t * config_setting_get_member(const config_setting_t * setting, const char * name);
56config_setting_t * config_setting_get_elem(const config_setting_t * setting, unsigned int index);
17fab6e5
AG
57const char * config_setting_get_name(const config_setting_t * setting);
58config_setting_t * config_setting_get_parent(const config_setting_t * setting);
0260eac5
AG
59
60int config_setting_get_int(const config_setting_t * setting);
61const char * config_setting_get_string(const config_setting_t * setting);
62
4bca3e51
AG
63gboolean config_setting_lookup_int(const config_setting_t * setting,
64 const char * name, int * value);
65gboolean config_setting_lookup_string(const config_setting_t * setting,
66 const char * name, const char ** value);
67
0260eac5 68config_setting_t * config_setting_add(config_setting_t * parent, const char * name, PanelConfType type);
0260eac5
AG
69
70gboolean config_setting_move_member(config_setting_t * setting, config_setting_t * parent, const char * name);
71gboolean config_setting_move_elem(config_setting_t * setting, config_setting_t * parent, int index);
72
73gboolean config_setting_set_int(config_setting_t * setting, int value);
74gboolean config_setting_set_string(config_setting_t * setting, const char * value);
75gboolean config_setting_remove(config_setting_t * parent, const char * name);
76gboolean config_setting_remove_elem(config_setting_t * parent, unsigned int index);
17fab6e5 77gboolean config_setting_destroy(config_setting_t * setting);
0260eac5 78
a8d4af54
AG
79#define config_group_set_int(_group,_name,_value) \
80 config_setting_set_int(config_setting_add(_group, _name, \
81 PANEL_CONF_TYPE_INT), \
82 _value)
83#define config_group_set_string(_group,_name,_value) \
84 config_setting_set_string(config_setting_add(_group, _name, \
85 PANEL_CONF_TYPE_STRING), \
86 _value)
87#define config_group_add_subgroup(_group,_name) \
88 config_setting_add(config_setting_add(_group, "", PANEL_CONF_TYPE_LIST), \
89 _name, PANEL_CONF_TYPE_GROUP)
90
0260eac5
AG
91PanelConfType config_setting_type(const config_setting_t * setting);
92#define config_setting_is_group(_s) config_setting_type(_s) == PANEL_CONF_TYPE_GROUP
93#define config_setting_is_list(_s) config_setting_type(_s) == PANEL_CONF_TYPE_LIST
94#define config_setting_is_scalar(_s) \
95 (config_setting_type(_s) == PANEL_CONF_TYPE_INT || \
96 config_setting_type(_s) == PANEL_CONF_TYPE_STRING)
97
17fab6e5 98void config_setting_set_save_hook(config_setting_t * setting, PanelConfSaveHook hook, gpointer user_data);
0260eac5
AG
99
100G_END_DECLS
101
102#endif /* __CONF_H__ */