From: Dana Jansens Date: Mon, 8 Aug 2011 16:35:52 +0000 (-0400) Subject: Make the ConfigValue list type into a gchar** string list instead. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=280801af0dbd6e97ae49893e2caf41cff92f057a;p=dana%2Fopenbox.git Make the ConfigValue list type into a gchar** string list instead. 1. I don't want to have to deal with nested lists cuz they just don't need to happen (now). --- diff --git a/openbox/config_value.c b/openbox/config_value.c index 0aa73599..b871ec0c 100644 --- a/openbox/config_value.c +++ b/openbox/config_value.c @@ -31,7 +31,7 @@ struct _ObConfigValue { } type; union { gchar *string; - GList *list; + gchar **list; ObActionList *actions; } v; }; @@ -48,13 +48,9 @@ void config_value_unref(ObConfigValue *v) case OB_CV_STRING: g_free(v->v.string); break; - case OB_CV_LIST: { - GList *it; - for (it = v->v.list; it; it = g_list_next(it)) - config_value_unref(it->data); - g_list_free(v->v.list); + case OB_CV_LIST: + g_strfreev(v->v.list); break; - } case OB_CV_ACTION_LIST: action_list_unref(v->v.actions); break; @@ -71,7 +67,7 @@ gboolean config_value_is_string(const ObConfigValue *v) return v->type == OB_CV_STRING; } -gboolean config_value_is_list(const ObConfigValue *v) +gboolean config_value_is_string_list(const ObConfigValue *v) { g_return_val_if_fail(v != NULL, FALSE); return v->type == OB_CV_LIST; @@ -116,9 +112,10 @@ void config_value_copy_ptr(ObConfigValue *v, *p.coord = c; break; } - case OB_CONFIG_VALUE_LIST: - *p.list = config_value_list(v); + case OB_CONFIG_VALUE_STRING_LIST: { + *p.list = config_value_string_list(v); break; + } case OB_CONFIG_VALUE_ACTIONLIST: *p.actions = config_value_action_list(v); break; @@ -211,11 +208,11 @@ void config_value_gravity_coord(ObConfigValue *v, GravityCoord *c) c->denom = atoi(s+1); } } -GList* config_value_list(ObConfigValue *v) +const gchar *const* config_value_string_list(ObConfigValue *v) { g_return_val_if_fail(v != NULL, NULL); - g_return_val_if_fail(config_value_is_list(v), NULL); - return v->v.list; + g_return_val_if_fail(config_value_is_string_list(v), NULL); + return (const gchar**)v->v.list; } ObActionList* config_value_action_list(ObConfigValue *v) { @@ -243,17 +240,12 @@ ObConfigValue* config_value_new_string_steal(gchar *s) return v; } -ObConfigValue* config_value_new_list(GList *list) +ObConfigValue* config_value_new_string_list(gchar **list) { - GList *c = g_list_copy(list); - GList *it; - - for (it = c; it; it = g_list_next(it)) - config_value_ref(it->data); - return config_value_new_list_steal(c); + return config_value_new_string_list_steal(g_strdupv(list)); } -ObConfigValue* config_value_new_list_steal(GList *list) +ObConfigValue* config_value_new_string_list_steal(gchar **list) { ObConfigValue *v = g_slice_new(ObConfigValue); v->ref = 1; diff --git a/openbox/config_value.h b/openbox/config_value.h index 5b756340..d1123341 100644 --- a/openbox/config_value.h +++ b/openbox/config_value.h @@ -38,13 +38,13 @@ typedef enum { OB_CONFIG_VALUE_INTEGER, OB_CONFIG_VALUE_FRACTION, OB_CONFIG_VALUE_GRAVITY_COORD, - OB_CONFIG_VALUE_LIST, + OB_CONFIG_VALUE_STRING_LIST, OB_CONFIG_VALUE_ACTIONLIST, NUM_OB_CONFIG_VALUE_TYPES } ObConfigValueDataType; /*! This holds a pointer to one of the possible types in ObConfigValueType. */ -typedef union { +typedef union _ObConfigValueDataPtr { const gpointer *pointer; /*!< Generic pointer */ const gchar **string; gboolean *boolean; @@ -54,8 +54,8 @@ typedef union { guint numer; guint denom; } *fraction; - GravityCoord *coord; - const GList **list; /*!< A list of ObConfigValue objects */ + struct _GravityCoord *coord; + const gchar *const**list; struct _ObActionList **actions; } ObConfigValueDataPtr; @@ -70,14 +70,15 @@ ObConfigValue* config_value_new_string_steal(gchar *s); /*! Creates a config value which holds a list of other values This function copies the list and adds a refcount to the values within. */ -ObConfigValue* config_value_new_list(GList *list); +ObConfigValue* config_value_new_string_list(gchar **list); /*! Creates a config value which holds a list of other values. This function steals ownership the list and the values within. */ -ObConfigValue* config_value_new_list_steal(GList *list); +ObConfigValue* config_value_new_string_list_steal(gchar **list); + ObConfigValue* config_value_new_action_list(struct _ObActionList *al); gboolean config_value_is_string(const ObConfigValue *v); -gboolean config_value_is_list(const ObConfigValue *v); +gboolean config_value_is_string_list(const ObConfigValue *v); gboolean config_value_is_action_list(const ObConfigValue *v); /*! Copies the data inside @v to the destination that the pointer @p is @@ -97,9 +98,9 @@ guint config_value_enum(ObConfigValue *v, const ObConfigValueEnum e[]); void config_value_fraction(ObConfigValue *v, gint *numer, gint *denom); void config_value_gravity_coord(ObConfigValue *v, struct _GravityCoord *c); -/* These ones are valid on a list value */ +/* These ones are valid on a string list value */ -GList* config_value_list(ObConfigValue *v); +gchar const*const* config_value_string_list(ObConfigValue *v); /* These ones are value on a action list value */