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.
24 typedef struct _ObConfigValue ObConfigValue;
25 typedef struct _ObConfigValueEnum ObConfigValueEnum;
27 struct _ObConfigValueEnum {
33 OB_CONFIG_VALUE_STRING,
34 OB_CONFIG_VALUE_BOOLEAN,
36 OB_CONFIG_VALUE_INTEGER,
37 OB_CONFIG_VALUE_FRACTION,
38 OB_CONFIG_VALUE_GRAVITY_COORD,
40 OB_CONFIG_VALUE_BUTTON,
41 OB_CONFIG_VALUE_STRING_LIST,
43 OB_CONFIG_VALUE_ACTIONLIST,
44 NUM_OB_CONFIG_VALUE_TYPES
45 } ObConfigValueDataType;
47 /*! This holds a pointer to one of the possible types in ObConfigValueType. */
48 typedef union _ObConfigValueDataPtr {
49 const gpointer *pointer; /*!< Generic pointer */
58 struct _GravityCoord *coord;
59 struct _ObKeyboardKey *key;
60 struct _ObMouseButton *button;
61 const gchar *const**list;
62 struct _ObActionList **actions;
63 } ObConfigValueDataPtr;
65 void config_value_ref(ObConfigValue *v);
66 void config_value_unref(ObConfigValue *v);
68 /*! Creates a new value by making a copy of the given string. */
69 ObConfigValue* config_value_new_string(const gchar *s);
70 /*! Creates a new value from a string, and steals ownership of the string. It
71 will be freed when then value is destroyed. */
72 ObConfigValue* config_value_new_string_steal(gchar *s);
74 /*! Creates a config value which holds a list of other values
75 This function copies the list and adds a refcount to the values within. */
76 ObConfigValue* config_value_new_string_list(gchar **list);
77 /*! Creates a config value which holds a list of other values.
78 This function steals ownership the list and the values within. */
79 ObConfigValue* config_value_new_string_list_steal(gchar **list);
81 ObConfigValue* config_value_new_action_list(struct _ObActionList *al);
83 gboolean config_value_is_string(const ObConfigValue *v);
84 gboolean config_value_is_string_list(const ObConfigValue *v);
85 gboolean config_value_is_action_list(const ObConfigValue *v);
87 /*! Copies the data inside @v to the destination that the pointer @p is
89 gboolean config_value_copy_ptr(ObConfigValue *v,
90 ObConfigValueDataType type,
91 ObConfigValueDataPtr p,
92 const ObConfigValueEnum e[]);
94 /* These ones are valid on a string value */
96 const gchar* config_value_string(ObConfigValue *v);
97 gboolean config_value_bool(ObConfigValue *v);
98 guint config_value_int(ObConfigValue *v);
99 /*! returns FALSE if the value isn't in the enumeration */
100 gboolean config_value_enum(ObConfigValue *v, const ObConfigValueEnum e[],
102 void config_value_fraction(ObConfigValue *v, gint *numer, gint *denom);
103 void config_value_gravity_coord(ObConfigValue *v, struct _GravityCoord *c);
104 /*! returns FALSE if the key string isn't valid */
105 gboolean config_value_key(ObConfigValue *v, struct _ObKeyboardKey *k);
106 /*! returns FALSE if the button string isn't valid */
107 gboolean config_value_button(ObConfigValue *v, struct _ObMouseButton *b);
109 /* These ones are valid on a string list value */
111 gchar const*const* config_value_string_list(ObConfigValue *v);
113 /* These ones are value on a action list value */
115 struct _ObActionList* config_value_action_list(ObConfigValue *v);