mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #514210: Allow multiple rows to be selected and remapped on QIF Import
account mapping pages. Also includes many whitespace adjustments. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17156 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d0ddccaa01
commit
23b3f81410
@ -79,7 +79,7 @@ acct_tree_add_accts(SCM accts,
|
||||
else
|
||||
compname = "";
|
||||
|
||||
if(!SCM_NULLP(SCM_CADDR(current))) {
|
||||
if (!SCM_NULLP(SCM_CADDR(current))) {
|
||||
leafnode = FALSE;
|
||||
}
|
||||
else {
|
||||
@ -87,7 +87,7 @@ acct_tree_add_accts(SCM accts,
|
||||
}
|
||||
|
||||
/* compute full name */
|
||||
if(base_name && *base_name) {
|
||||
if (base_name && *base_name) {
|
||||
acctname = g_strjoin(gnc_get_account_separator_string(),
|
||||
base_name, compname, (char *)NULL);
|
||||
}
|
||||
@ -95,7 +95,7 @@ acct_tree_add_accts(SCM accts,
|
||||
acctname = g_strdup(compname);
|
||||
}
|
||||
|
||||
checked = (SCM_CADR (current) == SCM_BOOL_T);
|
||||
checked = (SCM_CADR(current) == SCM_BOOL_T);
|
||||
|
||||
gtk_tree_store_append(store, &iter, parent);
|
||||
gtk_tree_store_set(store, &iter,
|
||||
@ -160,7 +160,7 @@ gnc_ui_qif_account_picker_new_cb(GtkButton * w, gpointer user_data)
|
||||
char * fullname;
|
||||
GtkWidget *dlg, *entry;
|
||||
|
||||
dlg = gtk_message_dialog_new (GTK_WINDOW(wind->dialog),
|
||||
dlg = gtk_message_dialog_new(GTK_WINDOW(wind->dialog),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_OK_CANCEL,
|
||||
@ -192,7 +192,7 @@ gnc_ui_qif_account_picker_new_cb(GtkButton * w, gpointer user_data)
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_qif_account_picker_changed_cb (GtkTreeSelection *selection,
|
||||
gnc_ui_qif_account_picker_changed_cb(GtkTreeSelection *selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
QIFAccountPickerDialog * wind = user_data;
|
||||
@ -202,22 +202,26 @@ gnc_ui_qif_account_picker_changed_cb (GtkTreeSelection *selection,
|
||||
|
||||
g_free(wind->selected_name);
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
|
||||
gtk_tree_model_get(model, &iter, ACCOUNT_COL_FULLNAME, &wind->selected_name, -1);
|
||||
scm_call_2(name_setter, wind->map_entry, scm_makfrom0str(wind->selected_name));
|
||||
gtk_tree_model_get(model, &iter,
|
||||
ACCOUNT_COL_FULLNAME, &wind->selected_name,
|
||||
-1);
|
||||
scm_call_2(name_setter, wind->map_entry,
|
||||
scm_makfrom0str(wind->selected_name));
|
||||
} else {
|
||||
wind->selected_name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_qif_account_picker_row_activated_cb (GtkTreeView *view, GtkTreePath *path,
|
||||
gnc_ui_qif_account_picker_row_activated_cb(GtkTreeView *view,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column,
|
||||
gpointer user_data)
|
||||
{
|
||||
QIFAccountPickerDialog *wind = user_data;
|
||||
g_return_if_fail (wind);
|
||||
g_return_if_fail(wind);
|
||||
|
||||
gtk_dialog_response (GTK_DIALOG (wind->dialog), GTK_RESPONSE_OK);
|
||||
gtk_dialog_response(GTK_DIALOG(wind->dialog), GTK_RESPONSE_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -232,21 +236,22 @@ gnc_ui_qif_account_picker_map_cb(GtkWidget * w, gpointer user_data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************
|
||||
* qif_account_picker_dialog
|
||||
* select an account from the ones that the engine knows about, plus
|
||||
* the ones that will be created newly by the QIF import. this is
|
||||
* sort of like fileBox... it returns a string for the account name or
|
||||
* NULL on cancel. It's modal.
|
||||
*
|
||||
* Select an account from the ones that the engine knows about,
|
||||
* plus those that will be created by the QIF import. Returns
|
||||
* a new Scheme map entry, or SCM_BOOL_F on cancel. Modal.
|
||||
****************************************************************/
|
||||
|
||||
SCM
|
||||
qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
|
||||
{
|
||||
QIFAccountPickerDialog * wind;
|
||||
SCM save_entry = scm_c_eval_string("qif-map-entry:clone");
|
||||
SCM clone_entry = scm_c_eval_string("qif-map-entry:clone");
|
||||
SCM init_pick = scm_c_eval_string("qif-map-entry:gnc-name");
|
||||
SCM saved_entry = scm_call_1(save_entry, map_entry);
|
||||
SCM new_entry = scm_call_1(clone_entry, map_entry);
|
||||
int response;
|
||||
const gchar * scmname;
|
||||
GladeXML *xml;
|
||||
@ -254,19 +259,20 @@ qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
|
||||
|
||||
wind = g_new0(QIFAccountPickerDialog, 1);
|
||||
|
||||
xml = gnc_glade_xml_new ("qif.glade", "QIF Import Account Picker");
|
||||
xml = gnc_glade_xml_new("qif.glade", "QIF Import Account Picker");
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_account_picker_new_cb",
|
||||
G_CALLBACK (gnc_ui_qif_account_picker_new_cb), wind);
|
||||
glade_xml_signal_connect_data(xml,
|
||||
"gnc_ui_qif_account_picker_new_cb",
|
||||
G_CALLBACK(gnc_ui_qif_account_picker_new_cb),
|
||||
wind);
|
||||
|
||||
wind->dialog = glade_xml_get_widget (xml, "QIF Import Account Picker");
|
||||
wind->treeview = GTK_TREE_VIEW(glade_xml_get_widget (xml, "account_tree"));
|
||||
wind->dialog = glade_xml_get_widget(xml, "QIF Import Account Picker");
|
||||
wind->treeview = GTK_TREE_VIEW(glade_xml_get_widget(xml, "account_tree"));
|
||||
wind->qif_wind = qif_wind;
|
||||
|
||||
wind->map_entry = map_entry;
|
||||
wind->map_entry = new_entry;
|
||||
|
||||
scmname = SCM_STRING_CHARS(scm_call_1(init_pick, map_entry));
|
||||
scmname = SCM_STRING_CHARS(scm_call_1(init_pick, new_entry));
|
||||
wind->selected_name = g_strdup(scmname);
|
||||
|
||||
scm_gc_protect_object(wind->map_entry);
|
||||
@ -283,16 +289,20 @@ qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
|
||||
g_object_unref(store);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer,
|
||||
"text", ACCOUNT_COL_NAME,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Account"),
|
||||
renderer,
|
||||
"text",
|
||||
ACCOUNT_COL_NAME,
|
||||
NULL);
|
||||
g_object_set(column, "expand", TRUE, NULL);
|
||||
gtk_tree_view_append_column(wind->treeview, column);
|
||||
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
g_object_set(renderer, "activatable", FALSE, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes(_("New?"), renderer,
|
||||
"active", ACCOUNT_COL_CHECK,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("New?"),
|
||||
renderer,
|
||||
"active",
|
||||
ACCOUNT_COL_CHECK,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(wind->treeview, column);
|
||||
|
||||
@ -308,7 +318,7 @@ qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
|
||||
G_CALLBACK(gnc_ui_qif_account_picker_map_cb),
|
||||
wind);
|
||||
|
||||
button = glade_xml_get_widget (xml, "newbutton");
|
||||
button = glade_xml_get_widget(xml, "newbutton");
|
||||
gtk_button_set_use_stock(GTK_BUTTON(button), TRUE);
|
||||
|
||||
/* this is to get the checkmarks set up right.. it will get called
|
||||
@ -324,10 +334,8 @@ qif_account_picker_dialog(QIFImportWindow * qif_wind, SCM map_entry)
|
||||
g_free(wind->selected_name);
|
||||
g_free(wind);
|
||||
|
||||
if (response == GTK_RESPONSE_OK) {
|
||||
return map_entry;
|
||||
}
|
||||
else {
|
||||
return saved_entry;
|
||||
}
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
return new_entry;
|
||||
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ gnc_ui_qif_import_commodity_destroy(QIFImportWindow * wind)
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
gnc_ui_qif_import_druid_destroy (QIFImportWindow * window)
|
||||
gnc_ui_qif_import_druid_destroy(QIFImportWindow * window)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
@ -307,8 +307,10 @@ get_next_druid_page(QIFImportWindow * wind, GnomeDruidPage * page)
|
||||
}
|
||||
}
|
||||
|
||||
if(next) return (GtkWidget *)next->data;
|
||||
else return NULL;
|
||||
if (next)
|
||||
return (GtkWidget *)next->data;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -396,7 +398,7 @@ get_prev_druid_page(QIFImportWindow * wind, GnomeDruidPage * page)
|
||||
|
||||
if(prev)
|
||||
return (GtkWidget *)prev->data;
|
||||
else
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -470,10 +472,10 @@ gnc_ui_qif_import_select_file_cb(GtkButton * button,
|
||||
/* Default to whatever's already present */
|
||||
default_dir = gnc_get_default_directory(GCONF_SECTION);
|
||||
|
||||
filter = gtk_file_filter_new ();
|
||||
gtk_file_filter_set_name (filter, "*.qif");
|
||||
gtk_file_filter_add_pattern (filter, "*.[Qq][Ii][Ff]");
|
||||
new_file_name = gnc_file_dialog (_("Select QIF File"),
|
||||
filter = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name(filter, "*.qif");
|
||||
gtk_file_filter_add_pattern(filter, "*.[Qq][Ii][Ff]");
|
||||
new_file_name = gnc_file_dialog(_("Select QIF File"),
|
||||
g_list_prepend (NULL, filter),
|
||||
default_dir,
|
||||
GNC_FILE_DIALOG_IMPORT);
|
||||
@ -781,7 +783,7 @@ gnc_ui_qif_import_date_format_next_cb(GnomeDruidPage * page,
|
||||
****************************************************************/
|
||||
|
||||
static void
|
||||
gnc_ui_qif_import_select_loaded_file_cb (GtkTreeSelection *selection,
|
||||
gnc_ui_qif_import_select_loaded_file_cb(GtkTreeSelection *selection,
|
||||
gpointer user_data)
|
||||
{
|
||||
QIFImportWindow * wind = user_data;
|
||||
@ -1063,7 +1065,7 @@ update_account_picker_page(QIFImportWindow * wind, SCM make_display,
|
||||
prev_row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(store), PREV_ROW));
|
||||
if (prev_row != -1) {
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||
path = gtk_tree_path_new_from_indices (prev_row, -1);
|
||||
path = gtk_tree_path_new_from_indices(prev_row, -1);
|
||||
gtk_tree_selection_select_path(selection, path);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
@ -1081,12 +1083,13 @@ update_accounts_page(QIFImportWindow * wind)
|
||||
|
||||
SCM make_account_display = scm_c_eval_string("qif-dialog:make-account-display");
|
||||
|
||||
update_account_picker_page (wind, make_account_display, wind->acct_view,
|
||||
update_account_picker_page(wind, make_account_display, wind->acct_view,
|
||||
wind->acct_map_info, &(wind->acct_display_info));
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* update_categories_page
|
||||
*
|
||||
* update the QIF category -> GNC Account picker
|
||||
****************************************************************/
|
||||
|
||||
@ -1095,12 +1098,13 @@ update_categories_page(QIFImportWindow * wind)
|
||||
{
|
||||
SCM make_category_display = scm_c_eval_string("qif-dialog:make-category-display");
|
||||
|
||||
update_account_picker_page (wind, make_category_display, wind->cat_view,
|
||||
update_account_picker_page(wind, make_category_display, wind->cat_view,
|
||||
wind->cat_map_info, &(wind->cat_display_info));
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* update_memo_page
|
||||
*
|
||||
* update the QIF memo -> GNC Account picker
|
||||
****************************************************************/
|
||||
|
||||
@ -1109,7 +1113,7 @@ update_memo_page(QIFImportWindow * wind)
|
||||
{
|
||||
SCM make_memo_display = scm_c_eval_string("qif-dialog:make-memo-display");
|
||||
|
||||
update_account_picker_page (wind, make_memo_display, wind->memo_view,
|
||||
update_account_picker_page(wind, make_memo_display, wind->memo_view,
|
||||
wind->memo_map_info, &(wind->memo_display_info));
|
||||
}
|
||||
|
||||
@ -1134,65 +1138,123 @@ create_account_picker_view(GtkWidget *widget,
|
||||
g_object_unref(store);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(col_name, renderer,
|
||||
"text", ACCOUNT_COL_QIF_NAME,
|
||||
column = gtk_tree_view_column_new_with_attributes(col_name,
|
||||
renderer,
|
||||
"text",
|
||||
ACCOUNT_COL_QIF_NAME,
|
||||
NULL);
|
||||
g_object_set(column, "expand", TRUE, NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("GnuCash account name"), renderer,
|
||||
"text", ACCOUNT_COL_GNC_NAME,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("GnuCash account name"),
|
||||
renderer,
|
||||
"text",
|
||||
ACCOUNT_COL_GNC_NAME,
|
||||
NULL);
|
||||
g_object_set(column, "expand", TRUE, NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
g_object_set(renderer, "activatable", FALSE, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes(_("New?"), renderer,
|
||||
"active", ACCOUNT_COL_NEW,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("New?"),
|
||||
renderer,
|
||||
"active",
|
||||
ACCOUNT_COL_NEW,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
g_object_set_data(G_OBJECT(store), PREV_ROW, GINT_TO_POINTER(-1));
|
||||
g_signal_connect(view, "row-activated", G_CALLBACK(callback), user_data);
|
||||
|
||||
/* Allow multiple rows to be selected. */
|
||||
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(view),
|
||||
GTK_SELECTION_MULTIPLE);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* select_line
|
||||
* generic function to process the selection when a user tries to edit
|
||||
* an account mapping in one of the "map QIF * to GNC" pages. This
|
||||
* calls out to the account picker, and then then updates the
|
||||
* appropriate data structures. Finally, it will call the update_page
|
||||
* function.
|
||||
*
|
||||
* This is a helper function for tree controls used by some druid
|
||||
* pages for mapping QIF values to GnuCash accounts. It processes
|
||||
* the selected rows when a user tries to edit the account mappings.
|
||||
* The account picker is displayed, and the chosen GnuCash account
|
||||
* becomes the new mapping for each row. Finally, the update_page
|
||||
* function is called.
|
||||
********************************************************************/
|
||||
|
||||
static void
|
||||
select_line (QIFImportWindow *wind, GtkTreeSelection *selection,
|
||||
select_line(QIFImportWindow *wind, GtkTreeSelection *selection,
|
||||
SCM display_info, SCM map_info,
|
||||
void (*update_page)(QIFImportWindow *))
|
||||
{
|
||||
SCM get_name = scm_c_eval_string("qif-map-entry:qif-name");
|
||||
SCM selected_acct;
|
||||
SCM get_qif_name = scm_c_eval_string("qif-map-entry:qif-name");
|
||||
SCM get_gnc_name = scm_c_eval_string("qif-map-entry:gnc-name");
|
||||
SCM set_gnc_name = scm_c_eval_string("qif-map-entry:set-gnc-name!");
|
||||
SCM map_entry;
|
||||
SCM gnc_name;
|
||||
GList *pathlist;
|
||||
GList *current;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gint row;
|
||||
|
||||
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
/* Get a list of selected rows. */
|
||||
pathlist = gtk_tree_selection_get_selected_rows(selection, &model);
|
||||
if (!pathlist)
|
||||
return;
|
||||
|
||||
|
||||
/*
|
||||
* Update the first selected row.
|
||||
*/
|
||||
|
||||
/* Get the row number of the first selected row. */
|
||||
if (!gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) pathlist->data))
|
||||
return;
|
||||
gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
|
||||
|
||||
/* Save the row number. */
|
||||
g_object_set_data(G_OBJECT(model), PREV_ROW, GINT_TO_POINTER(row));
|
||||
if (row == -1)
|
||||
return;
|
||||
|
||||
/* find the <qif-map-entry> corresponding to the selected row */
|
||||
selected_acct = scm_list_ref(display_info, scm_int2num(row));
|
||||
/* Find the <qif-map-entry> corresponding to the selected row. */
|
||||
map_entry = scm_list_ref(display_info, scm_int2num(row));
|
||||
|
||||
/* call the account picker to update it */
|
||||
selected_acct = qif_account_picker_dialog(wind, selected_acct);
|
||||
/* Call the account picker to update it. */
|
||||
map_entry = qif_account_picker_dialog(wind, map_entry);
|
||||
if (map_entry == SCM_BOOL_F)
|
||||
return;
|
||||
gnc_name = scm_call_1(get_gnc_name, map_entry);
|
||||
|
||||
scm_hash_set_x(map_info, scm_call_1(get_name, selected_acct), selected_acct);
|
||||
/* Update the mapping hash table. */
|
||||
scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
|
||||
|
||||
/* update display */
|
||||
|
||||
/*
|
||||
* Map all other selected rows to the same GnuCash account.
|
||||
*/
|
||||
for (current = pathlist->next; current; current = current->next)
|
||||
{
|
||||
/* Get the row number. */
|
||||
gtk_tree_model_get_iter(model, &iter, (GtkTreePath *) current->data);
|
||||
gtk_tree_model_get(model, &iter, ACCOUNT_COL_INDEX, &row, -1);
|
||||
|
||||
/* Update the <qif-map-entry> for the selected row. */
|
||||
map_entry = scm_list_ref(display_info, scm_int2num(row));
|
||||
scm_call_2(set_gnc_name, map_entry, gnc_name);
|
||||
|
||||
/* Update the mapping hash table. */
|
||||
scm_hash_set_x(map_info, scm_call_1(get_qif_name, map_entry), map_entry);
|
||||
}
|
||||
|
||||
/* Free the path list. */
|
||||
g_list_foreach(pathlist, (GFunc) gtk_tree_path_free, NULL);
|
||||
g_list_free(pathlist);
|
||||
|
||||
/* Update the display. */
|
||||
update_page(wind);
|
||||
}
|
||||
|
||||
@ -1210,10 +1272,10 @@ gnc_ui_qif_import_account_line_select_cb(GtkTreeView *view, GtkTreePath *path,
|
||||
QIFImportWindow *wind = user_data;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
g_return_if_fail (view && wind);
|
||||
selection = gtk_tree_view_get_selection (view);
|
||||
g_return_if_fail(view && wind);
|
||||
selection = gtk_tree_view_get_selection(view);
|
||||
|
||||
select_line (wind, selection, wind->acct_display_info, wind->acct_map_info,
|
||||
select_line(wind, selection, wind->acct_display_info, wind->acct_map_info,
|
||||
update_accounts_page);
|
||||
}
|
||||
|
||||
@ -1231,10 +1293,10 @@ gnc_ui_qif_import_category_line_select_cb(GtkTreeView *view, GtkTreePath *path,
|
||||
QIFImportWindow *wind = user_data;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
g_return_if_fail (view && wind);
|
||||
selection = gtk_tree_view_get_selection (view);
|
||||
g_return_if_fail(view && wind);
|
||||
selection = gtk_tree_view_get_selection(view);
|
||||
|
||||
select_line (wind, selection, wind->cat_display_info, wind->cat_map_info,
|
||||
select_line(wind, selection, wind->cat_display_info, wind->cat_map_info,
|
||||
update_categories_page);
|
||||
}
|
||||
|
||||
@ -1252,10 +1314,10 @@ gnc_ui_qif_import_memo_line_select_cb(GtkTreeView *view, GtkTreePath *path,
|
||||
QIFImportWindow *wind = user_data;
|
||||
GtkTreeSelection *selection;
|
||||
|
||||
g_return_if_fail (view && wind);
|
||||
selection = gtk_tree_view_get_selection (view);
|
||||
g_return_if_fail(view && wind);
|
||||
selection = gtk_tree_view_get_selection(view);
|
||||
|
||||
select_line (wind, selection, wind->memo_display_info, wind->memo_map_info,
|
||||
select_line(wind, selection, wind->memo_display_info, wind->memo_map_info,
|
||||
update_memo_page);
|
||||
}
|
||||
|
||||
@ -1455,7 +1517,7 @@ gnc_ui_qif_import_prepare_duplicates(QIFImportWindow * wind)
|
||||
}
|
||||
|
||||
selection = gtk_tree_view_get_selection(view);
|
||||
path = gtk_tree_path_new_from_indices (0, -1);
|
||||
path = gtk_tree_path_new_from_indices(0, -1);
|
||||
gtk_tree_selection_select_path(selection, path);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
@ -1511,7 +1573,7 @@ gnc_ui_qif_import_convert(QIFImportWindow * wind)
|
||||
gtk_combo_box_get_active_text(GTK_COMBO_BOX(wind->currency_picker));
|
||||
|
||||
/* Let the user know we're busy. */
|
||||
gnc_suspend_gui_refresh ();
|
||||
gnc_suspend_gui_refresh();
|
||||
gnc_set_busy_cursor(NULL, TRUE);
|
||||
|
||||
/* Update the commodities. */
|
||||
@ -1817,8 +1879,8 @@ gnc_ui_qif_import_comm_next_cb(GnomeDruidPage * page,
|
||||
|
||||
book = gnc_get_current_book();
|
||||
table = gnc_commodity_table_get_table(book);
|
||||
if (gnc_commodity_namespace_is_iso (namespace) &&
|
||||
!gnc_commodity_table_lookup (table, namespace, mnemonic))
|
||||
if (gnc_commodity_namespace_is_iso(namespace) &&
|
||||
!gnc_commodity_table_lookup(table, namespace, mnemonic))
|
||||
{
|
||||
gnc_warning_dialog(wind->window,
|
||||
_("You must enter an existing national "
|
||||
@ -1942,7 +2004,7 @@ gnc_ui_qif_import_commodity_prepare_cb(GnomeDruidPage * page,
|
||||
gnc_unset_busy_cursor(NULL);
|
||||
}
|
||||
|
||||
gnc_druid_set_colors (GNOME_DRUID (wind->druid));
|
||||
gnc_druid_set_colors(GNOME_DRUID(wind->druid));
|
||||
}
|
||||
|
||||
static QIFDruidPage *
|
||||
@ -1978,7 +2040,7 @@ make_qif_druid_page(SCM security_hash_key, gnc_commodity *comm)
|
||||
/* Set the page colors. */
|
||||
gnome_druid_page_standard_set_background(page, & std_bg_color);
|
||||
gnome_druid_page_standard_set_logo_background(page, & std_logo_bg_color);
|
||||
gnome_druid_page_standard_set_title_foreground (page, & std_title_color);
|
||||
gnome_druid_page_standard_set_title_foreground(page, & std_title_color);
|
||||
|
||||
/*
|
||||
* Add all the widgets to the page.
|
||||
@ -1988,7 +2050,7 @@ make_qif_druid_page(SCM security_hash_key, gnc_commodity *comm)
|
||||
|
||||
info_label = gtk_label_new(_("Pick the commodity's exchange or listing "
|
||||
"(NASDAQ, NYSE, etc)."));
|
||||
gtk_label_set_justify (GTK_LABEL(info_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_justify(GTK_LABEL(info_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(top_vbox), info_label, TRUE, TRUE, 0);
|
||||
|
||||
temp = gtk_hbox_new(FALSE, 0);
|
||||
@ -2007,7 +2069,7 @@ make_qif_druid_page(SCM security_hash_key, gnc_commodity *comm)
|
||||
info_label = gtk_label_new(_("Enter the full name of the commodity, "
|
||||
"such as \"Red Hat Stock\""));
|
||||
|
||||
gtk_label_set_justify (GTK_LABEL(info_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_justify(GTK_LABEL(info_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(top_vbox), info_label, TRUE, TRUE, 0);
|
||||
|
||||
temp = gtk_hbox_new(FALSE, 0);
|
||||
@ -2028,7 +2090,7 @@ make_qif_druid_page(SCM security_hash_key, gnc_commodity *comm)
|
||||
info_label = gtk_label_new(_("Enter the ticker symbol (such as \"RHAT\") or "
|
||||
"other unique abbreviation for the name."));
|
||||
|
||||
gtk_label_set_justify (GTK_LABEL(info_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_justify(GTK_LABEL(info_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(top_vbox), info_label, TRUE, TRUE, 0);
|
||||
|
||||
temp = gtk_hbox_new(FALSE, 0);
|
||||
@ -2048,7 +2110,7 @@ make_qif_druid_page(SCM security_hash_key, gnc_commodity *comm)
|
||||
|
||||
next_label = gtk_label_new(_("Click \"Forward\" to accept the information "
|
||||
"and move on."));
|
||||
gtk_label_set_justify (GTK_LABEL(next_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_label_set_justify(GTK_LABEL(next_label), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_end(GTK_BOX(top_vbox), next_label, TRUE, TRUE, 0);
|
||||
|
||||
|
||||
@ -2115,7 +2177,7 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_qif_import_duplicate_new_select_cb (GtkTreeSelection *selection,
|
||||
gnc_ui_qif_import_duplicate_new_select_cb(GtkTreeSelection *selection,
|
||||
QIFImportWindow *wind)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
@ -2136,7 +2198,7 @@ reset_ignore_old_select(gboolean *ignore)
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_ui_qif_import_duplicate_old_select_cb (GtkTreeSelection *selection,
|
||||
gnc_ui_qif_import_duplicate_old_select_cb(GtkTreeSelection *selection,
|
||||
QIFImportWindow *wind)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
@ -2293,21 +2355,21 @@ gnc_ui_qif_import_druid_get_mappings(QIFImportWindow * w)
|
||||
/* ======================================================== */
|
||||
|
||||
static gboolean
|
||||
show_handler (const char *class, gint component_id,
|
||||
show_handler(const char *class, gint component_id,
|
||||
gpointer user_data, gpointer iter_data)
|
||||
{
|
||||
QIFImportWindow *qif_win = user_data;
|
||||
|
||||
if (!qif_win)
|
||||
return(FALSE);
|
||||
gtk_window_present (GTK_WINDOW(qif_win->window));
|
||||
gtk_window_present(GTK_WINDOW(qif_win->window));
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_file_qif_import (void)
|
||||
gnc_file_qif_import(void)
|
||||
{
|
||||
if (gnc_forall_gui_components (DRUID_QIF_IMPORT_CM_CLASS,
|
||||
if (gnc_forall_gui_components(DRUID_QIF_IMPORT_CM_CLASS,
|
||||
show_handler, NULL))
|
||||
return;
|
||||
|
||||
@ -2315,6 +2377,7 @@ gnc_file_qif_import (void)
|
||||
gnc_ui_qif_import_druid_make();
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************
|
||||
* gnc_ui_qif_import_druid_make()
|
||||
* build the druid.
|
||||
@ -2356,93 +2419,93 @@ gnc_ui_qif_import_druid_make(void)
|
||||
|
||||
retval = g_new0(QIFImportWindow, 1);
|
||||
|
||||
xml = gnc_glade_xml_new ("qif.glade", "QIF Import Druid");
|
||||
xml = gnc_glade_xml_new("qif.glade", "QIF Import Druid");
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_cancel_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_cancel_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_cancel_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_generic_next_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_generic_next_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_generic_next_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_generic_back_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_generic_back_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_generic_back_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_select_file_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_select_file_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_select_file_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_load_file_back_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_load_file_back_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_load_file_back_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_load_file_next_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_load_file_next_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_load_file_next_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_date_format_next_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_date_format_next_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_date_format_next_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_loaded_files_prepare_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_loaded_files_prepare_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_loaded_files_prepare_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_load_another_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_load_another_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_load_another_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_unload_file_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_unload_file_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_unload_file_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_default_acct_next_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_default_acct_next_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_default_acct_next_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_default_acct_back_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_default_acct_back_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_default_acct_back_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_accounts_prepare_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_accounts_prepare_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_accounts_prepare_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_categories_prepare_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_categories_prepare_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_categories_prepare_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_categories_next_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_categories_next_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_categories_next_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_memo_prepare_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_memo_prepare_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_memo_prepare_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_memo_next_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_memo_next_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_memo_next_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_currency_back_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_currency_back_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_currency_back_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_currency_next_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_currency_next_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_currency_next_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_commodity_prepare_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_commodity_prepare_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_commodity_prepare_cb), retval);
|
||||
|
||||
glade_xml_signal_connect_data
|
||||
(xml, "gnc_ui_qif_import_finish_cb",
|
||||
G_CALLBACK (gnc_ui_qif_import_finish_cb), retval);
|
||||
G_CALLBACK(gnc_ui_qif_import_finish_cb), retval);
|
||||
|
||||
retval->window = glade_xml_get_widget (xml, "QIF Import Druid");
|
||||
retval->window = glade_xml_get_widget(xml, "QIF Import Druid");
|
||||
|
||||
retval->imported_files = SCM_EOL;
|
||||
retval->selected_file = SCM_BOOL_F;
|
||||
@ -2461,19 +2524,19 @@ gnc_ui_qif_import_druid_make(void)
|
||||
retval->match_transactions = SCM_BOOL_F;
|
||||
retval->selected_transaction = 0;
|
||||
|
||||
retval->druid = glade_xml_get_widget (xml, "qif_import_druid");
|
||||
retval->filename_entry = glade_xml_get_widget (xml, "qif_filename_entry");
|
||||
retval->acct_entry = glade_xml_get_widget (xml, "qif_account_entry");
|
||||
retval->date_format_combo = glade_xml_get_widget (xml, "date_format_combobox");
|
||||
retval->druid = glade_xml_get_widget(xml, "qif_import_druid");
|
||||
retval->filename_entry = glade_xml_get_widget(xml, "qif_filename_entry");
|
||||
retval->acct_entry = glade_xml_get_widget(xml, "qif_account_entry");
|
||||
retval->date_format_combo = glade_xml_get_widget(xml, "date_format_combobox");
|
||||
retval->selected_file_view = glade_xml_get_widget(xml, "selected_file_view");
|
||||
retval->currency_picker = glade_xml_get_widget (xml, "currency_comboboxentry");
|
||||
retval->acct_view = glade_xml_get_widget (xml, "account_page_view");
|
||||
retval->cat_view = glade_xml_get_widget (xml, "category_page_view");
|
||||
retval->memo_view = glade_xml_get_widget (xml, "memo_page_view");
|
||||
retval->currency_picker = glade_xml_get_widget(xml, "currency_comboboxentry");
|
||||
retval->acct_view = glade_xml_get_widget(xml, "account_page_view");
|
||||
retval->cat_view = glade_xml_get_widget(xml, "category_page_view");
|
||||
retval->memo_view = glade_xml_get_widget(xml, "memo_page_view");
|
||||
retval->new_transaction_view =
|
||||
glade_xml_get_widget (xml, "new_transaction_view");
|
||||
glade_xml_get_widget(xml, "new_transaction_view");
|
||||
retval->old_transaction_view =
|
||||
glade_xml_get_widget (xml, "old_transaction_view");
|
||||
glade_xml_get_widget(xml, "old_transaction_view");
|
||||
|
||||
retval->pre_comm_pages = NULL;
|
||||
retval->post_comm_pages = NULL;
|
||||
@ -2497,17 +2560,17 @@ gnc_ui_qif_import_druid_make(void)
|
||||
for(i=0; i < NUM_PRE_PAGES; i++) {
|
||||
retval->pre_comm_pages =
|
||||
g_list_append(retval->pre_comm_pages,
|
||||
glade_xml_get_widget (xml, pre_page_names[i]));
|
||||
glade_xml_get_widget(xml, pre_page_names[i]));
|
||||
}
|
||||
for(i=0; i < NUM_POST_PAGES; i++) {
|
||||
retval->post_comm_pages =
|
||||
g_list_append(retval->post_comm_pages,
|
||||
glade_xml_get_widget (xml, post_page_names[i]));
|
||||
glade_xml_get_widget(xml, post_page_names[i]));
|
||||
}
|
||||
for(i=0; i < NUM_DOC_PAGES; i++) {
|
||||
retval->doc_pages =
|
||||
g_list_append(retval->doc_pages,
|
||||
glade_xml_get_widget (xml, doc_page_names[i]));
|
||||
glade_xml_get_widget(xml, doc_page_names[i]));
|
||||
}
|
||||
|
||||
/* Set up the selected file view */
|
||||
@ -2517,8 +2580,10 @@ gnc_ui_qif_import_druid_make(void)
|
||||
g_object_unref(store);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Account"), renderer,
|
||||
"text", FILENAME_COL_NAME,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Account"),
|
||||
renderer,
|
||||
"text",
|
||||
FILENAME_COL_NAME,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
@ -2545,21 +2610,27 @@ gnc_ui_qif_import_druid_make(void)
|
||||
g_object_unref(store);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
|
||||
"text", QIF_TRANS_COL_DATE,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Date"),
|
||||
renderer,
|
||||
"text",
|
||||
QIF_TRANS_COL_DATE,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
|
||||
"text", QIF_TRANS_COL_DESCRIPTION,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Description"),
|
||||
renderer,
|
||||
"text",
|
||||
QIF_TRANS_COL_DESCRIPTION,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
gtk_tree_view_column_set_expand(column, TRUE);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Amount"), renderer,
|
||||
"text", QIF_TRANS_COL_AMOUNT,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Amount"),
|
||||
renderer,
|
||||
"text",
|
||||
QIF_TRANS_COL_AMOUNT,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
@ -2577,27 +2648,35 @@ gnc_ui_qif_import_druid_make(void)
|
||||
g_object_unref(store);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Date"), renderer,
|
||||
"text", QIF_TRANS_COL_DATE,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Date"),
|
||||
renderer,
|
||||
"text",
|
||||
QIF_TRANS_COL_DATE,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Description"), renderer,
|
||||
"text", QIF_TRANS_COL_DESCRIPTION,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Description"),
|
||||
renderer,
|
||||
"text",
|
||||
QIF_TRANS_COL_DESCRIPTION,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
gtk_tree_view_column_set_expand(column, TRUE);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Amount"), renderer,
|
||||
"text", QIF_TRANS_COL_AMOUNT,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Amount"),
|
||||
renderer,
|
||||
"text",
|
||||
QIF_TRANS_COL_AMOUNT,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Dup?"), renderer,
|
||||
"active", QIF_TRANS_COL_CHECKED,
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Dup?"),
|
||||
renderer,
|
||||
"active",
|
||||
QIF_TRANS_COL_CHECKED,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(view, column);
|
||||
|
||||
@ -2650,12 +2729,12 @@ gnc_ui_qif_import_druid_make(void)
|
||||
get_named_page(retval, "load_file_page"));
|
||||
}
|
||||
|
||||
gnc_druid_set_colors (GNOME_DRUID (retval->druid));
|
||||
gnc_druid_set_colors(GNOME_DRUID(retval->druid));
|
||||
|
||||
gnc_register_gui_component(DRUID_QIF_IMPORT_CM_CLASS, NULL, NULL, retval);
|
||||
|
||||
gtk_widget_show_all(retval->window);
|
||||
gtk_window_present (GTK_WINDOW(retval->window));
|
||||
gtk_window_present(GTK_WINDOW(retval->window));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user