Save the gathered widget properties to a key File.
194 auto group = get_group_prefix() + m_name;
197 g_key_file_set_string (keyfile, group.c_str(), CSV_NAME, m_name.c_str());
199 g_key_file_set_integer (keyfile, group.c_str(), CSV_SKIP_START, m_skip_start_lines);
200 g_key_file_set_integer (keyfile, group.c_str(), CSV_SKIP_END, m_skip_end_lines);
201 g_key_file_set_boolean (keyfile, group.c_str(), CSV_SKIP_ALT, m_skip_alt_lines);
202 g_key_file_set_boolean (keyfile, group.c_str(), CSV_FORMAT,
203 (m_file_format == GncImpFileFormat::CSV) ?
true :
false);
205 g_key_file_set_string (keyfile, group.c_str(), CSV_SEP, m_separators.c_str());
206 g_key_file_set_integer (keyfile, group.c_str(), CSV_DATE, m_date_format);
207 std::ostringstream cmt_ss;
208 cmt_ss <<
"Supported date formats: ";
212 { cmt_ss << fmt_num++ <<
": '" << fmt.
m_fmt <<
"', "; });
213 auto cmt = cmt_ss.str().substr(0, static_cast<long>(cmt_ss.tellp()) - 2);
214 g_key_file_set_comment (keyfile, group.c_str(), CSV_DATE, cmt.c_str(),
nullptr);
215 g_key_file_set_integer (keyfile, group.c_str(), CSV_CURRENCY, m_currency_format);
216 g_key_file_set_string (keyfile, group.c_str(), CSV_ENCODING, m_encoding.c_str());
218 if (!m_column_widths.empty())
219 g_key_file_set_integer_list (keyfile, group.c_str(), CSV_COL_WIDTHS,
220 (gint*)(m_column_widths.data()), m_column_widths.size());
223 GError *key_error =
nullptr;
225 auto enc_val = g_key_file_get_string (keyfile, group.c_str(), CSV_ENCODING, &key_error);
226 auto enc_str = std::string{enc_val};
230 if ((key_error) || (enc_str != m_encoding.c_str()))
234 g_warning (
"Error reading group %s key %s: %s", group.c_str(), CSV_ENCODING, key_error->message);
235 g_error_free (key_error);
238 g_warning (
"Error comparing group %s key %s: '%s' and '%s'", group.c_str(), CSV_ENCODING, enc_str.c_str(), group.c_str());
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
static const std::vector< GncDateFormat > c_formats
A vector with all the date formats supported by the string constructor.