gnucash master: Multiple changes pushed
Geert Janssens
gjanssens at code.gnucash.org
Sun Nov 30 09:07:31 EST 2014
Updated via https://github.com/Gnucash/gnucash/commit/32dd1993 (commit)
via https://github.com/Gnucash/gnucash/commit/eec86eec (commit)
from https://github.com/Gnucash/gnucash/commit/1b53d7fa (commit)
commit 32dd199326dde126dd3f7ca5c4e9ba83a7a9579e
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Wed Nov 19 11:19:51 2014 +0000
Bug 679791 - Import Template for importing CSV files - part2
This patch adds the option to Save and Load the CSV import settings.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 45cb90d..3df8e25 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -394,6 +394,7 @@ src/import-export/csv-imp/assistant-csv-trans-import.glade
src/import-export/csv-imp/csv-account-import.c
src/import-export/csv-imp/gnc-csv-gnumeric-popup.c
src/import-export/csv-imp/gnc-csv-model.c
+src/import-export/csv-imp/gnc-csv-trans-settings.c
src/import-export/csv-imp/gncmod-csv-import.c
src/import-export/csv-imp/gnc-plugin-csv-import.c
[type: gettext/gsettings]src/import-export/csv-imp/gschemas/org.gnucash.dialogs.import.csv.gschema.xml.in.in
diff --git a/src/import-export/csv-imp/Makefile.am b/src/import-export/csv-imp/Makefile.am
index 6d75ffb..db92cb1 100644
--- a/src/import-export/csv-imp/Makefile.am
+++ b/src/import-export/csv-imp/Makefile.am
@@ -9,7 +9,8 @@ libgncmod_csv_import_la_SOURCES = \
gnc-plugin-csv-import.c \
csv-account-import.c \
gnc-csv-model.c \
- gnc-csv-gnumeric-popup.c
+ gnc-csv-gnumeric-popup.c \
+ gnc-csv-trans-settings.c
noinst_HEADERS = \
assistant-csv-account-import.h \
@@ -17,7 +18,8 @@ noinst_HEADERS = \
gnc-plugin-csv-import.h \
csv-account-import.h \
gnc-csv-model.h \
- gnc-csv-gnumeric-popup.h
+ gnc-csv-gnumeric-popup.h \
+ gnc-csv-trans-settings.h
libgncmod_csv_import_la_LDFLAGS = -avoid-version
diff --git a/src/import-export/csv-imp/assistant-csv-trans-import.c b/src/import-export/csv-imp/assistant-csv-trans-import.c
index 6badfc6..4a334f5 100644
--- a/src/import-export/csv-imp/assistant-csv-trans-import.c
+++ b/src/import-export/csv-imp/assistant-csv-trans-import.c
@@ -30,6 +30,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <stdlib.h>
#include "gnc-ui.h"
#include "gnc-uri-utils.h"
@@ -38,8 +39,10 @@
#include "gnc-component-manager.h"
+#include "gnc-state.h"
#include "assistant-utils.h"
#include "assistant-csv-trans-import.h"
+#include "gnc-csv-trans-settings.h"
#include "import-account-matcher.h"
#include "import-main-matcher.h"
@@ -55,13 +58,6 @@
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_ASSISTANT;
-/** Enumeration for separator checkbutton types. These are the
- * different types of checkbuttons that the user can click to
- * configure separators in a delimited file. */
-enum SEP_BUTTON_TYPES {SEP_SPACE, SEP_TAB, SEP_COMMA, SEP_COLON, SEP_SEMICOLON, SEP_HYPHEN,
- SEP_NUM_OF_TYPES
- };
-
typedef struct
{
@@ -71,15 +67,20 @@ typedef struct
gchar *starting_dir; /**< The starting directory for import file */
gchar *file_name; /**< The import file name */
+ GtkWidget *settings_combo; /**< The Settings Combo */
+ GtkWidget *combo_hbox; /**< The Settings Combo hbox */
GtkWidget *check_label; /**< The widget for the check label */
GtkWidget *check_butt; /**< The widget for the check label button */
GtkWidget *start_row_spin; /**< The widget for the start row spinner */
GtkWidget *end_row_spin; /**< The widget for the end row spinner */
GtkWidget *skip_rows; /**< The widget for Skip alternate rows from start row */
+ GtkWidget *csv_button; /**< The widget for the CSV button */
+ GtkWidget *fixed_button; /**< The widget for the Fixed Width button */
int start_row; /**< The liststore start row, smallest is 0 */
int end_row; /**< The liststore end row, max number of rows -1 */
GncCsvParseData *parse_data; /**< The actual data we are previewing */
+ CsvSettings *settings_data; /**< The settings to be saved and loaded */
GOCharmapSel *encselector; /**< The widget for selecting the encoding */
GtkCheckButton *sep_buttons[SEP_NUM_OF_TYPES]; /**< Checkbuttons for common separators */
GtkCheckButton *custom_cbutton; /**< The checkbutton for a custom separator */
@@ -148,11 +149,514 @@ void csv_import_trans_skiprows_cb (GtkWidget *checkbox, gpointer user_data);
void csv_import_trans_auto_cb (GtkWidget *cb, gpointer user_data);
void csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *info);
+void csv_import_trans_delete_settings_cb (GtkWidget *button, CsvImportTrans *info);
+void csv_import_trans_save_settings_cb (GtkWidget *button, CsvImportTrans *info);
+void csv_import_trans_changed_settings_cb (GtkWidget *button, CsvImportTrans *info);
+void csv_import_trans_load_settings (CsvImportTrans *info);
+
static void gnc_csv_preview_update_assist (CsvImportTrans* info);
+void gnc_csv_reset_preview_setting (CsvImportTrans* info, gboolean block);
gboolean preview_settings_valid (CsvImportTrans *info);
+static gboolean delete_column (CsvImportTrans* info, int col, gboolean test_only);
/*************************************************************************/
+
+/*******************************************************
+ * csv_import_trans_load_settings
+ *
+ * Load the settings from a key file
+ *******************************************************/
+void
+csv_import_trans_load_settings (CsvImportTrans *info)
+{
+ GtkTreeIter iter;
+ gchar *group = NULL, *name = NULL;
+
+ // Get the Active Selection
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(info->settings_combo), &iter))
+ {
+ GtkTreeModel *model;
+ GtkAdjustment *adj;
+ int i;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(info->settings_combo));
+ gtk_tree_model_get (model, &iter, SET_GROUP, &group, SET_NAME, &name, -1);
+
+ // Test for default selection, return
+ if (g_strcmp0 (group, NULL) == 0)
+ return;
+
+ // Load the settings from the keyfile
+ if (gnc_csv_trans_load_settings (info->settings_data, group))
+ {
+ GtkWidget *dialog;
+ const gchar *title = _("Load the Import Settings.");
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("There were problems reading some saved settings, continuing to load.\n Please review and save again."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+
+ // Set start row
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->start_row_spin));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->start_row_spin), info->settings_data->header_rows);
+
+ // Set end row
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->end_row_spin));
+ gtk_adjustment_set_upper (adj, info->num_of_rows);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->end_row_spin), info->num_of_rows - info->settings_data->footer_rows);
+
+ // Set Aternate rows
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->skip_rows), info->settings_data->skip_alt_rows);
+
+ // Set Import Format
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->csv_button), info->settings_data->csv_format);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->fixed_button), !info->settings_data->csv_format);
+
+ // This Section deals with the separators
+ if (info->settings_data->csv_format)
+ {
+ for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->sep_buttons[i]), info->settings_data->separator[i]);
+ }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->custom_cbutton), info->settings_data->custom);
+ if (info->settings_data->custom)
+ gtk_entry_set_text (GTK_ENTRY(info->custom_entry), info->settings_data->custom_entry);
+ else
+ gtk_entry_set_text (GTK_ENTRY(info->custom_entry), "");
+ }
+
+ // This section deals with the combo's and character encoding
+ gtk_combo_box_set_active (GTK_COMBO_BOX(info->date_format_combo), info->settings_data->date_active);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(info->currency_format_combo), info->settings_data->currency_active);
+ go_charmap_sel_set_encoding (info->encselector, info->settings_data->encoding);
+
+ // This section deals with the column widths
+ if ((!info->settings_data->csv_format) && (!g_strcmp0 (info->settings_data->column_widths, NULL) == 0))
+ {
+ GError *error = NULL;
+ gchar **widths;
+ int i, max_line;
+ int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
+
+ // Clear the fixed width entries, if any...
+ if (colcount != 0)
+ {
+ for (i = colcount; i >= 0; i--)
+ {
+ delete_column (info, i, FALSE);
+ }
+ }
+
+ widths = g_strsplit (info->settings_data->column_widths, ",", -1);
+ max_line = info->longest_line;
+
+ for (i=0; widths[i] != NULL; i++)
+ {
+ int charindex = 0;
+
+ if (widths[i] != NULL)
+ charindex = atoi (widths[i]);
+
+ if (max_line > charindex)
+ stf_parse_options_fixed_splitpositions_add (info->parse_data->options, charindex);
+ else
+ gnc_error_dialog (NULL, "%s", _("There was a problem with the column widths, please review."));
+
+ if (gnc_csv_parse (info->parse_data, FALSE, &error))
+ {
+ gnc_error_dialog (NULL, "%s", _("There was a problem with the column widths, please review."));
+ g_error_free (error);
+ g_free (group);
+ g_free (name);
+ return;
+ }
+ gnc_csv_preview_update_assist (info);
+ }
+ g_strfreev (widths);
+ }
+
+ // This section deals with the column types
+ if (!g_strcmp0 (info->settings_data->column_types, NULL) == 0)
+ {
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+ gchar **columns;
+ int i, t;
+ gboolean error = FALSE;
+
+ columns = g_strsplit (info->settings_data->column_types, ",", -1);
+
+ // store contains the actual strings appearing in the column types treeview.
+ store = gtk_tree_view_get_model (info->ctreeview);
+
+ // Get an iterator for the first (and only) row.
+ gtk_tree_model_get_iter_first (store, &iter);
+
+ // Even Entries are the column types / names
+ for (i=0; columns[i] != NULL; i++)
+ {
+ int s = i * 2 + 1;
+ gboolean found = FALSE;
+
+ for (t = 0; t < GNC_CSV_NUM_COL_TYPES; t++)
+ {
+ gchar *type = gnc_csv_column_type_strs[t];
+
+ // Check to see if column type is valid
+ if (g_strcmp0 (type, columns[i]) == 0)
+ {
+ /* Get the type string first. (store is arranged so that every two
+ * columns is a pair of the model used for the combobox and the
+ * string that appears, so that store looks like:
+ * model 0, string 0, model 1, string 1, ..., model ncols, string ncols. */
+ if (s < gtk_tree_model_get_n_columns (store))
+ gtk_list_store_set (GTK_LIST_STORE(store), &iter, s, columns[i], -1);
+ found = TRUE;
+ }
+ }
+ if (!found)
+ error = TRUE;
+ }
+ if (error)
+ gnc_error_dialog (NULL, "%s", _("There was a problem with the column types, please review."));
+
+ g_strfreev (columns);
+ }
+ }
+ g_free (group);
+ g_free (name);
+}
+
+
+/*******************************************************
+ * csv_import_trans_delete_settings_cb
+ *
+ * call back to delete a settings entry
+ *******************************************************/
+void
+csv_import_trans_delete_settings_cb (GtkWidget *button, CsvImportTrans *info)
+{
+ GKeyFile *keyfile;
+ GtkTreeIter iter;
+ GtkWidget *dialog;
+ gint response;
+ gchar *group = NULL, *name = NULL;
+ const gchar *title = _("Delete the Import Settings.");
+
+ // Get the Key file
+ keyfile = gnc_state_get_current ();
+
+ // Get the Active Selection
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(info->settings_combo), &iter))
+ {
+ GtkTreeModel *model;
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(info->settings_combo));
+ gtk_tree_model_get (model, &iter, SET_GROUP, &group, SET_NAME, &name, -1);
+
+ if (g_strcmp0 (group, NULL) == 0)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("You can not Delete the 'No Settings' entry."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_OK_CANCEL,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("Do you really want to delete the selection."));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response == GTK_RESPONSE_OK)
+ {
+ g_key_file_remove_group (keyfile, group, NULL);
+ gnc_csv_trans_find_settings (model);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(info->settings_combo), 0); // Default
+ gnc_csv_reset_preview_setting (info, FALSE); // Reset the widgets
+ }
+ }
+ g_free (group);
+ g_free (name);
+ }
+}
+
+
+/*******************************************************
+ * csv_import_trans_changed_settings_cb
+ *
+ * Apply settings when selection changed.
+ *******************************************************/
+void
+csv_import_trans_changed_settings_cb (GtkWidget *button, CsvImportTrans *info)
+{
+ csv_import_trans_load_settings (info);
+}
+
+
+/*******************************************************
+ * csv_import_trans_save_settings_cb
+ *
+ * Save the settings to a Key File.
+ *******************************************************/
+void
+csv_import_trans_save_settings_cb (GtkWidget *button, CsvImportTrans *info)
+{
+ GtkTreeIter iter;
+ GtkWidget *dialog;
+ GtkWidget *entry;
+ gchar *group = NULL, *name = NULL;
+ const gchar *title = _("Save the Import Settings.");
+ gboolean error = FALSE;
+ const gchar *entry_text;
+
+ // Get the Entry Text
+ entry = gtk_bin_get_child (GTK_BIN(info->settings_combo));
+ entry_text = gtk_entry_get_text (GTK_ENTRY(entry));
+
+ // If entry used, this lot is by passed.
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(info->settings_combo), &iter))
+ {
+ GtkTreeModel *model;
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(info->settings_combo));
+ gtk_tree_model_get (model, &iter, SET_GROUP, &group, SET_NAME, &name, -1);
+
+ if (g_strcmp0 (group, NULL) == 0)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("You can not save to 'No Settings'."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ error = TRUE;
+ }
+ g_free (group);
+ g_free (name);
+ }
+ else // Check for blank entry_text
+ {
+ if (strlen (entry_text) == 0 || g_strcmp0 (entry_text, NULL) == 0)
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("The settings name is blank."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ error = TRUE;
+ }
+ else // Check for entry_text in settings list
+ {
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean valid = FALSE;
+ gboolean found = FALSE;
+ gint response;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(info->settings_combo));
+
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+
+ while (valid)
+ {
+ gchar *name = NULL;
+
+ // Walk through the list, reading each row
+ gtk_tree_model_get (model, &iter, SET_NAME, &name, -1);
+
+ if (g_strcmp0 (name, entry_text) == 0)
+ found = TRUE;
+
+ g_free (name);
+
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+
+ if (found) // We have found entry_text in liststore
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_OK_CANCEL,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("Setting name already exists, over write."));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (response != GTK_RESPONSE_OK)
+ error = TRUE;
+ }
+ }
+ }
+
+ // Call save settings if we have no errors
+ if (error == FALSE)
+ {
+ int i;
+ GList *columns;
+ GList *column;
+ GtkTreeModel *store;
+ GtkTreeIter iter;
+ gchar *details = NULL;
+
+ /* This section deals with the header and rows */
+ info->settings_data->header_rows = gtk_spin_button_get_value (GTK_SPIN_BUTTON(info->start_row_spin));
+ info->settings_data->footer_rows = info->num_of_rows - gtk_spin_button_get_value (GTK_SPIN_BUTTON(info->end_row_spin));
+ info->settings_data->skip_alt_rows = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->skip_rows));
+ info->settings_data->csv_format = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csv_button));
+
+ /* This Section deals with the separators */
+ for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+ {
+ info->settings_data->separator[i] = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->sep_buttons[i]));
+ }
+ info->settings_data->custom = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->custom_cbutton));
+ info->settings_data->custom_entry = gtk_entry_get_text (GTK_ENTRY(info->custom_entry));
+
+ /* This section deals with the combo's and character encoding */
+ info->settings_data->date_active = gtk_combo_box_get_active (GTK_COMBO_BOX(info->date_format_combo));
+ info->settings_data->currency_active = gtk_combo_box_get_active (GTK_COMBO_BOX(info->currency_format_combo));
+ info->settings_data->encoding = go_charmap_sel_get_encoding (info->encselector);
+
+ /* This section deals with the Treeview column names */
+ columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(info->ctreeview));
+ // store contains the actual strings appearing in the column types treeview.
+ store = gtk_tree_view_get_model (info->ctreeview);
+ // Get an iterator for the first (and only) row.
+ gtk_tree_model_get_iter_first (store, &iter);
+
+ for (column = columns, i = 1; column; column = g_list_next (column), i = i + 2)
+ {
+ gchar *contents = NULL;
+
+ /* Get the type string first. (store is arranged so that every two
+ * columns is a pair of the model used for the combobox and the
+ * string that appears, so that store looks like:
+ * model 0, string 0, model 1, string 1, ..., model ncols, string ncols. */
+ gtk_tree_model_get (store, &iter, i, &contents, -1);
+
+ if (!details)
+ details = g_strdup (contents);
+ else
+ {
+ gchar *details_prev = details;
+ details = g_strjoin (",", details_prev, contents, NULL);
+ g_free (details_prev);
+ }
+ g_free (contents);
+ }
+ g_list_free (columns);
+
+ info->settings_data->column_types = g_strdup (details);
+ g_free (details);
+
+ /* Save the column widths in fixed mode */
+ if (info->settings_data->csv_format)
+ info->settings_data->column_widths = "5,10,15";
+ else
+ {
+ gchar *details = NULL;
+ int i = 0;
+ int number_of_splits = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
+
+ for (i = 0; i < number_of_splits - 1; i++)
+ {
+ gchar *str_width = g_strdup_printf ("%d", stf_parse_options_fixed_splitpositions_nth (info->parse_data->options, i));
+
+ if (!details)
+ details = g_strdup (str_width);
+ else
+ {
+ gchar *details_prev = details;
+ details = g_strjoin (",", details_prev, str_width, NULL);
+ g_free (details_prev);
+ }
+ g_free (str_width);
+ }
+ info->settings_data->column_widths = g_strdup (details);
+ g_free (details);
+ }
+
+ // Save the settings
+ if (!gnc_csv_trans_save_settings (info->settings_data, g_strdup (entry_text)))
+ {
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean valid = FALSE;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("The settings have been saved."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ // Update the settings store
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(info->settings_combo));
+ gnc_csv_trans_find_settings (model);
+
+ // Get the first entry in model
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ while (valid)
+ {
+ gchar *name = NULL;
+
+ // Walk through the list, reading each row
+ gtk_tree_model_get (model, &iter, SET_NAME, &name, -1);
+
+ if (g_strcmp0 (name, entry_text) == 0) // Set Active, the one Saved.
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX(info->settings_combo), &iter);
+
+ g_free (name);
+
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+ }
+ else
+ {
+ dialog = gtk_message_dialog_new (GTK_WINDOW(info->window),
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", _("There was a problem saving the settings, please try again."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ }
+ }
+}
+
+
/**************************************************
* csv_import_trans_file_chooser_confirm_cb
*
@@ -216,7 +720,7 @@ csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *inf
if (info->parse_data) // Free parse_data if we have come back here
{
gnc_csv_parse_data_free (info->parse_data);
- gnc_csv_reset_preview_setting (info);
+ gnc_csv_reset_preview_setting (info, TRUE);
}
info->parse_data = parse_data;
info->previewing_errors = FALSE; /* We're looking at all the data. */
@@ -270,7 +774,6 @@ void row_selection_update (CsvImportTrans* info)
if (valid)
gtk_list_store_set (store, &iter, 0, NULL, -1);
}
-
}
/* End of File */
@@ -1326,50 +1829,69 @@ static void gnc_csv_preview_update_assist (CsvImportTrans* info)
*
* Reset the widgets on the preview settings page
*******************************************************/
-void gnc_csv_reset_preview_setting (CsvImportTrans *info)
+void gnc_csv_reset_preview_setting (CsvImportTrans *info, gboolean block)
{
int i;
+ GtkAdjustment *adj;
+ int colcount = stf_parse_options_fixed_splitpositions_count (info->parse_data->options);
+
+ // Clear the fixed width entries, if any...
+ if (colcount != 0)
+ {
+ for (i = colcount; i >= 0; i--)
+ {
+ delete_column (info, i, FALSE);
+ }
+ }
+
+ // Reset Start Row
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->start_row_spin));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->start_row_spin), 1);
+
+ // Reset End Row
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->end_row_spin));
+ gtk_adjustment_set_upper (adj, info->num_of_rows);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->end_row_spin), info->num_of_rows);
// Reset Skip Rows
- g_signal_handlers_block_by_func (info->skip_rows, csv_import_trans_skiprows_cb, info);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->skip_rows), FALSE);
- g_signal_handlers_unblock_by_func (info->skip_rows, csv_import_trans_skiprows_cb, info);
// Reset Import Format
g_signal_handlers_block_by_func (info->csv_button, separated_or_fixed_selected, info);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->csv_button), TRUE);
g_signal_handlers_unblock_by_func (info->csv_button, separated_or_fixed_selected, info);
+ if (block) // We need to block these when we go back to the file page
+ {
+ g_signal_handlers_block_by_func (info->custom_cbutton, sep_button_clicked, info);
+ g_signal_handlers_block_by_func (info->custom_entry, sep_button_clicked, info);
+ }
+
// Reset the separators
for (i = 0; i < SEP_NUM_OF_TYPES; i++)
{
- g_signal_handlers_block_by_func (info->sep_buttons[i], sep_button_clicked, info);
+ if (block) // We need to block these when we go back to the file page
+ g_signal_handlers_block_by_func (info->sep_buttons[i], sep_button_clicked, info);
if (i == 2)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->sep_buttons[i]), TRUE);
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->sep_buttons[i]), FALSE);
- g_signal_handlers_unblock_by_func (info->sep_buttons[i], sep_button_clicked, info);
+ if (block) // Now unblock
+ g_signal_handlers_unblock_by_func (info->sep_buttons[i], sep_button_clicked, info);
}
- g_signal_handlers_block_by_func (info->custom_cbutton, sep_button_clicked, info);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->custom_cbutton), FALSE);
- g_signal_handlers_unblock_by_func (info->custom_cbutton, sep_button_clicked, info);
-
- g_signal_handlers_block_by_func (info->custom_entry, sep_button_clicked, info);
gtk_entry_set_text (GTK_ENTRY(info->custom_entry), "");
- g_signal_handlers_unblock_by_func (info->custom_entry, sep_button_clicked, info);
+
+ if (block) // Now unblock
+ {
+ g_signal_handlers_unblock_by_func (info->custom_cbutton, sep_button_clicked, info);
+ g_signal_handlers_unblock_by_func (info->custom_entry, sep_button_clicked, info);
+ }
// Reset the combo's and character encoding
- g_signal_handlers_block_by_func (info->date_format_combo, date_format_selected, info);
gtk_combo_box_set_active (GTK_COMBO_BOX(info->date_format_combo), 0);
- g_signal_handlers_unblock_by_func (info->date_format_combo, date_format_selected, info);
-
- g_signal_handlers_block_by_func (info->currency_format_combo, currency_format_selected, info);
gtk_combo_box_set_active (GTK_COMBO_BOX(info->currency_format_combo), 0);
- g_signal_handlers_unblock_by_func (info->currency_format_combo, currency_format_selected, info);
-
- g_signal_handlers_block_by_func (info->encselector, encoding_selected, info);
go_charmap_sel_set_encoding (info->encselector, "UTF-8");
- g_signal_handlers_unblock_by_func (info->encselector, encoding_selected, info);
}
@@ -1387,6 +1909,9 @@ void load_settings (CsvImportTrans *info)
info->file_name = NULL;
info->starting_dir = NULL;
+ /* Init Settings data. */
+ info->settings_data = gnc_csv_trans_new_settings_data();
+
/* The default directory for the user to select files. */
info->starting_dir = gnc_get_default_directory (GNC_PREFS_GROUP);
}
@@ -1401,6 +1926,8 @@ void
csv_import_trans_assistant_start_page_prepare (GtkAssistant *assistant,
gpointer user_data)
{
+ CsvImportTrans *info = user_data;
+
gint num = gtk_assistant_get_current_page (assistant);
GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
@@ -1414,8 +1941,10 @@ csv_import_trans_assistant_file_page_prepare (GtkAssistant *assistant,
gpointer user_data)
{
CsvImportTrans *info = user_data;
- gint num = gtk_assistant_get_current_page (assistant);
- GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
+ GtkAdjustment *adj;
+ GtkTreeModel *settings_store;
+ gint num = gtk_assistant_get_current_page (assistant);
+ GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
info->account_picker->auto_create = TRUE; /* Step over account page if we find matching online id */
info->previewing_errors = FALSE; /* We're looking at all the data. */
@@ -1425,6 +1954,19 @@ csv_import_trans_assistant_file_page_prepare (GtkAssistant *assistant,
if (info->starting_dir)
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
+ /* Reset start row to first row 1 */
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->start_row_spin));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->start_row_spin), 1);
+
+ /* Reset upper value to 999 */
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->end_row_spin));
+ gtk_adjustment_set_upper (adj, 999);
+
+ /* Get settings store and populate */
+ settings_store = gtk_combo_box_get_model (GTK_COMBO_BOX(info->settings_combo));
+ gnc_csv_trans_find_settings (settings_store);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(info->settings_combo), 0);
+
/* Disable the Forward Assistant Button */
gtk_assistant_set_page_complete (assistant, page, FALSE);
}
@@ -1455,7 +1997,12 @@ csv_import_trans_assistant_preview_page_prepare (GtkAssistant *assistant,
gtk_widget_show (GTK_WIDGET(info->instructions_image));
gtk_widget_show (GTK_WIDGET(info->instructions_label));
- /* Set spin buttons not sensative */
+ /* Reset start row */
+ adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->start_row_spin));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->start_row_spin), 1);
+
+ /* Set spin buttons and settings combo hbox not sensative */
+ gtk_widget_set_sensitive (info->combo_hbox, FALSE);
gtk_widget_set_sensitive (info->start_row_spin, FALSE);
gtk_widget_set_sensitive (info->end_row_spin, FALSE);
gtk_widget_set_sensitive (info->skip_rows, FALSE);
@@ -1477,10 +2024,6 @@ csv_import_trans_assistant_preview_page_prepare (GtkAssistant *assistant,
gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->end_row_spin), info->num_of_rows);
}
- /* Set start row */
- adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(info->start_row_spin));
- gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->start_row_spin), 1);
-
/* Update the row selection highlight */
row_selection_update (info);
}
@@ -1737,6 +2280,9 @@ csv_import_trans_close_handler (gpointer user_data)
if (!(info->parse_data == NULL))
gnc_csv_parse_data_free (info->parse_data);
+ if (!(info->settings_data == NULL))
+ gnc_csv_trans_settings_data_free (info->settings_data);
+
if (!(info->account_picker == NULL))
info->account_picker = NULL;
@@ -1756,7 +2302,8 @@ csv_import_trans_assistant_create (CsvImportTrans *info)
GtkBuilder *builder;
GtkWidget *window;
GtkWidget *box;
- GtkWidget *button, *csv_button, *h_box;
+ GtkWidget *button, *h_box;
+ GtkWidget *save_button, *del_button;
builder = gtk_builder_new();
gnc_builder_add_from_file (builder , "assistant-csv-trans-import.glade", "start_row_adj");
@@ -1809,7 +2356,7 @@ csv_import_trans_assistant_create (CsvImportTrans *info)
g_signal_connect (G_OBJECT(button), "clicked",
G_CALLBACK(csv_import_trans_file_chooser_confirm_cb), info);
- box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
+ box = GTK_WIDGET(gtk_builder_get_object (builder, "file_page"));
gtk_box_pack_start (GTK_BOX(box), info->file_chooser, TRUE, TRUE, 6);
gtk_widget_show (info->file_chooser);
@@ -1823,11 +2370,40 @@ csv_import_trans_assistant_create (CsvImportTrans *info)
"hyphen_cbutton"
};
GtkContainer *date_format_container, *currency_format_container;
- int i;
+ int i;
+ GtkTable *enctable;
+ GtkListStore *settings_store;
- /* The table containing info->encselector and the separator configuration widgets */
- GtkTable* enctable;
+ // Add Settings combo
+ settings_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ info->settings_combo = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL(settings_store));
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(info->settings_combo), SET_NAME);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(info->settings_combo), 0);
+
+ info->combo_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "combo_hbox"));
+ gtk_box_pack_start (GTK_BOX(info->combo_hbox), info->settings_combo, FALSE, FALSE, 6);
+ gtk_widget_show (info->settings_combo);
+ g_signal_connect (G_OBJECT(info->settings_combo), "changed",
+ G_CALLBACK(csv_import_trans_changed_settings_cb), (gpointer)info);
+
+ // Add Save Settings button
+ save_button = gtk_button_new_with_label (_("Save Settings"));
+ gtk_box_pack_start (GTK_BOX(info->combo_hbox), save_button, FALSE, FALSE, 6);
+ gtk_widget_show (save_button);
+
+ g_signal_connect (G_OBJECT(save_button), "clicked",
+ G_CALLBACK(csv_import_trans_save_settings_cb), (gpointer)info);
+
+ // Add Deelete Settings button
+ del_button = gtk_button_new_with_label (_("Delete Settings"));
+ gtk_box_pack_start (GTK_BOX(info->combo_hbox), del_button, FALSE, FALSE, 6);
+ gtk_widget_show (del_button);
+
+ g_signal_connect (G_OBJECT(del_button), "clicked",
+ G_CALLBACK(csv_import_trans_delete_settings_cb), (gpointer)info);
+
+ /* The table containing info->encselector and the separator configuration widgets */
info->start_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "start_row"));
info->end_row_spin = GTK_WIDGET(gtk_builder_get_object (builder, "end_row"));
info->skip_rows = GTK_WIDGET(gtk_builder_get_object (builder, "skip_rows"));
@@ -1906,8 +2482,9 @@ csv_import_trans_assistant_create (CsvImportTrans *info)
gtk_widget_show_all (GTK_WIDGET(currency_format_container));
/* Connect the CSV/Fixed-Width radio button event handler. */
- csv_button = GTK_WIDGET(gtk_builder_get_object (builder, "csv_button"));
- g_signal_connect (csv_button, "toggled",
+ info->csv_button = GTK_WIDGET(gtk_builder_get_object (builder, "csv_button"));
+ info->fixed_button = GTK_WIDGET(gtk_builder_get_object (builder, "fixed_button"));
+ g_signal_connect (info->csv_button, "toggled",
G_CALLBACK(separated_or_fixed_selected), (gpointer)info);
/* Load the data treeview and connect it to its resizing event handler. */
@@ -1935,7 +2512,7 @@ csv_import_trans_assistant_create (CsvImportTrans *info)
info->match_label = GTK_WIDGET(gtk_builder_get_object (builder, "match_label"));
/* Summary Page */
- info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));
+ info->summary_label = GTK_WIDGET(gtk_builder_get_object (builder, "summary_label"));
g_signal_connect (G_OBJECT(window), "destroy",
G_CALLBACK (csv_import_trans_assistant_destroy_cb), info);
diff --git a/src/import-export/csv-imp/assistant-csv-trans-import.glade b/src/import-export/csv-imp/assistant-csv-trans-import.glade
index d61fb30..9870ead 100644
--- a/src/import-export/csv-imp/assistant-csv-trans-import.glade
+++ b/src/import-export/csv-imp/assistant-csv-trans-import.glade
@@ -22,7 +22,9 @@ All transactions imported will be associated to one account for each import and
Various options exist for specifying the delimiter as well as a fixed width option. With the fixed width option, double click on the bar above the displayed rows to set the column width.
-There is an option for specifying the start row, end row and an option to skip alternate rows begining from the start row. These can be used if you have some header text, a points collected status row or multiple accounts in the same file.</property>
+There is an option for specifying the start row, end row and an option to skip alternate rows begining from the start row. These can be used if you have some header text, a points collected status row or multiple accounts in the same file.
+
+On the preview page you can Load and Save the settings. To save the settings, select a previously saved entry or replace the text and press the Save Settings button.</property>
<property name="wrap">True</property>
</object>
<packing>
@@ -51,9 +53,6 @@ Select location and file name for the Import, then click 'OK'...
<property name="position">0</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
</object>
<packing>
<property name="title" translatable="yes">Select File for Import</property>
@@ -67,546 +66,576 @@ Select location and file name for the Import, then click 'OK'...
<property name="border_width">12</property>
<property name="spacing">2</property>
<child>
- <object class="GtkHBox" id="hbox1">
+ <object class="GtkFrame" id="frame5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkVBox" id="vbox1">
+ <object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <object class="GtkHBox" id="hbox6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Start import on row </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="start_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- <property name="adjustment">start_row_adj</property>
- <signal name="value-changed" handler="csv_import_trans_srow_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label10">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes"> and stop on row </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="end_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
- <property name="adjustment">end_row_adj</property>
- <signal name="value-changed" handler="csv_import_trans_erow_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="skip_rows">
- <property name="label" translatable="yes">Skip alternate rows from the start row</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="csv_import_trans_skiprows_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkHSeparator" id="hseparator7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">8</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Data type: </property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="csv_button">
- <property name="label" translatable="yes">Separated</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="radiobutton2">
- <property name="label" translatable="yes">Fixed-Width</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
- <property name="group">csv_button</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkHSeparator" id="hseparator6">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkFrame" id="frame2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="date_format_container">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="left_padding">12</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Date Format</property>
- <property name="use_markup">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkAlignment" id="currency_format_container">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="left_padding">12</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Currency format</property>
- <property name="use_markup">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">5</property>
- </packing>
- </child>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">12</property>
<child>
- <object class="GtkHSeparator" id="hseparator3">
+ <object class="GtkHBox" id="combo_hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- <property name="position">6</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
</child>
+ <child type="label">
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"> Load and Save Settings </property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkVBox" id="vbox3">
+ <object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="left_padding">12</property>
<child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkTable" id="enctable">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Encoding: </property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHSeparator" id="hseparator1">
+ <object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">5</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="left_padding">12</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkTable" id="table1">
+ <object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">3</property>
- <property name="n_columns">3</property>
- <property name="column_spacing">3</property>
- <property name="row_spacing">3</property>
- <property name="homogeneous">True</property>
<child>
- <object class="GtkCheckButton" id="space_cbutton">
- <property name="label" translatable="yes">Space</property>
+ <object class="GtkHBox" id="hbox6">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Start import on row </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="start_row">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">â—</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">start_row_adj</property>
+ <signal name="value-changed" handler="csv_import_trans_srow_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"> and stop on row </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="end_row">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="invisible_char">â—</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">end_row_adj</property>
+ <signal name="value-changed" handler="csv_import_trans_erow_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="tab_cbutton">
- <property name="label" translatable="yes">Tab</property>
+ <object class="GtkCheckButton" id="skip_rows">
+ <property name="label" translatable="yes">Skip alternate rows from the start row</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
<property name="draw_indicator">True</property>
+ <signal name="toggled" handler="csv_import_trans_skiprows_cb" swapped="no"/>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="comma_cbutton">
- <property name="label" translatable="yes">Comma (,)</property>
+ <object class="GtkHSeparator" id="hseparator2">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="colon_cbutton">
- <property name="label" translatable="yes">Colon (:)</property>
+ <object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Data type: </property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="csv_button">
+ <property name="label" translatable="yes">Separated</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="fixed_button">
+ <property name="label" translatable="yes">Fixed-Width</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">csv_button</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="semicolon_cbutton">
- <property name="label" translatable="yes">Semicolon (;)</property>
+ <object class="GtkHSeparator" id="hseparator6">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">5</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="hyphen_cbutton">
- <property name="label" translatable="yes">Hyphen (-)</property>
+ <object class="GtkHBox" id="hbox7">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFrame" id="frame2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="date_format_container">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="bottom_padding">5</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Date Format</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="currency_format_container">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="bottom_padding">5</property>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Currency format</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkTable" id="enctable">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Encoding: </property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="custom_cbutton">
- <property name="label" translatable="yes">Custom</property>
+ <object class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="use_action_appearance">False</property>
- <property name="draw_indicator">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkEntry" id="custom_entry">
+ <object class="GtkFrame" id="frame1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="invisible_char">●</property>
- <property name="invisible_char_set">True</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">True</property>
- <property name="secondary_icon_sensitive">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="bottom_padding">5</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">3</property>
+ <property name="column_spacing">3</property>
+ <property name="row_spacing">3</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkCheckButton" id="space_cbutton">
+ <property name="label" translatable="yes">Space</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="tab_cbutton">
+ <property name="label" translatable="yes">Tab</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="comma_cbutton">
+ <property name="label" translatable="yes">Comma (,)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="colon_cbutton">
+ <property name="label" translatable="yes">Colon (:)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="semicolon_cbutton">
+ <property name="label" translatable="yes">Semicolon (;)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="hyphen_cbutton">
+ <property name="label" translatable="yes">Hyphen (-)</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="custom_cbutton">
+ <property name="label" translatable="yes">Custom</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="custom_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="invisible_char">â—</property>
+ <property name="invisible_char_set">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Separators</property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">3</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Separators</property>
- <property name="use_markup">True</property>
- </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkHSeparator" id="hseparator2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">6</property>
- <property name="position">3</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_markup">True</property>
+ </object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -646,7 +675,7 @@ Select location and file name for the Import, then click 'OK'...
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -698,7 +727,7 @@ Select location and file name for the Import, then click 'OK'...
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -710,7 +739,6 @@ Select location and file name for the Import, then click 'OK'...
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
<property name="xalign">1</property>
<property name="image_position">right</property>
<property name="active">True</property>
@@ -743,7 +771,7 @@ Select location and file name for the Import, then click 'OK'...
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
- <property name="position">3</property>
+ <property name="position">5</property>
</packing>
</child>
</object>
@@ -757,12 +785,6 @@ Select location and file name for the Import, then click 'OK'...
<property name="can_focus">False</property>
<property name="border_width">12</property>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkLabel" id="account_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -848,6 +870,7 @@ More information can be displayed by using the help button.</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">label</property>
<property name="use_markup">True</property>
+ <property name="wrap">True</property>
</object>
<packing>
<property name="expand">True</property>
diff --git a/src/import-export/csv-imp/gnc-csv-trans-settings.c b/src/import-export/csv-imp/gnc-csv-trans-settings.c
new file mode 100644
index 0000000..54fc2a5
--- /dev/null
+++ b/src/import-export/csv-imp/gnc-csv-trans-settings.c
@@ -0,0 +1,353 @@
+/*******************************************************************\
+ * gnc-csv-trans-settings.c -- Save and Load CSV Import Settings *
+ * *
+ * Copyright (C) 2014 Robert Fewell *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This program 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact: *
+ * *
+ * Free Software Foundation Voice: +1-617-542-5942 *
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
+ * Boston, MA 02110-1301, USA gnu at gnu.org *
+\********************************************************************/
+/** @file gnc-csv-trans-settings.c
+ @brief CSV Import Settings
+ @author Copyright (c) 2014 Robert Fewell
+*/
+#include "config.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "gnc-state.h"
+#include "gnc-csv-trans-settings.h"
+
+#define CSV_GROUP_PREFIX "CSV - "
+#define CSV_NAME "Name"
+#define CSV_FORMAT "CsvFormat"
+#define CSV_ALT_ROWS "AltRows"
+#define CSV_START_ROW "StartRow"
+#define CSV_END_ROWS "EndRows"
+
+#define CSV_SEP "Separator"
+
+#define CSV_CUSTOM "Custom"
+#define CSV_CUSTOM_ENTRY "CustomEntry"
+
+#define CSV_DATE "DateActive"
+#define CSV_CURRENCY "CurrencyActive"
+
+#define CSV_ENCODING "Encoding"
+#define CSV_COL_TYPES "ColumnTypes"
+#define CSV_COL_WIDTHS "ColumnWidths"
+
+
+/**************************************************
+ * gnc_csv_trans_new_settings_data
+ *
+ * Create CsvSettings structure and set defaults
+ **************************************************/
+CsvSettings * gnc_csv_trans_new_settings_data (void)
+{
+ CsvSettings* settings_data = g_new (CsvSettings, 1);
+ int i;
+
+ settings_data->header_rows = 1;
+ settings_data->skip_alt_rows = FALSE;
+ settings_data->csv_format = TRUE;
+
+ settings_data->encoding = "UTF-8";
+
+ for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+ {
+ settings_data->separator[i] = FALSE;
+ }
+
+ settings_data->custom = FALSE;
+ settings_data->date_active = 0;
+ settings_data->currency_active = 0;
+
+ return settings_data;
+}
+
+
+/**************************************************
+ * gnc_csv_trans_settings_data_free
+ *
+ * settings_data whose memory will be freed
+ **************************************************/
+void gnc_csv_trans_settings_data_free (CsvSettings* settings_data)
+{
+ /* All non-NULL pointers that have been initialized and must be freed. */
+ g_free (settings_data);
+}
+
+
+/**************************************************
+ * gnc_csv_trans_find_settings
+ *
+ * find the setting entries in a key file
+ **************************************************/
+void
+gnc_csv_trans_find_settings (GtkTreeModel *settings_store)
+{
+ GtkTreeIter iter;
+ GKeyFile *keyfile;
+ gchar **groups = NULL;
+ gint i;
+ gsize grouplenght;
+ GError *key_error = NULL;
+
+ // Get the Key file
+ keyfile = gnc_state_get_current ();
+
+ // Find all Groups
+ groups = g_key_file_get_groups (keyfile, &grouplenght);
+
+ // Clear the list store
+ gtk_list_store_clear (GTK_LIST_STORE(settings_store));
+
+ // Append the default entry
+ gtk_list_store_append (GTK_LIST_STORE(settings_store), &iter);
+ gtk_list_store_set (GTK_LIST_STORE(settings_store), &iter, SET_GROUP, NULL, SET_NAME, _("No Settings"), -1);
+
+ // Search all Groups for ones starting with prefix
+ for (i=0; i < grouplenght; i++)
+ {
+ if (g_str_has_prefix (groups[i], CSV_GROUP_PREFIX))
+ {
+ gchar *name = g_key_file_get_string (keyfile, groups[i], CSV_NAME, &key_error);
+
+ if (key_error == NULL)
+ {
+ gtk_list_store_append (GTK_LIST_STORE(settings_store), &iter);
+ gtk_list_store_set (GTK_LIST_STORE(settings_store), &iter, SET_GROUP, groups[i], SET_NAME, name, -1);
+ }
+ else
+ {
+ g_warning ("Error reading group '%s' name '%s': %s", groups[i], CSV_NAME, key_error->message);
+ g_clear_error (&key_error);
+ }
+ g_free (name);
+ }
+ }
+ // free the strings
+ g_strfreev (groups);
+}
+
+
+/**************************************************
+ * load_error
+ *
+ * record the error in the log file
+ **************************************************/
+static gboolean
+load_error (GError **key_error, gchar *group)
+{
+ GError *kerror;
+ kerror = g_error_copy (*key_error);
+ g_warning ("Error reading group '%s' : %s", group, kerror->message);
+ g_clear_error (key_error);
+ g_error_free (kerror);
+ return TRUE;
+}
+
+/**************************************************
+ * gnc_csv_trans_load_settings
+ *
+ * load the settings from a key file
+ **************************************************/
+gboolean
+gnc_csv_trans_load_settings (CsvSettings *settings_data, gchar *group)
+{
+ GKeyFile *keyfile;
+ gint i;
+ GError *key_error = NULL;
+ gboolean key_boolean = FALSE;
+ int key_int = 0;
+ gchar *key_char = NULL;
+ gboolean error = FALSE;
+
+ // Get the Key file
+ keyfile = gnc_state_get_current ();
+
+ key_int = g_key_file_get_integer (keyfile, group, CSV_START_ROW, &key_error);
+ settings_data->header_rows = (key_error) ? 1 : key_int;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ key_int = g_key_file_get_integer (keyfile, group, CSV_END_ROWS, &key_error);
+ settings_data->footer_rows = (key_error) ? 0 : key_int;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ key_boolean = g_key_file_get_boolean (keyfile, group, CSV_ALT_ROWS, &key_error);
+ settings_data->skip_alt_rows = (key_error) ? FALSE : key_boolean;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ key_boolean = g_key_file_get_boolean (keyfile, group, CSV_FORMAT, &key_error);
+ settings_data->csv_format = (key_error) ? TRUE : key_boolean;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+ {
+ gchar *sep;
+ sep = g_strdup_printf ("%s%d", CSV_SEP, i);
+ key_boolean = g_key_file_get_boolean (keyfile, group, sep, &key_error);
+ settings_data->separator[i] = (key_error) ? FALSE : key_boolean;
+ if (key_error)
+ error = load_error (&key_error, group);
+ g_free (sep);
+ }
+
+ key_boolean = g_key_file_get_boolean (keyfile, group, CSV_CUSTOM, &key_error);
+ settings_data->custom = (key_error) ? FALSE : key_boolean;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ settings_data->custom_entry = g_key_file_get_string (keyfile, group, CSV_CUSTOM_ENTRY, &key_error);
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ key_int = g_key_file_get_integer (keyfile, group, CSV_DATE, &key_error);
+ settings_data->date_active = (key_error) ? 0 : key_int;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ key_int = g_key_file_get_integer (keyfile, group, CSV_CURRENCY, &key_error);
+ settings_data->currency_active = (key_error) ? 0 : key_int;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ key_char = g_key_file_get_string (keyfile, group, CSV_ENCODING, &key_error);
+ settings_data->encoding = (key_error) ? "UTF-8" : key_char;
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ settings_data->column_types = g_key_file_get_string (keyfile, group, CSV_COL_TYPES, &key_error);
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ settings_data->column_widths = g_key_file_get_string (keyfile, group, CSV_COL_WIDTHS, &key_error);
+ if (key_error)
+ error = load_error (&key_error, group);
+
+ g_free (key_char);
+ return error;
+}
+
+
+/**************************************************
+ * gnc_csv_trans_save_settings
+ *
+ * save settings to a key file
+ **************************************************/
+gboolean
+gnc_csv_trans_save_settings (CsvSettings *settings_data, gchar *settings_name)
+{
+ GKeyFile *keyfile;
+ gchar **groups = NULL;
+ gint i;
+ gsize grouplenght;
+ gchar *group = NULL;
+ gchar *test_string = NULL;
+ GError *key_error = NULL;
+ gboolean error = FALSE;
+
+ // Get the Key file
+ keyfile = gnc_state_get_current ();
+
+ // Find all Groups
+ groups = g_key_file_get_groups (keyfile, &grouplenght);
+
+ // Search all Groups for ones starting with prefix
+ for (i=0; i < grouplenght; i++)
+ {
+ if (g_str_has_prefix (groups[i], CSV_GROUP_PREFIX))
+ {
+ gchar *name = g_key_file_get_string (keyfile, groups[i], CSV_NAME, NULL);
+
+ if (g_strcmp0 (name, settings_name) == 0)
+ group = g_strdup (groups[i]);
+
+ g_free (name);
+ }
+ }
+
+ // group is NULL, saving to a new group, create a guid
+ if (g_strcmp0 (group, NULL) == 0)
+ {
+ GncGUID *settings_guid;
+ gchar *string_guid;
+
+ settings_guid = guid_new ();
+ string_guid = guid_to_string (settings_guid);
+
+ group = g_strconcat (CSV_GROUP_PREFIX, string_guid, NULL);
+
+ g_free (string_guid);
+ guid_free (settings_guid);
+ }
+
+ // Start Saving the settings
+ g_key_file_set_string (keyfile, group, CSV_NAME, settings_name);
+
+ g_key_file_set_integer (keyfile, group, CSV_START_ROW, settings_data->header_rows);
+ g_key_file_set_integer (keyfile, group, CSV_END_ROWS, settings_data->footer_rows);
+ g_key_file_set_boolean (keyfile, group, CSV_ALT_ROWS, settings_data->skip_alt_rows);
+ g_key_file_set_boolean (keyfile, group, CSV_FORMAT, settings_data->csv_format);
+
+ for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+ {
+ gchar *sep;
+ sep = g_strdup_printf ("%s%d", CSV_SEP, i);
+ g_key_file_set_boolean (keyfile, group, sep, settings_data->separator[i]);
+ g_free (sep);
+ }
+
+ g_key_file_set_boolean (keyfile, group, CSV_CUSTOM, settings_data->custom);
+ g_key_file_set_string (keyfile, group, CSV_CUSTOM_ENTRY, settings_data->custom_entry);
+
+ g_key_file_set_integer (keyfile, group, CSV_DATE, settings_data->date_active);
+ g_key_file_set_integer (keyfile, group, CSV_CURRENCY, settings_data->currency_active);
+
+ g_key_file_set_string (keyfile, group, CSV_ENCODING, settings_data->encoding);
+
+ g_key_file_set_string (keyfile, group, CSV_COL_TYPES, settings_data->column_types);
+
+ g_key_file_set_string (keyfile, group, CSV_COL_WIDTHS, settings_data->column_widths);
+
+ // free the strings
+ g_free (settings_name);
+ g_strfreev (groups);
+
+ // Do a test read of column types
+ test_string = g_key_file_get_string (keyfile, group, CSV_COL_TYPES, &key_error);
+
+ if ((key_error) || (!g_strcmp0 (test_string, settings_data->column_types) == 0))
+ {
+ if (key_error)
+ {
+ g_warning ("Error reading group %s key %s: %s", group, CSV_COL_TYPES, key_error->message);
+ g_error_free (key_error);
+ }
+ else
+ g_warning ("Error comparing group %s key %s: '%s' and '%s'", group, CSV_COL_TYPES, test_string, group);
+ error = TRUE;
+ }
+ g_free (group);
+ g_free (test_string);
+ return error;
+}
diff --git a/src/import-export/csv-imp/gnc-csv-trans-settings.h b/src/import-export/csv-imp/gnc-csv-trans-settings.h
new file mode 100644
index 0000000..197243a
--- /dev/null
+++ b/src/import-export/csv-imp/gnc-csv-trans-settings.h
@@ -0,0 +1,100 @@
+/*******************************************************************\
+ * gnc-csv-trans-settings.h -- Save and Load CSV Import Settings *
+ * *
+ * Copyright (C) 2014 Robert Fewell *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 2 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This program 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact: *
+ * *
+ * Free Software Foundation Voice: +1-617-542-5942 *
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
+ * Boston, MA 02110-1301, USA gnu at gnu.org *
+\********************************************************************/
+/** @file gnc-csv-trans-settings.h
+ @brief CSV Import Settings
+ @author Copyright (c) 2014 Robert Fewell
+*/
+#ifndef GNC_CSV_TRANS_SETTINGS_H
+#define GNC_CSV_TRANS_SETTINGS_H
+
+/** Enumeration for separator checkbutton types. These are the
+ * different types of checkbuttons that the user can click to
+ * configure separators in a delimited file. */
+enum SEP_BUTTON_TYPES {SEP_SPACE, SEP_TAB, SEP_COMMA, SEP_COLON, SEP_SEMICOLON, SEP_HYPHEN,
+ SEP_NUM_OF_TYPES};
+
+/** Enumeration for the settings combo's */
+enum SETTINGS_COL {SET_GROUP, SET_NAME};
+
+typedef struct
+{
+ int header_rows; // Number of header rows
+ int footer_rows; // Number of footer rows
+ gboolean csv_format; // CSV import Format
+ gboolean skip_alt_rows; // Skip alternate rows
+
+ const gchar *encoding; // File encoding
+
+ gboolean separator[SEP_NUM_OF_TYPES]; // The seperators
+
+ gboolean custom; // Custom entry set
+ const gchar *custom_entry; // Custom Entry
+
+ int date_active; // Date Active id
+ int currency_active; // Currency Active id
+ const gchar *column_types; // The Column types in order
+ const gchar *column_widths; // The Column widths
+} CsvSettings;
+
+/** Finds CSV settings entries in the key file and populates the
+ * tree model.
+ *
+ * @param settings_store The liststore that is used for the combo's
+ * which holds the key name and visual text.
+ */
+void gnc_csv_trans_find_settings (GtkTreeModel *settings_store);
+
+/** Save the gathered widget properties to a key File.
+ *
+ * @param settings_data The settings structure where all the settings
+ * are located.
+ *
+ * @param settings_name The name the settings will be stored under.
+ *
+ * @return TRUE if there was a problem in saving.
+ */
+gboolean gnc_csv_trans_save_settings (CsvSettings *settings_data, gchar *settings_name);
+
+/** Load the widget properties from a key File.
+ *
+ * @param settings_data The settings structure where all the settings
+ * are located.
+ *
+ * @param group The group name where the settings are stored in the
+ * key file.
+ *
+ * @return TRUE if there was a problem.
+ */
+gboolean gnc_csv_trans_load_settings (CsvSettings *settings_data, gchar *group);
+
+/** Create a new CsvSettings structure and set default values.
+ *
+ * @return CsvSettings settings structure.
+ */
+CsvSettings * gnc_csv_trans_new_settings_data (void);
+
+/** Free the CsvSettings structure.
+ */
+void gnc_csv_trans_settings_data_free (CsvSettings *settings_data);
+
+#endif
commit eec86eec80e4519a553b0539ace4bf6cb9d5b3df
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Wed Nov 19 11:15:25 2014 +0000
Bug 679791 - Import Template for importing CSV files - part 1.
This patch fixes the resetting of the widgets on the setting
preview page when you navigate back to the file selection page
in the assistant.
diff --git a/src/import-export/csv-imp/assistant-csv-trans-import.c b/src/import-export/csv-imp/assistant-csv-trans-import.c
index 0c1e8a4..6badfc6 100644
--- a/src/import-export/csv-imp/assistant-csv-trans-import.c
+++ b/src/import-export/csv-imp/assistant-csv-trans-import.c
@@ -176,10 +176,14 @@ csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *inf
{
gchar *filepath = gnc_uri_get_path (file_name);
gchar *filedir = g_path_get_dirname (filepath);
+ if (info->starting_dir)
+ g_free (info->starting_dir);
info->starting_dir = g_strdup (filedir);
g_free (filedir);
g_free (filepath);
+ if (info->file_name)
+ g_free (info->file_name);
info->file_name = g_strdup (file_name);
error = NULL;
/* Load the file into parse_data. */
@@ -190,6 +194,7 @@ csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *inf
gnc_error_dialog (NULL, "%s", error->message);
if (error->code == GNC_CSV_FILE_OPEN_ERR)
{
+ g_free (file_name);
gnc_csv_parse_data_free (parse_data);
return;
}
@@ -208,6 +213,11 @@ csv_import_trans_file_chooser_confirm_cb (GtkWidget *button, CsvImportTrans *inf
}
else
{
+ if (info->parse_data) // Free parse_data if we have come back here
+ {
+ gnc_csv_parse_data_free (info->parse_data);
+ gnc_csv_reset_preview_setting (info);
+ }
info->parse_data = parse_data;
info->previewing_errors = FALSE; /* We're looking at all the data. */
info->approved = FALSE; /* This is FALSE until the user clicks "OK". */
@@ -547,6 +557,10 @@ static void encoding_selected (GOCharmapSel* selector, const char* encoding,
}
gnc_csv_preview_update_assist (info);
+
+ /* Refresh the row highlighting */
+ row_selection_update (info);
+
info->encoding_selected_called = FALSE;
}
else /* If this is the first call of the function ... */
@@ -675,6 +689,9 @@ make_new_column (CsvImportTrans* info, int col, int dx, gboolean test_only)
return FALSE;
}
gnc_csv_preview_update_assist (info);
+
+ /* Refresh the row highlighting */
+ row_selection_update (info);
}
return TRUE;
@@ -709,6 +726,9 @@ widen_column (CsvImportTrans* info, int col, gboolean test_only)
return FALSE;
}
gnc_csv_preview_update_assist (info);
+
+ /* Refresh the row highlighting */
+ row_selection_update (info);
}
return TRUE;
}
@@ -741,6 +761,9 @@ narrow_column (CsvImportTrans* info, int col, gboolean test_only)
return FALSE;
}
gnc_csv_preview_update_assist (info);
+
+ /* Refresh the row highlighting */
+ row_selection_update (info);
}
return TRUE;
}
@@ -763,6 +786,9 @@ delete_column (CsvImportTrans* info, int col, gboolean test_only)
return FALSE;
}
gnc_csv_preview_update_assist (info);
+
+ /* Refresh the row highlighting */
+ row_selection_update (info);
}
return TRUE;
}
@@ -1296,6 +1322,58 @@ static void gnc_csv_preview_update_assist (CsvImportTrans* info)
/*******************************************************
+ * gnc_csv_reset_preview_setting
+ *
+ * Reset the widgets on the preview settings page
+ *******************************************************/
+void gnc_csv_reset_preview_setting (CsvImportTrans *info)
+{
+ int i;
+
+ // Reset Skip Rows
+ g_signal_handlers_block_by_func (info->skip_rows, csv_import_trans_skiprows_cb, info);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->skip_rows), FALSE);
+ g_signal_handlers_unblock_by_func (info->skip_rows, csv_import_trans_skiprows_cb, info);
+
+ // Reset Import Format
+ g_signal_handlers_block_by_func (info->csv_button, separated_or_fixed_selected, info);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->csv_button), TRUE);
+ g_signal_handlers_unblock_by_func (info->csv_button, separated_or_fixed_selected, info);
+
+ // Reset the separators
+ for (i = 0; i < SEP_NUM_OF_TYPES; i++)
+ {
+ g_signal_handlers_block_by_func (info->sep_buttons[i], sep_button_clicked, info);
+ if (i == 2)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->sep_buttons[i]), TRUE);
+ else
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->sep_buttons[i]), FALSE);
+ g_signal_handlers_unblock_by_func (info->sep_buttons[i], sep_button_clicked, info);
+ }
+ g_signal_handlers_block_by_func (info->custom_cbutton, sep_button_clicked, info);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(info->custom_cbutton), FALSE);
+ g_signal_handlers_unblock_by_func (info->custom_cbutton, sep_button_clicked, info);
+
+ g_signal_handlers_block_by_func (info->custom_entry, sep_button_clicked, info);
+ gtk_entry_set_text (GTK_ENTRY(info->custom_entry), "");
+ g_signal_handlers_unblock_by_func (info->custom_entry, sep_button_clicked, info);
+
+ // Reset the combo's and character encoding
+ g_signal_handlers_block_by_func (info->date_format_combo, date_format_selected, info);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(info->date_format_combo), 0);
+ g_signal_handlers_unblock_by_func (info->date_format_combo, date_format_selected, info);
+
+ g_signal_handlers_block_by_func (info->currency_format_combo, currency_format_selected, info);
+ gtk_combo_box_set_active (GTK_COMBO_BOX(info->currency_format_combo), 0);
+ g_signal_handlers_unblock_by_func (info->currency_format_combo, currency_format_selected, info);
+
+ g_signal_handlers_block_by_func (info->encselector, encoding_selected, info);
+ go_charmap_sel_set_encoding (info->encselector, "UTF-8");
+ g_signal_handlers_unblock_by_func (info->encselector, encoding_selected, info);
+}
+
+
+/*******************************************************
* load_settings
*
* load the default settings for the assistant
Summary of changes:
po/POTFILES.in | 1 +
src/import-export/csv-imp/Makefile.am | 6 +-
.../csv-imp/assistant-csv-trans-import.c | 701 ++++++++++++++-
.../csv-imp/assistant-csv-trans-import.glade | 949 +++++++++++----------
src/import-export/csv-imp/gnc-csv-trans-settings.c | 353 ++++++++
src/import-export/csv-imp/gnc-csv-trans-settings.h | 100 +++
6 files changed, 1622 insertions(+), 488 deletions(-)
create mode 100644 src/import-export/csv-imp/gnc-csv-trans-settings.c
create mode 100644 src/import-export/csv-imp/gnc-csv-trans-settings.h
More information about the gnucash-changes
mailing list