From a9ccf6533dec4b803f9949a15e7a8d58de4041d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Wed, 25 Sep 2019 18:21:02 +0200 Subject: [PATCH] LayerSelector: Use Layer Settings for CSV export. This makes the mapping parser unnecessary. It can be removed --- layer/layer-selector.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/layer/layer-selector.c b/layer/layer-selector.c index b40bead..fcda12d 100644 --- a/layer/layer-selector.c +++ b/layer/layer-selector.c @@ -711,29 +711,14 @@ static void layer_selector_load_mapping_clicked(GtkWidget *button, gpointer user */ static void layer_selector_save_layer_mapping_data(LayerSelector *self, const gchar *file_name) { - FILE *file; - char workbuff[512]; - GList *le_list; - GList *temp; + LayerSettings *layer_settings; - /* Overwrite existing file */ - file = fopen((const char *)file_name, "w"); + g_return_if_fail(LAYER_IS_SELECTOR(self)); + g_return_if_fail(file_name); - le_list = gtk_container_get_children(GTK_CONTAINER(self->list_box)); - - /* File format is CSV: ,,,,,,, */ - for (temp = le_list; temp != NULL; temp = temp->next) { - /* To be sure it is a valid string */ - workbuff[0] = 0; - mapping_parser_gen_csv_line(LAYER_ELEMENT(temp->data), workbuff, sizeof(workbuff)); - fwrite(workbuff, sizeof(char), strlen(workbuff), file); - } - - g_list_free(le_list); - - /* Save File */ - fflush(file); - fclose(file); + /* Get layer settings. No need to check return value. to_csv func is safe */ + layer_settings = layer_selector_export_rendered_layer_info(self); + (void)layer_settings_to_csv(layer_settings, file_name); } /**