1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 config_value.h for the Openbox window manager
4 Copyright (c) 2011 Dana Jansens
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.
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.
16 See the COPYING file for a copy of the GNU General Public License.
26 typedef struct _ObConfigValue ObConfigValue;
27 typedef struct _ObConfigValueEnum ObConfigValueEnum;
29 struct _ObConfigValueEnum {
35 OB_CONFIG_VALUE_STRING,
36 OB_CONFIG_VALUE_BOOLEAN,
38 OB_CONFIG_VALUE_INTEGER,
39 OB_CONFIG_VALUE_FRACTION,
40 OB_CONFIG_VALUE_GRAVITY_COORD,
42 OB_CONFIG_VALUE_ACTIONLIST,
43 NUM_OB_CONFIG_VALUE_TYPES
44 } ObConfigValueDataType;
46 /*! This holds a pointer to one of the possible types in ObConfigValueType. */
48 const gpointer *pointer; /*!< Generic pointer */
58 const GList **list; /*!< A list of ObConfigValue objects */
59 struct _ObActionList **actions;
60 } ObConfigValueDataPtr;
62 void config_value_ref(ObConfigValue *v);
63 void config_value_unref(ObConfigValue *v);
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);
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);
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);
83 /*! Copies the data inside @v to the destination that the pointer @p is
85 void config_value_copy_ptr(ObConfigValue *v,
86 ObConfigValueDataType type,
87 ObConfigValueDataPtr *p,
88 const ObConfigValueEnum e[]);
90 /* These ones are valid on a string value */
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);
100 /* These ones are valid on a list value */
102 GList* config_value_list(ObConfigValue *v);
104 /* These ones are value on a action list value */
106 struct _ObActionList* config_value_action_list(ObConfigValue *v);