Upgrade _matrix_g_enum_to_string() so it can convert dashes to any character
This commit is contained in:
		| @@ -1049,7 +1049,7 @@ matrix_filter_get_json_node(MatrixJsonCompact *matrix_json_compact, GError **err | ||||
|     json_builder_end_array(builder); | ||||
|  | ||||
|     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"); | ||||
|     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_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); | ||||
|  | ||||
|   | ||||
| @@ -35,7 +35,7 @@ | ||||
|  * Returns: (transfer full) the converted enum name, which must be freed | ||||
|  */ | ||||
| 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); | ||||
|     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++) { | ||||
|                 if (*a == '-') { | ||||
|                     *a = '_'; | ||||
|                     *a = convert_dashes; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -23,7 +23,7 @@ | ||||
|  | ||||
| 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); | ||||
|  | ||||
| G_END_DECLS | ||||
|   | ||||
| @@ -384,7 +384,7 @@ namespace Matrix { | ||||
|  | ||||
|     /* Utilities */ | ||||
|     [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")] | ||||
|     public int _g_enum_nick_to_value(GLib.Type enum_type, string nick) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user