]> icculus.org git repositories - dana/openbox.git/blob - openbox/config_value.h
Rename obt_xml_find_node() to obt_xml_find_sibling(). Add obt_xml_tree_get_node(...
[dana/openbox.git] / openbox / config_value.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    config_value.h for the Openbox window manager
4    Copyright (c) 2011        Dana Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include "geom.h"
20
21 #include <glib.h>
22
23 struct _GravityCoord;
24 struct _ObActionList;
25
26 typedef struct _ObConfigValue ObConfigValue;
27 typedef struct _ObConfigValueEnum ObConfigValueEnum;
28
29 struct _ObConfigValueEnum {
30     const gchar *name;
31     guint value;
32 };
33
34 typedef enum {
35     OB_CONFIG_VALUE_STRING,
36     OB_CONFIG_VALUE_BOOLEAN,
37     OB_CONFIG_VALUE_ENUM,
38     OB_CONFIG_VALUE_INTEGER,
39     OB_CONFIG_VALUE_FRACTION,
40     OB_CONFIG_VALUE_GRAVITY_COORD,
41     OB_CONFIG_VALUE_LIST,
42     OB_CONFIG_VALUE_ACTIONLIST,
43     NUM_OB_CONFIG_VALUE_TYPES
44 } ObConfigValueDataType;
45
46 /*! This holds a pointer to one of the possible types in ObConfigValueType. */
47 typedef union {
48     const gpointer *pointer; /*!< Generic pointer */
49     const gchar **string;
50     gboolean *boolean;
51     guint *integer;
52     guint *enumeration;
53     struct {
54         guint numer;
55         guint denom;
56     } *fraction;
57     GravityCoord *coord;
58     const GList **list; /*!< A list of ObConfigValue objects */
59     struct _ObActionList **actions;
60 } ObConfigValueDataPtr;
61
62 void config_value_ref(ObConfigValue *v);
63 void config_value_unref(ObConfigValue *v);
64
65 /*! Creates a new value by making a copy of the given string. */
66 ObConfigValue* config_value_new_string(const gchar *s);
67 /*! Creates a new value from a string, and steals ownership of the string. It
68   will be freed when then value is destroyed. */
69 ObConfigValue* config_value_new_string_steal(gchar *s);
70
71 /*! Creates a config value which holds a list of other values
72   This function copies the list and adds a refcount to the values within. */
73 ObConfigValue* config_value_new_list(GList *list);
74 /*! Creates a config value which holds a list of other values.
75   This function steals ownership the list and the values within. */
76 ObConfigValue* config_value_new_list_steal(GList *list);
77 ObConfigValue* config_value_new_action_list(struct _ObActionList *al);
78
79 gboolean config_value_is_string(const ObConfigValue *v);
80 gboolean config_value_is_list(const ObConfigValue *v);
81 gboolean config_value_is_action_list(const ObConfigValue *v);
82
83 /*! Copies the data inside @v to the destination that the pointer @p is
84   pointing to. */
85 void config_value_copy_ptr(ObConfigValue *v,
86                            ObConfigValueDataType type,
87                            ObConfigValueDataPtr p,
88                            const ObConfigValueEnum e[]);
89
90 /* These ones are valid on a string value */
91
92 const gchar* config_value_string(ObConfigValue *v);
93 gboolean config_value_bool(ObConfigValue *v);
94 guint config_value_int(ObConfigValue *v);
95 /*! returns (guint)-1 if an error */
96 guint config_value_enum(ObConfigValue *v, const ObConfigValueEnum e[]);
97 void config_value_fraction(ObConfigValue *v, gint *numer, gint *denom);
98 void config_value_gravity_coord(ObConfigValue *v, struct _GravityCoord *c);
99
100 /* These ones are valid on a list value */
101
102 GList* config_value_list(ObConfigValue *v);
103
104 /* These ones are value on a action list value */
105
106 struct _ObActionList* config_value_action_list(ObConfigValue *v);