Upgrade _matrix_g_enum_to_string() so it can convert dashes to any character

This commit is contained in:
Gergely Polonkai 2017-11-10 15:28:43 +01:00
parent 91fb94de91
commit cb170dc4d9
4 changed files with 6 additions and 6 deletions

View File

@ -1049,7 +1049,7 @@ matrix_filter_get_json_node(MatrixJsonCompact *matrix_json_compact, GError **err
json_builder_end_array(builder); json_builder_end_array(builder);
json_builder_set_member_name(builder, "event_format"); json_builder_set_member_name(builder, "event_format");
json_builder_add_string_value(builder, _matrix_g_enum_to_string(MATRIX_TYPE_EVENT_FORMAT, priv->_event_format, TRUE)); json_builder_add_string_value(builder, _matrix_g_enum_to_string(MATRIX_TYPE_EVENT_FORMAT, priv->_event_format, '_'));
json_builder_set_member_name(builder, "presence"); json_builder_set_member_name(builder, "presence");
node = matrix_json_compact_get_json_node(MATRIX_JSON_COMPACT(priv->_presence_filter), &inner_error); node = matrix_json_compact_get_json_node(MATRIX_JSON_COMPACT(priv->_presence_filter), &inner_error);
@ -2231,7 +2231,7 @@ matrix_search_grouping_get_json_node(MatrixJsonCompact *matrix_json_compact, GEr
json_builder_set_member_name(builder, "key"); json_builder_set_member_name(builder, "key");
json_builder_add_string_value(builder, _matrix_g_enum_to_string(MATRIX_TYPE_SEARCH_GROUP_BY, priv->_key, TRUE)); json_builder_add_string_value(builder, _matrix_g_enum_to_string(MATRIX_TYPE_SEARCH_GROUP_BY, priv->_key, '_'));
json_builder_end_object(builder); json_builder_end_object(builder);

View File

@ -35,7 +35,7 @@
* Returns: (transfer full) the converted enum name, which must be freed * Returns: (transfer full) the converted enum name, which must be freed
*/ */
gchar * gchar *
_matrix_g_enum_to_string(GType enum_type, gint value, gboolean convert_dashes) _matrix_g_enum_to_string(GType enum_type, gint value, gchar convert_dashes)
{ {
GEnumClass *enum_class = g_type_class_ref(enum_type); GEnumClass *enum_class = g_type_class_ref(enum_type);
GEnumValue *enum_value = g_enum_get_value(enum_class, value); GEnumValue *enum_value = g_enum_get_value(enum_class, value);
@ -49,7 +49,7 @@ _matrix_g_enum_to_string(GType enum_type, gint value, gboolean convert_dashes)
for (a = nick; *a; a++) { for (a = nick; *a; a++) {
if (*a == '-') { if (*a == '-') {
*a = '_'; *a = convert_dashes;
} }
} }
} }

View File

@ -23,7 +23,7 @@
G_BEGIN_DECLS G_BEGIN_DECLS
gchar *_matrix_g_enum_to_string(GType enum_type, gint value, gboolean convert_dashes); gchar *_matrix_g_enum_to_string(GType enum_type, gint value, gchar convert_dashes);
gint _matrix_g_enum_nick_to_value(GType enum_type, const gchar *nick, GError **error); gint _matrix_g_enum_nick_to_value(GType enum_type, const gchar *nick, GError **error);
G_END_DECLS G_END_DECLS

View File

@ -384,7 +384,7 @@ namespace Matrix {
/* Utilities */ /* Utilities */
[CCode (cheader_filename = "utils.h", cname = "_matrix_g_enum_to_string")] [CCode (cheader_filename = "utils.h", cname = "_matrix_g_enum_to_string")]
public string? _g_enum_value_to_nick(GLib.Type enum_type, int value, bool convert_dashes = true); public string? _g_enum_value_to_nick(GLib.Type enum_type, int value, char convert_dashes = '_');
[CCode (cheader_filename = "utils.h", cname = "_matrix_g_enum_nick_to_value")] [CCode (cheader_filename = "utils.h", cname = "_matrix_g_enum_nick_to_value")]
public int _g_enum_nick_to_value(GLib.Type enum_type, string nick) public int _g_enum_nick_to_value(GLib.Type enum_type, string nick)