Add ag_house_system_id_to_nick() and ag_house_system_nick_to_id()

This is to convert between house system ID (required for chart generating)
and GEnum nick (required for saving).
This commit is contained in:
Gergely Polonkai 2014-08-04 00:31:25 +02:00
parent 3ad29b3f2d
commit 881b58080a
2 changed files with 37 additions and 0 deletions

View File

@ -143,6 +143,38 @@ xml_read_gresource(void *context, char *buffer, int len)
return len; return len;
} }
const gchar *
ag_house_system_id_to_nick(GsweHouseSystem house_system)
{
GEnumClass *house_system_class;
GEnumValue *enum_value;
house_system_class = g_type_class_ref(GSWE_TYPE_HOUSE_SYSTEM);
enum_value = g_enum_get_value(house_system_class, house_system);
if (enum_value) {
return enum_value->value_nick;
}
return NULL;
}
GsweHouseSystem
ag_house_system_nick_to_id(const gchar *nick)
{
GEnumClass *house_system_class;
GEnumValue *enum_value;
house_system_class = g_type_class_ref(GSWE_TYPE_HOUSE_SYSTEM);
enum_value = g_enum_get_value_by_nick(house_system_class, nick);
if (enum_value) {
return enum_value->value;
}
return GSWE_HOUSE_SYSTEM_NONE;
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {

View File

@ -1,6 +1,8 @@
#ifndef __ASTROGNOME_H__ #ifndef __ASTROGNOME_H__
#define __ASTROGNOME_H__ #define __ASTROGNOME_H__
#include <swe-glib.h>
typedef struct { typedef struct {
gboolean version; gboolean version;
gboolean quit; gboolean quit;
@ -10,5 +12,8 @@ typedef struct {
extern GtkFileFilter *filter_all; extern GtkFileFilter *filter_all;
extern GtkFileFilter *filter_chart; extern GtkFileFilter *filter_chart;
const gchar *ag_house_system_id_to_nick(GsweHouseSystem house_system);
GsweHouseSystem ag_house_system_nick_to_id(const gchar *nick);
#endif /* __ASTROGNOME_H__ */ #endif /* __ASTROGNOME_H__ */