Bug 798753 - UX improvements in new import dialog

Rename the dialog to not mention export since we don't use it for that.
Change the key-column names to be specific to the listview.
Add tooltips to the listviews to explain what they're for
Persist the selected imexporter and profile in the book's state file.
Stop the inappropriate "there are transactions do you want to import
them?" dialog (missing AWAIT_TRANSACTIONS in gnc_ab_import_context call).
This commit is contained in:
John Ralls 2023-02-26 12:10:41 -08:00
parent 89e2bef427
commit ba12e31251
4 changed files with 99 additions and 5 deletions

View File

@ -28,6 +28,7 @@
#include <config.h> #include <config.h>
#include <stdbool.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include "dialog-ab-select-imexporter.h" #include "dialog-ab-select-imexporter.h"
#include <dialog-utils.h> #include <dialog-utils.h>
@ -232,6 +233,35 @@ tree_view_get_name (GtkTreeView *tv)
return NULL; return NULL;
} }
static void
tree_view_set_name (GtkTreeView *tree, const char* name)
{
GtkTreeIter iter;
GtkTreeModel* model = gtk_tree_view_get_model(tree);
bool found = false;
if (!gtk_tree_model_get_iter_first(model, &iter))
return;
do
{
char* row_name;
gtk_tree_model_get(model, &iter, NAME_COL, &row_name, -1);
if (!g_strcmp0(name, row_name))
{
found = true;
break;
}
}
while(gtk_tree_model_iter_next(model, &iter));
if (found)
{
GtkTreeSelection *sel = gtk_tree_view_get_selection(tree);
gtk_tree_selection_select_iter(sel, &iter);
}
}
char* char*
gnc_ab_select_imex_dlg_get_imexporter_name (GncABSelectImExDlg* imexd) gnc_ab_select_imex_dlg_get_imexporter_name (GncABSelectImExDlg* imexd)
{ {
@ -243,3 +273,17 @@ gnc_ab_select_imex_dlg_get_profile_name (GncABSelectImExDlg* imexd)
{ {
return tree_view_get_name (GTK_TREE_VIEW (imexd->select_profile)); return tree_view_get_name (GTK_TREE_VIEW (imexd->select_profile));
} }
void
gnc_ab_select_imex_dlg_set_imexporter_name (GncABSelectImExDlg* imexd, const char* name)
{
if (name)
tree_view_set_name (GTK_TREE_VIEW (imexd->select_imexporter), name);
}
void
gnc_ab_select_imex_dlg_set_profile_name (GncABSelectImExDlg* imexd, const char* name)
{
if (name)
tree_view_set_name (GTK_TREE_VIEW (imexd->select_profile), name);
}

View File

@ -70,6 +70,14 @@ int gnc_ab_select_imex_dlg_run (GncABSelectImExDlg* imexd);
char* char*
gnc_ab_select_imex_dlg_get_imexporter_name (GncABSelectImExDlg* imexd); gnc_ab_select_imex_dlg_get_imexporter_name (GncABSelectImExDlg* imexd);
/**
* Get the selected importer/exporter name
* @param imexd the dialog with the selection
* @para name the importer/exporter name to select.
*/
void
gnc_ab_select_imex_dlg_set_imexporter_name (GncABSelectImExDlg* imexd, const char* name);
/** /**
* Get the selected file format profile name * Get the selected file format profile name
* @param imexd the dialog with the selection * @param imexd the dialog with the selection
@ -78,6 +86,14 @@ gnc_ab_select_imex_dlg_get_imexporter_name (GncABSelectImExDlg* imexd);
char* char*
gnc_ab_select_imex_dlg_get_profile_name (GncABSelectImExDlg* imexd); gnc_ab_select_imex_dlg_get_profile_name (GncABSelectImExDlg* imexd);
/**
* Get the selected file format profile name
* @param imexd the dialog with the selection
* @param name the profile to select.
*/
void
gnc_ab_select_imex_dlg_set_profile_name (GncABSelectImExDlg* imexd, const char* name);
G_END_DECLS G_END_DECLS
#endif //DIALOG_AB_SELECT_IMEXPORTER_H #endif //DIALOG_AB_SELECT_IMEXPORTER_H

View File

@ -1658,7 +1658,7 @@
<object class="GtkDialog" id="aqbanking-select-imexporter-dialog"> <object class="GtkDialog" id="aqbanking-select-imexporter-dialog">
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="border-width">5</property> <property name="border-width">5</property>
<property name="title" translatable="yes">Select File Importer/Exporter</property> <property name="title" translatable="yes">Select File Import Format and Template</property>
<property name="type-hint">dialog</property> <property name="type-hint">dialog</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3"> <object class="GtkBox" id="dialog-vbox3">
@ -1727,9 +1727,10 @@
<property name="model">imexporter-list</property> <property name="model">imexporter-list</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name='tooltip-text' translatable='yes'>This list contains the file formats that AQBanking knows how to import. The profile list contains specializations and is populated according to which format you select in this list.</property>
<child> <child>
<object class="GtkTreeViewColumn" id="imexporter-name"> <object class="GtkTreeViewColumn" id="imexporter-name">
<property name="title" translatable="yes">Name</property> <property name="title" translatable="yes">File Format</property>
<child> <child>
<object class="GtkCellRendererText"/> <object class="GtkCellRendererText"/>
<attributes> <attributes>
@ -1768,12 +1769,14 @@
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="hscrollbar-policy">never</property> <property name="hscrollbar-policy">never</property>
<property name="shadow-type">in</property> <property name="shadow-type">in</property>
<!--property name="title" translatable="yes">Import Template</property-->
<property name="min-content-height">300</property> <property name="min-content-height">300</property>
<child> <child>
<object class="GtkTreeView" id="profile-sel"> <object class="GtkTreeView" id="profile-sel">
<property name="model">profile-list</property> <property name="model">profile-list</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name='tooltip-text' translatable='yes'>This list one or more specialization templates that adjust the import for different banks uses of fields in the selected import format.</property>
<!-- Request the maximum width for the profile <!-- Request the maximum width for the profile
list so that it doesn't change the dialog list so that it doesn't change the dialog
width when an imexporter with long width when an imexporter with long
@ -1781,7 +1784,7 @@
<property name="width-request">400</property> <property name="width-request">400</property>
<child> <child>
<object class="GtkTreeViewColumn" id="profile-name"> <object class="GtkTreeViewColumn" id="profile-name">
<property name="title" translatable="yes">Name</property> <property name="title" translatable="yes">Profiles</property>
<child> <child>
<object class="GtkCellRendererText"/> <object class="GtkCellRendererText"/>
<attributes> <attributes>

View File

@ -60,6 +60,7 @@ typedef GWEN_SYNCIO GWEN_IO_LAYER;
#include "gnc-ui-util.h" #include "gnc-ui-util.h"
#include "import-account-matcher.h" #include "import-account-matcher.h"
#include "import-main-matcher.h" #include "import-main-matcher.h"
#include <gnc-state.h>
/* This static indicates the debugging module that this .o belongs to. */ /* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_IMPORT; static QofLogModule log_module = GNC_MOD_IMPORT;
@ -103,13 +104,38 @@ named_import_get_context (GtkWindow *parent, AB_BANKING *api,
return context; return context;
} }
static const char *GNC_STATE_SECTION = "dialogs.aqb.file-import";
static const char *STATE_KEY_LAST_FORMAT = "format";
static const char *STATE_KEY_LAST_PROFILE = "profile";
static void
load_imexporter_and_profile(char** imexporter, char** profile)
{
GKeyFile *state_file = gnc_state_get_current();
if (g_key_file_has_key(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_FORMAT, NULL))
*imexporter = g_key_file_get_string (state_file, GNC_STATE_SECTION, STATE_KEY_LAST_FORMAT, NULL);
if (g_key_file_has_key(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_PROFILE, NULL))
*profile = g_key_file_get_string (state_file, GNC_STATE_SECTION, STATE_KEY_LAST_PROFILE, NULL);
}
static void
save_imexporter_and_profile(const char* imexporter, const char *profile)
{
GKeyFile *state_file = gnc_state_get_current();
g_key_file_set_string(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_FORMAT, imexporter);
g_key_file_set_string(state_file, GNC_STATE_SECTION, STATE_KEY_LAST_PROFILE, profile);
}
void void
gnc_file_aqbanking_import_dialog (GtkWindow *parent) gnc_file_aqbanking_import_dialog (GtkWindow *parent)
{ {
AB_BANKING* api = gnc_AB_BANKING_new (); AB_BANKING* api = gnc_AB_BANKING_new ();
GncABSelectImExDlg* imexd = GncABSelectImExDlg* imexd =
gnc_ab_select_imex_dlg_new (GTK_WIDGET (parent), api); gnc_ab_select_imex_dlg_new (GTK_WIDGET (parent), api);
char *imexporter, *profile; char *imexporter = NULL, *profile = NULL;
AB_IMEXPORTER_CONTEXT* ctx = NULL; AB_IMEXPORTER_CONTEXT* ctx = NULL;
if (!imexd) if (!imexd)
@ -119,6 +145,9 @@ gnc_file_aqbanking_import_dialog (GtkWindow *parent)
gnc_AB_BANKING_fini(api); gnc_AB_BANKING_fini(api);
return; return;
} }
load_imexporter_and_profile(&imexporter, &profile);
gnc_ab_select_imex_dlg_set_imexporter_name(imexd, imexporter);
gnc_ab_select_imex_dlg_set_profile_name(imexd, profile);
if (!gnc_ab_select_imex_dlg_run (imexd)) if (!gnc_ab_select_imex_dlg_run (imexd))
{ {
@ -137,10 +166,12 @@ gnc_file_aqbanking_import_dialog (GtkWindow *parent)
if (ctx) if (ctx)
{ {
GncABImExContextImport* ieci = NULL; GncABImExContextImport* ieci = NULL;
ieci = gnc_ab_import_context (ctx, 0, FALSE, api, GTK_WIDGET(parent)); ieci = gnc_ab_import_context (ctx, AWAIT_TRANSACTIONS, FALSE, api, GTK_WIDGET(parent));
g_free(ieci); g_free(ieci);
AB_ImExporterContext_free(ctx); AB_ImExporterContext_free(ctx);
} }
save_imexporter_and_profile(imexporter, profile);
g_free (imexporter); g_free (imexporter);
g_free (profile); g_free (profile);
} }