35 #include <glib/gi18n.h> 36 #include <glib/gstdio.h> 43 #include "dialog-account-picker.h" 46 #include "dialog-utils.h" 48 #include "assistant-qif-import.h" 49 #include "gnc-component-manager.h" 52 #include "gnc-gui-query.h" 53 #include "gnc-guile-utils.h" 61 #include "swig-runtime.h" 62 #include "guile-mappings.h" 65 #define ASSISTANT_QIF_IMPORT_CM_CLASS "assistant-qif-import" 66 #define GNC_PREFS_GROUP "dialogs.import.qif" 67 #define GNC_PREF_SHOW_DOC "show-doc" 68 #define GNC_PREF_DEFAULT_TRANS_STATUS_CLEARED "default-status-cleared" 69 #define GNC_PREF_DEFAULT_TRANS_STATUS_NOTCLEARED "default-status-notcleared" 70 #define GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED "default-status-reconciled" 72 #define PREV_ROW "prev_row" 74 static QofLogModule log_module = GNC_MOD_ASSISTANT;
78 FILENAME_COL_INDEX = 0,
85 ACCOUNT_COL_INDEX = 0,
89 ACCOUNT_COL_ELLIPSIZE,
99 QIF_TRANS_COL_INDEX = 0,
101 QIF_TRANS_COL_DATE_INT64,
102 QIF_TRANS_COL_DESCRIPTION,
103 QIF_TRANS_COL_AMOUNT,
104 QIF_TRANS_COL_AMOUNT_DOUBLE,
105 QIF_TRANS_COL_CHECKED,
114 GtkWidget * filename_entry;
117 GtkWidget * load_pause;
118 GtkWidget * load_start;
119 GtkWidget * load_log;
120 GNCProgressDialog *load_progress;
123 GtkWidget * acct_entry;
126 GtkWidget * date_format_combo;
129 GtkWidget * selected_file_view;
130 GtkWidget * unload_file_btn;
133 GtkWidget * acct_view;
134 GtkWidget * acct_view_count;
135 GtkWidget * acct_view_btn;
138 GtkWidget * cat_view;
139 GtkWidget * cat_view_count;
140 GtkWidget * cat_view_btn;
143 GtkWidget * memo_view;
144 GtkWidget * memo_view_count;
145 GtkWidget * memo_view_btn;
148 GtkWidget * currency_picker;
149 GtkWidget * book_option_label;
150 GtkWidget * book_option_message;
154 GtkWidget * commodity_notebook;
155 GList * commodity_notebook_pages;
159 GtkWidget * convert_pause;
160 GtkWidget * convert_start;
161 GtkWidget * convert_log;
162 GNCProgressDialog *convert_progress;
165 GtkWidget * new_transaction_view;
166 GtkWidget * old_transaction_view;
169 GtkWidget * summary_text;
171 gboolean show_doc_pages;
172 gboolean ask_date_format;
174 gboolean read_file_warnings;
176 gboolean acct_tree_found;
183 SCM acct_display_info;
186 SCM cat_display_info;
189 SCM memo_display_info;
195 GList * new_namespaces;
198 SCM imported_account_tree;
199 SCM match_transactions;
200 SCM transaction_status;
201 int selected_transaction;
207 GtkWidget *notebook_page;
208 GtkWidget *namespace_combo;
209 GtkWidget *name_entry;
210 GtkWidget *mnemonic_entry;
211 gnc_commodity *commodity;
212 gboolean page_complete;
218 static void gnc_ui_qif_import_assistant_destroy (GtkWidget *
object, gpointer user_data);
219 static void gnc_ui_qif_import_assistant_close_handler (gpointer user_data);
221 static gboolean gnc_ui_qif_import_assistant_skip_page (GtkAssistant *assistant, GtkWidget *page, QIFImportWindow *wind);
222 static int gnc_ui_qif_import_assistant_page_forward (
int current_page, gpointer data);
224 void gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data);
225 void gnc_ui_qif_import_prepare_cb (GtkAssistant *assistant, GtkWidget *page, gpointer user_data);
226 void gnc_ui_qif_import_finish_cb (GtkAssistant *gtkassistant, gpointer user_data);
227 void gnc_ui_qif_import_close_cb (GtkAssistant *gtkassistant, gpointer user_data);
229 void gnc_ui_qif_import_intro_prepare (GtkAssistant *assistant, gpointer user_data);
231 void gnc_ui_qif_import_load_file_prepare (GtkAssistant *assistant, gpointer user_data);
232 void gnc_ui_qif_import_select_file_cb (GtkButton *button, gpointer user_data);
234 void gnc_ui_qif_import_load_progress_prepare (GtkAssistant *assistant, gpointer user_data);
235 void gnc_ui_qif_import_load_progress_pause_cb (GtkButton *button, gpointer user_data);
236 void gnc_ui_qif_import_load_progress_start_cb (GtkButton * button, gpointer user_data);
238 static gboolean gnc_ui_qif_import_skip_date_format (GtkAssistant *assistant, QIFImportWindow *wind);
239 void gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data);
241 void gnc_ui_qif_import_account_prepare (GtkAssistant *assistant, gpointer user_data);
242 static gboolean gnc_ui_qif_import_skip_account (GtkAssistant *assistant, QIFImportWindow *wind);
243 void gnc_ui_qif_import_acct_valid_cb (GtkWidget *widget, gpointer user_data);
244 void gnc_ui_qif_import_acct_enter_cb (GtkWidget * widget, gpointer user_data);
246 void gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant, gpointer user_data);
247 void gnc_ui_qif_import_load_another_cb (GtkButton *button, gpointer user_data);
248 void gnc_ui_qif_import_unload_file_cb (GtkButton *button, gpointer user_data);
250 static void update_file_page (QIFImportWindow * wind);
252 void gnc_ui_qif_import_account_match_prepare (GtkAssistant *assistant, gpointer user_data);
253 void gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant, gpointer user_data);
254 static gboolean gnc_ui_qif_import_skip_account_doc (QIFImportWindow *wind);
255 void gnc_ui_qif_import_account_rematch_cb (GtkButton *button, gpointer user_data);
257 void gnc_ui_qif_import_category_match_prepare (GtkAssistant *assistant, gpointer user_data);
258 static gboolean gnc_ui_qif_import_skip_category_match (QIFImportWindow *wind);
259 void gnc_ui_qif_import_category_doc_prepare (GtkAssistant *assistant, gpointer user_data);
260 static gboolean gnc_ui_qif_import_skip_category_doc (QIFImportWindow *wind);
261 void gnc_ui_qif_import_category_rematch_cb (GtkButton *button, gpointer user_data);
263 void gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant, gpointer user_data);
264 static gboolean gnc_ui_qif_import_skip_memo_match (QIFImportWindow *wind);
265 void gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant, gpointer user_data);
266 static gboolean gnc_ui_qif_import_skip_memo_doc (QIFImportWindow *wind);
267 void gnc_ui_qif_import_memo_rematch_cb (GtkButton *button, gpointer user_data);
269 void gnc_ui_qif_import_currency_prepare (GtkAssistant *assistant, gpointer user_data);
271 void gnc_ui_qif_import_commodity_prepare (GtkAssistant *assistant, gpointer user_data);
272 static gboolean gnc_ui_qif_import_skip_commodity (QIFImportWindow *wind);
273 void gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data);
274 void gnc_ui_qif_import_comm_namespace_changed_cb (GtkWidget *widget, gpointer user_data);
276 void gnc_ui_qif_import_convert_progress_prepare (GtkAssistant *assistant, gpointer user_data);
277 void gnc_ui_qif_import_convert_progress_pause_cb (GtkButton * button, gpointer user_data);
278 void gnc_ui_qif_import_convert_progress_start_cb (GtkButton * button, gpointer user_data);
280 void gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant, gpointer user_data);
281 static gboolean gnc_ui_qif_import_skip_duplicates_match (QIFImportWindow *wind);
282 void gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant, gpointer user_data);
283 static gboolean gnc_ui_qif_import_skip_duplicates_doc (QIFImportWindow *wind);
285 void gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant, gpointer user_data);
287 void gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
290 mark_page_complete (GtkAssistant *assistant, gboolean page_status)
292 gint num = gtk_assistant_get_current_page (assistant);
293 GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
294 gtk_assistant_set_page_complete (assistant, page, page_status);
307 update_account_picker_page (QIFImportWindow * wind, SCM make_display,
308 GtkWidget *view, SCM map_info, SCM * display_info)
310 SCM get_qif_name = scm_c_eval_string (
"qif-map-entry:qif-name");
311 SCM get_gnc_name = scm_c_eval_string (
"qif-map-entry:gnc-name");
312 SCM get_new = scm_c_eval_string (
"qif-map-entry:new-acct?");
314 gchar *qif_name = NULL;
315 gchar *gnc_name = NULL;
322 GtkTreeSelection *selection;
324 store = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(view)));
327 accts_left = scm_call_3 (make_display,
328 wind->imported_files,
330 wind->gnc_acct_info);
332 scm_gc_unprotect_object (*display_info);
333 *display_info = accts_left;
334 scm_gc_protect_object (*display_info);
337 gtk_list_store_clear (store);
339 while (!scm_is_null (accts_left))
341 qif_name = gnc_scm_call_1_to_string (get_qif_name, SCM_CAR(accts_left));
342 gnc_name = gnc_scm_call_1_to_string (get_gnc_name, SCM_CAR(accts_left));
343 checked = (scm_call_1 (get_new, SCM_CAR(accts_left)) == SCM_BOOL_T);
345 gtk_list_store_append (store, &iter);
346 gtk_list_store_set (store, &iter,
347 ACCOUNT_COL_INDEX, row++,
348 ACCOUNT_COL_QIF_NAME, qif_name,
349 ACCOUNT_COL_GNC_NAME, gnc_name,
350 ACCOUNT_COL_NEW, checked,
351 ACCOUNT_COL_ELLIPSIZE, PANGO_ELLIPSIZE_START,
353 accts_left = SCM_CDR(accts_left);
359 prev_row = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(store), PREV_ROW));
360 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
363 path = gtk_tree_path_new_from_indices (prev_row, -1);
365 path = gtk_tree_path_new_from_indices (0, -1);
367 gtk_tree_selection_select_path (selection, path);
370 if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL(store), NULL) > 0)
371 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), path, NULL, TRUE, 0.5, 0.0);
372 gtk_tree_path_free (path);
382 update_account_page (QIFImportWindow * wind)
385 SCM make_account_display = scm_c_eval_string (
"qif-dialog:make-account-display");
387 update_account_picker_page (wind, make_account_display, wind->acct_view,
388 wind->acct_map_info, &(wind->acct_display_info));
398 update_category_page (QIFImportWindow * wind)
400 SCM make_category_display = scm_c_eval_string (
"qif-dialog:make-category-display");
402 update_account_picker_page (wind, make_category_display, wind->cat_view,
403 wind->cat_map_info, &(wind->cat_display_info));
413 update_memo_page (QIFImportWindow * wind)
415 SCM make_memo_display = scm_c_eval_string (
"qif-dialog:make-memo-display");
417 update_account_picker_page (wind, make_memo_display, wind->memo_view,
418 wind->memo_map_info, &(wind->memo_display_info));
428 gnc_ui_qif_import_commodity_destroy (QIFImportWindow * wind)
431 GtkWidget *notebook_page;
432 QIFCommNotebookPage *comm_nb_page;
434 for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
436 notebook_page = pageptr->data;
437 comm_nb_page = g_object_get_data (G_OBJECT(notebook_page),
"page_struct");
440 scm_gc_unprotect_object (comm_nb_page->hash_key);
443 g_free (comm_nb_page);
447 g_list_free (wind->commodity_notebook_pages);
448 wind->commodity_notebook_pages = NULL;
457 gnc_ui_qif_import_assistant_destroy (GtkWidget *
object, gpointer user_data)
459 QIFImportWindow * wind = user_data;
465 gnc_ui_qif_import_commodity_destroy (wind);
467 gnc_unregister_gui_component_by_data (ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
469 gtk_widget_destroy (wind->window);
471 scm_gc_unprotect_object (wind->imported_files);
472 scm_gc_unprotect_object (wind->selected_file);
473 scm_gc_unprotect_object (wind->gnc_acct_info);
474 scm_gc_unprotect_object (wind->cat_display_info);
475 scm_gc_unprotect_object (wind->cat_map_info);
476 scm_gc_unprotect_object (wind->memo_display_info);
477 scm_gc_unprotect_object (wind->memo_map_info);
478 scm_gc_unprotect_object (wind->acct_display_info);
479 scm_gc_unprotect_object (wind->acct_map_info);
480 scm_gc_unprotect_object (wind->security_hash);
481 scm_gc_unprotect_object (wind->security_prefs);
482 scm_gc_unprotect_object (wind->new_securities);
483 scm_gc_unprotect_object (wind->ticker_map);
484 scm_gc_unprotect_object (wind->imported_account_tree);
485 scm_gc_unprotect_object (wind->match_transactions);
496 gnc_ui_qif_import_select_loaded_file_cb (GtkTreeSelection *selection,
499 QIFImportWindow * wind = user_data;
505 button = (wind->unload_file_btn);
506 if (gtk_tree_selection_get_selected (selection, &model, &iter))
508 gtk_tree_model_get (model, &iter, FILENAME_COL_INDEX, &row, -1);
509 if (scm_is_list (wind->imported_files) &&
510 (scm_ilength (wind->imported_files) > row))
512 scm_gc_unprotect_object (wind->selected_file);
513 wind->selected_file = scm_list_ref (wind->imported_files,
515 scm_gc_protect_object (wind->selected_file);
516 g_object_set (button,
"sensitive", TRUE, (gchar*)NULL);
521 scm_gc_unprotect_object (wind->selected_file);
522 wind->selected_file = SCM_BOOL_F;
523 scm_gc_protect_object (wind->selected_file);
524 g_object_set (button,
"sensitive", FALSE, (gchar*)NULL);
533 create_account_picker_view (GtkWidget *widget,
534 const gchar *col_name,
535 GCallback activate_cb,
539 GtkTreeView *view = GTK_TREE_VIEW(widget);
540 GtkTreeSelection *selection = gtk_tree_view_get_selection (view);
542 GtkCellRenderer *renderer;
543 GtkTreeViewColumn *column;
545 store = gtk_list_store_new (NUM_ACCOUNT_COLS, G_TYPE_INT, G_TYPE_STRING,
546 G_TYPE_STRING, G_TYPE_BOOLEAN,
547 PANGO_TYPE_ELLIPSIZE_MODE);
548 gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
551 gtk_tree_view_set_reorderable (view, FALSE);
554 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
555 ACCOUNT_COL_QIF_NAME,
557 g_object_unref (store);
559 renderer = gtk_cell_renderer_text_new ();
560 column = gtk_tree_view_column_new_with_attributes (col_name,
563 ACCOUNT_COL_QIF_NAME,
565 ACCOUNT_COL_ELLIPSIZE,
568 g_object_set (G_OBJECT(column),
"expand", TRUE,
"reorderable",
569 TRUE,
"resizable", TRUE, NULL);
571 gtk_tree_view_append_column (view, column);
572 gtk_tree_view_column_set_sort_column_id (column, ACCOUNT_COL_QIF_NAME);
574 renderer = gtk_cell_renderer_text_new ();
575 column = gtk_tree_view_column_new_with_attributes (_(
"GnuCash account name"),
578 ACCOUNT_COL_GNC_NAME,
580 ACCOUNT_COL_ELLIPSIZE,
583 g_object_set (G_OBJECT(column),
"expand", TRUE,
"reorderable",
584 TRUE,
"resizable", TRUE, NULL);
586 gtk_tree_view_append_column (view, column);
587 gtk_tree_view_column_set_sort_column_id (column, ACCOUNT_COL_GNC_NAME);
589 renderer = gtk_cell_renderer_toggle_new ();
590 g_object_set(renderer,
"activatable", FALSE, NULL);
591 column = gtk_tree_view_column_new_with_attributes (_(
"New?"),
596 gtk_tree_view_append_column (view, column);
598 g_object_set_data (G_OBJECT(store), PREV_ROW, GINT_TO_POINTER(-1));
601 g_signal_connect (view,
"row-activated", G_CALLBACK(activate_cb), user_data);
602 g_signal_connect (selection,
"changed", G_CALLBACK(select_cb), user_data);
605 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
620 rematch_line (QIFImportWindow *wind, GtkTreeSelection *selection,
621 SCM display_info, SCM map_info,
622 void (*update_page)(QIFImportWindow *))
624 SCM get_qif_name = scm_c_eval_string (
"qif-map-entry:qif-name");
625 SCM get_gnc_name = scm_c_eval_string (
"qif-map-entry:gnc-name");
626 SCM set_gnc_name = scm_c_eval_string (
"qif-map-entry:set-gnc-name!");
636 pathlist = gtk_tree_selection_get_selected_rows (selection, &model);
645 if (!gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) pathlist->data))
647 gtk_tree_model_get (model, &iter, ACCOUNT_COL_INDEX, &row, -1);
650 g_object_set_data (G_OBJECT(model), PREV_ROW, GINT_TO_POINTER(row));
655 map_entry = scm_list_ref (display_info, scm_from_int (row));
658 if (!qif_account_picker_dialog (GTK_WINDOW(wind->window), wind, map_entry))
660 gnc_name = scm_call_1 (get_gnc_name, map_entry);
663 scm_hash_set_x (map_info, scm_call_1 (get_qif_name, map_entry), map_entry);
668 for (current = pathlist->next; current; current = current->next)
671 gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) current->data);
672 gtk_tree_model_get (model, &iter, ACCOUNT_COL_INDEX, &row, -1);
675 map_entry = scm_list_ref (display_info, scm_from_int (row));
676 scm_call_2 (set_gnc_name, map_entry, gnc_name);
679 scm_hash_set_x (map_info, scm_call_1 (get_qif_name, map_entry), map_entry);
683 g_list_foreach (pathlist, (GFunc) gtk_tree_path_free, NULL);
684 g_list_free (pathlist);
698 gnc_ui_qif_import_account_activate_cb (GtkTreeView *view, GtkTreePath *path,
699 GtkTreeViewColumn *column,
702 QIFImportWindow *wind = user_data;
704 g_return_if_fail (wind);
706 rematch_line (wind, gtk_tree_view_get_selection (view),
707 wind->acct_display_info, wind->acct_map_info,
708 update_account_page);
720 gnc_ui_qif_import_account_select_cb (GtkTreeSelection *selection,
723 QIFImportWindow *wind = user_data;
724 gint count = gtk_tree_selection_count_selected_rows (selection);
727 g_return_if_fail (wind);
730 if (wind->acct_view_count)
732 count_str = g_strdup_printf (
"%d", count);
733 gtk_label_set_text (GTK_LABEL(wind->acct_view_count), count_str);
738 if (wind->acct_view_btn)
741 gtk_widget_set_sensitive (wind->acct_view_btn, TRUE);
743 gtk_widget_set_sensitive (wind->acct_view_btn, FALSE);
755 gnc_ui_qif_import_category_activate_cb (GtkTreeView *view, GtkTreePath *path,
756 GtkTreeViewColumn *column,
759 QIFImportWindow *wind = user_data;
760 GtkTreeSelection *selection;
762 g_return_if_fail (view && wind);
763 selection = gtk_tree_view_get_selection (view);
765 rematch_line (wind, selection, wind->cat_display_info, wind->cat_map_info,
766 update_category_page);
778 gnc_ui_qif_import_category_select_cb (GtkTreeSelection *selection,
781 QIFImportWindow *wind = user_data;
782 gint count = gtk_tree_selection_count_selected_rows (selection);
785 g_return_if_fail (wind);
788 if (wind->cat_view_count)
790 count_str = g_strdup_printf (
"%d", count);
791 gtk_label_set_text (GTK_LABEL(wind->cat_view_count), count_str);
796 if (wind->cat_view_btn)
799 gtk_widget_set_sensitive (wind->cat_view_btn, TRUE);
801 gtk_widget_set_sensitive (wind->cat_view_btn, FALSE);
813 gnc_ui_qif_import_memo_activate_cb (GtkTreeView *view, GtkTreePath *path,
814 GtkTreeViewColumn *column,
817 QIFImportWindow *wind = user_data;
818 GtkTreeSelection *selection;
820 g_return_if_fail (view && wind);
821 selection = gtk_tree_view_get_selection (view);
823 rematch_line (wind, selection, wind->memo_display_info, wind->memo_map_info,
836 gnc_ui_qif_import_memo_select_cb (GtkTreeSelection *selection,
839 QIFImportWindow *wind = user_data;
840 gint count = gtk_tree_selection_count_selected_rows (selection);
843 g_return_if_fail (wind);
846 if (wind->memo_view_count)
848 count_str = g_strdup_printf (
"%d", count);
849 gtk_label_set_text (GTK_LABEL(wind->memo_view_count), count_str);
854 if (wind->memo_view_btn)
857 gtk_widget_set_sensitive (wind->memo_view_btn, TRUE);
859 gtk_widget_set_sensitive (wind->memo_view_btn, FALSE);
867 static QIFCommNotebookPage *
868 new_security_notebook_page (SCM security_hash_key, gnc_commodity *comm, QIFImportWindow *wind)
870 QIFCommNotebookPage *comm_nb_page = g_new0(QIFCommNotebookPage, 1);
876 GtkWidget *notebook_page;
877 GtkWidget *notebook_label;
880 _(
"Enter a name or short description, such as \"Red Hat Stock\".");
881 char *mnemonic_tooltip =
882 _(
"Enter the ticker symbol or other well known abbreviation, such as" 883 " \"RHT\". If there isn't one, or you don't know it, create your own.");
884 char *namespace_tooltip =
885 _(
"Select the exchange on which the symbol is traded, or select the" 886 " type of investment (such as FUND for mutual funds.) If you don't" 887 " see your exchange or an appropriate investment type, you can" 888 " enter a new one.");
891 notebook_page = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
892 gtk_box_set_homogeneous (GTK_BOX (notebook_page), FALSE);
893 comm_nb_page->notebook_page = notebook_page;
894 g_object_set_data (G_OBJECT(notebook_page),
"page_struct", comm_nb_page);
897 comm_nb_page->commodity = comm;
898 comm_nb_page->hash_key = security_hash_key;
899 scm_gc_protect_object (comm_nb_page->hash_key);
903 str = str ? str :
"";
904 title = g_strdup_printf (
"\"%s\"", str);
907 notebook_label = gtk_label_new (title);
908 gnc_label_set_alignment (notebook_label, 0.0, 0.5);
909 gtk_notebook_append_page (GTK_NOTEBOOK(wind->commodity_notebook),
910 notebook_page, notebook_label);
914 comm_nb_page->page_complete = TRUE;
917 table = gtk_grid_new ();
918 gtk_grid_set_row_spacing (GTK_GRID(
table), 6);
919 gtk_grid_set_column_spacing (GTK_GRID(
table), 12);
922 comm_nb_page->name_entry = gtk_entry_new ();
923 gtk_entry_set_text (GTK_ENTRY(comm_nb_page->name_entry),
925 label = gtk_label_new_with_mnemonic (_(
"Name or _description"));
926 gtk_label_set_mnemonic_widget (GTK_LABEL(label), comm_nb_page->name_entry);
927 gnc_label_set_alignment (label, 0, 0.5);
929 gtk_widget_set_tooltip_text (label, name_tooltip);
930 gtk_widget_set_tooltip_text (comm_nb_page->name_entry, name_tooltip);
932 gtk_grid_attach (GTK_GRID(
table), label, 0, 0, 1, 1);
933 gtk_widget_set_halign (label, GTK_ALIGN_FILL);
934 gtk_widget_set_valign (label, GTK_ALIGN_FILL);
935 gtk_widget_set_hexpand (label, TRUE);
936 gtk_widget_set_vexpand (label, FALSE);
937 g_object_set (label,
"margin", 0, NULL);
939 gtk_grid_attach (GTK_GRID(
table), comm_nb_page->name_entry, 1, 0, 1, 1);
941 g_signal_connect (comm_nb_page->name_entry,
"changed",
942 G_CALLBACK(gnc_ui_qif_import_comm_changed_cb), wind);
945 comm_nb_page->mnemonic_entry = gtk_entry_new ();
946 gtk_entry_set_text (GTK_ENTRY(comm_nb_page->mnemonic_entry),
948 label = gtk_label_new_with_mnemonic (
949 _(
"_Ticker symbol or other abbreviation"));
950 gtk_label_set_mnemonic_widget (GTK_LABEL(label), comm_nb_page->mnemonic_entry);
951 gnc_label_set_alignment (label, 0, 0.5);
953 gtk_widget_set_tooltip_text (label, mnemonic_tooltip);
954 gtk_widget_set_tooltip_text (comm_nb_page->mnemonic_entry, mnemonic_tooltip);
956 gtk_grid_attach (GTK_GRID(
table), label, 0, 1, 1, 1);
957 gtk_widget_set_halign (label, GTK_ALIGN_FILL);
958 gtk_widget_set_valign (label, GTK_ALIGN_FILL);
959 gtk_widget_set_hexpand (label, TRUE);
960 gtk_widget_set_vexpand (label, FALSE);
961 g_object_set (label,
"margin", 0, NULL);
963 gtk_grid_attach (GTK_GRID(
table), comm_nb_page->mnemonic_entry, 1, 1, 1, 1);
965 g_signal_connect (comm_nb_page->mnemonic_entry,
"changed",
966 G_CALLBACK(gnc_ui_qif_import_comm_changed_cb), wind);
969 store = gtk_list_store_new (1, G_TYPE_STRING);
970 comm_nb_page->namespace_combo = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL(store));
971 g_object_unref (store);
973 entry = gtk_bin_get_child (GTK_BIN(comm_nb_page->namespace_combo));
974 gtk_widget_set_events (GTK_WIDGET(entry), GDK_FOCUS_CHANGE_MASK);
975 g_signal_connect (G_OBJECT (entry),
"changed",
976 G_CALLBACK(gnc_ui_qif_import_comm_namespace_changed_cb), wind);
979 gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(comm_nb_page->namespace_combo), 0);
981 gnc_cbwe_add_completion (GTK_COMBO_BOX(comm_nb_page->namespace_combo));
982 label = gtk_label_new_with_mnemonic (
983 _(
"_Exchange or abbreviation type"));
984 gtk_label_set_mnemonic_widget (GTK_LABEL(label), comm_nb_page->namespace_combo);
985 gnc_label_set_alignment (label, 0, 0.5);
987 gtk_widget_set_tooltip_text (label, namespace_tooltip);
988 gtk_widget_set_tooltip_text (comm_nb_page->namespace_combo, namespace_tooltip);
990 gtk_grid_attach (GTK_GRID(
table), label, 0, 2, 1, 1);
991 gtk_widget_set_halign (label, GTK_ALIGN_FILL);
992 gtk_widget_set_valign (label, GTK_ALIGN_FILL);
993 gtk_widget_set_hexpand (label, TRUE);
994 gtk_widget_set_vexpand (label, FALSE);
995 g_object_set (label,
"margin", 0, NULL);
997 gtk_grid_attach (GTK_GRID(
table), comm_nb_page->namespace_combo, 1, 2, 1, 1);
998 gtk_container_set_border_width (GTK_CONTAINER(notebook_page), 12);
999 gtk_box_pack_start (GTK_BOX(notebook_page),
table, FALSE, FALSE, 12);
1000 gtk_widget_show_all (GTK_WIDGET(wind->commodity_notebook));
1001 return comm_nb_page;
1011 prepare_security_pages (QIFImportWindow * wind)
1013 SCM hash_ref = scm_c_eval_string (
"hash-ref");
1018 gnc_commodity * commodity;
1019 QIFCommNotebookPage * new_comm_nb_page;
1024 gnc_set_busy_cursor (NULL, TRUE);
1025 securities = wind->new_securities;
1026 current = wind->commodity_notebook_pages;
1027 while (!scm_is_null (securities) && (securities != SCM_BOOL_F))
1032 current = current->next;
1037 comm_ptr_token = scm_call_2 (hash_ref,
1038 wind->security_hash,
1039 SCM_CAR(securities));
1041 #define FUNC_NAME "new_security_notebook_page" 1042 commodity = SWIG_MustGetPtr (comm_ptr_token,
1043 SWIG_TypeQuery (
"_p_gnc_commodity"), 1, 0);
1047 new_comm_nb_page = new_security_notebook_page (SCM_CAR(securities), commodity, wind);
1050 wind->commodity_notebook_pages = g_list_append (wind->commodity_notebook_pages,
1051 new_comm_nb_page->notebook_page);
1053 gtk_widget_show_all (new_comm_nb_page->notebook_page);
1055 wind->num_new_pages = wind->num_new_pages + 1;
1056 securities = SCM_CDR(securities);
1058 gnc_unset_busy_cursor (NULL);
1059 PINFO (
"Number of New Security pages is %d", wind->num_new_pages);
1070 gnc_ui_qif_import_commodity_update (QIFImportWindow * wind)
1073 GtkWidget *notebook_page;
1074 QIFCommNotebookPage *comm_nb_page;
1075 const gchar *mnemonic = NULL;
1076 gchar *name_space = NULL;
1077 const gchar *fullname = NULL;
1078 gnc_commodity *tab_commodity;
1080 for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
1082 notebook_page = pageptr->data;
1083 comm_nb_page = g_object_get_data (G_OBJECT(notebook_page),
"page_struct");
1086 mnemonic = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->mnemonic_entry));
1088 fullname = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->name_entry));
1096 tab_commodity = gnc_commodity_table_lookup (gnc_get_current_commodities(),
1097 name_space, mnemonic);
1098 if (!tab_commodity || tab_commodity == comm_nb_page->commodity)
1100 comm_nb_page->commodity);
1103 scm_hash_set_x (wind->security_hash,
1104 comm_nb_page->hash_key,
1105 SWIG_NewPointerObj (tab_commodity,
1106 SWIG_TypeQuery(
"_p_gnc_commodity"), 0));
1108 g_free (name_space);
1113 _gfec_error_handler (
const char *message)
1115 PERR (
"qif-import:qif-to-gnc-undo encountered an error: %s", message);
1125 gnc_ui_qif_import_convert_undo (QIFImportWindow * wind)
1127 SCM undo = scm_c_eval_string (
"qif-import:qif-to-gnc-undo");
1129 gnc_set_busy_cursor (NULL, TRUE);
1132 if (wind->imported_account_tree != SCM_BOOL_F)
1133 gfec_apply (undo, scm_list_1 (wind->imported_account_tree),
1134 _gfec_error_handler);
1137 scm_gc_unprotect_object (wind->imported_account_tree);
1138 wind->imported_account_tree = SCM_BOOL_F;
1139 scm_gc_protect_object (wind->imported_account_tree);
1142 scm_gc_unprotect_object (wind->match_transactions);
1143 wind->match_transactions = SCM_BOOL_F;
1144 scm_gc_protect_object (wind->match_transactions);
1146 gnc_unset_busy_cursor (NULL);
1157 refresh_old_transactions (QIFImportWindow * wind,
int selection)
1159 SCM possible_matches;
1162 Transaction * gnc_xtn;
1164 const gchar * amount_str;
1167 GtkListStore *store;
1169 static GMutex mutex;
1170 if (!g_mutex_trylock(&mutex))
1173 view = GTK_TREE_VIEW(wind->old_transaction_view);
1174 store = GTK_LIST_STORE(gtk_tree_view_get_model (view));
1175 gtk_list_store_clear (store);
1176 g_mutex_unlock (&mutex);
1178 if (wind->match_transactions != SCM_BOOL_F)
1180 possible_matches = SCM_CDR(scm_list_ref (wind->match_transactions,
1181 scm_from_int (wind->selected_transaction)));
1182 scm_call_2 (scm_c_eval_string (
"qif-import:refresh-match-selection"),
1183 possible_matches, scm_from_int (selection));
1185 while (!scm_is_null (possible_matches))
1187 gdouble amount_gd = 0;
1189 memset (datebuff, 0,
sizeof (datebuff));
1190 current_xtn = SCM_CAR(possible_matches);
1191 #define FUNC_NAME "xaccTransCountSplits" 1192 gnc_xtn = SWIG_MustGetPtr (SCM_CAR(current_xtn),
1193 SWIG_TypeQuery (
"_p_Transaction"), 1, 0);
1195 selected = SCM_CDR(current_xtn);
1199 amount_str = _(
"(split)");
1206 gnc_account_print_info
1211 gtk_list_store_append (store, &iter);
1216 QIF_TRANS_COL_INDEX, rownum++,
1217 QIF_TRANS_COL_DATE, datebuff,
1220 QIF_TRANS_COL_AMOUNT, amount_str,
1221 QIF_TRANS_COL_AMOUNT_DOUBLE, amount_gd,
1222 QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
1225 possible_matches = SCM_CDR(possible_matches);
1237 gnc_ui_qif_import_duplicate_new_select_cb (GtkTreeSelection *selection,
1238 QIFImportWindow *wind)
1240 GtkTreeModel *model;
1243 if (gtk_tree_selection_get_selected (selection, &model, &iter))
1244 gtk_tree_model_get (model, &iter, QIF_TRANS_COL_INDEX,
1245 &wind->selected_transaction, -1);
1246 refresh_old_transactions (wind, -1);
1254 reset_ignore_old_select (gboolean *ignore)
1267 gnc_ui_qif_import_duplicate_old_select_cb (GtkTreeSelection *selection,
1268 QIFImportWindow *wind)
1270 GtkTreeModel *model;
1273 static gboolean ignore_old_select = FALSE;
1277 if (!gtk_tree_selection_get_selected (selection, &model, &iter))
1279 gtk_tree_selection_unselect_all (selection);
1284 if (ignore_old_select)
1286 ignore_old_select = TRUE;
1287 g_idle_add ((GSourceFunc)reset_ignore_old_select, &ignore_old_select);
1291 gtk_tree_model_get (model, &iter, QIF_TRANS_COL_INDEX, &row, -1);
1292 refresh_old_transactions (wind, row);
1304 gnc_ui_qif_import_check_acct_tree (
GncPluginPage *page, gpointer user_data)
1306 gboolean *found = user_data;
1308 if (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page) && found)
1319 do_cancel (QIFImportWindow * wind)
1322 GtkWidget *notebook_page;
1323 QIFCommNotebookPage *comm_nb_page;
1324 gnc_commodity_table *
table;
1326 gnc_set_busy_cursor (NULL, TRUE);
1329 gnc_ui_qif_import_convert_undo (wind);
1332 for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
1334 notebook_page = pageptr->data;
1335 comm_nb_page = g_object_get_data (G_OBJECT(notebook_page),
"page_struct");
1340 table = gnc_get_current_commodities ();
1341 while (wind->new_namespaces)
1346 g_free (wind->new_namespaces->data);
1347 wind->new_namespaces = g_list_delete_link (wind->new_namespaces,
1348 wind->new_namespaces);
1350 gnc_unset_busy_cursor (NULL);
1353 gnc_close_gui_component_by_data (ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
1364 cancel_timeout_cb (gpointer data)
1366 QIFImportWindow *wind = data;
1386 gnc_ui_qif_import_cancel_cb (GtkAssistant *gtkassistant, gpointer user_data)
1388 QIFImportWindow *wind = user_data;
1389 gint currentpage = gtk_assistant_get_current_page (gtkassistant);
1390 GtkWidget *mypage = gtk_assistant_get_nth_page (gtkassistant, currentpage);
1391 const char *pagename = gtk_buildable_get_name (GTK_BUILDABLE(mypage));
1392 const char *fmt = _(
"Are you sure you want to cancel?");
1394 if (!g_strcmp0 (pagename,
"summary_page"))
1398 gnc_ui_qif_import_close_cb (gtkassistant, user_data);
1402 if (!gnc_verify_dialog (GTK_WINDOW(gtkassistant), FALSE,
"%s", fmt))
1408 scm_c_eval_string (
"(qif-import:cancel)");
1411 g_timeout_add (200, cancel_timeout_cb, user_data);
1425 gnc_ui_qif_import_close_cb (GtkAssistant *gtkassistant, gpointer user_data)
1427 QIFImportWindow *wind = user_data;
1430 if (!wind->acct_tree_found)
1436 gnc_close_gui_component_by_data (ASSISTANT_QIF_IMPORT_CM_CLASS, wind);
1446 gnc_ui_qif_import_assistant_get_mappings (QIFImportWindow * w)
1448 return scm_list_3 (w->acct_map_info,
1460 static int gnc_ui_qif_import_assistant_page_forward (
int current_page, gpointer data)
1462 QIFImportWindow *wind = data;
1463 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
1464 int page_count = gtk_assistant_get_n_pages (assistant);
1465 int next_page = current_page;
1467 for (next_page = current_page + 1; next_page < page_count; next_page++)
1469 GtkWidget *page = gtk_assistant_get_nth_page (assistant, next_page);
1477 if (wind->load_stop && next_page < (page_count - 1))
1480 if (!gnc_ui_qif_import_assistant_skip_page (assistant, page, wind))
1485 return current_page;
1495 gnc_ui_qif_import_assistant_skip_page (GtkAssistant *assistant, GtkWidget *page, QIFImportWindow *wind)
1497 const char *pagename = gtk_buildable_get_name (GTK_BUILDABLE(page));
1498 gboolean rv = FALSE;
1500 ENTER(
"Page %s", pagename);
1502 if (!g_strcmp0 (pagename,
"date_format_page"))
1505 rv = gnc_ui_qif_import_skip_date_format (assistant, wind);
1507 else if (!g_strcmp0 (pagename,
"account_name_page"))
1510 rv = gnc_ui_qif_import_skip_account (assistant, wind);
1512 else if (!g_strcmp0 (pagename,
"account_doc_page"))
1515 rv = gnc_ui_qif_import_skip_account_doc (wind);
1517 else if (!g_strcmp0 (pagename,
"category_doc_page"))
1520 rv = gnc_ui_qif_import_skip_category_doc (wind);
1522 else if (!g_strcmp0 (pagename,
"category_match_page"))
1525 rv = gnc_ui_qif_import_skip_category_match (wind);
1527 else if (!g_strcmp0 (pagename,
"memo_doc_page"))
1530 rv = gnc_ui_qif_import_skip_memo_doc (wind);
1532 else if (!g_strcmp0 (pagename,
"memo_match_page"))
1535 rv = gnc_ui_qif_import_skip_memo_match (wind);
1537 else if (!g_strcmp0 (pagename,
"commodity_page"))
1540 rv = gnc_ui_qif_import_skip_commodity (wind);
1542 else if (!g_strcmp0 (pagename,
"duplicates_doc_page"))
1545 rv = gnc_ui_qif_import_skip_duplicates_doc (wind);
1547 else if (!g_strcmp0 (pagename,
"duplicates_match_page"))
1550 rv = gnc_ui_qif_import_skip_duplicates_match (wind);
1554 LEAVE(
"%s", rv ?
"Skipped" :
"Not Skipped");
1572 get_preferences (QIFImportWindow *wind)
1574 gchar tmp_transaction_status =
'n';
1576 g_return_if_fail (wind);
1579 wind->show_doc_pages =
1584 tmp_transaction_status =
'c';
1585 else if (
gnc_prefs_get_bool (GNC_PREFS_GROUP, GNC_PREF_DEFAULT_TRANS_STATUS_RECONCILED))
1586 tmp_transaction_status =
'y';
1588 wind->transaction_status = SCM_MAKE_CHAR(tmp_transaction_status);
1598 initialize_scheme (QIFImportWindow *wind)
1602 SCM create_ticker_map;
1604 g_return_if_fail (wind);
1607 wind->imported_files = SCM_EOL;
1608 wind->selected_file = SCM_BOOL_F;
1609 wind->gnc_acct_info = SCM_BOOL_F;
1610 wind->cat_display_info = SCM_BOOL_F;
1611 wind->cat_map_info = SCM_BOOL_F;
1612 wind->acct_display_info = SCM_BOOL_F;
1613 wind->acct_map_info = SCM_BOOL_F;
1614 wind->memo_display_info = SCM_BOOL_F;
1615 wind->memo_map_info = SCM_BOOL_F;
1616 wind->security_hash = SCM_BOOL_F;
1617 wind->security_prefs = SCM_BOOL_F;
1618 wind->new_securities = SCM_BOOL_F;
1619 wind->ticker_map = SCM_BOOL_F;
1620 wind->imported_account_tree = SCM_BOOL_F;
1621 wind->match_transactions = SCM_BOOL_F;
1625 load_map_prefs = scm_c_eval_string (
"qif-import:load-map-prefs");
1626 mapping_info = scm_call_0 (load_map_prefs);
1627 wind->gnc_acct_info = scm_list_ref (mapping_info, scm_from_int (0));
1628 wind->acct_map_info = scm_list_ref (mapping_info, scm_from_int (1));
1629 wind->cat_map_info = scm_list_ref (mapping_info, scm_from_int (2));
1630 wind->memo_map_info = scm_list_ref (mapping_info, scm_from_int (3));
1631 wind->security_hash = scm_list_ref (mapping_info, scm_from_int (4));
1632 wind->security_prefs = scm_list_ref (mapping_info, scm_from_int (5));
1635 create_ticker_map = scm_c_eval_string (
"make-ticker-map");
1636 wind->ticker_map = scm_call_0 (create_ticker_map);
1639 scm_gc_protect_object (wind->imported_files);
1640 scm_gc_protect_object (wind->selected_file);
1641 scm_gc_protect_object (wind->gnc_acct_info);
1642 scm_gc_protect_object (wind->cat_display_info);
1643 scm_gc_protect_object (wind->cat_map_info);
1644 scm_gc_protect_object (wind->memo_display_info);
1645 scm_gc_protect_object (wind->memo_map_info);
1646 scm_gc_protect_object (wind->acct_display_info);
1647 scm_gc_protect_object (wind->acct_map_info);
1648 scm_gc_protect_object (wind->security_hash);
1649 scm_gc_protect_object (wind->security_prefs);
1650 scm_gc_protect_object (wind->new_securities);
1651 scm_gc_protect_object (wind->ticker_map);
1652 scm_gc_protect_object (wind->imported_account_tree);
1653 scm_gc_protect_object (wind->match_transactions);
1667 gnc_ui_qif_import_intro_prepare (GtkAssistant *assistant, gpointer user_data)
1669 QIFImportWindow *wind = user_data;
1670 SCM unload = scm_c_eval_string (
"qif-dialog:unload-qif-file");
1674 wind->load_stop = FALSE;
1675 wind->read_file_warnings = FALSE;
1677 files_list = scm_call_2 (unload, wind->selected_file, wind->imported_files);
1679 scm_gc_unprotect_object (wind->imported_files);
1680 wind->imported_files = files_list;
1681 scm_gc_protect_object (wind->imported_files);
1683 scm_gc_unprotect_object (wind->selected_file);
1684 wind->selected_file = SCM_BOOL_F;
1685 scm_gc_protect_object (wind->selected_file);
1699 gnc_ui_qif_import_load_file_complete (GtkAssistant *assistant,
1702 QIFImportWindow * wind = user_data;
1703 const gchar * path_to_load;
1706 path_to_load = gtk_entry_get_text (GTK_ENTRY(wind->filename_entry));
1709 if (strlen (path_to_load) == 0)
1710 gnc_error_dialog (GTK_WINDOW(assistant),
"%s", _(
"Please select a file to load."));
1711 else if (g_access (path_to_load, R_OK) < 0)
1712 gnc_error_dialog (GTK_WINDOW(assistant),
"%s",
1713 _(
"File not found or read permission denied. " 1714 "Please select another file."));
1717 SCM qif_file_loaded = scm_c_eval_string(
"qif-dialog:qif-file-loaded?");
1720 if (scm_call_2 (qif_file_loaded,
1721 scm_from_locale_string (path_to_load ? path_to_load :
""),
1722 wind->imported_files) == SCM_BOOL_T)
1723 gnc_error_dialog (GTK_WINDOW(assistant),
"%s",
1724 _(
"That QIF file is already loaded. " 1725 "Please select another file."));
1743 gnc_ui_qif_import_load_file_prepare (GtkAssistant *assistant, gpointer user_data)
1745 QIFImportWindow * wind = user_data;
1746 const gchar * path_to_load;
1747 gboolean page_status = FALSE;
1751 path_to_load = gtk_entry_get_text (GTK_ENTRY(wind->filename_entry));
1754 if (strlen (path_to_load) != 0)
1756 page_status = gnc_ui_qif_import_load_file_complete (assistant, user_data);
1758 mark_page_complete(assistant, page_status);
1770 gnc_ui_qif_import_select_file_cb (GtkButton * button,
1773 QIFImportWindow * wind = user_data;
1775 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
1777 GtkFileFilter *filter;
1778 char * new_file_name;
1779 char *file_name, *default_dir;
1782 default_dir = gnc_get_default_directory (GNC_PREFS_GROUP);
1784 filter = gtk_file_filter_new ();
1785 gtk_file_filter_set_name (filter,
"*.qif");
1786 gtk_file_filter_add_pattern (filter,
"*.[Qq][Ii][Ff]");
1788 _(
"Select QIF File"),
1789 g_list_prepend (NULL, filter),
1791 GNC_FILE_DIALOG_IMPORT);
1793 if (new_file_name == NULL)
1795 g_free (default_dir);
1798 else if (!g_path_is_absolute (new_file_name))
1800 file_name = g_build_filename (default_dir, new_file_name, NULL);
1801 g_free (new_file_name);
1805 file_name = new_file_name;
1807 g_free (default_dir);
1808 default_dir = g_path_get_dirname (file_name);
1809 gnc_set_default_directory (GNC_PREFS_GROUP, default_dir);
1811 g_free (default_dir);
1814 gtk_entry_set_text (GTK_ENTRY(wind->filename_entry), file_name);
1817 mark_page_complete (assistant,
1818 gnc_ui_qif_import_load_file_complete (assistant, user_data));
1832 gnc_ui_qif_import_load_progress_pause_cb (GtkButton * button,
1835 QIFImportWindow *wind = user_data;
1836 SCM toggle_pause = scm_c_eval_string (
"qif-import:toggle-pause");
1843 progress = SWIG_NewPointerObj (wind->load_progress,
1844 SWIG_TypeQuery (
"_p__GNCProgressDialog"),
1848 scm_call_1 (toggle_pause, progress);
1851 if (strcmp (gtk_button_get_label (button), _(
"_Resume")))
1853 gtk_button_set_use_underline (button, TRUE);
1854 gtk_button_set_label (button, _(
"_Resume"));
1858 gtk_button_set_use_underline (button, FALSE);
1859 gtk_button_set_label (button, _(
"P_ause"));
1870 gnc_ui_qif_import_load_progress_start_cb (GtkButton * button,
1873 QIFImportWindow *wind = user_data;
1874 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
1876 const gchar * path_to_load;
1878 SCM make_qif_file = scm_c_eval_string (
"make-qif-file");
1879 SCM qif_file_load = scm_c_eval_string (
"qif-file:read-file");
1880 SCM qif_file_parse = scm_c_eval_string (
"qif-file:parse-fields");
1881 SCM unload_qif_file = scm_c_eval_string (
"qif-dialog:unload-qif-file");
1882 SCM parse_results = scm_c_eval_string (
"qif-file:parse-fields-results");
1884 SCM imported_files = SCM_EOL;
1885 SCM load_return = SCM_BOOL_F, parse_return = SCM_BOOL_F;
1890 gtk_widget_set_sensitive (wind->load_pause, TRUE);
1893 path_to_load = gtk_entry_get_text (GTK_ENTRY(wind->filename_entry));
1896 scm_qiffile = scm_call_0 (make_qif_file);
1897 scm_gc_unprotect_object (wind->selected_file);
1898 wind->selected_file = scm_qiffile;
1899 scm_gc_protect_object (wind->selected_file);
1900 imported_files = scm_cons (scm_qiffile, wind->imported_files);
1903 progress = SWIG_NewPointerObj (wind->load_progress,
1904 SWIG_TypeQuery (
"_p__GNCProgressDialog"),
1908 scm_c_eval_string (
"(qif-import:reset-cancel-pause)");
1923 load_return = scm_call_4 (qif_file_load,
1924 SCM_CAR(imported_files),
1925 scm_from_locale_string (path_to_load ? path_to_load :
""),
1929 if (load_return == SCM_BOOL_T)
1934 gtk_widget_set_sensitive (wind->load_pause, FALSE);
1940 wind->load_stop = TRUE;
1942 else if (load_return == SCM_BOOL_F || !scm_is_list (load_return))
1947 gtk_widget_set_sensitive (wind->load_pause, FALSE);
1951 _(
"An error occurred while loading the QIF file."));
1954 gnc_error_dialog (GTK_WINDOW(assistant),
"%s",
1955 _(
"An error occurred while loading the QIF file."));
1959 wind->load_stop = TRUE;
1961 else if (!scm_is_null (load_return))
1963 if (SCM_CAR(load_return) == SCM_BOOL_F)
1965 imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
1966 scm_gc_unprotect_object (wind->imported_files);
1967 wind->imported_files = imported_files;
1968 scm_gc_protect_object (wind->imported_files);
1973 gtk_widget_set_sensitive (wind->load_pause, FALSE);
1975 wind->load_stop = TRUE;
1978 wind->read_file_warnings = TRUE;
1993 if (!wind->load_stop)
1996 parse_return = scm_call_2 (qif_file_parse, SCM_CAR(imported_files),
1999 wind->ask_date_format = FALSE;
2000 wind->date_format = NULL;
2002 if (parse_return == SCM_BOOL_T)
2007 gtk_widget_set_sensitive (wind->load_pause, FALSE);
2011 imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
2017 wind->load_stop = TRUE;
2019 else if (parse_return == SCM_BOOL_F || !scm_is_list(parse_return))
2024 gtk_widget_set_sensitive (wind->load_pause, FALSE);
2028 imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
2032 _(
"A bug was detected while parsing the QIF file."));
2035 gnc_error_dialog (GTK_WINDOW(assistant),
"%s",
2036 _(
"A bug was detected while parsing the QIF file."));
2040 wind->load_stop = TRUE;
2042 else if (!scm_is_null (parse_return))
2045 if (SCM_CAR(parse_return) == SCM_BOOL_T)
2052 if ((date_formats = scm_call_2 (parse_results,
2053 SCM_CDR(parse_return),
2054 scm_from_locale_symbol (
"date"))) != SCM_BOOL_F)
2056 GtkComboBox *combo_box;
2057 GtkTreeModel *model;
2061 g_signal_handlers_block_by_func (wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind);
2064 combo_box = GTK_COMBO_BOX(wind->date_format_combo);
2065 model = gtk_combo_box_get_model (combo_box);
2066 gtk_list_store_clear (GTK_LIST_STORE(model));
2068 gtk_combo_box_set_active (GTK_COMBO_BOX(wind->date_format_combo), -1);
2071 while (scm_is_list (date_formats) && !scm_is_null (date_formats))
2073 gtk_list_store_append (GTK_LIST_STORE(model), &iter);
2074 gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, gnc_scm_symbol_to_locale_string (SCM_CAR(date_formats)), -1);
2076 date_formats = SCM_CDR(date_formats);
2080 g_signal_handlers_unblock_by_func (wind->date_format_combo, gnc_ui_qif_import_date_valid_cb, wind);
2082 wind->ask_date_format = TRUE;
2084 wind->load_stop = TRUE;
2089 imported_files = scm_call_2 (unload_qif_file, scm_qiffile, imported_files);
2093 gtk_widget_set_sensitive (wind->load_pause, FALSE);
2095 wind->load_stop = TRUE;
2100 mark_page_complete (assistant, TRUE);
2103 gtk_widget_set_sensitive (wind->load_pause, FALSE);
2104 gtk_widget_set_sensitive (wind->load_start, FALSE);
2110 scm_gc_unprotect_object (wind->imported_files);
2111 wind->imported_files = imported_files;
2112 scm_gc_protect_object (wind->imported_files);
2114 gtk_widget_set_sensitive (wind->load_pause, FALSE);
2118 if (wind->load_stop == FALSE && wind->read_file_warnings == FALSE)
2121 gtk_assistant_next_page (assistant);
2123 wind->load_stop = FALSE;
2133 gnc_ui_qif_import_load_progress_prepare (GtkAssistant *assistant, gpointer user_data)
2135 QIFImportWindow *wind = user_data;
2140 _(
"When you press the Start Button, GnuCash will load your QIF file. If there are no errors or warnings, you will automatically proceed to the next step. Otherwise, the details will be shown below for your review."));
2146 gtk_widget_set_sensitive (wind->load_pause, FALSE);
2147 gtk_widget_set_sensitive (wind->load_start, TRUE);
2150 mark_page_complete (assistant, FALSE);
2164 gnc_ui_qif_import_skip_date_format (GtkAssistant *assistant, QIFImportWindow *wind)
2166 return ! wind->ask_date_format;
2176 qif_import_reparse_dates (QIFImportWindow* wind)
2178 SCM reparse_dates = scm_c_eval_string (
"qif-file:reparse-dates");
2179 SCM format_sym = scm_from_locale_symbol (wind->date_format);
2182 scm_call_2 (reparse_dates, wind->selected_file, format_sym);
2183 g_free (wind->date_format);
2184 wind->date_format = NULL;
2185 wind->ask_date_format = FALSE;
2189 gnc_ui_qif_import_date_valid_cb (GtkWidget *widget, gpointer user_data)
2191 QIFImportWindow * wind = user_data;
2192 GtkTreeModel *model;
2195 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
2198 model = gtk_combo_box_get_model (GTK_COMBO_BOX(wind->date_format_combo));
2199 gtk_combo_box_get_active_iter (GTK_COMBO_BOX(wind->date_format_combo), &iter);
2200 gtk_tree_model_get (model, &iter, 0, &wind->date_format, -1);
2202 if (!wind->date_format)
2204 g_critical (
"QIF import: BUG DETECTED in gnc_ui_qif_import_date_valid_cb. Format is NULL.");
2207 qif_import_reparse_dates (wind);
2209 mark_page_complete (assistant, TRUE);
2222 gnc_ui_qif_import_account_prepare (GtkAssistant *assistant, gpointer user_data)
2224 QIFImportWindow * wind = user_data;
2226 SCM check_from_acct = scm_c_eval_string (
"qif-file:check-from-acct");
2229 if (wind->selected_file == SCM_BOOL_F)
2231 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
2232 gtk_entry_set_text (GTK_ENTRY(wind->filename_entry),
"");
2233 gtk_assistant_set_current_page (assistant, 1);
2238 if (scm_call_1 (check_from_acct, wind->selected_file) != SCM_BOOL_T)
2241 SCM default_acct = scm_c_eval_string (
"qif-file:path-to-accountname");
2242 gchar * default_acctname = NULL;
2244 default_acctname = gnc_scm_call_1_to_string (default_acct, wind->selected_file);
2245 gtk_entry_set_text (GTK_ENTRY(wind->acct_entry), default_acctname);
2246 g_free (default_acctname);
2257 gnc_ui_qif_import_skip_account (GtkAssistant *assistant, QIFImportWindow *wind)
2259 SCM check_from_acct = scm_c_eval_string (
"qif-file:check-from-acct");
2260 if (wind->selected_file != SCM_BOOL_F &&
2261 scm_call_1 (check_from_acct, wind->selected_file) == SCM_BOOL_T)
2272 gnc_ui_qif_import_acct_enter_cb (GtkWidget * widget,
2275 QIFImportWindow * wind = user_data;
2277 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
2279 const gchar * acct_name = gtk_entry_get_text (GTK_ENTRY(wind->acct_entry));
2281 if (!acct_name || acct_name[0] == 0)
2284 mark_page_complete (assistant, FALSE);
2289 mark_page_complete (assistant, TRUE);
2292 gtk_assistant_next_page (assistant);
2303 gnc_ui_qif_import_acct_valid_cb (GtkWidget * widget,
2306 QIFImportWindow * wind = user_data;
2308 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
2310 const gchar * acct_name = gtk_entry_get_text (GTK_ENTRY(wind->acct_entry));
2312 if (!acct_name || acct_name[0] == 0)
2315 mark_page_complete (assistant, FALSE);
2320 mark_page_complete (assistant, TRUE);
2335 gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant,
2338 QIFImportWindow * wind = user_data;
2340 const gchar * acct_name = gtk_entry_get_text (GTK_ENTRY(wind->acct_entry));
2341 SCM fix_default = scm_c_eval_string (
"qif-import:fix-from-acct");
2344 if (wind->selected_file != SCM_BOOL_F)
2346 scm_name = scm_from_utf8_string (acct_name ? acct_name :
"");
2347 scm_call_2 (fix_default, wind->selected_file, scm_name);
2350 mark_page_complete (assistant, TRUE);
2353 update_file_page (wind);
2363 gnc_ui_qif_import_load_another_cb (GtkButton * button,
2366 QIFImportWindow * wind = user_data;
2367 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
2369 gtk_entry_set_text (GTK_ENTRY(wind->filename_entry),
"");
2371 gtk_assistant_set_current_page (assistant, 1);
2381 gnc_ui_qif_import_unload_file_cb (GtkButton * button,
2384 QIFImportWindow * wind = user_data;
2386 SCM unload_qif_file = scm_c_eval_string (
"qif-dialog:unload-qif-file");
2389 if (wind->selected_file != SCM_BOOL_F)
2392 scm_call_2 (unload_qif_file, wind->selected_file, wind->imported_files);
2394 scm_gc_unprotect_object (wind->imported_files);
2395 wind->imported_files = imported_files;
2396 scm_gc_protect_object (wind->imported_files);
2398 scm_gc_unprotect_object (wind->selected_file);
2399 wind->selected_file = SCM_BOOL_F;
2400 scm_gc_protect_object (wind->selected_file);
2402 update_file_page (wind);
2413 update_file_page (QIFImportWindow * wind)
2415 SCM loaded_file_list = wind->imported_files;
2419 GtkListStore *store;
2422 GtkTreeRowReference *reference = NULL;
2424 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
2425 gint num_of_files = 0;
2428 view = GTK_TREE_VIEW(wind->selected_file_view);
2429 store = GTK_LIST_STORE(gtk_tree_view_get_model (view));
2430 gtk_list_store_clear (store);
2431 qif_file_path = scm_c_eval_string (
"qif-file:path");
2433 mark_page_complete (assistant, FALSE);
2435 while (!scm_is_null (loaded_file_list))
2437 gchar *row_text = NULL;
2438 SCM scm_qiffile = SCM_BOOL_F;
2440 scm_qiffile = SCM_CAR(loaded_file_list);
2441 row_text = gnc_scm_call_1_to_string (qif_file_path, scm_qiffile);
2443 gtk_list_store_append (store, &iter);
2444 gtk_list_store_set (store, &iter,
2445 FILENAME_COL_INDEX, row++,
2446 FILENAME_COL_NAME, row_text,
2450 if (scm_qiffile == wind->selected_file)
2452 path = gtk_tree_model_get_path (GTK_TREE_MODEL(store), &iter);
2453 reference = gtk_tree_row_reference_new (GTK_TREE_MODEL(store), path);
2454 gtk_tree_path_free (path);
2456 loaded_file_list = SCM_CDR(loaded_file_list);
2461 GtkTreeSelection* selection = gtk_tree_view_get_selection (view);
2462 path = gtk_tree_row_reference_get_path (reference);
2465 gtk_tree_selection_select_path (selection, path);
2466 gtk_tree_path_free (path);
2468 gtk_tree_row_reference_free (reference);
2472 num_of_files = gtk_tree_model_iter_n_children (GTK_TREE_MODEL(store), NULL);
2474 if (num_of_files > 0)
2475 mark_page_complete (assistant, TRUE);
2506 gnc_ui_qif_import_account_doc_prepare (GtkAssistant *assistant,
2510 mark_page_complete (assistant, TRUE);
2519 gnc_ui_qif_import_skip_account_doc (QIFImportWindow *wind)
2521 return !wind->show_doc_pages;
2534 gnc_ui_qif_import_account_match_prepare (GtkAssistant *assistant,
2537 QIFImportWindow * wind = user_data;
2540 gnc_set_busy_cursor (NULL, TRUE);
2541 update_account_page (wind);
2542 update_category_page (wind);
2543 update_memo_page (wind);
2544 gnc_unset_busy_cursor (NULL);
2547 mark_page_complete (assistant, TRUE);
2559 gnc_ui_qif_import_account_rematch_cb (GtkButton *button, gpointer user_data)
2561 QIFImportWindow *wind = user_data;
2563 g_return_if_fail (wind);
2566 gtk_tree_view_get_selection (GTK_TREE_VIEW(wind->acct_view)),
2567 wind->acct_display_info,
2568 wind->acct_map_info,
2569 update_account_page);
2581 gnc_ui_qif_import_category_doc_prepare (GtkAssistant *assistant,
2585 mark_page_complete (assistant, TRUE);
2594 gnc_ui_qif_import_skip_category_doc (QIFImportWindow *wind)
2597 if (!wind->show_doc_pages)
2601 if (scm_is_list (wind->cat_display_info) && scm_is_null (wind->cat_display_info))
2619 gnc_ui_qif_import_category_match_prepare (GtkAssistant *assistant,
2623 mark_page_complete (assistant, TRUE);
2632 gnc_ui_qif_import_skip_category_match (QIFImportWindow *wind)
2635 if (scm_is_list (wind->cat_display_info) && scm_is_null (wind->cat_display_info))
2650 gnc_ui_qif_import_category_rematch_cb (GtkButton *button, gpointer user_data)
2652 QIFImportWindow *wind = user_data;
2654 g_return_if_fail (wind);
2657 gtk_tree_view_get_selection (GTK_TREE_VIEW(wind->cat_view)),
2658 wind->cat_display_info,
2660 update_category_page);
2672 gnc_ui_qif_import_memo_doc_prepare (GtkAssistant *assistant, gpointer user_data)
2675 mark_page_complete (assistant, TRUE);
2684 gnc_ui_qif_import_skip_memo_doc (QIFImportWindow *wind)
2687 if (!wind->show_doc_pages)
2691 if (scm_is_list (wind->memo_display_info) && scm_is_null (wind->memo_display_info))
2709 gnc_ui_qif_import_memo_match_prepare (GtkAssistant *assistant, gpointer user_data)
2712 mark_page_complete (assistant, TRUE);
2721 gnc_ui_qif_import_skip_memo_match (QIFImportWindow *wind)
2724 if (scm_is_list (wind->memo_display_info) && scm_is_null (wind->memo_display_info))
2739 gnc_ui_qif_import_memo_rematch_cb (GtkButton *button, gpointer user_data)
2741 QIFImportWindow * wind = user_data;
2743 g_return_if_fail (wind);
2746 gtk_tree_view_get_selection (GTK_TREE_VIEW(wind->memo_view)),
2747 wind->memo_display_info,
2748 wind->memo_map_info,
2764 gnc_ui_qif_import_currency_prepare (GtkAssistant *assistant, gpointer user_data)
2766 gint num = gtk_assistant_get_current_page (assistant);
2767 GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);
2768 QIFImportWindow *wind = user_data;
2770 g_return_if_fail (wind);
2775 gtk_assistant_set_page_title (assistant, page,
2776 _(
"Choose the QIF file currency and select Book Options"));
2777 gtk_widget_show (wind->book_option_label);
2778 gtk_widget_show (wind->book_option_message);
2782 gtk_assistant_set_page_title (assistant, page,
2783 _(
"Choose the QIF file currency"));
2784 gtk_widget_hide (wind->book_option_label);
2785 gtk_widget_hide (wind->book_option_message);
2789 mark_page_complete (assistant, TRUE);
2806 gnc_ui_qif_import_new_securities (QIFImportWindow * wind)
2809 SCM update_securities = scm_c_eval_string (
"qif-import:update-security-hash");
2812 updates = scm_call_4 (update_securities,
2813 wind->security_hash,
2815 wind->acct_map_info,
2816 wind->security_prefs);
2817 if (updates != SCM_BOOL_F)
2820 scm_gc_unprotect_object (wind->new_securities);
2821 if (wind->new_securities != SCM_BOOL_F)
2823 wind->new_securities = scm_append (scm_list_2 (wind->new_securities,
2826 wind->new_securities = updates;
2827 scm_gc_protect_object (wind->new_securities);
2832 if (wind->new_securities != SCM_BOOL_F)
2846 gnc_ui_qif_import_commodity_notebook_update_combos (QIFImportWindow * wind, gboolean init_combos)
2849 GtkWidget *notebook_page;
2850 QIFCommNotebookPage *comm_nb_page;
2852 for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
2856 notebook_page = pageptr->data;
2857 comm_nb_page = g_object_get_data (G_OBJECT(notebook_page),
"page_struct");
2866 comm_nb_page->namespace_combo,
2871 gtk_entry_set_text (GTK_ENTRY(gtk_bin_get_child (
2872 GTK_BIN(comm_nb_page->namespace_combo))),
"");
2887 gnc_ui_qif_import_commodity_all_notebook_pages_complete (QIFImportWindow * wind)
2890 GtkWidget *notebook_page;
2891 QIFCommNotebookPage *comm_nb_page;
2892 gboolean pages_complete = TRUE;
2894 for (pageptr = wind->commodity_notebook_pages; pageptr; pageptr = pageptr->next)
2896 notebook_page = pageptr->data;
2897 comm_nb_page = g_object_get_data (G_OBJECT(notebook_page),
"page_struct");
2899 if (!comm_nb_page->page_complete)
2900 pages_complete = FALSE;
2902 return pages_complete;
2910 gnc_ui_qif_import_commodity_prepare (GtkAssistant *assistant, gpointer user_data)
2912 QIFImportWindow *wind = user_data;
2915 mark_page_complete (assistant,
2916 gnc_ui_qif_import_commodity_all_notebook_pages_complete (wind));
2919 if (wind->new_securities != SCM_BOOL_F)
2921 wind->timeout_id = 0;
2924 prepare_security_pages (wind);
2927 gnc_ui_qif_import_commodity_notebook_update_combos (wind, TRUE);
2937 gnc_ui_qif_import_skip_commodity (QIFImportWindow *wind)
2939 return !gnc_ui_qif_import_new_securities (wind);
2948 gnc_ui_qif_import_comm_valid (GtkAssistant *assistant, gpointer user_data)
2950 QIFImportWindow * wind = user_data;
2951 gint num = gtk_notebook_get_current_page (GTK_NOTEBOOK(wind->commodity_notebook));
2952 GtkWidget * notebook_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK(wind->commodity_notebook), num);
2953 QIFCommNotebookPage * comm_nb_page = g_object_get_data (G_OBJECT(notebook_page),
"page_struct");
2956 gnc_commodity_table *
table;
2957 gnc_commodity_namespace *newns;
2960 const gchar *name = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->name_entry));
2961 const gchar *mnemonic = gtk_entry_get_text (GTK_ENTRY(comm_nb_page->mnemonic_entry));
2964 comm_nb_page->page_complete = TRUE;
2966 if (!name || (name[0] == 0))
2968 comm_nb_page->page_complete = FALSE;
2969 g_free (name_space);
2972 else if (!mnemonic || (mnemonic[0] == 0))
2974 comm_nb_page->page_complete = FALSE;
2975 g_free (name_space);
2978 else if (!name_space || (name_space[0] == 0))
2980 comm_nb_page->page_complete = FALSE;
2982 g_free (name_space);
2991 book = gnc_get_current_book ();
2994 !gnc_commodity_table_lookup (
table, name_space, mnemonic))
2996 gnc_warning_dialog (GTK_WINDOW(assistant),
"%s",
2997 _(
"You must enter an existing national " 2998 "currency or enter a different type."));
3000 comm_nb_page->page_complete = FALSE;
3001 g_free (name_space);
3013 wind->new_namespaces = g_list_prepend (wind->new_namespaces, name_space);
3016 g_warning (
"QIF import: Couldn't create namespace %s", name_space);
3017 g_free (name_space);
3021 g_free (name_space);
3024 gnc_ui_qif_import_commodity_notebook_update_combos (wind, FALSE);
3026 return gnc_ui_qif_import_commodity_all_notebook_pages_complete (wind);
3034 gnc_ui_qif_import_comm_changed_cb (GtkWidget *widget, gpointer user_data)
3036 QIFImportWindow *wind = user_data;
3037 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
3039 mark_page_complete (assistant,
3040 gnc_ui_qif_import_comm_valid (assistant, user_data));
3045 do_page_check (gpointer user_data)
3047 QIFImportWindow *wind = user_data;
3048 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
3050 mark_page_complete (assistant,
3051 gnc_ui_qif_import_comm_valid (assistant, wind));
3053 wind->timeout_id = 0;
3062 gnc_ui_qif_import_comm_namespace_changed_cb (GtkWidget *widget, gpointer user_data)
3064 QIFImportWindow *wind = user_data;
3066 if (wind->timeout_id)
3067 g_source_remove (wind->timeout_id);
3072 wind->timeout_id = g_timeout_add (500, (GSourceFunc)do_page_check, wind);
3086 gnc_ui_qif_import_convert_progress_pause_cb (GtkButton * button,
3089 QIFImportWindow *wind = user_data;
3090 SCM toggle_pause = scm_c_eval_string (
"qif-import:toggle-pause");
3097 progress = SWIG_NewPointerObj (wind->convert_progress,
3098 SWIG_TypeQuery (
"_p__GNCProgressDialog"),
3102 scm_call_1 (toggle_pause, progress);
3105 if (strcmp (gtk_button_get_label (button), _(
"_Resume")))
3107 gtk_button_set_use_underline (button, TRUE);
3108 gtk_button_set_label (button, _(
"_Resume"));
3112 gtk_button_set_use_underline (button, FALSE);
3113 gtk_button_set_label (button, _(
"P_ause"));
3124 gnc_ui_qif_import_convert_progress_start_cb (GtkButton * button,
3127 QIFImportWindow *wind = user_data;
3128 GtkAssistant *assistant = GTK_ASSISTANT(wind->window);
3130 SCM qif_to_gnc = scm_c_eval_string (
"qif-import:qif-to-gnc");
3131 SCM find_duplicates = scm_c_eval_string (
"gnc:account-tree-find-duplicates");
3135 SCM progress = SWIG_NewPointerObj (wind->convert_progress,
3136 SWIG_TypeQuery (
"_p__GNCProgressDialog"),
3140 const gchar *currname = gtk_entry_get_text (GTK_ENTRY(gtk_bin_get_child (
3141 GTK_BIN(GTK_COMBO_BOX(wind->currency_picker)))));
3145 gtk_widget_set_sensitive (wind->convert_pause, TRUE);
3146 gtk_widget_set_sensitive (wind->convert_start, FALSE);
3149 scm_c_eval_string (
"(qif-import:reset-cancel-pause)");
3152 gnc_ui_qif_import_commodity_update (wind);
3165 retval = scm_apply (qif_to_gnc,
3166 scm_list_n (wind->imported_files,
3167 wind->acct_map_info,
3169 wind->memo_map_info,
3170 wind->security_hash,
3171 scm_from_utf8_string (currname ? currname :
""),
3172 wind->transaction_status,
3178 if (retval == SCM_BOOL_T)
3183 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3187 gnc_ui_qif_import_convert_undo (wind);
3194 wind->load_stop = TRUE;
3196 else if (retval == SCM_BOOL_F)
3201 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3205 gnc_ui_qif_import_convert_undo (wind);
3209 _(
"A bug was detected while converting the QIF data."));
3212 gnc_error_dialog (GTK_WINDOW(assistant),
"%s",
3213 _(
"A bug was detected while converting the QIF data."));
3217 wind->load_stop = TRUE;
3219 else if (scm_is_symbol (retval))
3224 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3228 gnc_ui_qif_import_convert_undo (wind);
3235 wind->load_stop = TRUE;
3237 if (wind->load_stop == FALSE)
3240 scm_gc_unprotect_object (wind->imported_account_tree);
3241 wind->imported_account_tree = retval;
3242 scm_gc_protect_object (wind->imported_account_tree);
3250 retval = scm_call_3 (find_duplicates,
3251 scm_c_eval_string (
"(gnc-get-current-root-account)"),
3252 wind->imported_account_tree, progress);
3256 scm_gc_unprotect_object (wind->match_transactions);
3257 wind->match_transactions = retval;
3258 scm_gc_protect_object (wind->match_transactions);
3260 if (retval == SCM_BOOL_T)
3263 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3266 wind->load_stop = TRUE;
3268 else if (retval == SCM_BOOL_F)
3274 gnc_ui_qif_import_convert_undo (wind);
3278 _(
"A bug was detected while detecting duplicates."));
3281 gnc_error_dialog (GTK_WINDOW(assistant),
"%s",
3282 _(
"A bug was detected while detecting duplicates."));
3285 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3287 wind->load_stop = TRUE;
3291 mark_page_complete (assistant, TRUE);
3294 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3295 gtk_widget_set_sensitive (wind->convert_start, FALSE);
3297 if (wind->load_stop == FALSE)
3301 _(
"Conversion completed"));
3304 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3308 if (gtk_text_buffer_get_char_count (gtk_text_view_get_buffer (GTK_TEXT_VIEW(wind->convert_log))) == 0) {
3309 gtk_assistant_next_page (assistant);
3321 gnc_ui_qif_import_convert_progress_prepare (GtkAssistant *assistant,
3324 QIFImportWindow *wind = user_data;
3329 _(
"When you press the Start Button, GnuCash will import your QIF data. " 3330 "If there are no errors or warnings, you will automatically proceed to " 3331 "the next step. Otherwise, the details will be shown below for your review."));
3337 gtk_widget_set_sensitive (wind->convert_pause, FALSE);
3338 gtk_widget_set_sensitive (wind->convert_start, TRUE);
3341 mark_page_complete (assistant, FALSE);
3346 wind->new_book = gnc_new_book_option_display (wind->window);
3358 gnc_ui_qif_import_duplicates_doc_prepare (GtkAssistant *assistant,
3362 mark_page_complete (assistant, TRUE);
3372 gnc_ui_qif_import_skip_duplicates_doc (QIFImportWindow *wind)
3375 if (!wind->show_doc_pages)
3379 if (scm_is_null (wind->match_transactions))
3393 gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
3396 QIFImportWindow * wind = user_data;
3399 GtkListStore *store;
3402 Transaction *gnc_xtn;
3405 GtkTreeSelection *selection;
3407 const gchar *amount_str;
3410 if (!scm_is_null (wind->match_transactions))
3412 view = GTK_TREE_VIEW(wind->new_transaction_view);
3413 store = GTK_LIST_STORE(gtk_tree_view_get_model (view));
3414 gtk_list_store_clear (store);
3416 if (!scm_is_list (wind->match_transactions))
3420 duplicates = wind->match_transactions;
3421 while (!scm_is_null (duplicates))
3423 gdouble amount_gd = 0;
3427 current_xtn = SCM_CAAR(duplicates);
3428 #define FUNC_NAME "xaccTransCountSplits" 3429 gnc_xtn = SWIG_MustGetPtr (current_xtn,
3430 SWIG_TypeQuery (
"_p_Transaction"), 1, 0);
3433 amount_str = _(
"(split)");
3439 gnc_account_print_info
3443 gtk_list_store_append (store, &iter);
3448 QIF_TRANS_COL_INDEX, rownum++,
3449 QIF_TRANS_COL_DATE, datebuff,
3450 QIF_TRANS_COL_DATE_INT64, send_time,
3452 QIF_TRANS_COL_AMOUNT, amount_str,
3453 QIF_TRANS_COL_AMOUNT_DOUBLE, amount_gd,
3456 duplicates = SCM_CDR(duplicates);
3458 selection = gtk_tree_view_get_selection (view);
3459 path = gtk_tree_path_new_from_indices (0, -1);
3460 gtk_tree_selection_select_path (selection, path);
3461 gtk_tree_path_free (path);
3465 mark_page_complete (assistant, TRUE);
3474 gnc_ui_qif_import_skip_duplicates_match (QIFImportWindow *wind)
3477 return scm_is_null (wind->match_transactions);
3489 gnc_ui_qif_import_end_page_prepare (GtkAssistant *assistant,
3493 mark_page_complete (assistant, TRUE);
3503 gnc_ui_qif_import_finish_cb (GtkAssistant *assistant,
3506 QIFImportWindow * wind = user_data;
3508 SCM save_map_prefs = scm_c_eval_string (
"qif-import:save-map-prefs");
3509 SCM cat_and_merge = scm_c_eval_string (
"gnc:account-tree-catenate-and-merge");
3510 SCM prune_xtns = scm_c_eval_string (
"gnc:prune-matching-transactions");
3514 gboolean acct_tree_found = FALSE;
3516 gnc_suspend_gui_refresh ();
3519 if (wind->match_transactions != SCM_BOOL_F)
3520 scm_call_1 (prune_xtns, wind->match_transactions);
3523 if (wind->imported_account_tree != SCM_BOOL_F)
3524 scm_call_2 (cat_and_merge,
3525 scm_c_eval_string (
"(gnc-get-current-root-account)"),
3526 wind->imported_account_tree);
3528 gnc_resume_gui_refresh ();
3531 scm_result = scm_apply (save_map_prefs,
3532 scm_list_5 (wind->acct_map_info, wind->cat_map_info,
3533 wind->memo_map_info, wind->security_hash,
3534 wind->security_prefs),
3537 if (scm_result == SCM_BOOL_F)
3538 gnc_warning_dialog (GTK_WINDOW(assistant),
"%s",
3539 _(
"GnuCash was unable to save your mapping preferences."));
3545 wind->acct_tree_found = acct_tree_found;
3546 if (!acct_tree_found)
3562 gnc_ui_qif_import_summary_page_prepare (GtkAssistant *assistant,
3565 QIFImportWindow * wind = user_data;
3567 const gchar *msg = wind->load_stop ?
3568 _(
"There was a problem with the import.") :
3569 _(
"QIF Import Completed.");
3571 gchar *text = g_markup_printf_escaped (
"<span size=\"large\"><b>%s</b></span>", msg);
3573 gtk_label_set_markup (GTK_LABEL(wind->summary_text), text);
3578 mark_page_complete (assistant, TRUE);
3585 void gnc_ui_qif_import_prepare_cb (GtkAssistant *assistant, GtkWidget *page,
3588 gint currentpage = gtk_assistant_get_current_page (assistant);
3589 GtkWidget *mypage = gtk_assistant_get_nth_page (assistant, currentpage);
3590 const char *pagename = gtk_buildable_get_name (GTK_BUILDABLE(mypage));
3592 ENTER(
"Page %s", pagename);
3594 if (!g_strcmp0 (pagename,
"start_page"))
3597 gnc_ui_qif_import_intro_prepare (assistant, user_data);
3599 else if (!g_strcmp0 (pagename,
"load_file_page"))
3602 gnc_ui_qif_import_load_file_prepare (assistant, user_data);
3604 else if (!g_strcmp0 (pagename,
"load_progress_page"))
3607 gnc_ui_qif_import_load_progress_prepare (assistant, user_data);
3609 else if (!g_strcmp0 (pagename,
"date_format_page"))
3614 else if (!g_strcmp0 (pagename,
"account_name_page"))
3617 gnc_ui_qif_import_account_prepare (assistant, user_data);
3619 else if (!g_strcmp0 (pagename,
"loaded_files_page"))
3622 gnc_ui_qif_import_loaded_files_prepare (assistant, user_data);
3624 else if (!g_strcmp0 (pagename,
"account_doc_page"))
3627 gnc_ui_qif_import_account_doc_prepare (assistant, user_data);
3629 else if (!g_strcmp0 (pagename,
"account_match_page"))
3632 gnc_ui_qif_import_account_match_prepare (assistant, user_data);
3634 else if (!g_strcmp0 (pagename,
"category_doc_page"))
3637 gnc_ui_qif_import_category_doc_prepare (assistant, user_data);
3639 else if (!g_strcmp0 (pagename,
"category_match_page"))
3642 gnc_ui_qif_import_category_match_prepare (assistant, user_data);
3644 else if (!g_strcmp0 (pagename,
"memo_doc_page"))
3647 gnc_ui_qif_import_memo_doc_prepare (assistant, user_data);
3649 else if (!g_strcmp0 (pagename,
"memo_match_page"))
3652 gnc_ui_qif_import_memo_match_prepare (assistant, user_data);
3654 else if (!g_strcmp0 (pagename,
"currency_book_option_page"))
3657 gnc_ui_qif_import_currency_prepare (assistant, user_data);
3659 else if (!g_strcmp0 (pagename,
"commodity_page"))
3662 gnc_ui_qif_import_commodity_prepare (assistant, user_data);
3664 else if (!g_strcmp0 (pagename,
"convert_progress_page"))
3667 gnc_ui_qif_import_convert_progress_prepare (assistant, user_data);
3669 else if (!g_strcmp0 (pagename,
"duplicates_doc_page"))
3672 gnc_ui_qif_import_duplicates_doc_prepare (assistant, user_data);
3674 else if (!g_strcmp0 (pagename,
"duplicates_match_page"))
3677 gnc_ui_qif_import_duplicates_match_prepare (assistant, user_data);
3679 else if (!g_strcmp0 (pagename,
"end_page"))
3682 gnc_ui_qif_import_end_page_prepare (assistant, user_data);
3684 else if (!g_strcmp0 (pagename,
"summary_page"))
3687 gnc_ui_qif_import_summary_page_prepare (assistant, user_data);
3699 get_assistant_widgets (QIFImportWindow *wind, GtkBuilder *builder)
3701 g_return_if_fail (wind);
3702 g_return_if_fail (builder);
3704 wind->window = GTK_WIDGET(gtk_builder_get_object (builder,
"qif_import_assistant"));
3705 wind->filename_entry = GTK_WIDGET(gtk_builder_get_object (builder,
"qif_filename_entry"));
3706 wind->load_pause = GTK_WIDGET(gtk_builder_get_object (builder,
"load_progress_pause"));
3707 wind->load_start = GTK_WIDGET(gtk_builder_get_object (builder,
"load_progress_start"));
3708 wind->load_log = GTK_WIDGET(gtk_builder_get_object (builder,
"load_progress_log"));
3710 GTK_LABEL(gtk_builder_get_object (builder,
"load_progress_primary")),
3711 GTK_LABEL(gtk_builder_get_object (builder,
"load_progress_secondary")),
3712 GTK_PROGRESS_BAR(gtk_builder_get_object (builder,
"load_progress_bar")),
3713 GTK_LABEL(gtk_builder_get_object (builder,
"load_progress_sub")),
3714 GTK_TEXT_VIEW(wind->load_log));
3715 wind->acct_entry = GTK_WIDGET(gtk_builder_get_object (builder,
"qif_account_entry"));
3716 wind->date_format_combo = GTK_WIDGET(gtk_builder_get_object (builder,
"date_format_combobox"));
3717 wind->selected_file_view = GTK_WIDGET(gtk_builder_get_object (builder,
"selected_file_view"));
3718 wind->unload_file_btn = GTK_WIDGET(gtk_builder_get_object (builder,
"unload_file_button"));
3719 wind->currency_picker = GTK_WIDGET(gtk_builder_get_object (builder,
"currency_comboboxentry"));
3720 wind->book_option_label = GTK_WIDGET(gtk_builder_get_object (builder,
"book_option_label"));
3721 wind->book_option_message = GTK_WIDGET(gtk_builder_get_object (builder,
"book_option_message_label"));
3722 wind->commodity_notebook = GTK_WIDGET(gtk_builder_get_object (builder,
"commodity_notebook"));
3723 wind->acct_view = GTK_WIDGET(gtk_builder_get_object (builder,
"account_page_view"));
3724 wind->acct_view_count = GTK_WIDGET(gtk_builder_get_object (builder,
"account_page_count"));
3725 wind->acct_view_btn = GTK_WIDGET(gtk_builder_get_object (builder,
"account_page_change"));
3726 wind->cat_view = GTK_WIDGET(gtk_builder_get_object (builder,
"category_page_view"));
3727 wind->cat_view_count = GTK_WIDGET(gtk_builder_get_object (builder,
"category_page_count"));
3728 wind->cat_view_btn = GTK_WIDGET(gtk_builder_get_object (builder,
"category_page_change"));
3729 wind->memo_view = GTK_WIDGET(gtk_builder_get_object (builder,
"memo_page_view"));
3730 wind->memo_view_count = GTK_WIDGET(gtk_builder_get_object (builder,
"memo_page_count"));
3731 wind->memo_view_btn = GTK_WIDGET(gtk_builder_get_object (builder,
"memo_page_change"));
3732 wind->convert_pause = GTK_WIDGET(gtk_builder_get_object (builder,
"convert_progress_pause"));
3733 wind->convert_start = GTK_WIDGET(gtk_builder_get_object (builder,
"convert_progress_start"));
3734 wind->convert_log = GTK_WIDGET(gtk_builder_get_object (builder,
"convert_progress_log"));
3736 GTK_LABEL(gtk_builder_get_object (builder,
"convert_progress_primary")),
3737 GTK_LABEL(gtk_builder_get_object (builder,
"convert_progress_secondary")),
3738 GTK_PROGRESS_BAR(gtk_builder_get_object (builder,
"convert_progress_bar")),
3739 GTK_LABEL(gtk_builder_get_object (builder,
"convert_progress_sub")),
3740 GTK_TEXT_VIEW(wind->convert_log));
3741 wind->summary_text = GTK_WIDGET(gtk_builder_get_object (builder,
"summary_page"));
3744 gtk_widget_set_name (GTK_WIDGET(wind->window),
"gnc-id-assistant-qif-import");
3745 gnc_widget_style_context_add_class (GTK_WIDGET(wind->window),
"gnc-class-imports");
3747 wind->new_transaction_view =
3748 GTK_WIDGET(gtk_builder_get_object (builder,
"new_transaction_view"));
3749 wind->old_transaction_view =
3750 GTK_WIDGET(gtk_builder_get_object (builder,
"old_transaction_view"));
3760 build_views (QIFImportWindow *wind)
3763 GtkListStore *store;
3764 GtkCellRenderer *renderer;
3765 GtkTreeViewColumn *column;
3766 GtkTreeSelection *selection;
3768 g_return_if_fail (wind);
3771 view = GTK_TREE_VIEW(wind->selected_file_view);
3772 store = gtk_list_store_new (NUM_FILENAME_COLS, G_TYPE_INT, G_TYPE_STRING);
3773 gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
3774 g_object_unref (store);
3776 renderer = gtk_cell_renderer_text_new ();
3777 column = gtk_tree_view_column_new_with_attributes (
"unused",
3782 gtk_tree_view_append_column (view, column);
3784 selection = gtk_tree_view_get_selection (view);
3785 g_signal_connect (selection,
"changed",
3786 G_CALLBACK(gnc_ui_qif_import_select_loaded_file_cb),
3790 create_account_picker_view (wind->acct_view, _(
"QIF account name"),
3791 G_CALLBACK(gnc_ui_qif_import_account_activate_cb),
3792 G_CALLBACK(gnc_ui_qif_import_account_select_cb),
3796 create_account_picker_view (wind->cat_view, _(
"QIF category name"),
3797 G_CALLBACK(gnc_ui_qif_import_category_activate_cb),
3798 G_CALLBACK(gnc_ui_qif_import_category_select_cb),
3802 create_account_picker_view (wind->memo_view, _(
"QIF payee/memo"),
3803 G_CALLBACK(gnc_ui_qif_import_memo_activate_cb),
3804 G_CALLBACK(gnc_ui_qif_import_memo_select_cb),
3808 view = GTK_TREE_VIEW(wind->new_transaction_view);
3809 store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT64,
3810 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_BOOLEAN);
3811 gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
3814 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
3815 QIF_TRANS_COL_DATE_INT64,
3816 GTK_SORT_ASCENDING);
3817 g_object_unref (store);
3820 gtk_tree_view_set_reorderable (view, FALSE);
3822 renderer = gtk_cell_renderer_text_new ();
3823 column = gtk_tree_view_column_new_with_attributes (_(
"Date"),
3828 g_object_set (G_OBJECT(column),
"reorderable", TRUE,
"resizable", TRUE, NULL);
3829 gtk_tree_view_append_column (view, column);
3830 gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DATE_INT64);
3832 renderer = gtk_cell_renderer_text_new ();
3833 column = gtk_tree_view_column_new_with_attributes (_(
"Description"),
3836 QIF_TRANS_COL_DESCRIPTION,
3838 g_object_set (G_OBJECT(column),
"reorderable", TRUE,
"resizable", TRUE, NULL);
3839 gtk_tree_view_append_column (view, column);
3840 gtk_tree_view_column_set_expand(column, TRUE);
3841 gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DESCRIPTION);
3843 renderer = gtk_cell_renderer_text_new ();
3844 column = gtk_tree_view_column_new_with_attributes (_(
"Amount"),
3847 QIF_TRANS_COL_AMOUNT,
3849 g_object_set (G_OBJECT(column),
"reorderable", TRUE,
"resizable", TRUE, NULL);
3850 gtk_tree_view_append_column (view, column);
3851 gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_AMOUNT_DOUBLE);
3853 selection = gtk_tree_view_get_selection (view);
3854 g_signal_connect (selection,
"changed",
3855 G_CALLBACK(gnc_ui_qif_import_duplicate_new_select_cb),
3859 view = GTK_TREE_VIEW(wind->old_transaction_view);
3860 store = gtk_list_store_new (NUM_QIF_TRANS_COLS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT64,
3861 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_BOOLEAN);
3862 gtk_tree_view_set_model (view, GTK_TREE_MODEL(store));
3865 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
3866 QIF_TRANS_COL_DATE_INT64,
3867 GTK_SORT_ASCENDING);
3868 g_object_unref (store);
3871 gtk_tree_view_set_reorderable (view, FALSE);
3873 renderer = gtk_cell_renderer_text_new ();
3874 column = gtk_tree_view_column_new_with_attributes (_(
"Date"),
3879 g_object_set (G_OBJECT(column),
"reorderable", TRUE,
"resizable", TRUE, NULL);
3880 gtk_tree_view_append_column (view, column);
3881 gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DATE_INT64);
3883 renderer = gtk_cell_renderer_text_new ();
3884 column = gtk_tree_view_column_new_with_attributes (_(
"Description"),
3887 QIF_TRANS_COL_DESCRIPTION,
3889 g_object_set (G_OBJECT(column),
"reorderable", TRUE,
"resizable", TRUE, NULL);
3890 gtk_tree_view_append_column (view, column);
3891 gtk_tree_view_column_set_expand (column, TRUE);
3892 gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_DESCRIPTION);
3894 renderer = gtk_cell_renderer_text_new ();
3895 column = gtk_tree_view_column_new_with_attributes (_(
"Amount"),
3898 QIF_TRANS_COL_AMOUNT,
3900 g_object_set (G_OBJECT(column),
"reorderable", TRUE,
"resizable", TRUE, NULL);
3901 gtk_tree_view_append_column (view, column);
3902 gtk_tree_view_column_set_sort_column_id (column, QIF_TRANS_COL_AMOUNT_DOUBLE);
3904 renderer = gtk_cell_renderer_toggle_new ();
3905 column = gtk_tree_view_column_new_with_attributes (_(
"Match?"),
3908 QIF_TRANS_COL_CHECKED,
3910 gtk_tree_view_append_column (view, column);
3912 selection = gtk_tree_view_get_selection (view);
3913 g_signal_connect (selection,
"changed",
3914 G_CALLBACK(gnc_ui_qif_import_duplicate_old_select_cb),
3925 gnc_ui_qif_import_assistant_make (QIFImportWindow *qif_win)
3927 GtkBuilder *builder;
3930 builder = gtk_builder_new ();
3931 gnc_builder_add_from_file (builder,
"assistant-qif-import.glade",
"date_format_liststore");
3932 gnc_builder_add_from_file (builder,
"assistant-qif-import.glade",
"qif_import_assistant");
3934 qif_win->new_namespaces = NULL;
3935 qif_win->selected_transaction = 0;
3936 qif_win->busy = FALSE;
3939 qif_win->new_book = gnc_is_new_book ();
3942 get_preferences (qif_win);
3947 initialize_scheme (qif_win);
3950 get_assistant_widgets (qif_win, builder);
3951 GtkAssistant *assistant = GTK_ASSISTANT(qif_win->window);
3957 build_views (qif_win);
3958 PINFO (
"Total Number of Assistant Pages is %d", gtk_assistant_get_n_pages (assistant));
3961 gtk_assistant_set_forward_page_func(assistant,
3962 gnc_ui_qif_import_assistant_page_forward, qif_win, NULL);
3968 gtk_widget_show (qif_win->currency_picker);
3969 box = GTK_WIDGET(gtk_builder_get_object (builder,
"currency_picker_hbox"));
3970 gtk_box_pack_start (GTK_BOX(box), qif_win->currency_picker, TRUE, TRUE, 0);
3972 gnc_restore_window_size (GNC_PREFS_GROUP,
3975 g_signal_connect (qif_win->window,
"destroy",
3976 G_CALLBACK(gnc_ui_qif_import_assistant_destroy), qif_win);
3978 gtk_builder_connect_signals (builder, qif_win);
3980 g_object_unref (G_OBJECT(builder));
3982 gtk_widget_show_all (qif_win->window);
3983 gtk_window_present (GTK_WINDOW(qif_win->window));
3985 return qif_win->window;
3993 gnc_ui_qif_import_assistant_close_handler (gpointer user_data)
3995 QIFImportWindow *qif_win = user_data;
3997 gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(qif_win->window));
3998 gtk_widget_destroy (qif_win->window);
4006 gnc_file_qif_import (
void)
4008 QIFImportWindow *qif_win;
4010 SCM has_regex = scm_c_eval_string (
"(defined? 'make-regexp)");
4012 if (scm_is_false(has_regex) == 1)
4014 gnc_warning_dialog(NULL, _(
"QIF import requires guile with regex support."));
4018 qif_win = g_new0 (QIFImportWindow, 1);
4021 gnc_ui_qif_import_assistant_make (qif_win);
4023 component_id = gnc_register_gui_component (ASSISTANT_QIF_IMPORT_CM_CLASS,
4024 NULL, gnc_ui_qif_import_assistant_close_handler,
4027 gnc_gui_component_watch_entity_type (component_id,
4029 QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
4031 gtk_widget_show_all (qif_win->window);
4033 gnc_window_adjust_for_screen (GTK_WINDOW(qif_win->window));
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table *table, gnc_commodity *comm)
Add a new commodity to the commodity table.
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
Split * xaccTransGetSplit(const Transaction *trans, int i)
Return a pointer to the indexed split in this transaction's split list.
The instance data structure for a content plugin.
void gnc_currency_edit_set_currency(GNCCurrencyEdit *gce, const gnc_commodity *currency)
Set the widget to display a certain currency name.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
GncPluginPage * gnc_plugin_page_account_tree_new(void)
Create a new "account tree" plugin page.
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
void gnc_progress_dialog_set_secondary(GNCProgressDialog *progress, const gchar *str)
Set the secondary text of the progress dialog.
void gnc_progress_dialog_append_log(GNCProgressDialog *progress, const gchar *str)
Append str to the progress log.
utility functions for the GnuCash UI
#define PINFO(format, args...)
Print an informational note.
gchar * gnc_ui_namespace_picker_ns(GtkWidget *cbwe)
Given a combo box, return the currently selected namespaces.
void gnc_progress_dialog_destroy(GNCProgressDialog *progress)
Destroy the dialog.
void gnc_progress_dialog_set_value(GNCProgressDialog *progress, gdouble value)
Set the fraction of the progress bar to fill, where 0 is empty and 1 is full.
API for displaying progress of long-running operations.
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
void gnc_progress_dialog_reset_value(GNCProgressDialog *progress)
Pop up to the top level and clear the progress bar.
const char * gnc_commodity_get_namespace(const gnc_commodity *cm)
Retrieve the namespace for the specified commodity.
void gnc_main_window_foreach_page(GncMainWindowPageFunc fn, gpointer user_data)
Iterator function to walk all pages in all windows, calling the specified function for each page...
#define PERR(format, args...)
Log a serious error.
#define ENTER(format, args...)
Print a function entry debugging message.
GtkWindow * gnc_ui_get_gtk_window(GtkWidget *widget)
Get a pointer to the widget's immediate top level GtkWindow.
gnc_commodity_namespace * gnc_commodity_table_add_namespace(gnc_commodity_table *table, const char *name_space, QofBook *book)
This function adds a new string to the list of commodity namespaces.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
Functions for adding content to a window.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
Dialog box should allow selection of anything.
GNCProgressDialog * gnc_progress_dialog_custom(GtkLabel *primary, GtkLabel *secondary, GtkProgressBar *bar, GtkLabel *suboperation, GtkTextView *log)
Creates a dialog for displaying the progress of an activity using existing widgets.
int xaccTransCountSplits(const Transaction *trans)
Returns the number of splits in this transaction.
Currency selection widget.
double gnc_numeric_to_double(gnc_numeric in)
Convert numeric to floating-point value.
Account handling public routines.
time64 xaccTransRetDatePosted(const Transaction *trans)
Retrieve the posted date of the transaction.
void gnc_progress_dialog_set_sub(GNCProgressDialog *progress, const gchar *str)
Set the suboperation text of the progress dialog.
int gnc_commodity_table_has_namespace(const gnc_commodity_table *table, const char *name_space)
Test to see if the indicated namespace exits in the commodity table.
void gnc_commodity_table_delete_namespace(gnc_commodity_table *table, const char *name_space)
This function deletes a string from the list of commodity namespaces.
gboolean gnc_commodity_namespace_is_iso(const char *name_space)
Checks to see if the specified commodity namespace is the namespace for ISO 4217 currencies.
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
void gnc_progress_dialog_reset_log(GNCProgressDialog *progress)
Show the progress log and delete any existing text.
void gnc_progress_dialog_set_primary(GNCProgressDialog *progress, const gchar *str)
Set the primary text of the progress dialog.
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value...
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
void qof_book_mark_session_dirty(QofBook *book)
The qof_book_mark_dirty() routine marks the book as having been modified.
Generic api to store and retrieve preferences.
Functions providing a chart of account page.
void gnc_commodity_set_fullname(gnc_commodity *cm, const char *fullname)
Set the full name for the specified commodity.
GtkWidget * gnc_currency_edit_new(void)
Create a new GNCCurrencyEdit widget which can be used to provide an easy way to enter ISO currency co...
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
void gnc_commodity_set_mnemonic(gnc_commodity *cm, const char *mnemonic)
Set the mnemonic for the specified commodity.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
#define LEAVE(format, args...)
Print a function exit debugging message.
void gnc_commodity_set_namespace(gnc_commodity *cm, const char *name_space)
Set the namespace for the specified commodity.
This file contains the functions to present a GUI to select a file or a database connection.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
guint gnc_progress_dialog_pop(GNCProgressDialog *progress)
Moves up one level in the stack of virtual bars.
API for Transactions and Splits (journal entries)
void gnc_ui_update_namespace_picker(GtkWidget *cbwe, const gchar *sel, dialog_commodity_mode mode)
Given a combo box, fill in the known commodity namespaces and then select one.
"select" and "new" commodity windows
size_t qof_print_date_buff(char *buff, size_t buflen, time64 secs)
Convenience: calls through to qof_print_date_dmy_buff().
void gnc_commodity_destroy(gnc_commodity *cm)
Destroy a commodity.
guint gnc_progress_dialog_push(GNCProgressDialog *progress, gdouble weight)
Create a new "virtual" progress bar that, as it becomes full, will fill the current bar by the fracti...