Skip to content
Snippets Groups Projects
Commit e6c431ce authored by mh17's avatar mh17
Browse files

config code moved into zmapConfig/zmapConfigLoader.c

parent faf2d38d
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@
* HISTORY:
* Last edited: Jul 29 09:53 2009 (edgrif)
* Created: Thu Oct 30 10:24:35 2008 (edgrif)
* CVS info: $Id: zmapStyleUtils.c,v 1.8 2009-12-03 15:08:06 mh17 Exp $
* CVS info: $Id: zmapStyleUtils.c,v 1.9 2009-12-14 11:37:09 mh17 Exp $
*-------------------------------------------------------------------
*/
......@@ -168,144 +168,6 @@ ZMAP_ENUM_TO_SHORT_TEXT_FUNC(zmapStyleBumpMode2ShortText, ZMapStyleBu
GData *zMapFeatureTypeGetFromFile(char *styles_list, char *styles_file_name)
{
GData *styles = NULL ;
ZMapConfigIniContext context ;
GList *settings_list = NULL, *free_this_list = NULL;
if ((context = zMapConfigIniContextProvideNamed(ZMAPSTANZA_STYLE_CONFIG)))
{
if (zMapConfigIniContextIncludeFile(context, styles_file_name))
// settings_list = zMapConfigIniContextGetNamed(context, ZMAPSTANZA_STYLE_CONFIG) ;
settings_list = zMapConfigIniContextGetStyleList(context, styles_list) ;
zMapConfigIniContextDestroy(context) ;
context = NULL;
}
if (settings_list)
{
free_this_list = settings_list ;
g_datalist_init(&styles) ;
do
{
ZMapKeyValue curr_config_style ;
ZMapFeatureTypeStyle new_style ;
GParameter params[100] ; /* TMP....make dynamic.... */
guint num_params ;
GParameter *curr_param ;
/* Reset params memory.... */
memset(&params, 0, sizeof(params)) ;
curr_param = params ;
num_params = 0 ;
curr_config_style = (ZMapKeyValue)(settings_list->data) ;
/* The first item is special, the "name" field is the name of the style and
* is derived from the name of the stanza and so must be treated specially. */
zMapAssert(curr_config_style->name && *(curr_config_style->name)) ;
g_value_init(&(curr_param->value), G_TYPE_STRING) ;
curr_param->name = curr_config_style->name ;
g_value_set_string(&(curr_param->value), curr_config_style->data.str) ;
num_params++ ;
curr_param++ ;
curr_config_style++ ;
while (curr_config_style->name)
{
if (curr_config_style->has_value)
{
curr_param->name = curr_config_style->name ;
switch (curr_config_style->type)
{
case ZMAPCONF_STR_ARRAY:
{
if (curr_config_style->conv_type == ZMAPCONV_STR2COLOUR)
{
g_value_init(&(curr_param->value), G_TYPE_STRING) ;
g_value_set_string(&(curr_param->value), curr_config_style->data.str) ;
}
break ;
}
case ZMAPCONF_STR:
{
if (curr_config_style->conv_type == ZMAPCONV_STR2ENUM)
{
int enum_value ;
enum_value = (curr_config_style->conv_func.str2enum)(curr_config_style->data.str) ;
g_value_init(&(curr_param->value), G_TYPE_INT) ;
g_value_set_int(&(curr_param->value), enum_value) ;
}
else
{
g_value_init(&(curr_param->value), G_TYPE_STRING) ;
g_value_set_string(&(curr_param->value), curr_config_style->data.str) ;
}
break ;
}
case ZMAPCONF_DOUBLE:
{
g_value_init(&(curr_param->value), G_TYPE_DOUBLE) ;
g_value_set_double(&(curr_param->value), curr_config_style->data.d) ;
break ;
}
case ZMAPCONF_INT:
{
g_value_init(&(curr_param->value), G_TYPE_INT) ;
g_value_set_int(&(curr_param->value), curr_config_style->data.i) ;
break ;
}
case ZMAPCONF_BOOLEAN:
{
g_value_init(&(curr_param->value), G_TYPE_BOOLEAN) ;
g_value_set_boolean(&(curr_param->value), curr_config_style->data.b) ;
break ;
}
default:
{
zMapAssertNotReached() ;
break ;
}
}
num_params++ ;
curr_param++ ;
}
curr_config_style++ ;
}
if ((new_style = zMapStyleCreateV(num_params, params)))
{
if (!zMapStyleSetAdd(&styles, new_style))
{
/* Free style, report error and move on. */
zMapStyleDestroy(new_style) ;
zMapLogWarning("Styles file \"%s\", stanza %s could not be added.",
styles_file_name, curr_config_style->name) ;
}
}
} while((settings_list = g_list_next(settings_list)));
}
zMapConfigStylesFreeList(free_this_list) ;
return styles ;
}
void zMapStyleSetPrintAll(ZMapIOOut dest, GData *type_set, char *user_string, gboolean full)
{
StylePrintStruct print_data ;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment