mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
This patch just changes the white space to be of a consistent format.
This commit is contained in:
parent
ba1f8cb1c6
commit
ea03301651
@ -65,9 +65,9 @@ void csv_export_assistant_file_page_prepare (GtkAssistant *assistant, gpointer u
|
||||
void csv_export_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer user_data);
|
||||
void csv_export_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
|
||||
|
||||
void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data );
|
||||
void csv_export_sep_cb (GtkWidget *radio, gpointer user_data );
|
||||
void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data );
|
||||
void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data);
|
||||
void csv_export_sep_cb (GtkWidget *radio, gpointer user_data);
|
||||
void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data);
|
||||
|
||||
void csv_export_show_range_cb (GtkRadioButton *button, gpointer user_data);
|
||||
void csv_export_start_date_cb (GtkWidget *radio, gpointer user_data);
|
||||
@ -115,11 +115,11 @@ csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info)
|
||||
|
||||
gtk_assistant_set_page_complete (assistant, page, FALSE);
|
||||
|
||||
file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
|
||||
file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(info->file_chooser));
|
||||
|
||||
if (file_name)
|
||||
{
|
||||
if (g_file_test(file_name, G_FILE_TEST_EXISTS ))
|
||||
if (g_file_test (file_name, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
const char *format = _("The file %s already exists. "
|
||||
"Are you sure you want to overwrite it?");
|
||||
@ -129,25 +129,25 @@ csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info)
|
||||
return;
|
||||
}
|
||||
|
||||
info->file_name = g_strdup(file_name);
|
||||
info->file_name = g_strdup (file_name);
|
||||
gtk_assistant_set_page_complete (assistant, page, TRUE);
|
||||
}
|
||||
|
||||
if (file_name)
|
||||
{
|
||||
gchar *filepath = gnc_uri_get_path ( file_name );
|
||||
gchar *filedir = g_path_get_dirname( filepath );
|
||||
info->starting_dir = g_strdup(filedir);
|
||||
g_free ( filedir );
|
||||
g_free ( filepath );
|
||||
gchar *filepath = gnc_uri_get_path (file_name);
|
||||
gchar *filedir = g_path_get_dirname (filepath);
|
||||
info->starting_dir = g_strdup (filedir);
|
||||
g_free (filedir);
|
||||
g_free (filepath);
|
||||
}
|
||||
g_free(file_name);
|
||||
g_free (file_name);
|
||||
|
||||
DEBUG("file_name selected is %s", info->file_name);
|
||||
DEBUG("starting directory is %s", info->starting_dir);
|
||||
|
||||
/* Step to next page if page is complete */
|
||||
if(gtk_assistant_get_page_complete(assistant, page))
|
||||
if(gtk_assistant_get_page_complete (assistant, page))
|
||||
gtk_assistant_set_current_page (assistant, num + 1);
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info)
|
||||
*
|
||||
* call back for type of separartor required
|
||||
*******************************************************/
|
||||
void csv_export_sep_cb (GtkWidget *radio, gpointer user_data )
|
||||
void csv_export_sep_cb (GtkWidget *radio, gpointer user_data)
|
||||
{
|
||||
CsvExportInfo *info = user_data;
|
||||
const gchar *name;
|
||||
@ -166,28 +166,28 @@ void csv_export_sep_cb (GtkWidget *radio, gpointer user_data )
|
||||
gint num = gtk_assistant_get_current_page (assistant);
|
||||
GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
|
||||
|
||||
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(radio)))
|
||||
{
|
||||
LEAVE("1st callback of pair. Defer to 2nd callback.");
|
||||
return;
|
||||
}
|
||||
|
||||
name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
|
||||
name = gtk_buildable_get_name (GTK_BUILDABLE(radio));
|
||||
|
||||
gtk_widget_set_sensitive(info->custom_entry, FALSE);
|
||||
gtk_widget_set_sensitive (info->custom_entry, FALSE);
|
||||
info->use_custom = FALSE;
|
||||
gtk_assistant_set_page_complete (assistant, page, TRUE);
|
||||
|
||||
if (g_strcmp0(name, "comma_radio") == 0)
|
||||
if (g_strcmp0 (name, "comma_radio") == 0)
|
||||
info->separator_str = ",";
|
||||
if (g_strcmp0(name, "colon_radio") == 0)
|
||||
if (g_strcmp0 (name, "colon_radio") == 0)
|
||||
info->separator_str = ":";
|
||||
if (g_strcmp0(name, "semicolon_radio") == 0)
|
||||
if (g_strcmp0 (name, "semicolon_radio") == 0)
|
||||
info->separator_str = ";";
|
||||
|
||||
if (g_strcmp0(name, "custom_radio") == 0)
|
||||
if (g_strcmp0 (name, "custom_radio") == 0)
|
||||
{
|
||||
gtk_widget_set_sensitive(info->custom_entry, TRUE);
|
||||
gtk_widget_set_sensitive (info->custom_entry, TRUE);
|
||||
info->use_custom = TRUE;
|
||||
if (gtk_entry_get_text_length (GTK_ENTRY(info->custom_entry)) == 0)
|
||||
gtk_assistant_set_page_complete (assistant, page, FALSE);
|
||||
@ -200,11 +200,11 @@ void csv_export_sep_cb (GtkWidget *radio, gpointer user_data )
|
||||
*
|
||||
* call back for use of quotes
|
||||
*******************************************************/
|
||||
void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data )
|
||||
void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data)
|
||||
{
|
||||
CsvExportInfo *info = user_data;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button)))
|
||||
info->use_quotes = TRUE;
|
||||
else
|
||||
info->use_quotes = FALSE;
|
||||
@ -216,7 +216,7 @@ void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data )
|
||||
*
|
||||
* call back for custom separator
|
||||
*******************************************************/
|
||||
void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data )
|
||||
void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
CsvExportInfo *info = user_data;
|
||||
const gchar *custom_str;
|
||||
@ -225,8 +225,8 @@ void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data )
|
||||
gint num = gtk_assistant_get_current_page (assistant);
|
||||
GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
|
||||
|
||||
custom_str = gtk_entry_get_text(GTK_ENTRY(info->custom_entry));
|
||||
info->separator_str = strdup(custom_str);
|
||||
custom_str = gtk_entry_get_text (GTK_ENTRY(info->custom_entry));
|
||||
info->separator_str = strdup (custom_str);
|
||||
|
||||
if (info->use_custom == TRUE && gtk_entry_get_text_length (GTK_ENTRY(info->custom_entry)) == 0)
|
||||
|
||||
@ -250,7 +250,7 @@ void load_settings (CsvExportInfo *info)
|
||||
info->starting_dir = NULL;
|
||||
|
||||
/* The default directory for the user to select files. */
|
||||
info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
|
||||
info->starting_dir = gnc_get_default_directory (GNC_PREFS_GROUP);
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
@ -272,11 +272,11 @@ csv_export_cursor_changed_cb (GtkWidget *widget, gpointer user_data)
|
||||
account = gnc_tree_view_account_get_cursor_account (account_tree);
|
||||
if (!account)
|
||||
{
|
||||
gtk_widget_set_sensitive(info->csva.select_button, FALSE);
|
||||
gtk_widget_set_sensitive (info->csva.select_button, FALSE);
|
||||
return;
|
||||
}
|
||||
num_children = gnc_tree_view_account_count_children(account_tree, account);
|
||||
gtk_widget_set_sensitive(info->csva.select_button, num_children > 0);
|
||||
num_children = gnc_tree_view_account_count_children (account_tree, account);
|
||||
gtk_widget_set_sensitive (info->csva.select_button, num_children > 0);
|
||||
}
|
||||
|
||||
|
||||
@ -318,7 +318,7 @@ show_acct_type_accounts (CsvExportInfo *info)
|
||||
Viewinfo.include_type[type] = FALSE;
|
||||
}
|
||||
gnc_tree_view_account_set_view_info (tree, &Viewinfo);
|
||||
csv_export_cursor_changed_cb(GTK_WIDGET(tree), info);
|
||||
csv_export_cursor_changed_cb (GTK_WIDGET(tree), info);
|
||||
}
|
||||
|
||||
|
||||
@ -482,41 +482,33 @@ get_filter_times (CsvExportInfo *info)
|
||||
{
|
||||
time64 time_val;
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_choose)))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.start_date_choose)))
|
||||
{
|
||||
time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.start_date));
|
||||
time_val = gnc_time64_get_day_start(time_val);
|
||||
time_val = gnc_date_edit_get_date (GNC_DATE_EDIT(info->csvd.start_date));
|
||||
time_val = gnc_time64_get_day_start (time_val);
|
||||
info->csvd.start_time = time_val;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
|
||||
{
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
|
||||
info->csvd.start_time = gnc_time64_get_today_start();
|
||||
}
|
||||
else
|
||||
{
|
||||
info->csvd.start_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.end_date_choose)))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.end_date_choose)))
|
||||
{
|
||||
time_val = gnc_date_edit_get_date(GNC_DATE_EDIT(info->csvd.end_date));
|
||||
time_val = gnc_time64_get_day_end(time_val);
|
||||
time_val = gnc_date_edit_get_date (GNC_DATE_EDIT(info->csvd.end_date));
|
||||
time_val = gnc_time64_get_day_end (time_val);
|
||||
info->csvd.end_time = time_val;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
|
||||
{
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(info->csvd.start_date_today)))
|
||||
info->csvd.end_time = gnc_time64_get_today_end();
|
||||
}
|
||||
else
|
||||
{
|
||||
info->csvd.end_time = gnc_time (NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -531,10 +523,10 @@ csv_export_show_range_cb (GtkRadioButton *button, gpointer user_data)
|
||||
CsvExportInfo *info = user_data;
|
||||
gboolean active;
|
||||
|
||||
g_return_if_fail(GTK_IS_RADIO_BUTTON(button));
|
||||
g_return_if_fail (GTK_IS_RADIO_BUTTON(button));
|
||||
|
||||
active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
|
||||
gtk_widget_set_sensitive(info->csvd.table, active);
|
||||
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
|
||||
gtk_widget_set_sensitive (info->csvd.table, active);
|
||||
}
|
||||
|
||||
|
||||
@ -548,7 +540,7 @@ csv_export_date_changed_cb (GtkWidget *w, gpointer user_data)
|
||||
{
|
||||
CsvExportInfo *info = user_data;
|
||||
|
||||
get_filter_times(info);
|
||||
get_filter_times (info);
|
||||
}
|
||||
|
||||
|
||||
@ -564,18 +556,18 @@ csv_export_start_date_cb (GtkWidget *radio, gpointer user_data)
|
||||
const gchar *name;
|
||||
gboolean active;
|
||||
|
||||
g_return_if_fail(GTK_IS_RADIO_BUTTON(radio));
|
||||
g_return_if_fail (GTK_IS_RADIO_BUTTON(radio));
|
||||
|
||||
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(radio)))
|
||||
{
|
||||
LEAVE("1st callback of pair. Defer to 2nd callback.");
|
||||
return;
|
||||
}
|
||||
|
||||
name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
|
||||
active = ( g_strcmp0(name, g_strdup("start_date_choose")) == 0 ? 1 : 0 );
|
||||
gtk_widget_set_sensitive(info->csvd.start_date, active);
|
||||
get_filter_times(info);
|
||||
name = gtk_buildable_get_name (GTK_BUILDABLE(radio));
|
||||
active = (g_strcmp0 (name, "start_date_choose") == 0 ? 1 : 0 );
|
||||
gtk_widget_set_sensitive (info->csvd.start_date, active);
|
||||
get_filter_times (info);
|
||||
}
|
||||
|
||||
|
||||
@ -591,18 +583,18 @@ csv_export_end_date_cb (GtkWidget *radio, gpointer user_data)
|
||||
const gchar *name;
|
||||
gboolean active;
|
||||
|
||||
g_return_if_fail(GTK_IS_RADIO_BUTTON(radio));
|
||||
g_return_if_fail (GTK_IS_RADIO_BUTTON(radio));
|
||||
|
||||
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(radio)))
|
||||
{
|
||||
LEAVE("1st callback of pair. Defer to 2nd callback.");
|
||||
return;
|
||||
}
|
||||
|
||||
name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
|
||||
active = ( g_strcmp0(name, g_strdup("end_date_choose")) == 0 ? 1 : 0 );
|
||||
gtk_widget_set_sensitive(info->csvd.end_date, active);
|
||||
get_filter_times(info);
|
||||
name = gtk_buildable_get_name (GTK_BUILDABLE(radio));
|
||||
active = (g_strcmp0 (name, "end_date_choose") == 0 ? 1 : 0 );
|
||||
gtk_widget_set_sensitive (info->csvd.end_date, active);
|
||||
get_filter_times (info);
|
||||
}
|
||||
|
||||
|
||||
@ -621,8 +613,8 @@ get_earliest_in_book (QofBook *book)
|
||||
GList *res;
|
||||
time64 earliest;
|
||||
|
||||
q = qof_query_create_for(GNC_ID_SPLIT);
|
||||
qof_query_set_max_results(q, 1);
|
||||
q = qof_query_create_for (GNC_ID_SPLIT);
|
||||
qof_query_set_max_results (q, 1);
|
||||
qof_query_set_book (q, book);
|
||||
|
||||
/* Sort by transaction date */
|
||||
@ -703,7 +695,7 @@ csv_export_assistant_file_page_prepare (GtkAssistant *assistant,
|
||||
|
||||
/* Set the default directory */
|
||||
if (info->starting_dir)
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(info->file_chooser), "");
|
||||
|
||||
/* Disable the Forward Assistant Button */
|
||||
@ -727,7 +719,7 @@ csv_export_assistant_finish_page_prepare (GtkAssistant *assistant,
|
||||
text = g_strdup_printf (gettext (finish_trans_string), info->file_name, info->csva.num_accounts);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL(info->finish_label), text);
|
||||
g_free(text);
|
||||
g_free (text);
|
||||
|
||||
/* Enable the Assistant Buttons */
|
||||
gtk_assistant_set_page_complete (assistant, page, TRUE);
|
||||
@ -740,7 +732,7 @@ csv_export_assistant_summary_page_prepare (GtkAssistant *assistant,
|
||||
{
|
||||
CsvExportInfo *info = user_data;
|
||||
gchar *text, *mtext;
|
||||
gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
|
||||
gnc_set_default_directory (GNC_PREFS_GROUP, info->starting_dir);
|
||||
|
||||
if (info->failed)
|
||||
text = _("There was a problem with the export, this could be due to lack of space, "
|
||||
@ -749,11 +741,11 @@ csv_export_assistant_summary_page_prepare (GtkAssistant *assistant,
|
||||
else
|
||||
text = _("File exported successfully!\n");
|
||||
|
||||
mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
|
||||
mtext = g_strdup_printf ("<span size=\"medium\"><b>%s</b></span>", text);
|
||||
|
||||
gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
|
||||
gtk_label_set_markup (GTK_LABEL(info->summary_label), mtext);
|
||||
|
||||
g_free(mtext);
|
||||
g_free (mtext);
|
||||
}
|
||||
|
||||
|
||||
@ -819,10 +811,10 @@ csv_export_close_handler (gpointer user_data)
|
||||
{
|
||||
CsvExportInfo *info = user_data;
|
||||
|
||||
g_free(info->file_name);
|
||||
g_free(info->starting_dir);
|
||||
g_free (info->file_name);
|
||||
g_free (info->starting_dir);
|
||||
|
||||
gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
|
||||
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
|
||||
gtk_widget_destroy (info->window);
|
||||
}
|
||||
|
||||
@ -854,7 +846,7 @@ csv_export_assistant_create (CsvExportInfo *info)
|
||||
info->start_page = GTK_WIDGET(gtk_builder_get_object(builder, "start_page"));
|
||||
info->start_label = GTK_WIDGET(gtk_builder_get_object(builder, "start_label"));
|
||||
info->custom_entry = GTK_WIDGET(gtk_builder_get_object(builder, "custom_entry"));
|
||||
gtk_widget_set_sensitive(info->custom_entry, FALSE);
|
||||
gtk_widget_set_sensitive (info->custom_entry, FALSE);
|
||||
|
||||
/* Account Page */
|
||||
info->account_page = GTK_WIDGET(gtk_builder_get_object(builder, "account_page"));
|
||||
@ -878,15 +870,15 @@ csv_export_assistant_create (CsvExportInfo *info)
|
||||
|
||||
selection = gtk_tree_view_get_selection (tree_view);
|
||||
gtk_tree_selection_set_mode (selection, GTK_SELECTION_EXTENDED);
|
||||
g_signal_connect (G_OBJECT (selection), "changed",
|
||||
G_CALLBACK (csv_export_account_changed_cb), info);
|
||||
g_signal_connect (G_OBJECT(selection), "changed",
|
||||
G_CALLBACK(csv_export_account_changed_cb), info);
|
||||
|
||||
gtk_widget_show (info->csva.account_treeview);
|
||||
box = GTK_WIDGET(gtk_builder_get_object (builder, "account_scroll"));
|
||||
gtk_container_add (GTK_CONTAINER (box), info->csva.account_treeview);
|
||||
gtk_container_add (GTK_CONTAINER(box), info->csva.account_treeview);
|
||||
|
||||
label = GTK_WIDGET(gtk_builder_get_object (builder, "accounts_label"));
|
||||
gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(tree_view));
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL(label), GTK_WIDGET(tree_view));
|
||||
|
||||
income_radio = GTK_WIDGET(gtk_builder_get_object (builder, "income_radio"));
|
||||
expense_radio = GTK_WIDGET(gtk_builder_get_object (builder, "expense_radio"));
|
||||
@ -896,25 +888,25 @@ csv_export_assistant_create (CsvExportInfo *info)
|
||||
liab_eq_radio = GTK_WIDGET(gtk_builder_get_object (builder, "liab_eq_radio"));
|
||||
info->csva.liab_eq_radio = liab_eq_radio;
|
||||
info->csva.account_type = ACCT_TYPE_EXPENSE;
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(expense_radio), TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(expense_radio), TRUE);
|
||||
|
||||
g_signal_connect (G_OBJECT (income_radio), "toggled",
|
||||
G_CALLBACK (csv_export_info_acct_type_cb), info);
|
||||
g_signal_connect (G_OBJECT (expense_radio), "toggled",
|
||||
G_CALLBACK (csv_export_info_acct_type_cb), info);
|
||||
g_signal_connect (G_OBJECT (asset_radio), "toggled",
|
||||
G_CALLBACK (csv_export_info_acct_type_cb), info);
|
||||
g_signal_connect (G_OBJECT (liab_eq_radio), "toggled",
|
||||
G_CALLBACK (csv_export_info_acct_type_cb), info);
|
||||
g_signal_connect (G_OBJECT(income_radio), "toggled",
|
||||
G_CALLBACK(csv_export_info_acct_type_cb), info);
|
||||
g_signal_connect (G_OBJECT(expense_radio), "toggled",
|
||||
G_CALLBACK(csv_export_info_acct_type_cb), info);
|
||||
g_signal_connect (G_OBJECT(asset_radio), "toggled",
|
||||
G_CALLBACK(csv_export_info_acct_type_cb), info);
|
||||
g_signal_connect (G_OBJECT(liab_eq_radio), "toggled",
|
||||
G_CALLBACK(csv_export_info_acct_type_cb), info);
|
||||
|
||||
/* select subaccounts button */
|
||||
button = GTK_WIDGET(gtk_builder_get_object (builder, "select_subaccounts_button"));
|
||||
info->csva.select_button = button;
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (csv_export_select_subaccounts_clicked_cb), info);
|
||||
g_signal_connect (G_OBJECT (info->csva.account_treeview), "cursor_changed",
|
||||
G_CALLBACK (csv_export_cursor_changed_cb), info);
|
||||
g_signal_connect (G_OBJECT(button), "clicked",
|
||||
G_CALLBACK(csv_export_select_subaccounts_clicked_cb), info);
|
||||
g_signal_connect (G_OBJECT(info->csva.account_treeview), "cursor_changed",
|
||||
G_CALLBACK(csv_export_cursor_changed_cb), info);
|
||||
|
||||
/* Set the date info */
|
||||
button = GTK_WIDGET(gtk_builder_get_object (builder, "show_range"));
|
||||
@ -925,11 +917,11 @@ csv_export_assistant_create (CsvExportInfo *info)
|
||||
|
||||
info->csvd.start_time = start_time;
|
||||
info->csvd.end_time = end_time;
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(button), FALSE);
|
||||
|
||||
table = GTK_WIDGET(gtk_builder_get_object (builder, "select_range_table"));
|
||||
info->csvd.table = table;
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(table), FALSE);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET(table), FALSE);
|
||||
|
||||
info->csvd.start_date_choose = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_choose"));
|
||||
info->csvd.start_date_today = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_today"));
|
||||
@ -939,16 +931,16 @@ csv_export_assistant_create (CsvExportInfo *info)
|
||||
/* Start date info */
|
||||
info->csvd.start_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
|
||||
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_hbox"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), info->csvd.start_date, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX(hbox), info->csvd.start_date, TRUE, TRUE, 0);
|
||||
gtk_widget_show (info->csvd.start_date);
|
||||
gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.start_date), start_time);
|
||||
g_signal_connect (G_OBJECT (info->csvd.start_date), "date-changed",
|
||||
G_CALLBACK (csv_export_date_changed_cb), info);
|
||||
g_signal_connect (G_OBJECT(info->csvd.start_date), "date-changed",
|
||||
G_CALLBACK(csv_export_date_changed_cb), info);
|
||||
|
||||
/* End date info */
|
||||
info->csvd.end_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
|
||||
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_hbox"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), info->csvd.end_date, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX(hbox), info->csvd.end_date, TRUE, TRUE, 0);
|
||||
gtk_widget_show (info->csvd.end_date);
|
||||
gnc_date_edit_set_time (GNC_DATE_EDIT(info->csvd.end_date), end_time);
|
||||
g_signal_connect (G_OBJECT (info->csvd.end_date), "date-changed",
|
||||
@ -962,37 +954,37 @@ csv_export_assistant_create (CsvExportInfo *info)
|
||||
/* File chooser Page */
|
||||
info->file_page = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
|
||||
info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||
button = gtk_button_new_from_stock(GTK_STOCK_OK);
|
||||
button = gtk_button_new_from_stock (GTK_STOCK_OK);
|
||||
gtk_widget_set_size_request (button, 100, -1);
|
||||
gtk_widget_show (button);
|
||||
h_box = gtk_hbox_new(TRUE, 0);
|
||||
h_box = gtk_hbox_new (TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
|
||||
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (csv_export_file_chooser_confirm_cb), info);
|
||||
g_signal_connect (G_OBJECT(button), "clicked",
|
||||
G_CALLBACK(csv_export_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);
|
||||
|
||||
/* Finish Page */
|
||||
info->finish_label = GTK_WIDGET(gtk_builder_get_object(builder, "end_page"));
|
||||
info->finish_label = GTK_WIDGET(gtk_builder_get_object (builder, "end_page"));
|
||||
|
||||
/* Summary Page */
|
||||
info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_page"));
|
||||
info->summary_label = GTK_WIDGET(gtk_builder_get_object (builder, "summary_page"));
|
||||
|
||||
g_signal_connect (G_OBJECT(window), "destroy",
|
||||
G_CALLBACK (csv_export_assistant_destroy_cb), info);
|
||||
G_CALLBACK(csv_export_assistant_destroy_cb), info);
|
||||
|
||||
gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
|
||||
if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
|
||||
if (gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
|
||||
{
|
||||
GObject *object = gtk_builder_get_object (builder, "paned");
|
||||
gnc_prefs_bind (GNC_PREFS_GROUP, GNC_PREF_PANED_POS, object, "position");
|
||||
}
|
||||
|
||||
gtk_builder_connect_signals(builder, info);
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
gtk_builder_connect_signals (builder, info);
|
||||
g_object_unref (G_OBJECT(builder));
|
||||
return window;
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,10 @@ gboolean write_line_to_file (FILE *fh, char * line)
|
||||
DEBUG("Account String: %s", line);
|
||||
|
||||
/* Write account line */
|
||||
len = strlen( line );
|
||||
written = fwrite( line, 1, len, fh );
|
||||
len = strlen (line);
|
||||
written = fwrite (line, 1, len, fh);
|
||||
|
||||
if ( written != len )
|
||||
if (written != len)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
@ -121,7 +121,7 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
|
||||
gchar *end_sep;
|
||||
gchar *mid_sep;
|
||||
|
||||
q = qof_query_create_for(GNC_ID_SPLIT);
|
||||
q = qof_query_create_for (GNC_ID_SPLIT);
|
||||
book = gnc_get_current_book();
|
||||
qof_query_set_book (q, book);
|
||||
|
||||
@ -129,12 +129,12 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
|
||||
if (info->use_quotes)
|
||||
{
|
||||
end_sep = "\"";
|
||||
mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
|
||||
mid_sep = g_strconcat ("\"", info->separator_str, "\"", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
end_sep = "";
|
||||
mid_sep = g_strconcat ( info->separator_str, NULL);
|
||||
mid_sep = g_strconcat (info->separator_str, NULL);
|
||||
}
|
||||
|
||||
/* Sort by transaction date */
|
||||
@ -147,7 +147,7 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
|
||||
xaccQueryAddDateMatchTT (q, TRUE, info->csvd.start_time, TRUE, info->csvd.end_time, QOF_QUERY_AND);
|
||||
|
||||
/* Run the query */
|
||||
for (splits = qof_query_run(q); splits; splits = splits->next)
|
||||
for (splits = qof_query_run (q); splits; splits = splits->next)
|
||||
{
|
||||
Split *split;
|
||||
Transaction *trans;
|
||||
@ -164,9 +164,9 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
|
||||
gchar *str_temp = NULL;
|
||||
|
||||
split = splits->data;
|
||||
trans = xaccSplitGetParent(split);
|
||||
nSplits = xaccTransCountSplits(trans);
|
||||
s_list = xaccTransGetSplitList(trans);
|
||||
trans = xaccSplitGetParent (split);
|
||||
nSplits = xaccTransCountSplits (trans);
|
||||
s_list = xaccTransGetSplitList (trans);
|
||||
|
||||
/* Date */
|
||||
date = qof_print_date (xaccTransGetDate (trans));
|
||||
@ -274,12 +274,12 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
|
||||
/* Loop through the list of splits for the Transcation */
|
||||
node = s_list;
|
||||
cnt = 0;
|
||||
while ( (cnt < nSplits) && (info->failed == FALSE))
|
||||
while ((cnt < nSplits) && (info->failed == FALSE))
|
||||
{
|
||||
t_split = node->data;
|
||||
|
||||
/* Start of line */
|
||||
part1 = g_strconcat ( end_sep, mid_sep, mid_sep, mid_sep, mid_sep, mid_sep, NULL);
|
||||
part1 = g_strconcat (end_sep, mid_sep, mid_sep, mid_sep, mid_sep, mid_sep, NULL);
|
||||
|
||||
/* Memo */
|
||||
currentSel = xaccSplitGetMemo (t_split) ? xaccSplitGetMemo (t_split) : "" ;
|
||||
@ -396,8 +396,8 @@ void csv_transactions_export (CsvExportInfo *info)
|
||||
info->failed = FALSE;
|
||||
|
||||
/* Open File for writing */
|
||||
fh = g_fopen( info->file_name, "w" );
|
||||
if ( fh != NULL )
|
||||
fh = g_fopen (info->file_name, "w" );
|
||||
if (fh != NULL)
|
||||
{
|
||||
gchar *header;
|
||||
gchar *end_sep;
|
||||
@ -408,16 +408,16 @@ void csv_transactions_export (CsvExportInfo *info)
|
||||
if (info->use_quotes)
|
||||
{
|
||||
end_sep = "\"";
|
||||
mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
|
||||
mid_sep = g_strconcat ("\"", info->separator_str, "\"", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
end_sep = "";
|
||||
mid_sep = g_strconcat ( info->separator_str, NULL);
|
||||
mid_sep = g_strconcat (info->separator_str, NULL);
|
||||
}
|
||||
|
||||
/* Header string */
|
||||
header = g_strconcat ( end_sep, _("Date"), mid_sep, _("Account Name"), mid_sep,
|
||||
header = g_strconcat (end_sep, _("Date"), mid_sep, _("Account Name"), mid_sep,
|
||||
(num_action ? _("Transaction Number") : _("Number")),
|
||||
mid_sep, _("Description"), mid_sep, _("Notes"),
|
||||
mid_sep, _("Memo"), mid_sep, _("Category"), mid_sep,
|
||||
@ -435,21 +435,21 @@ void csv_transactions_export (CsvExportInfo *info)
|
||||
DEBUG("Header String: %s", header);
|
||||
|
||||
/* Write header line */
|
||||
if (!write_line_to_file(fh, header))
|
||||
if (!write_line_to_file (fh, header))
|
||||
{
|
||||
info->failed = TRUE;
|
||||
g_free(mid_sep);
|
||||
g_free(header);
|
||||
g_free (mid_sep);
|
||||
g_free (header);
|
||||
return;
|
||||
}
|
||||
g_free(mid_sep);
|
||||
g_free(header);
|
||||
g_free (mid_sep);
|
||||
g_free (header);
|
||||
|
||||
/* Go through list of accounts */
|
||||
for (ptr = info->csva.account_list, i = 0; ptr; ptr = g_list_next(ptr), i++)
|
||||
{
|
||||
acc = ptr->data;
|
||||
DEBUG("Account being processed is : %s", xaccAccountGetName(acc));
|
||||
DEBUG("Account being processed is : %s", xaccAccountGetName (acc));
|
||||
account_splits (info, acc, fh);
|
||||
}
|
||||
}
|
||||
|
@ -47,16 +47,16 @@ static QofLogModule log_module = GNC_MOD_ASSISTANT;
|
||||
* successfull.
|
||||
*******************************************************/
|
||||
static
|
||||
gboolean write_line_to_file ( FILE *fh, char * line)
|
||||
gboolean write_line_to_file (FILE *fh, char * line)
|
||||
{
|
||||
int len, written;
|
||||
DEBUG("Account String: %s", line);
|
||||
|
||||
/* Write account line */
|
||||
len = strlen( line );
|
||||
written = fwrite( line, 1, len, fh );
|
||||
len = strlen (line);
|
||||
written = fwrite (line, 1, len, fh);
|
||||
|
||||
if ( written != len )
|
||||
if (written != len)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
@ -114,13 +114,13 @@ void csv_tree_export (CsvExportInfo *info)
|
||||
DEBUG("File name is : %s", info->file_name);
|
||||
|
||||
/* Get list of Accounts */
|
||||
root = gnc_book_get_root_account( gnc_get_current_book() );
|
||||
accts = gnc_account_get_descendants_sorted( root );
|
||||
root = gnc_book_get_root_account (gnc_get_current_book());
|
||||
accts = gnc_account_get_descendants_sorted (root);
|
||||
info->failed = FALSE;
|
||||
|
||||
/* Open File for writing */
|
||||
fh = g_fopen( info->file_name, "w" );
|
||||
if ( fh != NULL )
|
||||
fh = g_fopen (info->file_name, "w");
|
||||
if (fh != NULL)
|
||||
{
|
||||
gchar *header;
|
||||
gchar *part1;
|
||||
@ -135,12 +135,12 @@ void csv_tree_export (CsvExportInfo *info)
|
||||
if (info->use_quotes)
|
||||
{
|
||||
end_sep = "\"";
|
||||
mid_sep = g_strconcat ( "\"", info->separator_str, "\"", NULL);
|
||||
mid_sep = g_strconcat ("\"", info->separator_str, "\"", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
end_sep = "";
|
||||
mid_sep = g_strconcat ( info->separator_str, NULL);
|
||||
mid_sep = g_strconcat (info->separator_str, NULL);
|
||||
}
|
||||
|
||||
/* Header string, 'eol = end of line marker' */
|
||||
@ -160,22 +160,22 @@ void csv_tree_export (CsvExportInfo *info)
|
||||
DEBUG("Header String: %s", header);
|
||||
|
||||
/* Write header line */
|
||||
if (!write_line_to_file(fh, header))
|
||||
if (!write_line_to_file (fh, header))
|
||||
{
|
||||
info->failed = TRUE;
|
||||
g_free(mid_sep);
|
||||
g_free(header);
|
||||
g_free (mid_sep);
|
||||
g_free (header);
|
||||
return;
|
||||
}
|
||||
g_free(header);
|
||||
g_free (header);
|
||||
|
||||
/* Go through list of accounts */
|
||||
for (ptr = accts, i = 0; ptr; ptr = g_list_next(ptr), i++)
|
||||
for (ptr = accts, i = 0; ptr; ptr = g_list_next (ptr), i++)
|
||||
{
|
||||
gchar *fullname = NULL;
|
||||
gchar *str_temp = NULL;
|
||||
acc = ptr->data;
|
||||
DEBUG("Account being processed is : %s", xaccAccountGetName(acc));
|
||||
DEBUG("Account being processed is : %s", xaccAccountGetName (acc));
|
||||
/* Type */
|
||||
currentSel = xaccAccountTypeEnumAsString (xaccAccountGetType (acc));
|
||||
part1 = g_strconcat (end_sep, currentSel, mid_sep, NULL);
|
||||
@ -246,21 +246,21 @@ void csv_tree_export (CsvExportInfo *info)
|
||||
DEBUG("Account String: %s", part2);
|
||||
|
||||
/* Write to file */
|
||||
if (!write_line_to_file(fh, part2))
|
||||
if (!write_line_to_file (fh, part2))
|
||||
{
|
||||
info->failed = TRUE;
|
||||
break;
|
||||
}
|
||||
g_free(part2);
|
||||
g_free (part2);
|
||||
}
|
||||
g_free(mid_sep);
|
||||
g_free (mid_sep);
|
||||
}
|
||||
else
|
||||
info->failed = TRUE;
|
||||
if (fh)
|
||||
fclose (fh);
|
||||
|
||||
g_list_free( accts );
|
||||
g_list_free (accts);
|
||||
LEAVE("");
|
||||
}
|
||||
|
||||
|
@ -131,17 +131,17 @@ csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info)
|
||||
|
||||
gtk_assistant_set_page_complete (assistant, page, FALSE);
|
||||
|
||||
file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser ));
|
||||
file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(info->file_chooser));
|
||||
|
||||
if (file_name)
|
||||
{
|
||||
gchar *filepath = gnc_uri_get_path ( file_name );
|
||||
gchar *filedir = g_path_get_dirname( filepath );
|
||||
info->starting_dir = g_strdup(filedir);
|
||||
g_free ( filedir );
|
||||
g_free ( filepath );
|
||||
gchar *filepath = gnc_uri_get_path (file_name);
|
||||
gchar *filedir = g_path_get_dirname (filepath);
|
||||
info->starting_dir = g_strdup (filedir);
|
||||
g_free (filedir);
|
||||
g_free (filepath);
|
||||
|
||||
info->file_name = g_strdup(file_name);
|
||||
info->file_name = g_strdup (file_name);
|
||||
|
||||
// generate preview
|
||||
gtk_list_store_clear (info->store);
|
||||
@ -153,13 +153,13 @@ csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info)
|
||||
else if (res == MATCH_FOUND)
|
||||
gtk_assistant_set_page_complete (assistant, page, TRUE);
|
||||
}
|
||||
g_free(file_name);
|
||||
g_free (file_name);
|
||||
|
||||
DEBUG("file_name selected is %s", info->file_name);
|
||||
DEBUG("starting directory is %s", info->starting_dir);
|
||||
|
||||
/* Step to next page if page is complete */
|
||||
if(gtk_assistant_get_page_complete(assistant, page))
|
||||
if(gtk_assistant_get_page_complete (assistant, page))
|
||||
gtk_assistant_set_current_page (assistant, num + 1);
|
||||
|
||||
}
|
||||
@ -170,7 +170,7 @@ csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info)
|
||||
*
|
||||
* call back for the start row / number of header rows
|
||||
*******************************************************/
|
||||
void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data )
|
||||
void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data)
|
||||
{
|
||||
CsvImportInfo *info = user_data;
|
||||
|
||||
@ -182,12 +182,12 @@ void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data )
|
||||
info->header_rows = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spin));
|
||||
|
||||
/* Get number of rows displayed */
|
||||
num_rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(info->store), NULL);
|
||||
num_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(info->store), NULL);
|
||||
|
||||
/* Modify background color for header rows */
|
||||
if (info->header_rows == 0)
|
||||
{
|
||||
valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, 0 );
|
||||
valid = gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(info->store), &iter, NULL, 0 );
|
||||
if (valid)
|
||||
gtk_list_store_set (info->store, &iter, ROW_COLOR, NULL, -1);
|
||||
}
|
||||
@ -195,7 +195,7 @@ void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data )
|
||||
{
|
||||
if (info->header_rows - 1 < num_rows)
|
||||
{
|
||||
valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, info->header_rows - 1 );
|
||||
valid = gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(info->store), &iter, NULL, info->header_rows - 1 );
|
||||
if (valid)
|
||||
gtk_list_store_set (info->store, &iter, ROW_COLOR, "pink", -1);
|
||||
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL(info->store), &iter);
|
||||
@ -211,19 +211,19 @@ void csv_import_hrows_cb (GtkWidget *spin, gpointer user_data )
|
||||
*
|
||||
* call back for type of separartor required
|
||||
*******************************************************/
|
||||
void csv_import_sep_cb (GtkWidget *radio, gpointer user_data )
|
||||
void csv_import_sep_cb (GtkWidget *radio, gpointer user_data)
|
||||
{
|
||||
CsvImportInfo *info = user_data;
|
||||
const gchar *name;
|
||||
gchar *temp;
|
||||
|
||||
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio)))
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(radio)))
|
||||
{
|
||||
LEAVE("1st callback of pair. Defer to 2nd callback.");
|
||||
return;
|
||||
}
|
||||
|
||||
name = gtk_buildable_get_name(GTK_BUILDABLE(radio));
|
||||
name = gtk_buildable_get_name (GTK_BUILDABLE(radio));
|
||||
|
||||
if (g_strcmp0 (name, "radio_semi") == 0)
|
||||
g_string_assign (info->regexp, "^(?<type>[^;]*);?(?<full_name>\"(?:[^\"]|\"\")*\"|[^;]*);?(?<name>\"(?:[^\"]|\"\")*\"|[^;]*);\
|
||||
@ -256,13 +256,13 @@ void csv_import_sep_cb (GtkWidget *radio, gpointer user_data )
|
||||
/* Generate preview */
|
||||
gtk_list_store_clear (info->store);
|
||||
|
||||
if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11 ) == MATCH_FOUND)
|
||||
if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11) == MATCH_FOUND)
|
||||
gtk_widget_set_sensitive (info->header_row_spin, TRUE);
|
||||
else
|
||||
gtk_widget_set_sensitive (info->header_row_spin, FALSE);
|
||||
|
||||
/* Reset Header spin to 0 */
|
||||
gtk_spin_button_set_value( GTK_SPIN_BUTTON(info->header_row_spin), 0 );
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON(info->header_row_spin), 0);
|
||||
}
|
||||
|
||||
|
||||
@ -281,7 +281,7 @@ void load_settings (CsvImportInfo *info)
|
||||
info->error = "";
|
||||
|
||||
/* The default directory for the user to select files. */
|
||||
info->starting_dir = gnc_get_default_directory(GNC_PREFS_GROUP);
|
||||
info->starting_dir = gnc_get_default_directory (GNC_PREFS_GROUP);
|
||||
}
|
||||
|
||||
|
||||
@ -313,28 +313,28 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
|
||||
GtkTextIter start, end;
|
||||
|
||||
/* Create the widgets */
|
||||
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
|
||||
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW(parent),
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
|
||||
NULL);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG(dialog));
|
||||
|
||||
// add a label
|
||||
label = gtk_label_new (msg);
|
||||
gtk_container_add (GTK_CONTAINER (content_area), label);
|
||||
gtk_container_add (GTK_CONTAINER(content_area), label);
|
||||
|
||||
// add a textview
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(view), GTK_WRAP_WORD_CHAR);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(view));
|
||||
gtk_text_buffer_set_text (buffer, default_input, -1);
|
||||
gtk_container_add (GTK_CONTAINER (content_area), view);
|
||||
gtk_container_add (GTK_CONTAINER(content_area), view);
|
||||
|
||||
// run the dialog
|
||||
gtk_widget_show_all (dialog);
|
||||
result = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
result = gtk_dialog_run (GTK_DIALOG(dialog));
|
||||
|
||||
if (result == GTK_RESPONSE_REJECT)
|
||||
user_input = 0;
|
||||
@ -380,7 +380,7 @@ csv_import_assistant_file_page_prepare (GtkAssistant *assistant,
|
||||
|
||||
/* Set the default directory */
|
||||
if (info->starting_dir)
|
||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);
|
||||
|
||||
/* Disable the Forward Assistant Button */
|
||||
gtk_assistant_set_page_complete (assistant, page, FALSE);
|
||||
@ -423,10 +423,10 @@ csv_import_assistant_finish_page_prepare (GtkAssistant *assistant,
|
||||
text = g_strdup_printf (gettext (finish_tree_string), info->file_name);
|
||||
}
|
||||
gtk_label_set_text (GTK_LABEL(info->finish_label), text);
|
||||
g_free(text);
|
||||
g_free (text);
|
||||
|
||||
/* Save the Window size and directory */
|
||||
gnc_set_default_directory(GNC_PREFS_GROUP, info->starting_dir);
|
||||
gnc_set_default_directory (GNC_PREFS_GROUP, info->starting_dir);
|
||||
|
||||
/* Enable the Assistant Buttons */
|
||||
gtk_assistant_set_page_complete (assistant, page, TRUE);
|
||||
@ -443,29 +443,29 @@ csv_import_assistant_summary_page_prepare (GtkAssistant *assistant,
|
||||
/* Before creating accounts, if this is a new book, let user specify
|
||||
* book options, since they affect how transactions are created */
|
||||
if (info->new_book)
|
||||
info->new_book = gnc_new_book_option_display(info->window);
|
||||
info->new_book = gnc_new_book_option_display (info->window);
|
||||
|
||||
if (!g_strcmp0(info->error, "") == 0)
|
||||
if (!g_strcmp0 (info->error, "") == 0)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (info->summary_error_view));
|
||||
text = g_strdup_printf(gettext ("Import completed but with errors!\n\nThe number of Accounts added was %u and "
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(info->summary_error_view));
|
||||
text = g_strdup_printf (gettext ("Import completed but with errors!\n\nThe number of Accounts added was %u and "
|
||||
"updated was %u.\n\nSee below for errors..." ), info->num_new, info->num_updates );
|
||||
errtext = g_strdup_printf ( "%s", info->error);
|
||||
errtext = g_strdup_printf ("%s", info->error);
|
||||
gtk_text_buffer_set_text (buffer, errtext, -1);
|
||||
g_free(errtext);
|
||||
g_free(info->error);
|
||||
g_free (errtext);
|
||||
g_free (info->error);
|
||||
}
|
||||
else
|
||||
text = g_strdup_printf(gettext ("Import completed successfully!\n\nThe number of Accounts added was %u and "
|
||||
text = g_strdup_printf (gettext ("Import completed successfully!\n\nThe number of Accounts added was %u and "
|
||||
"updated was %u.\n" ), info->num_new, info->num_updates );
|
||||
|
||||
mtext = g_strdup_printf("<span size=\"medium\"><b>%s</b></span>", text);
|
||||
gtk_label_set_markup(GTK_LABEL(info->summary_label), mtext);
|
||||
mtext = g_strdup_printf ("<span size=\"medium\"><b>%s</b></span>", text);
|
||||
gtk_label_set_markup (GTK_LABEL(info->summary_label), mtext);
|
||||
|
||||
g_free(text);
|
||||
g_free(mtext);
|
||||
g_free (text);
|
||||
g_free (mtext);
|
||||
}
|
||||
|
||||
|
||||
@ -473,7 +473,7 @@ void
|
||||
csv_import_assistant_prepare (GtkAssistant *assistant, GtkWidget *page,
|
||||
gpointer user_data)
|
||||
{
|
||||
gint currentpage = gtk_assistant_get_current_page(assistant);
|
||||
gint currentpage = gtk_assistant_get_current_page (assistant);
|
||||
|
||||
switch (currentpage)
|
||||
{
|
||||
@ -541,11 +541,11 @@ csv_import_close_handler (gpointer user_data)
|
||||
{
|
||||
CsvImportInfo *info = user_data;
|
||||
|
||||
g_free(info->starting_dir);
|
||||
g_free(info->file_name);
|
||||
g_string_free(info->regexp, TRUE);
|
||||
g_free (info->starting_dir);
|
||||
g_free (info->file_name);
|
||||
g_string_free (info->regexp, TRUE);
|
||||
|
||||
gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(info->window));
|
||||
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
|
||||
gtk_widget_destroy (info->window);
|
||||
}
|
||||
|
||||
@ -564,8 +564,8 @@ csv_import_assistant_create (CsvImportInfo *info)
|
||||
gchar *mnemonic_desc = NULL;
|
||||
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder , "assistant-csv-account-import.glade", "num_hrows_adj");
|
||||
gnc_builder_add_from_file (builder , "assistant-csv-account-import.glade", "CSV Account Import Assistant");
|
||||
gnc_builder_add_from_file (builder, "assistant-csv-account-import.glade", "num_hrows_adj");
|
||||
gnc_builder_add_from_file (builder, "assistant-csv-account-import.glade", "CSV Account Import Assistant");
|
||||
window = GTK_WIDGET(gtk_builder_get_object (builder, "CSV Account Import Assistant"));
|
||||
info->window = window;
|
||||
|
||||
@ -576,19 +576,19 @@ csv_import_assistant_create (CsvImportInfo *info)
|
||||
load_settings (info);
|
||||
|
||||
/* Enable buttons on all page. */
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT(window),
|
||||
GTK_WIDGET(gtk_builder_get_object(builder, "start_page")),
|
||||
TRUE);
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT(window),
|
||||
GTK_WIDGET(gtk_builder_get_object(builder, "file_page")),
|
||||
FALSE);
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT(window),
|
||||
GTK_WIDGET(gtk_builder_get_object(builder, "import_tree_page")),
|
||||
TRUE);
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT(window),
|
||||
GTK_WIDGET(gtk_builder_get_object(builder, "end_page")),
|
||||
FALSE);
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT (window),
|
||||
gtk_assistant_set_page_complete (GTK_ASSISTANT(window),
|
||||
GTK_WIDGET(gtk_builder_get_object(builder, "summary_page")),
|
||||
TRUE);
|
||||
|
||||
@ -596,19 +596,19 @@ csv_import_assistant_create (CsvImportInfo *info)
|
||||
|
||||
/* File chooser Page */
|
||||
info->file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
g_signal_connect (G_OBJECT (info->file_chooser), "file-activated",
|
||||
G_CALLBACK (csv_import_file_chooser_confirm_cb), info);
|
||||
button = gtk_button_new_from_stock(GTK_STOCK_OK);
|
||||
g_signal_connect (G_OBJECT(info->file_chooser), "file-activated",
|
||||
G_CALLBACK(csv_import_file_chooser_confirm_cb), info);
|
||||
button = gtk_button_new_from_stock (GTK_STOCK_OK);
|
||||
gtk_widget_set_size_request (button, 100, -1);
|
||||
gtk_widget_show (button);
|
||||
h_box = gtk_hbox_new(TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(h_box), button, FALSE, FALSE, 0);
|
||||
h_box = gtk_hbox_new (TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX(h_box), button, FALSE, FALSE, 0);
|
||||
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(info->file_chooser), h_box);
|
||||
g_signal_connect (G_OBJECT (button), "clicked",
|
||||
G_CALLBACK (csv_import_file_chooser_confirm_cb), info);
|
||||
g_signal_connect (G_OBJECT(button), "clicked",
|
||||
G_CALLBACK(csv_import_file_chooser_confirm_cb), info);
|
||||
|
||||
box = GTK_WIDGET(gtk_builder_get_object(builder, "file_page"));
|
||||
gtk_box_pack_start (GTK_BOX (box), info->file_chooser, TRUE, TRUE, 6);
|
||||
gtk_box_pack_start (GTK_BOX(box), info->file_chooser, TRUE, TRUE, 6);
|
||||
gtk_widget_show (info->file_chooser);
|
||||
|
||||
/* Account Tree Page */
|
||||
@ -625,14 +625,14 @@ csv_import_assistant_create (CsvImportInfo *info)
|
||||
info->store = gtk_list_store_new (N_COLUMNS,
|
||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
|
||||
gtk_tree_view_set_model( GTK_TREE_VIEW(info->tree_view), GTK_TREE_MODEL(info->store) );
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW(info->tree_view), GTK_TREE_MODEL(info->store));
|
||||
#define CREATE_COLUMN(description,column_id) \
|
||||
renderer = gtk_cell_renderer_text_new (); \
|
||||
mnemonic_desc = mnemonic_escape(_(description)); \
|
||||
mnemonic_desc = mnemonic_escape (_(description)); \
|
||||
column = gtk_tree_view_column_new_with_attributes (mnemonic_desc, renderer, "text", column_id, NULL); \
|
||||
gtk_tree_view_column_add_attribute(column, renderer, "background", ROW_COLOR); \
|
||||
gtk_tree_view_column_add_attribute (column, renderer, "background", ROW_COLOR); \
|
||||
gtk_tree_view_column_set_resizable (column, TRUE); \
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (info->tree_view), column); \
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW(info->tree_view), column); \
|
||||
g_free (mnemonic_desc);
|
||||
CREATE_COLUMN ("type", TYPE);
|
||||
CREATE_COLUMN ("full_name", FULL_NAME);
|
||||
@ -648,18 +648,18 @@ csv_import_assistant_create (CsvImportInfo *info)
|
||||
CREATE_COLUMN ("place_holder", PLACE_HOLDER);
|
||||
|
||||
/* Finish Page */
|
||||
info->finish_label = GTK_WIDGET(gtk_builder_get_object(builder, "end_page"));
|
||||
info->finish_label = GTK_WIDGET(gtk_builder_get_object (builder, "end_page"));
|
||||
/* Summary Page */
|
||||
info->summary_label = GTK_WIDGET(gtk_builder_get_object(builder, "summary_label"));
|
||||
info->summary_error_view = GTK_WIDGET(gtk_builder_get_object(builder, "summary_error_view"));
|
||||
info->summary_label = GTK_WIDGET(gtk_builder_get_object (builder, "summary_label"));
|
||||
info->summary_error_view = GTK_WIDGET(gtk_builder_get_object (builder, "summary_error_view"));
|
||||
|
||||
g_signal_connect (G_OBJECT(window), "destroy",
|
||||
G_CALLBACK (csv_import_assistant_destroy_cb), info);
|
||||
G_CALLBACK(csv_import_assistant_destroy_cb), info);
|
||||
|
||||
gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
|
||||
|
||||
gtk_builder_connect_signals(builder, info);
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
gtk_builder_connect_signals (builder, info);
|
||||
g_object_unref (G_OBJECT(builder));
|
||||
return window;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -68,7 +68,7 @@ static QofLogModule log_module = GNC_MOD_ASSISTANT;
|
||||
*******************************************************/
|
||||
csv_import_result
|
||||
csv_import_read_file (const gchar *filename, const gchar *parser_regexp,
|
||||
GtkListStore *store, guint max_rows )
|
||||
GtkListStore *store, guint max_rows)
|
||||
{
|
||||
FILE *f;
|
||||
char *line;
|
||||
@ -232,14 +232,14 @@ csv_account_import (CsvImportInfo *info)
|
||||
|
||||
ENTER("");
|
||||
book = gnc_get_current_book();
|
||||
root = gnc_book_get_root_account(book);
|
||||
root = gnc_book_get_root_account (book);
|
||||
|
||||
info->num_new = 0;
|
||||
info->num_updates = 0;
|
||||
|
||||
/* Move to the first valid entry in store */
|
||||
row = info->header_rows;
|
||||
valid = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(info->store), &iter, NULL, row );
|
||||
valid = gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(info->store), &iter, NULL, row );
|
||||
while (valid)
|
||||
{
|
||||
/* Walk through the list, reading each row */
|
||||
@ -258,13 +258,13 @@ csv_account_import (CsvImportInfo *info)
|
||||
PLACE_HOLDER, &place_holder, -1);
|
||||
|
||||
/* See if we can find the account by full name */
|
||||
acc = gnc_account_lookup_by_full_name(root, full_name);
|
||||
acc = gnc_account_lookup_by_full_name (root, full_name);
|
||||
|
||||
DEBUG("Row is %u and full name is %s", row, full_name);
|
||||
if (acc == NULL)
|
||||
{
|
||||
/* Account does not exist, Lets try and add it */
|
||||
if (g_strrstr(full_name, name) != NULL)
|
||||
if (g_strrstr (full_name, name) != NULL)
|
||||
{
|
||||
gint string_position;
|
||||
gnc_commodity *commodity;
|
||||
@ -272,21 +272,21 @@ csv_account_import (CsvImportInfo *info)
|
||||
gchar *full_parent;
|
||||
|
||||
/* Get full name of parent account, allow for separator */
|
||||
string_position = strlen(full_name) - strlen(name) - 1;
|
||||
string_position = strlen (full_name) - strlen (name) - 1;
|
||||
|
||||
if (string_position == -1)
|
||||
full_parent = g_strdup(full_name);
|
||||
full_parent = g_strdup (full_name);
|
||||
else
|
||||
full_parent = g_strndup(full_name, string_position);
|
||||
full_parent = g_strndup (full_name, string_position);
|
||||
|
||||
parent = gnc_account_lookup_by_full_name(root, full_parent);
|
||||
parent = gnc_account_lookup_by_full_name (root, full_parent);
|
||||
g_free (full_parent);
|
||||
|
||||
if (parent == NULL && string_position != -1)
|
||||
{
|
||||
gchar *text = g_strdup_printf( gettext("Row %u, path to account %s not found, added as top level\n"), row + 1, name );
|
||||
info->error = g_strconcat(info->error, text, NULL);
|
||||
g_free(text);
|
||||
gchar *text = g_strdup_printf (gettext("Row %u, path to account %s not found, added as top level\n"), row + 1, name);
|
||||
info->error = g_strconcat (info->error, text, NULL);
|
||||
g_free (text);
|
||||
PINFO("Unable to import Row %u for account %s, path not found!", row, name);
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ csv_account_import (CsvImportInfo *info)
|
||||
|
||||
/* Do we have a valid commodity */
|
||||
table = gnc_commodity_table_get_table (book);
|
||||
commodity = gnc_commodity_table_lookup( table, commodityn, commoditym);
|
||||
commodity = gnc_commodity_table_lookup (table, commodityn, commoditym);
|
||||
|
||||
if (commodity)
|
||||
{
|
||||
@ -305,27 +305,27 @@ csv_account_import (CsvImportInfo *info)
|
||||
acc = xaccMallocAccount (book);
|
||||
xaccAccountBeginEdit (acc);
|
||||
xaccAccountSetName (acc, name);
|
||||
xaccAccountSetType(acc, xaccAccountStringToEnum (type));
|
||||
xaccAccountSetType (acc, xaccAccountStringToEnum (type));
|
||||
|
||||
if (!g_strcmp0(notes, "") == 0)
|
||||
if (!g_strcmp0 (notes, "") == 0)
|
||||
xaccAccountSetNotes (acc, notes);
|
||||
if (!g_strcmp0(description, "") == 0)
|
||||
if (!g_strcmp0 (description, "") == 0)
|
||||
xaccAccountSetDescription (acc, description);
|
||||
if (!g_strcmp0(code, "") == 0)
|
||||
if (!g_strcmp0 (code, "") == 0)
|
||||
xaccAccountSetCode (acc, code);
|
||||
|
||||
if (!g_strcmp0(color, "") == 0)
|
||||
if (!g_strcmp0 (color, "") == 0)
|
||||
{
|
||||
if (gdk_color_parse(color, &testcolor))
|
||||
if (gdk_color_parse (color, &testcolor))
|
||||
xaccAccountSetColor (acc, color);
|
||||
}
|
||||
|
||||
if (g_strcmp0(hidden, "T") == 0)
|
||||
if (g_strcmp0 (hidden, "T") == 0)
|
||||
xaccAccountSetHidden (acc, TRUE);
|
||||
if (g_strcmp0(place_holder, "T") == 0)
|
||||
if (g_strcmp0 (place_holder, "T") == 0)
|
||||
xaccAccountSetPlaceholder (acc, TRUE);
|
||||
|
||||
xaccAccountSetCommodity(acc, commodity);
|
||||
xaccAccountSetCommodity (acc, commodity);
|
||||
xaccAccountBeginEdit (parent);
|
||||
gnc_account_append_child (parent, acc);
|
||||
xaccAccountCommitEdit (parent);
|
||||
@ -334,18 +334,18 @@ csv_account_import (CsvImportInfo *info)
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *err_string = g_strdup_printf( gettext("Row %u, commodity %s / %s not found\n"), row + 1,
|
||||
gchar *err_string = g_strdup_printf (gettext("Row %u, commodity %s / %s not found\n"), row + 1,
|
||||
commoditym, commodityn);
|
||||
info->error = g_strconcat(info->error, err_string, NULL);
|
||||
g_free(err_string);
|
||||
info->error = g_strconcat (info->error, err_string, NULL);
|
||||
g_free (err_string);
|
||||
PINFO("Unable to import Row %u for account %s, commodity!", row, full_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *err_string = g_strdup_printf( gettext("Row %u, account %s not in %s\n"), row + 1, name, full_name);
|
||||
info->error = g_strconcat(info->error, err_string, NULL);
|
||||
g_free(err_string);
|
||||
gchar *err_string = g_strdup_printf (gettext("Row %u, account %s not in %s\n"), row + 1, name, full_name);
|
||||
info->error = g_strconcat (info->error, err_string, NULL);
|
||||
g_free (err_string);
|
||||
PINFO("Unable to import Row %u for account %s, name!", row, full_name);
|
||||
}
|
||||
}
|
||||
@ -354,19 +354,19 @@ csv_account_import (CsvImportInfo *info)
|
||||
/* Lets try and update the color, notes, description, code entries */
|
||||
DEBUG("Existing account, will try and update account %s", full_name);
|
||||
info->num_updates = info->num_updates + 1;
|
||||
if (!g_strcmp0(color, "") == 0)
|
||||
if (!g_strcmp0 (color, "") == 0)
|
||||
{
|
||||
if (gdk_color_parse(color, &testcolor))
|
||||
if (gdk_color_parse (color, &testcolor))
|
||||
xaccAccountSetColor (acc, color);
|
||||
}
|
||||
|
||||
if (!g_strcmp0(notes, "") == 0)
|
||||
if (!g_strcmp0 (notes, "") == 0)
|
||||
xaccAccountSetNotes (acc, notes);
|
||||
|
||||
if (!g_strcmp0(description, "") == 0)
|
||||
if (!g_strcmp0 (description, "") == 0)
|
||||
xaccAccountSetDescription (acc, description);
|
||||
|
||||
if (!g_strcmp0(code, "") == 0)
|
||||
if (!g_strcmp0 (code, "") == 0)
|
||||
xaccAccountSetCode (acc, code);
|
||||
}
|
||||
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (info->store), &iter);
|
||||
|
@ -44,7 +44,7 @@ typedef enum _csv_import_result csv_import_result;
|
||||
csv_import_result
|
||||
csv_import_read_file (const gchar *filename, const gchar *parser_regexp, GtkListStore *store, guint max_rows );
|
||||
|
||||
void csv_account_import(CsvImportInfo *info);
|
||||
void csv_account_import (CsvImportInfo *info);
|
||||
|
||||
#endif /* CSV_ACCOUNT_IMPORT_H */
|
||||
|
||||
|
@ -55,11 +55,11 @@ gchar* gnc_csv_column_type_strs[GNC_CSV_NUM_COL_TYPES] = {N_("None"),
|
||||
/** A set of sensible defaults for parsing CSV files.
|
||||
* @return StfParseOptions_t* for parsing a file with comma separators
|
||||
*/
|
||||
static StfParseOptions_t* default_parse_options(void)
|
||||
static StfParseOptions_t* default_parse_options (void)
|
||||
{
|
||||
StfParseOptions_t* options = stf_parse_options_new();
|
||||
stf_parse_options_set_type(options, PARSE_TYPE_CSV);
|
||||
stf_parse_options_csv_set_separators(options, ",", NULL);
|
||||
stf_parse_options_set_type (options, PARSE_TYPE_CSV);
|
||||
stf_parse_options_csv_set_separators (options, ",", NULL);
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ static StfParseOptions_t* default_parse_options(void)
|
||||
* @param format An index specifying a format in date_format_user
|
||||
* @return The parsed value of date_str on success or -1 on failure
|
||||
*/
|
||||
static time64 parse_date_with_year(const char* date_str, int format)
|
||||
static time64 parse_date_with_year (const char* date_str, int format)
|
||||
{
|
||||
time64 rawtime; /* The integer time */
|
||||
struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
|
||||
@ -90,9 +90,9 @@ static time64 parse_date_with_year(const char* date_str, int format)
|
||||
const char* regex = "^ *([0-9]+) *[-/.'] *([0-9]+) *[-/.'] *([0-9]+).*$|^ *([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]).*$";
|
||||
|
||||
/* We get our matches using the regular expression. */
|
||||
regcomp(&preg, regex, REG_EXTENDED);
|
||||
regexec(&preg, date_str, 4, pmatch, 0);
|
||||
regfree(&preg);
|
||||
regcomp (&preg, regex, REG_EXTENDED);
|
||||
regexec (&preg, date_str, 4, pmatch, 0);
|
||||
regfree (&preg);
|
||||
|
||||
/* If there wasn't a match, there was an error. */
|
||||
if (pmatch[0].rm_eo == 0)
|
||||
@ -148,7 +148,7 @@ static time64 parse_date_with_year(const char* date_str, int format)
|
||||
/* Copy the matching substring into date_segment so that we can
|
||||
* convert it into an integer. */
|
||||
mem_length = pmatch[j].rm_eo - pmatch[j].rm_so;
|
||||
memcpy(date_segment, date_str + pmatch[j].rm_so, mem_length);
|
||||
memcpy (date_segment, date_str + pmatch[j].rm_so, mem_length);
|
||||
date_segment[mem_length] = '\0';
|
||||
|
||||
/* Set the appropriate member of retvalue. Save the original
|
||||
@ -157,7 +157,7 @@ static time64 parse_date_with_year(const char* date_str, int format)
|
||||
switch (segment_type)
|
||||
{
|
||||
case 'y':
|
||||
retvalue.tm_year = atoi(date_segment);
|
||||
retvalue.tm_year = atoi (date_segment);
|
||||
|
||||
/* Handle two-digit years. */
|
||||
if (retvalue.tm_year < 100)
|
||||
@ -172,11 +172,11 @@ static time64 parse_date_with_year(const char* date_str, int format)
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
orig_month = retvalue.tm_mon = atoi(date_segment) - 1;
|
||||
orig_month = retvalue.tm_mon = atoi (date_segment) - 1;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
orig_day = retvalue.tm_mday = atoi(date_segment);
|
||||
orig_day = retvalue.tm_mday = atoi (date_segment);
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
@ -211,7 +211,7 @@ static time64 parse_date_with_year(const char* date_str, int format)
|
||||
* @param format An index specifying a format in date_format_user
|
||||
* @return The parsed value of date_str on success or -1 on failure
|
||||
*/
|
||||
static time64 parse_date_without_year(const char* date_str, int format)
|
||||
static time64 parse_date_without_year (const char* date_str, int format)
|
||||
{
|
||||
time64 rawtime; /* The integer time */
|
||||
struct tm retvalue, test_retvalue; /* The time in a broken-down structure */
|
||||
@ -231,9 +231,9 @@ static time64 parse_date_without_year(const char* date_str, int format)
|
||||
const char* regex = "^ *([0-9]+) *[-/.'] *([0-9]+).*$";
|
||||
|
||||
/* We get our matches using the regular expression. */
|
||||
regcomp(&preg, regex, REG_EXTENDED);
|
||||
regexec(&preg, date_str, 3, pmatch, 0);
|
||||
regfree(&preg);
|
||||
regcomp (&preg, regex, REG_EXTENDED);
|
||||
regexec (&preg, date_str, 3, pmatch, 0);
|
||||
regfree (&preg);
|
||||
|
||||
/* If there wasn't a match, there was an error. */
|
||||
if (pmatch[0].rm_eo == 0)
|
||||
@ -259,7 +259,7 @@ static time64 parse_date_without_year(const char* date_str, int format)
|
||||
/* Copy the matching substring into date_segment so that we can
|
||||
* convert it into an integer. */
|
||||
mem_length = pmatch[j].rm_eo - pmatch[j].rm_so;
|
||||
date_segment = g_new(gchar, mem_length);
|
||||
date_segment = g_new (gchar, mem_length);
|
||||
memcpy(date_segment, date_str + pmatch[j].rm_so, mem_length);
|
||||
date_segment[mem_length] = '\0';
|
||||
|
||||
@ -269,14 +269,14 @@ static time64 parse_date_without_year(const char* date_str, int format)
|
||||
switch (segment_type)
|
||||
{
|
||||
case 'm':
|
||||
orig_month = retvalue.tm_mon = atoi(date_segment) - 1;
|
||||
orig_month = retvalue.tm_mon = atoi (date_segment) - 1;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
orig_day = retvalue.tm_mday = atoi(date_segment);
|
||||
orig_day = retvalue.tm_mday = atoi (date_segment);
|
||||
break;
|
||||
}
|
||||
g_free(date_segment);
|
||||
g_free (date_segment);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
@ -310,18 +310,18 @@ static time64 parse_date_without_year(const char* date_str, int format)
|
||||
* @param format An index specifying a format in date_format_user
|
||||
* @return The parsed value of date_str on success or -1 on failure
|
||||
*/
|
||||
time64 parse_date(const char* date_str, int format)
|
||||
time64 parse_date (const char* date_str, int format)
|
||||
{
|
||||
if (strchr(date_format_user[format], 'y'))
|
||||
return parse_date_with_year(date_str, format);
|
||||
if (strchr (date_format_user[format], 'y'))
|
||||
return parse_date_with_year (date_str, format);
|
||||
else
|
||||
return parse_date_without_year(date_str, format);
|
||||
return parse_date_without_year (date_str, format);
|
||||
}
|
||||
|
||||
/** Constructor for GncCsvParseData.
|
||||
* @return Pointer to a new GncCSvParseData
|
||||
*/
|
||||
GncCsvParseData* gnc_csv_new_parse_data(void)
|
||||
GncCsvParseData* gnc_csv_new_parse_data (void)
|
||||
{
|
||||
GncCsvParseData* parse_data = g_new(GncCsvParseData, 1);
|
||||
parse_data->encoding = "UTF-8";
|
||||
@ -346,32 +346,32 @@ GncCsvParseData* gnc_csv_new_parse_data(void)
|
||||
/** Destructor for GncCsvParseData.
|
||||
* @param parse_data Parse data whose memory will be freed
|
||||
*/
|
||||
void gnc_csv_parse_data_free(GncCsvParseData* parse_data)
|
||||
void gnc_csv_parse_data_free (GncCsvParseData* parse_data)
|
||||
{
|
||||
/* All non-NULL pointers have been initialized and must be freed. */
|
||||
|
||||
if (parse_data->raw_mapping != NULL)
|
||||
{
|
||||
g_mapped_file_unref(parse_data->raw_mapping);
|
||||
g_mapped_file_unref (parse_data->raw_mapping);
|
||||
}
|
||||
|
||||
if (parse_data->file_str.begin != NULL)
|
||||
g_free(parse_data->file_str.begin);
|
||||
g_free (parse_data->file_str.begin);
|
||||
|
||||
if (parse_data->orig_lines != NULL)
|
||||
stf_parse_general_free(parse_data->orig_lines);
|
||||
stf_parse_general_free (parse_data->orig_lines);
|
||||
|
||||
if (parse_data->orig_row_lengths != NULL)
|
||||
g_array_free(parse_data->orig_row_lengths, FALSE);
|
||||
g_array_free (parse_data->orig_row_lengths, FALSE);
|
||||
|
||||
if (parse_data->options != NULL)
|
||||
stf_parse_options_free(parse_data->options);
|
||||
stf_parse_options_free (parse_data->options);
|
||||
|
||||
if (parse_data->column_types != NULL)
|
||||
g_array_free(parse_data->column_types, TRUE);
|
||||
g_array_free (parse_data->column_types, TRUE);
|
||||
|
||||
if (parse_data->error_lines != NULL)
|
||||
g_list_free(parse_data->error_lines);
|
||||
g_list_free (parse_data->error_lines);
|
||||
|
||||
if (parse_data->transactions != NULL)
|
||||
{
|
||||
@ -380,15 +380,15 @@ void gnc_csv_parse_data_free(GncCsvParseData* parse_data)
|
||||
* the list before freeing the entire list. */
|
||||
do
|
||||
{
|
||||
g_free(transactions->data);
|
||||
transactions = g_list_next(transactions);
|
||||
g_free (transactions->data);
|
||||
transactions = g_list_next (transactions);
|
||||
}
|
||||
while (transactions != NULL);
|
||||
g_list_free(parse_data->transactions);
|
||||
g_list_free (parse_data->transactions);
|
||||
}
|
||||
|
||||
g_free(parse_data->chunk);
|
||||
g_free(parse_data);
|
||||
g_free (parse_data->chunk);
|
||||
g_free (parse_data);
|
||||
}
|
||||
|
||||
/** Converts raw file data using a new encoding. This function must be
|
||||
@ -399,7 +399,7 @@ void gnc_csv_parse_data_free(GncCsvParseData* parse_data)
|
||||
* @param error Will point to an error on failure
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding,
|
||||
int gnc_csv_convert_encoding (GncCsvParseData* parse_data, const char* encoding,
|
||||
GError** error)
|
||||
{
|
||||
gsize bytes_read, bytes_written;
|
||||
@ -412,7 +412,7 @@ int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding,
|
||||
g_free(parse_data->file_str.begin);
|
||||
|
||||
/* Do the actual translation to UTF-8. */
|
||||
parse_data->file_str.begin = g_convert(parse_data->raw_str.begin,
|
||||
parse_data->file_str.begin = g_convert (parse_data->raw_str.begin,
|
||||
parse_data->raw_str.end - parse_data->raw_str.begin,
|
||||
"UTF-8", encoding, &bytes_read, &bytes_written,
|
||||
error);
|
||||
@ -439,43 +439,43 @@ int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding,
|
||||
* @param error Will contain an error if there is a failure
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
int gnc_csv_load_file(GncCsvParseData* parse_data, const char* filename,
|
||||
int gnc_csv_load_file (GncCsvParseData* parse_data, const char* filename,
|
||||
GError** error)
|
||||
{
|
||||
const char* guess_enc = NULL;
|
||||
|
||||
/* Get the raw data first and handle an error if one occurs. */
|
||||
parse_data->raw_mapping = g_mapped_file_new(filename, FALSE, error);
|
||||
parse_data->raw_mapping = g_mapped_file_new (filename, FALSE, error);
|
||||
if (parse_data->raw_mapping == NULL)
|
||||
{
|
||||
/* TODO Handle file opening errors more specifically,
|
||||
* e.g. inexistent file versus no read permission. */
|
||||
parse_data->raw_str.begin = NULL;
|
||||
g_clear_error (error);
|
||||
g_set_error(error, 0, GNC_CSV_FILE_OPEN_ERR, "%s", _("File opening failed."));
|
||||
g_set_error (error, 0, GNC_CSV_FILE_OPEN_ERR, "%s", _("File opening failed."));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Copy the mapping's contents into parse-data->raw_str. */
|
||||
parse_data->raw_str.begin = g_mapped_file_get_contents(parse_data->raw_mapping);
|
||||
parse_data->raw_str.end = parse_data->raw_str.begin + g_mapped_file_get_length(parse_data->raw_mapping);
|
||||
parse_data->raw_str.begin = g_mapped_file_get_contents (parse_data->raw_mapping);
|
||||
parse_data->raw_str.end = parse_data->raw_str.begin + g_mapped_file_get_length (parse_data->raw_mapping);
|
||||
|
||||
/* Make a guess at the encoding of the data. */
|
||||
if (!g_mapped_file_get_length(parse_data->raw_mapping) == 0)
|
||||
guess_enc = go_guess_encoding((const char*)(parse_data->raw_str.begin),
|
||||
if (!g_mapped_file_get_length (parse_data->raw_mapping) == 0)
|
||||
guess_enc = go_guess_encoding ((const char*)(parse_data->raw_str.begin),
|
||||
(size_t)(parse_data->raw_str.end - parse_data->raw_str.begin),
|
||||
"UTF-8", NULL);
|
||||
if (guess_enc == NULL)
|
||||
{
|
||||
g_set_error(error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
|
||||
g_set_error (error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
|
||||
return 1;
|
||||
}
|
||||
/* Convert using the guessed encoding into parse_data->file_str and
|
||||
* handle any errors that occur. */
|
||||
gnc_csv_convert_encoding(parse_data, guess_enc, error);
|
||||
gnc_csv_convert_encoding (parse_data, guess_enc, error);
|
||||
if (parse_data->file_str.begin == NULL)
|
||||
{
|
||||
g_set_error(error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
|
||||
g_set_error (error, 0, GNC_CSV_ENCODING_ERR, "%s", _("Unknown encoding."));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -494,21 +494,21 @@ int gnc_csv_load_file(GncCsvParseData* parse_data, const char* filename,
|
||||
* @param error Will contain an error if there is a failure
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError** error)
|
||||
int gnc_csv_parse (GncCsvParseData* parse_data, gboolean guessColTypes, GError** error)
|
||||
{
|
||||
/* max_cols is the number of columns in the row with the most columns. */
|
||||
int i, max_cols = 0;
|
||||
|
||||
if (parse_data->orig_lines != NULL)
|
||||
{
|
||||
stf_parse_general_free(parse_data->orig_lines);
|
||||
stf_parse_general_free (parse_data->orig_lines);
|
||||
}
|
||||
|
||||
/* If everything is fine ... */
|
||||
if (parse_data->file_str.begin != NULL)
|
||||
{
|
||||
/* Do the actual parsing. */
|
||||
parse_data->orig_lines = stf_parse_general(parse_data->options, parse_data->chunk,
|
||||
parse_data->orig_lines = stf_parse_general (parse_data->options, parse_data->chunk,
|
||||
parse_data->file_str.begin,
|
||||
parse_data->file_str.end);
|
||||
}
|
||||
@ -520,12 +520,12 @@ int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError**
|
||||
|
||||
/* Record the original row lengths of parse_data->orig_lines. */
|
||||
if (parse_data->orig_row_lengths != NULL)
|
||||
g_array_free(parse_data->orig_row_lengths, FALSE);
|
||||
g_array_free (parse_data->orig_row_lengths, FALSE);
|
||||
|
||||
parse_data->orig_row_lengths =
|
||||
g_array_sized_new(FALSE, FALSE, sizeof(int), parse_data->orig_lines->len);
|
||||
g_array_sized_new (FALSE, FALSE, sizeof(int), parse_data->orig_lines->len);
|
||||
|
||||
g_array_set_size(parse_data->orig_row_lengths, parse_data->orig_lines->len);
|
||||
g_array_set_size (parse_data->orig_row_lengths, parse_data->orig_lines->len);
|
||||
parse_data->orig_max_row = 0;
|
||||
for (i = 0; i < parse_data->orig_lines->len; i++)
|
||||
{
|
||||
@ -538,7 +538,7 @@ int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError**
|
||||
/* If it failed, generate an error. */
|
||||
if (parse_data->orig_lines == NULL)
|
||||
{
|
||||
g_set_error(error, 0, 0, "Parsing failed.");
|
||||
g_set_error (error, 0, 0, "Parsing failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -553,13 +553,13 @@ int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError**
|
||||
{
|
||||
/* Free parse_data->column_types if it's already been created. */
|
||||
if (parse_data->column_types != NULL)
|
||||
g_array_free(parse_data->column_types, TRUE);
|
||||
g_array_free (parse_data->column_types, TRUE);
|
||||
|
||||
/* Create parse_data->column_types and fill it with guesses based
|
||||
* on the contents of each column. */
|
||||
parse_data->column_types = g_array_sized_new(FALSE, FALSE, sizeof(int),
|
||||
parse_data->column_types = g_array_sized_new (FALSE, FALSE, sizeof(int),
|
||||
max_cols);
|
||||
g_array_set_size(parse_data->column_types, max_cols);
|
||||
g_array_set_size (parse_data->column_types, max_cols);
|
||||
/* TODO Make it actually guess. */
|
||||
for (i = 0; i < parse_data->column_types->len; i++)
|
||||
{
|
||||
@ -574,7 +574,7 @@ int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError**
|
||||
* parse_data->column_types should have already been
|
||||
* initialized, so we don't check for it being NULL. */
|
||||
int i = parse_data->column_types->len;
|
||||
g_array_set_size(parse_data->column_types, max_cols);
|
||||
g_array_set_size (parse_data->column_types, max_cols);
|
||||
for (; i < parse_data->column_types->len; i++)
|
||||
{
|
||||
parse_data->column_types->data[i] = GNC_CSV_NONE;
|
||||
@ -605,9 +605,9 @@ typedef struct
|
||||
/** Constructor for TransProperty.
|
||||
* @param type The type of the new property (see TransProperty.type for possible values)
|
||||
*/
|
||||
static TransProperty* trans_property_new(int type, TransPropertyList* list)
|
||||
static TransProperty* trans_property_new (int type, TransPropertyList* list)
|
||||
{
|
||||
TransProperty* prop = g_new(TransProperty, 1);
|
||||
TransProperty* prop = g_new (TransProperty, 1);
|
||||
prop->type = type;
|
||||
prop->list = list;
|
||||
prop->value = NULL;
|
||||
@ -617,7 +617,7 @@ static TransProperty* trans_property_new(int type, TransPropertyList* list)
|
||||
/** Destructor for TransProperty.
|
||||
* @param prop The property to be freed
|
||||
*/
|
||||
static void trans_property_free(TransProperty* prop)
|
||||
static void trans_property_free (TransProperty* prop)
|
||||
{
|
||||
switch (prop->type)
|
||||
{
|
||||
@ -632,7 +632,7 @@ static void trans_property_free(TransProperty* prop)
|
||||
g_free(prop->value);
|
||||
break;
|
||||
}
|
||||
g_free(prop);
|
||||
g_free (prop);
|
||||
}
|
||||
|
||||
/** Sets the value of the property by parsing str. Note: this should
|
||||
@ -642,7 +642,7 @@ static void trans_property_free(TransProperty* prop)
|
||||
* @param str The string to be parsed
|
||||
* @return TRUE on success, FALSE on failure
|
||||
*/
|
||||
static gboolean trans_property_set(TransProperty* prop, char* str)
|
||||
static gboolean trans_property_set (TransProperty* prop, char* str)
|
||||
{
|
||||
char *endptr, *possible_currency_symbol, *str_dupe;
|
||||
gnc_numeric val;
|
||||
@ -656,37 +656,37 @@ static gboolean trans_property_set(TransProperty* prop, char* str)
|
||||
case GNC_CSV_DESCRIPTION:
|
||||
case GNC_CSV_NOTES:
|
||||
case GNC_CSV_NUM:
|
||||
prop->value = g_strdup(str);
|
||||
prop->value = g_strdup (str);
|
||||
return TRUE;
|
||||
|
||||
case GNC_CSV_BALANCE:
|
||||
case GNC_CSV_DEPOSIT:
|
||||
case GNC_CSV_WITHDRAWAL:
|
||||
str_dupe = g_strdup(str); /* First, we make a copy so we can't mess up real data. */
|
||||
str_dupe = g_strdup (str); /* First, we make a copy so we can't mess up real data. */
|
||||
/* If a cell is empty make its value = 0.0 */
|
||||
if ( strcmp(str_dupe, "") == 0)
|
||||
if (strcmp (str_dupe, "") == 0)
|
||||
{
|
||||
g_free(str_dupe);
|
||||
str_dupe = g_strdup("0.0");
|
||||
g_free (str_dupe);
|
||||
str_dupe = g_strdup ("0.0");
|
||||
}
|
||||
/* Go through str_dupe looking for currency symbols. */
|
||||
for (possible_currency_symbol = str_dupe; *possible_currency_symbol;
|
||||
possible_currency_symbol = g_utf8_next_char(possible_currency_symbol))
|
||||
possible_currency_symbol = g_utf8_next_char (possible_currency_symbol))
|
||||
{
|
||||
if (g_unichar_type(g_utf8_get_char(possible_currency_symbol)) == G_UNICODE_CURRENCY_SYMBOL)
|
||||
if (g_unichar_type (g_utf8_get_char (possible_currency_symbol)) == G_UNICODE_CURRENCY_SYMBOL)
|
||||
{
|
||||
/* If we find a currency symbol, save the position just ahead
|
||||
* of the currency symbol (next_symbol), and find the null
|
||||
* terminator of the string (last_symbol). */
|
||||
char *next_symbol = g_utf8_next_char(possible_currency_symbol), *last_symbol = next_symbol;
|
||||
char *next_symbol = g_utf8_next_char (possible_currency_symbol), *last_symbol = next_symbol;
|
||||
while (*last_symbol)
|
||||
last_symbol = g_utf8_next_char(last_symbol);
|
||||
last_symbol = g_utf8_next_char (last_symbol);
|
||||
|
||||
/* Move all of the string (including the null byte, which is
|
||||
* why we have +1 in the size parameter) following the
|
||||
* currency symbol back one character, thereby overwriting the
|
||||
* currency symbol. */
|
||||
memmove(possible_currency_symbol, next_symbol, last_symbol - next_symbol + 1);
|
||||
memmove (possible_currency_symbol, next_symbol, last_symbol - next_symbol + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -696,33 +696,33 @@ static gboolean trans_property_set(TransProperty* prop, char* str)
|
||||
{
|
||||
case 0:
|
||||
/* Currancy locale */
|
||||
if (!(xaccParseAmount(str_dupe, TRUE, &val, &endptr)))
|
||||
if (!(xaccParseAmount (str_dupe, TRUE, &val, &endptr)))
|
||||
{
|
||||
g_free(str_dupe);
|
||||
g_free (str_dupe);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
/* Currancy decimal period */
|
||||
if (!(xaccParseAmountExtended(str_dupe, TRUE, '-', '.', ',', "\003\003", "$+", &val, &endptr)))
|
||||
if (!(xaccParseAmountExtended (str_dupe, TRUE, '-', '.', ',', "\003\003", "$+", &val, &endptr)))
|
||||
{
|
||||
g_free(str_dupe);
|
||||
g_free (str_dupe);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
/* Currancy decimal comma */
|
||||
if (!(xaccParseAmountExtended(str_dupe, TRUE, '-', ',', '.', "\003\003", "$+", &val, &endptr)))
|
||||
if (!(xaccParseAmountExtended (str_dupe, TRUE, '-', ',', '.', "\003\003", "$+", &val, &endptr)))
|
||||
{
|
||||
g_free(str_dupe);
|
||||
g_free (str_dupe);
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
prop->value = g_new(gnc_numeric, 1);
|
||||
prop->value = g_new (gnc_numeric, 1);
|
||||
*((gnc_numeric*)(prop->value)) = val;
|
||||
g_free(str_dupe);
|
||||
g_free (str_dupe);
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
@ -734,9 +734,9 @@ static gboolean trans_property_set(TransProperty* prop, char* str)
|
||||
* @param date_format An index from date_format_user for how date properties should be parsed
|
||||
* @return A pointer to a new TransPropertyList
|
||||
*/
|
||||
static TransPropertyList* trans_property_list_new(Account* account, int date_format, int currency_format)
|
||||
static TransPropertyList* trans_property_list_new (Account* account, int date_format, int currency_format)
|
||||
{
|
||||
TransPropertyList* list = g_new(TransPropertyList, 1);
|
||||
TransPropertyList* list = g_new (TransPropertyList, 1);
|
||||
list->account = account;
|
||||
list->date_format = date_format;
|
||||
list->currency_format = currency_format;
|
||||
@ -747,17 +747,17 @@ static TransPropertyList* trans_property_list_new(Account* account, int date_for
|
||||
/** Destructor for TransPropertyList.
|
||||
* @param list The list to be freed
|
||||
*/
|
||||
static void trans_property_list_free(TransPropertyList* list)
|
||||
static void trans_property_list_free (TransPropertyList* list)
|
||||
{
|
||||
/* Free all of the properties in this list before freeeing the list itself. */
|
||||
GList* properties_begin = list->properties;
|
||||
while (list->properties != NULL)
|
||||
{
|
||||
trans_property_free((TransProperty*)(list->properties->data));
|
||||
list->properties = g_list_next(list->properties);
|
||||
trans_property_free ((TransProperty*)(list->properties->data));
|
||||
list->properties = g_list_next (list->properties);
|
||||
}
|
||||
g_list_free(properties_begin);
|
||||
g_free(list);
|
||||
g_list_free (properties_begin);
|
||||
g_free (list);
|
||||
}
|
||||
|
||||
/** Adds a property to the list it's linked with.
|
||||
@ -765,9 +765,9 @@ static void trans_property_list_free(TransPropertyList* list)
|
||||
* associated with a list when it's constructed.)
|
||||
* @param property The property to be added to its list
|
||||
*/
|
||||
static void trans_property_list_add(TransProperty* property)
|
||||
static void trans_property_list_add (TransProperty* property)
|
||||
{
|
||||
property->list->properties = g_list_append(property->list->properties, property);
|
||||
property->list->properties = g_list_append (property->list->properties, property);
|
||||
}
|
||||
|
||||
/** Adds a split to a transaction.
|
||||
@ -776,16 +776,16 @@ static void trans_property_list_add(TransProperty* property)
|
||||
* @param book The book where the split should be stored
|
||||
* @param amount The amount of the split
|
||||
*/
|
||||
static void trans_add_split(Transaction* trans, Account* account, QofBook* book,
|
||||
static void trans_add_split (Transaction* trans, Account* account, QofBook* book,
|
||||
gnc_numeric amount, const char *num)
|
||||
{
|
||||
Split* split = xaccMallocSplit(book);
|
||||
xaccSplitSetAccount(split, account);
|
||||
xaccSplitSetParent(split, trans);
|
||||
xaccSplitSetAmount(split, amount);
|
||||
xaccSplitSetValue(split, amount);
|
||||
Split* split = xaccMallocSplit (book);
|
||||
xaccSplitSetAccount (split, account);
|
||||
xaccSplitSetParent (split, trans);
|
||||
xaccSplitSetAmount (split, amount);
|
||||
xaccSplitSetValue (split, amount);
|
||||
/* set tran-num and/or split-action per book option */
|
||||
gnc_set_num_action(trans, split, num, NULL);
|
||||
gnc_set_num_action (trans, split, num, NULL);
|
||||
}
|
||||
|
||||
/** Tests a TransPropertyList for having enough essential properties.
|
||||
@ -795,7 +795,7 @@ static void trans_add_split(Transaction* trans, Account* account, QofBook* book,
|
||||
* @param error Contains an error message on failure
|
||||
* @return TRUE if there are enough essentials; FALSE otherwise
|
||||
*/
|
||||
static gboolean trans_property_list_verify_essentials(TransPropertyList* list, gchar** error)
|
||||
static gboolean trans_property_list_verify_essentials (TransPropertyList* list, gchar** error)
|
||||
{
|
||||
int i;
|
||||
/* possible_errors lists the ways in which a list can fail this test. */
|
||||
@ -823,7 +823,7 @@ static gboolean trans_property_list_verify_essentials(TransPropertyList* list, g
|
||||
possible_errors[NO_AMOUNT] = NULL;
|
||||
break;
|
||||
}
|
||||
list->properties = g_list_next(list->properties);
|
||||
list->properties = g_list_next (list->properties);
|
||||
}
|
||||
list->properties = properties_begin;
|
||||
|
||||
@ -832,10 +832,10 @@ static gboolean trans_property_list_verify_essentials(TransPropertyList* list, g
|
||||
{
|
||||
if (possible_errors[i] != NULL)
|
||||
{
|
||||
errors_list = g_list_append(errors_list, GINT_TO_POINTER(i));
|
||||
errors_list = g_list_append (errors_list, GINT_TO_POINTER(i));
|
||||
/* Since we added an error, we want to also store its length for
|
||||
* when we construct the full error string. */
|
||||
possible_error_lengths[i] = strlen(_(possible_errors[i]));
|
||||
possible_error_lengths[i] = strlen (_(possible_errors[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -854,12 +854,12 @@ static gboolean trans_property_list_verify_essentials(TransPropertyList* list, g
|
||||
{
|
||||
/* We add an extra 1 to account for spaces in between messages. */
|
||||
full_error_size += possible_error_lengths[GPOINTER_TO_INT(errors_list->data)] + 1;
|
||||
errors_list = g_list_next(errors_list);
|
||||
errors_list = g_list_next (errors_list);
|
||||
}
|
||||
errors_list = errors_list_begin;
|
||||
|
||||
/* Append the error messages one after another. */
|
||||
error_message = error_message_begin = g_new(gchar, full_error_size);
|
||||
error_message = error_message_begin = g_new (gchar, full_error_size);
|
||||
while (errors_list)
|
||||
{
|
||||
i = GPOINTER_TO_INT(errors_list->data);
|
||||
@ -871,10 +871,10 @@ static gboolean trans_property_list_verify_essentials(TransPropertyList* list, g
|
||||
*error_message = ' ';
|
||||
error_message++;
|
||||
|
||||
errors_list = g_list_next(errors_list);
|
||||
errors_list = g_list_next (errors_list);
|
||||
}
|
||||
*error_message = '\0'; /* Replace the last space with the null byte. */
|
||||
g_list_free(errors_list_begin);
|
||||
g_list_free (errors_list_begin);
|
||||
|
||||
*error = error_message_begin;
|
||||
return FALSE;
|
||||
@ -886,13 +886,13 @@ static gboolean trans_property_list_verify_essentials(TransPropertyList* list, g
|
||||
* @param error Contains an error on failure
|
||||
* @return On success, a GncCsvTransLine; on failure, the trans pointer is NULL
|
||||
*/
|
||||
static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gchar** error)
|
||||
static GncCsvTransLine* trans_property_list_to_trans (TransPropertyList* list, gchar** error)
|
||||
{
|
||||
GncCsvTransLine* trans_line = g_new(GncCsvTransLine, 1);
|
||||
GncCsvTransLine* trans_line = g_new (GncCsvTransLine, 1);
|
||||
GList* properties_begin = list->properties;
|
||||
QofBook* book = gnc_account_get_book(list->account);
|
||||
gnc_commodity* currency = xaccAccountGetCommodity(list->account);
|
||||
gnc_numeric amount = double_to_gnc_numeric(0.0, xaccAccountGetCommoditySCU(list->account),
|
||||
QofBook* book = gnc_account_get_book (list->account);
|
||||
gnc_commodity* currency = xaccAccountGetCommodity (list->account);
|
||||
gnc_numeric amount = double_to_gnc_numeric (0.0, xaccAccountGetCommoditySCU (list->account),
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gchar *num = NULL;
|
||||
|
||||
@ -910,15 +910,15 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
trans_line->line_no = -1;
|
||||
|
||||
/* Make sure this is a transaction with all the columns we need. */
|
||||
if (!trans_property_list_verify_essentials(list, error))
|
||||
if (!trans_property_list_verify_essentials (list, error))
|
||||
{
|
||||
g_free(trans_line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
trans_line->trans = xaccMallocTransaction(book);
|
||||
xaccTransBeginEdit(trans_line->trans);
|
||||
xaccTransSetCurrency(trans_line->trans, currency);
|
||||
trans_line->trans = xaccMallocTransaction (book);
|
||||
xaccTransBeginEdit (trans_line->trans);
|
||||
xaccTransSetCurrency (trans_line->trans, currency);
|
||||
|
||||
/* Go through each of the properties and edit the transaction accordingly. */
|
||||
list->properties = properties_begin;
|
||||
@ -928,15 +928,15 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
switch (prop->type)
|
||||
{
|
||||
case GNC_CSV_DATE:
|
||||
xaccTransSetDatePostedSecsNormalized(trans_line->trans, *((time64*)(prop->value)));
|
||||
xaccTransSetDatePostedSecsNormalized (trans_line->trans, *((time64*)(prop->value)));
|
||||
break;
|
||||
|
||||
case GNC_CSV_DESCRIPTION:
|
||||
xaccTransSetDescription(trans_line->trans, (char*)(prop->value));
|
||||
xaccTransSetDescription (trans_line->trans, (char*)(prop->value));
|
||||
break;
|
||||
|
||||
case GNC_CSV_NOTES:
|
||||
xaccTransSetNotes(trans_line->trans, (char*)(prop->value));
|
||||
xaccTransSetNotes (trans_line->trans, (char*)(prop->value));
|
||||
break;
|
||||
|
||||
case GNC_CSV_NUM:
|
||||
@ -953,9 +953,9 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
case GNC_CSV_DEPOSIT: /* Add deposits to the existing amount. */
|
||||
if (prop->value != NULL)
|
||||
{
|
||||
amount = gnc_numeric_add(*((gnc_numeric*)(prop->value)),
|
||||
amount = gnc_numeric_add (*((gnc_numeric*)(prop->value)),
|
||||
amount,
|
||||
xaccAccountGetCommoditySCU(list->account),
|
||||
xaccAccountGetCommoditySCU (list->account),
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
amount_set = TRUE;
|
||||
/* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
|
||||
@ -966,9 +966,9 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
case GNC_CSV_WITHDRAWAL: /* Withdrawals are just negative deposits. */
|
||||
if (prop->value != NULL)
|
||||
{
|
||||
amount = gnc_numeric_add(gnc_numeric_neg(*((gnc_numeric*)(prop->value))),
|
||||
amount = gnc_numeric_add (gnc_numeric_neg(*((gnc_numeric*)(prop->value))),
|
||||
amount,
|
||||
xaccAccountGetCommoditySCU(list->account),
|
||||
xaccAccountGetCommoditySCU (list->account),
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
amount_set = TRUE;
|
||||
/* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
|
||||
@ -986,13 +986,13 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
}
|
||||
break;
|
||||
}
|
||||
list->properties = g_list_next(list->properties);
|
||||
list->properties = g_list_next (list->properties);
|
||||
}
|
||||
|
||||
/* Add a split with the cumulative amount value. */
|
||||
trans_add_split(trans_line->trans, list->account, book, amount, num);
|
||||
trans_add_split (trans_line->trans, list->account, book, amount, num);
|
||||
if (num)
|
||||
g_free(num);
|
||||
g_free (num);
|
||||
|
||||
return trans_line;
|
||||
}
|
||||
@ -1007,7 +1007,7 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
* @param redo_errors TRUE to convert only error data, FALSE for all data
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
int gnc_csv_parse_to_trans (GncCsvParseData* parse_data, Account* account,
|
||||
gboolean redo_errors)
|
||||
{
|
||||
gboolean hasBalanceColumn;
|
||||
@ -1033,7 +1033,7 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
}
|
||||
if (parse_data->transactions != NULL)
|
||||
{
|
||||
g_list_free(parse_data->transactions);
|
||||
g_list_free (parse_data->transactions);
|
||||
}
|
||||
}
|
||||
parse_data->error_lines = NULL;
|
||||
@ -1048,9 +1048,9 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
{
|
||||
/* Move last_transaction to the end. */
|
||||
last_transaction = parse_data->transactions;
|
||||
while (g_list_next(last_transaction) != NULL)
|
||||
while (g_list_next (last_transaction) != NULL)
|
||||
{
|
||||
last_transaction = g_list_next(last_transaction);
|
||||
last_transaction = g_list_next (last_transaction);
|
||||
}
|
||||
}
|
||||
/* ... we use only the lines in error_lines. */
|
||||
@ -1077,7 +1077,7 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
/* This flag is TRUE if there are any errors in this row. */
|
||||
gboolean errors = FALSE;
|
||||
gchar* error_message = NULL;
|
||||
TransPropertyList* list = trans_property_list_new(account, parse_data->date_format, parse_data->currency_format );
|
||||
TransPropertyList* list = trans_property_list_new (account, parse_data->date_format, parse_data->currency_format );
|
||||
GncCsvTransLine* trans_line = NULL;
|
||||
|
||||
for (j = 0; j < line->len; j++)
|
||||
@ -1086,20 +1086,20 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
if ((column_types->data[j] != GNC_CSV_NONE) && (column_types->data[j] != GNC_CSV_ACCOUNT))
|
||||
{
|
||||
/* Affect the transaction appropriately. */
|
||||
TransProperty* property = trans_property_new(column_types->data[j], list);
|
||||
gboolean succeeded = trans_property_set(property, line->pdata[j]);
|
||||
TransProperty* property = trans_property_new (column_types->data[j], list);
|
||||
gboolean succeeded = trans_property_set (property, line->pdata[j]);
|
||||
|
||||
/* TODO Maybe move error handling to within TransPropertyList functions? */
|
||||
if (succeeded)
|
||||
{
|
||||
trans_property_list_add(property);
|
||||
trans_property_list_add (property);
|
||||
}
|
||||
else
|
||||
{
|
||||
errors = TRUE;
|
||||
error_message = g_strdup_printf(_("%s column could not be understood."),
|
||||
error_message = g_strdup_printf (_("%s column could not be understood."),
|
||||
_(gnc_csv_column_type_strs[property->type]));
|
||||
trans_property_free(property);
|
||||
trans_property_free (property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1108,16 +1108,16 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
/* If we had success, add the transaction to parse_data->transaction. */
|
||||
if (!errors)
|
||||
{
|
||||
trans_line = trans_property_list_to_trans(list, &error_message);
|
||||
trans_line = trans_property_list_to_trans (list, &error_message);
|
||||
errors = trans_line == NULL;
|
||||
}
|
||||
|
||||
trans_property_list_free(list);
|
||||
trans_property_list_free (list);
|
||||
|
||||
/* If there were errors, add this line to parse_data->error_lines. */
|
||||
if (errors)
|
||||
{
|
||||
parse_data->error_lines = g_list_append(parse_data->error_lines,
|
||||
parse_data->error_lines = g_list_append (parse_data->error_lines,
|
||||
GINT_TO_POINTER(i));
|
||||
/* If there's already an error message, we need to replace it. */
|
||||
if (line->len > (int)(parse_data->orig_row_lengths->data[i]))
|
||||
@ -1128,7 +1128,7 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
else
|
||||
{
|
||||
/* Put the error message at the end of the line. */
|
||||
g_ptr_array_add(line, error_message);
|
||||
g_ptr_array_add (line, error_message);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1143,32 +1143,32 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
|
||||
/* If we can just put it at the end, do so and increment last_transaction. */
|
||||
if (last_transaction == NULL ||
|
||||
xaccTransGetDate(((GncCsvTransLine*)(last_transaction->data))->trans) <= xaccTransGetDate(trans_line->trans))
|
||||
xaccTransGetDate (((GncCsvTransLine*)(last_transaction->data))->trans) <= xaccTransGetDate (trans_line->trans))
|
||||
{
|
||||
parse_data->transactions = g_list_append(parse_data->transactions, trans_line);
|
||||
parse_data->transactions = g_list_append (parse_data->transactions, trans_line);
|
||||
/* If this is the first transaction, we need to get last_transaction on track. */
|
||||
if (last_transaction == NULL)
|
||||
last_transaction = parse_data->transactions;
|
||||
else /* Otherwise, we can just continue. */
|
||||
last_transaction = g_list_next(last_transaction);
|
||||
last_transaction = g_list_next (last_transaction);
|
||||
}
|
||||
/* Otherwise, search backward for the correct spot. */
|
||||
else
|
||||
{
|
||||
GList* insertion_spot = last_transaction;
|
||||
while (insertion_spot != NULL &&
|
||||
xaccTransGetDate(((GncCsvTransLine*)(insertion_spot->data))->trans) > xaccTransGetDate(trans_line->trans))
|
||||
xaccTransGetDate (((GncCsvTransLine*)(insertion_spot->data))->trans) > xaccTransGetDate (trans_line->trans))
|
||||
{
|
||||
insertion_spot = g_list_previous(insertion_spot);
|
||||
insertion_spot = g_list_previous (insertion_spot);
|
||||
}
|
||||
/* Move insertion_spot one location forward since we have to
|
||||
* use the g_list_insert_before function. */
|
||||
if (insertion_spot == NULL) /* We need to handle the case of inserting at the beginning of the list. */
|
||||
insertion_spot = parse_data->transactions;
|
||||
else
|
||||
insertion_spot = g_list_next(insertion_spot);
|
||||
insertion_spot = g_list_next (insertion_spot);
|
||||
|
||||
parse_data->transactions = g_list_insert_before(parse_data->transactions, insertion_spot, trans_line);
|
||||
parse_data->transactions = g_list_insert_before (parse_data->transactions, insertion_spot, trans_line);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1176,7 +1176,7 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
if (redo_errors)
|
||||
{
|
||||
/* Move to the next error line in the list. */
|
||||
error_lines = g_list_next(error_lines);
|
||||
error_lines = g_list_next (error_lines);
|
||||
if (error_lines == NULL)
|
||||
i = parse_data->orig_lines->len; /* Don't continue the for loop. */
|
||||
else
|
||||
@ -1207,53 +1207,53 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
* differs from what it will be after the transactions are
|
||||
* imported. This will be sum of all the previous transactions for
|
||||
* any given transaction. */
|
||||
gnc_numeric balance_offset = double_to_gnc_numeric(0.0,
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
gnc_numeric balance_offset = double_to_gnc_numeric (0.0,
|
||||
xaccAccountGetCommoditySCU (account),
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
while (transactions != NULL)
|
||||
{
|
||||
GncCsvTransLine* trans_line = (GncCsvTransLine*)transactions->data;
|
||||
if (trans_line->balance_set)
|
||||
{
|
||||
time64 date = xaccTransGetDate(trans_line->trans);
|
||||
time64 date = xaccTransGetDate (trans_line->trans);
|
||||
/* Find what the balance should be by adding the offset to the actual balance. */
|
||||
gnc_numeric existing_balance = gnc_numeric_add(balance_offset,
|
||||
xaccAccountGetBalanceAsOfDate(account, date),
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
gnc_numeric existing_balance = gnc_numeric_add (balance_offset,
|
||||
xaccAccountGetBalanceAsOfDate (account, date),
|
||||
xaccAccountGetCommoditySCU (account),
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* The amount of the transaction is the difference between the new and existing balance. */
|
||||
gnc_numeric amount = gnc_numeric_sub(trans_line->balance,
|
||||
gnc_numeric amount = gnc_numeric_sub (trans_line->balance,
|
||||
existing_balance,
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
xaccAccountGetCommoditySCU (account),
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
SplitList* splits = xaccTransGetSplitList(trans_line->trans);
|
||||
SplitList* splits = xaccTransGetSplitList (trans_line->trans);
|
||||
while (splits)
|
||||
{
|
||||
SplitList* next_splits = g_list_next(splits);
|
||||
xaccSplitDestroy((Split*)splits->data);
|
||||
SplitList* next_splits = g_list_next (splits);
|
||||
xaccSplitDestroy ((Split*)splits->data);
|
||||
splits = next_splits;
|
||||
}
|
||||
|
||||
trans_add_split(trans_line->trans, account,
|
||||
gnc_account_get_book(account), amount, trans_line->num);
|
||||
trans_add_split (trans_line->trans, account,
|
||||
gnc_account_get_book (account), amount, trans_line->num);
|
||||
if (trans_line->num)
|
||||
g_free(trans_line->num);
|
||||
g_free (trans_line->num);
|
||||
|
||||
/* This new transaction needs to be added to the balance offset. */
|
||||
balance_offset = gnc_numeric_add(balance_offset,
|
||||
balance_offset = gnc_numeric_add (balance_offset,
|
||||
amount,
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
xaccAccountGetCommoditySCU (account),
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
transactions = g_list_next(transactions);
|
||||
transactions = g_list_next (transactions);
|
||||
}
|
||||
}
|
||||
|
||||
if (redo_errors) /* Now that we're at the end, we do the freeing. */
|
||||
{
|
||||
g_list_free(begin_error_lines);
|
||||
g_list_free (begin_error_lines);
|
||||
}
|
||||
|
||||
/* We need to resize parse_data->column_types since errors may have added columns. */
|
||||
@ -1263,7 +1263,7 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
max_cols = ((GPtrArray*)(parse_data->orig_lines->pdata[i]))->len;
|
||||
}
|
||||
i = parse_data->column_types->len;
|
||||
parse_data->column_types = g_array_set_size(parse_data->column_types, max_cols);
|
||||
parse_data->column_types = g_array_set_size (parse_data->column_types, max_cols);
|
||||
for (; i < max_cols; i++)
|
||||
{
|
||||
parse_data->column_types->data[i] = GNC_CSV_NONE;
|
||||
|
@ -118,19 +118,19 @@ typedef struct
|
||||
int currency_format; /**< The currency format, 0 for locale, 1 for comma dec and 2 for period */
|
||||
} GncCsvParseData;
|
||||
|
||||
GncCsvParseData* gnc_csv_new_parse_data(void);
|
||||
GncCsvParseData* gnc_csv_new_parse_data (void);
|
||||
|
||||
void gnc_csv_parse_data_free(GncCsvParseData* parse_data);
|
||||
void gnc_csv_parse_data_free (GncCsvParseData* parse_data);
|
||||
|
||||
int gnc_csv_load_file(GncCsvParseData* parse_data, const char* filename,
|
||||
int gnc_csv_load_file (GncCsvParseData* parse_data, const char* filename,
|
||||
GError** error);
|
||||
|
||||
int gnc_csv_convert_encoding(GncCsvParseData* parse_data, const char* encoding, GError** error);
|
||||
int gnc_csv_convert_encoding (GncCsvParseData* parse_data, const char* encoding, GError** error);
|
||||
|
||||
int gnc_csv_parse(GncCsvParseData* parse_data, gboolean guessColTypes, GError** error);
|
||||
int gnc_csv_parse (GncCsvParseData* parse_data, gboolean guessColTypes, GError** error);
|
||||
|
||||
int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account, gboolean redo_errors);
|
||||
int gnc_csv_parse_to_trans (GncCsvParseData* parse_data, Account* account, gboolean redo_errors);
|
||||
|
||||
time64 parse_date(const char* date_str, int format);
|
||||
time64 parse_date (const char* date_str, int format);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user