2016-01-15 16:58:35 +00:00
|
|
|
/*
|
|
|
|
* This file is part of matrix-glib-sdk
|
|
|
|
*
|
|
|
|
* matrix-glib-sdk is free software: you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation, either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* matrix-glib-sdk is distributed in the hope that it will be
|
|
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with matrix-glib-sdk. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
gchar *
|
2016-01-24 08:08:00 +00:00
|
|
|
_g_enum_to_string(GType enum_type, gint value, gboolean convert_dashes)
|
2016-01-15 16:58:35 +00:00
|
|
|
{
|
|
|
|
GEnumClass *enum_class = g_type_class_ref(enum_type);
|
|
|
|
GEnumValue *enum_value = g_enum_get_value(enum_class, value);
|
|
|
|
gchar *nick = NULL;
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
nick = g_strdup(enum_value->value_nick);
|
|
|
|
|
|
|
|
if (convert_dashes) {
|
|
|
|
gchar *a;
|
|
|
|
|
|
|
|
for (a = nick; *a; a++) {
|
|
|
|
if (*a == '-') {
|
|
|
|
*a = '_';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_type_class_unref(enum_class);
|
|
|
|
|
|
|
|
return nick;
|
|
|
|
}
|