Skip to content

Commit

Permalink
Merge branch 'Bug796896' of https://github.com/Bob-IT/gnucash into maint
Browse files Browse the repository at this point in the history
  • Loading branch information
gjanssens committed Nov 28, 2018
2 parents 61cd799 + 458dac8 commit de6c173
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 312 deletions.
3 changes: 1 addition & 2 deletions gnucash/gtkbuilder/assistant-csv-account-import.glade
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.20.4 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="num_hrows_adj">
Expand Down Expand Up @@ -279,7 +279,6 @@ Enter file name and location for the Import...
</child>
</object>
<packing>
<property name="page_type">progress</property>
<property name="title" translatable="yes">Import Account Preview, first 10 rows only</property>
<property name="complete">True</property>
<property name="has_padding">False</property>
Expand Down
54 changes: 11 additions & 43 deletions gnucash/gtkbuilder/assistant-csv-price-import.glade
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.20.4 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="end_row_adj">
Expand Down Expand Up @@ -66,6 +66,7 @@ Click on 'Forward' to proceed or 'Cancel' to Abort Import.</property>
</object>
<packing>
<property name="page_type">intro</property>
<property name="title" translatable="yes">Price Import Assistant</property>
<property name="complete">True</property>
<property name="has_padding">False</property>
</packing>
Expand Down Expand Up @@ -453,6 +454,7 @@ Select location and file name for the Import, then click 'OK'...
<property name="label" translatable="yes">Double-click anywhere on the table below to insert a column break</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
Expand Down Expand Up @@ -480,6 +482,7 @@ Select location and file name for the Import, then click 'OK'...
<property name="label" translatable="yes">Right-click anywhere in a column to modify it (widen, narrow, merge)</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
Expand Down Expand Up @@ -920,48 +923,13 @@ For example
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkViewport" id="viewport2">
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="vbox8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTreeView" id="ctreeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="headers_visible">False</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
</child>
Expand Down Expand Up @@ -1042,7 +1010,7 @@ For example
</child>
</object>
<packing>
<property name="page_type">intro</property>
<property name="title" translatable="yes">Import Preview</property>
<property name="complete">True</property>
<property name="has_padding">False</property>
</packing>
Expand Down
56 changes: 12 additions & 44 deletions gnucash/gtkbuilder/assistant-csv-trans-import.glade
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.20.4 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="account_match_store">
Expand Down Expand Up @@ -57,6 +57,7 @@ Lastly, for repeated imports the preview page has buttons to Load and Save the s
</object>
<packing>
<property name="page_type">intro</property>
<property name="title" translatable="yes">Transaction Import Assistant</property>
<property name="complete">True</property>
<property name="has_padding">False</property>
</packing>
Expand Down Expand Up @@ -453,6 +454,7 @@ Select location and file name for the Import, then click 'OK'...
<property name="label" translatable="yes">Double-click anywhere on the table below to insert a column break</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
Expand Down Expand Up @@ -480,6 +482,7 @@ Select location and file name for the Import, then click 'OK'...
<property name="label" translatable="yes">Right-click anywhere in a column to modify it (widen, narrow, merge)</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
Expand Down Expand Up @@ -854,48 +857,13 @@ For example
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkViewport" id="viewport2">
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="vbox8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTreeView" id="ctreeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="headers_visible">False</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTreeView" id="treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2"/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection2"/>
</child>
</object>
</child>
Expand Down Expand Up @@ -982,7 +950,7 @@ For example
</child>
</object>
<packing>
<property name="page_type">intro</property>
<property name="title" translatable="yes">Import Preview</property>
<property name="complete">True</property>
<property name="has_padding">False</property>
</packing>
Expand Down Expand Up @@ -1098,7 +1066,7 @@ For example
</child>
</object>
<packing>
<property name="title" translatable="yes">Match Import accounts with GnuCash accounts</property>
<property name="title" translatable="yes">Match Import and GnuCash accounts</property>
<property name="has_padding">False</property>
</packing>
</child>
Expand Down
61 changes: 26 additions & 35 deletions gnucash/import-export/csv-exp/assistant-csv-export.c
Expand Up @@ -73,7 +73,7 @@ void csv_export_show_range_cb (GtkRadioButton *button, gpointer user_data);
void csv_export_start_date_cb (GtkWidget *radio, gpointer user_data);
void csv_export_end_date_cb (GtkWidget *radio, gpointer user_data);

void csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info);
void csv_export_file_chooser_selection_changed_cb (GtkFileChooser *chooser, CsvExportInfo *info);

static const gchar *finish_tree_string = N_(
/* Translators: %s is the file name string. */
Expand Down Expand Up @@ -121,55 +121,43 @@ static const gchar *start_trans_simple_string = N_(


/**************************************************
* csv_export_file_chooser_confirm_cb
* csv_export_file_chooser_selection_changed_cb
*
* call back for ok button in file chooser widget
* call back for GtkFileChooser widget
**************************************************/
void
csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info)
csv_export_file_chooser_selection_changed_cb (GtkFileChooser *chooser, CsvExportInfo *info)
{
GtkAssistant *assistant = GTK_ASSISTANT(info->window);
gint num = gtk_assistant_get_current_page (assistant);
GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);

gchar *file_name;

gtk_assistant_set_page_complete (assistant, page, FALSE);

file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(info->file_chooser));

if (file_name)
/* Test for a valid filename and not a directory */
if (file_name && !g_file_test (file_name, G_FILE_TEST_IS_DIR))
{
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?");

/* if user says cancel, we should break out */
if (!gnc_verify_dialog (GTK_WINDOW (assistant), FALSE, format, file_name))
return;
}
gchar *filepath = gnc_uri_get_path (file_name);
gchar *filedir = g_path_get_dirname (filepath);

g_free (info->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);
g_free (info->starting_dir);
info->starting_dir = g_strdup (filedir);

g_free (filedir);
g_free (filepath);

gtk_assistant_set_page_complete (assistant, page, TRUE);
}
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))
gtk_assistant_set_current_page (assistant, num + 1);
}


Expand Down Expand Up @@ -268,7 +256,6 @@ csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data)
info->separator_str = strdup (custom_str);

if (info->use_custom == TRUE && gtk_entry_get_text_length (GTK_ENTRY(info->custom_entry)) == 0)

gtk_assistant_set_page_complete (assistant, page, FALSE);
else
gtk_assistant_set_page_complete (assistant, page, TRUE);
Expand Down Expand Up @@ -701,6 +688,16 @@ csv_export_assistant_finish_page_prepare (GtkAssistant *assistant,
gtk_label_set_text (GTK_LABEL(info->finish_label), text);
g_free (text);

/* Test if the filename exists */
if (g_file_test (info->file_name, G_FILE_TEST_EXISTS))
{
const char *format = _("The file %s already exists. "
"Are you sure you want to overwrite it?");

/* if user says cancel, we should go back a page */
if (!gnc_verify_dialog (GTK_WINDOW (assistant), FALSE, format, info->file_name))
gtk_assistant_previous_page (assistant);
}
/* Enable the Assistant Buttons */
gtk_assistant_set_page_complete (assistant, page, TRUE);
}
Expand Down Expand Up @@ -921,15 +918,9 @@ 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_with_mnemonic (_("_OK"));
gtk_widget_set_size_request (button, 100, -1);
gtk_widget_show (button);
h_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_homogeneous (GTK_BOX (h_box), TRUE);
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(info->file_chooser), "selection-changed",
G_CALLBACK(csv_export_file_chooser_selection_changed_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);
Expand Down

0 comments on commit de6c173

Please sign in to comment.