26 #include <glib/gi18n.h> 28 #include "dialog-imap-editor.h" 30 #include "dialog-utils.h" 31 #include "gnc-component-manager.h" 32 #include "gnc-session.h" 39 #define DIALOG_IMAP_CM_CLASS "dialog-imap-edit" 40 #define GNC_PREFS_GROUP "dialogs.imap-editor" 42 #define IMAP_FRAME_BAYES "import-map-bayes" 43 #define IMAP_FRAME "import-map" 45 #define IMAP_FRAME_DESC "desc" 46 #define IMAP_FRAME_MEMO "memo" 47 #define IMAP_FRAME_CSV "csv-account-map" 50 enum GncImapColumn {SOURCE_FULL_ACC, SOURCE_ACCOUNT, BASED_ON, MATCH_STRING,
51 MAP_FULL_ACC, MAP_ACCOUNT, HEAD, CATEGORY, COUNT, FILTER};
62 guint inv_dialog_shown_bayes : 1;
63 guint inv_dialog_shown_nbayes : 1;
64 guint inv_dialog_shown_online : 1;
75 GtkWidget *radio_bayes;
76 GtkWidget *radio_nbayes;
77 GtkWidget *radio_online;
79 GtkWidget *filter_button;
80 GtkWidget *filter_text_entry;
81 GtkWidget *filter_label;
82 gboolean apply_selection_filter;
84 GtkWidget *total_entries_label;
86 gint tot_invalid_maps;
88 GtkWidget *expand_button;
89 GtkWidget *collapse_button;
90 GtkWidget *remove_button;
96 static QofLogModule log_module = GNC_MOD_GUI;
98 void gnc_imap_dialog_window_destroy_cb (GtkWidget *
object, gpointer user_data);
99 void gnc_imap_dialog_close_cb (GtkDialog *dialog, gpointer user_data);
100 void gnc_imap_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data);
102 static void get_account_info (
ImapDialog *imap_dialog);
105 gnc_imap_dialog_window_destroy_cb (GtkWidget *
object, gpointer user_data)
110 gnc_unregister_gui_component_by_data (DIALOG_IMAP_CM_CLASS, imap_dialog);
112 if (imap_dialog->dialog)
114 gtk_widget_destroy (imap_dialog->dialog);
115 imap_dialog->dialog = NULL;
117 g_free (imap_dialog);
122 gnc_imap_dialog_close_cb (GtkDialog *dialog, gpointer user_data)
127 gnc_close_gui_component_by_data (DIALOG_IMAP_CM_CLASS, imap_dialog);
132 delete_info_bayes (
Account *source_account, gchar *head, gint depth)
141 delete_info_nbayes (
Account *source_account, gchar *head,
142 gchar *category, gchar *match_string, gint depth)
156 delete_selected_row (
ImapDialog *imap_dialog, GtkTreeIter *iter)
158 Account *source_account = NULL;
159 gchar *full_source_account;
167 if (gtk_tree_model_iter_parent (imap_dialog->model, &parent, iter))
168 num = gtk_tree_model_iter_n_children (imap_dialog->model, &parent);
170 gtk_tree_model_get (imap_dialog->model, iter, SOURCE_ACCOUNT, &source_account,
171 SOURCE_FULL_ACC, &full_source_account,
174 MATCH_STRING, &match_string, -1);
176 PINFO(
"Account is '%s', Head is '%s', Category is '%s', Match String is '%s'",
177 full_source_account, head, category, match_string);
179 if (source_account != NULL)
181 GtkTreePath *tree_path;
185 tree_path = gtk_tree_model_get_path (imap_dialog->model, iter);
186 depth = gtk_tree_path_get_depth (tree_path);
187 gtk_tree_path_free (tree_path);
189 if (imap_dialog->type == ONLINE)
192 if (imap_dialog->type == BAYES)
193 delete_info_bayes (source_account, head, depth);
195 if (imap_dialog->type == NBAYES)
196 delete_info_nbayes (source_account, head, category, match_string, depth);
198 gtk_tree_store_remove (GTK_TREE_STORE(imap_dialog->model), iter);
200 if (num == 1 && (imap_dialog->type != ONLINE))
201 gtk_tree_store_remove (GTK_TREE_STORE(imap_dialog->model), &parent);
204 gtk_label_set_text (GTK_LABEL(imap_dialog->total_entries_label),
" ");
211 g_free (match_string);
212 if (full_source_account)
213 g_free (full_source_account);
217 find_invalid_mappings_total (GtkTreeModel *model, GtkTreePath *path,
220 Account *source_account = NULL;
225 gtk_tree_model_get (model, iter, SOURCE_ACCOUNT, &source_account,
226 MAP_ACCOUNT, &map_account,
229 depth = gtk_tree_path_get_depth (path);
231 if ((source_account != NULL) && (map_account == NULL))
233 if (((g_strcmp0 (head,
"online_id") == 0) && (depth == 1)) || (depth == 2))
234 imap_dialog->tot_invalid_maps ++;
241 gnc_imap_dialog_delete (
ImapDialog *imap_dialog)
244 GtkTreeModel *fmodel;
247 GtkTreeSelection *selection;
249 fmodel = gtk_tree_view_get_model (GTK_TREE_VIEW(imap_dialog->view));
250 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(imap_dialog->view));
252 list = gtk_tree_selection_get_selected_rows (selection, &fmodel);
259 imap_dialog->tot_invalid_maps = 0;
262 list = g_list_reverse (list);
265 gnc_suspend_gui_refresh();
268 for (row = g_list_first (list); row; row = g_list_next (row))
270 if (gtk_tree_model_get_iter (fmodel, &fiter, row->data))
272 gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER(fmodel), &iter, &fiter);
273 delete_selected_row (imap_dialog, &iter);
276 g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
280 gnc_resume_gui_refresh();
283 gtk_tree_model_foreach (imap_dialog->model,
284 (GtkTreeModelForeachFunc)find_invalid_mappings_total,
287 if (imap_dialog->tot_invalid_maps == 0)
288 gtk_widget_hide (imap_dialog->remove_button);
293 find_invalid_mappings (GtkTreeModel *model, GtkTreePath *path,
294 GtkTreeIter *iter, GList **rowref_list)
296 Account *source_account = NULL;
301 gtk_tree_model_get (model, iter, SOURCE_ACCOUNT, &source_account,
302 MAP_ACCOUNT, &map_account,
305 depth = gtk_tree_path_get_depth (path);
307 if ((source_account != NULL) && (map_account == NULL))
309 if (((g_strcmp0 (head,
"online_id") == 0) && (depth == 1)) || (depth == 2))
311 GtkTreeRowReference *rowref = gtk_tree_row_reference_new (model, path);
312 *rowref_list = g_list_prepend (*rowref_list, rowref);
320 gnc_imap_remove_invalid_maps (
ImapDialog *imap_dialog)
322 GList *rr_list = NULL;
325 gtk_tree_model_foreach (imap_dialog->model,
326 (GtkTreeModelForeachFunc)find_invalid_mappings,
330 gnc_suspend_gui_refresh();
333 for (node = rr_list; node != NULL; node = node->next)
335 GtkTreePath *path = gtk_tree_row_reference_get_path ((GtkTreeRowReference*)node->data);
341 if (gtk_tree_model_get_iter (GTK_TREE_MODEL(imap_dialog->model), &iter, path))
342 delete_selected_row (imap_dialog, &iter);
344 gtk_tree_path_free (path);
349 gnc_resume_gui_refresh();
351 g_list_foreach (rr_list, (GFunc)gtk_tree_row_reference_free, NULL);
352 g_list_free (rr_list);
356 gnc_imap_invalid_maps_dialog (
ImapDialog *imap_dialog)
358 gtk_widget_hide (imap_dialog->remove_button);
360 if (imap_dialog->tot_invalid_maps > 0)
363 gchar *message = g_strdup_printf (ngettext (
"There is %d invalid mapping,\n\nWould you like to remove it now?",
364 "There are %d invalid mappings,\n\nWould you like to remove them now?",
365 imap_dialog->tot_invalid_maps),
366 imap_dialog->tot_invalid_maps);
368 gchar *message2 = g_strdup_printf (gettext (
"To see the invalid mappings, use a filter of '%s'"), _(
"Map Account NOT found"));
370 gchar *text = g_strdup_printf (
"%s\n\n%s\n\n%s", message, message2, _(
"(Note, if there is a large number, it may take a while)"));
372 if (gnc_verify_dialog (GTK_WINDOW (imap_dialog->dialog), FALSE,
"%s", text))
374 gnc_imap_remove_invalid_maps (imap_dialog);
375 gtk_widget_hide (imap_dialog->remove_button);
379 gtk_widget_show (imap_dialog->remove_button);
381 if (imap_dialog->type == BAYES)
382 imap_dialog->inv_dialog_shown.inv_dialog_shown_bayes = TRUE;
383 if (imap_dialog->type == NBAYES)
384 imap_dialog->inv_dialog_shown.inv_dialog_shown_nbayes = TRUE;
385 if (imap_dialog->type == ONLINE)
386 imap_dialog->inv_dialog_shown.inv_dialog_shown_online = TRUE;
395 gnc_imap_dialog_response_cb (GtkDialog *dialog, gint response_id, gpointer user_data)
401 case GTK_RESPONSE_APPLY:
402 gnc_imap_dialog_delete (imap_dialog);
405 case GTK_RESPONSE_REJECT:
406 gnc_imap_invalid_maps_dialog (imap_dialog);
409 case GTK_RESPONSE_CLOSE:
411 gnc_close_gui_component_by_data (DIALOG_IMAP_CM_CLASS, imap_dialog);
417 filter_test_and_move_next (
ImapDialog *imap_dialog, GtkTreeIter *iter,
418 const gchar *filter_text)
420 GtkTreePath *tree_path;
427 gtk_tree_model_get (imap_dialog->model, iter, MATCH_STRING, &match_string, MAP_FULL_ACC, &map_full_acc, -1);
430 tree_path = gtk_tree_model_get_path (imap_dialog->model, iter);
431 depth = gtk_tree_path_get_depth (tree_path);
434 gtk_tree_store_set (GTK_TREE_STORE(imap_dialog->model), iter, FILTER, TRUE, -1);
437 if (filter_text && *filter_text !=
'\0')
439 if (match_string != NULL)
441 if ((g_strrstr (match_string, filter_text) == NULL) &&
442 (g_strrstr (map_full_acc, filter_text) == NULL ))
443 gtk_tree_store_set (GTK_TREE_STORE(imap_dialog->model), iter, FILTER, FALSE, -1);
445 gtk_tree_view_expand_to_path (GTK_TREE_VIEW(imap_dialog->view), tree_path);
450 gtk_tree_path_down (tree_path);
453 gtk_tree_path_next (tree_path);
454 if (!gtk_tree_model_get_iter (imap_dialog->model, iter, tree_path))
456 gtk_tree_path_prev (tree_path);
457 gtk_tree_path_up (tree_path);
458 gtk_tree_path_next (tree_path);
461 valid = gtk_tree_model_get_iter (imap_dialog->model, iter, tree_path);
463 gtk_tree_path_free (tree_path);
464 g_free (match_string);
465 g_free (map_full_acc);
471 filter_button_cb (GtkButton *button,
ImapDialog *imap_dialog)
475 const gchar *filter_text;
477 filter_text = gtk_entry_get_text (GTK_ENTRY(imap_dialog->filter_text_entry));
480 gtk_tree_view_collapse_all (GTK_TREE_VIEW(imap_dialog->view));
481 imap_dialog->apply_selection_filter = FALSE;
484 gtk_tree_selection_unselect_all (gtk_tree_view_get_selection
485 (GTK_TREE_VIEW(imap_dialog->view)));
488 if (filter_text && *filter_text !=
'\0')
489 imap_dialog->apply_selection_filter = TRUE;
491 valid = gtk_tree_model_get_iter_first (imap_dialog->model, &iter);
495 valid = filter_test_and_move_next (imap_dialog, &iter, filter_text);
497 gtk_widget_grab_focus (GTK_WIDGET(imap_dialog->view));
501 expand_button_cb (GtkButton *button,
ImapDialog *imap_dialog)
504 gtk_entry_set_text (GTK_ENTRY(imap_dialog->filter_text_entry),
"");
506 filter_button_cb (button, imap_dialog);
508 gtk_tree_view_expand_all (GTK_TREE_VIEW(imap_dialog->view));
512 collapse_button_cb (GtkButton *button,
ImapDialog *imap_dialog)
515 gtk_entry_set_text (GTK_ENTRY(imap_dialog->filter_text_entry),
"");
517 filter_button_cb (button, imap_dialog);
519 gtk_tree_view_collapse_all (GTK_TREE_VIEW(imap_dialog->view));
523 list_type_selected_cb (GtkToggleButton* button,
ImapDialog *imap_dialog)
527 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(imap_dialog->radio_bayes)))
529 else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(imap_dialog->radio_nbayes)))
535 gtk_widget_grab_focus (GTK_WIDGET(imap_dialog->filter_text_entry));
538 if (type != imap_dialog->type)
540 gboolean inv_dialog_shown = FALSE;
542 imap_dialog->type = type;
543 get_account_info (imap_dialog);
545 if ((imap_dialog->type == BAYES) && (imap_dialog->inv_dialog_shown.inv_dialog_shown_bayes))
546 inv_dialog_shown = TRUE;
548 if ((imap_dialog->type == NBAYES) && (imap_dialog->inv_dialog_shown.inv_dialog_shown_nbayes))
549 inv_dialog_shown = TRUE;
551 if ((imap_dialog->type == ONLINE) && (imap_dialog->inv_dialog_shown.inv_dialog_shown_online))
552 inv_dialog_shown = TRUE;
554 if (!inv_dialog_shown)
555 gnc_imap_invalid_maps_dialog (imap_dialog);
560 show_count_column (
ImapDialog *imap_dialog, gboolean show)
562 GtkTreeViewColumn *tree_column;
565 tree_column = gtk_tree_view_get_column (GTK_TREE_VIEW(imap_dialog->view), 4);
566 gtk_tree_view_column_set_visible (tree_column, show);
569 tree_column = gtk_tree_view_get_column (GTK_TREE_VIEW(imap_dialog->view), 1);
570 gtk_tree_view_column_set_visible (tree_column, !show);
572 gtk_tree_view_columns_autosize (GTK_TREE_VIEW(imap_dialog->view));
578 gchar *fullname = NULL;
579 gchar *map_fullname = NULL;
584 if (imapInfo->map_account == NULL)
587 imap_dialog->tot_invalid_maps ++;
589 map_fullname = g_strdup (_(
"Map Account NOT found"));
595 imap_dialog->tot_entries ++;
597 PINFO(
"Add to Store: Source Acc '%s', Head is '%s', Category is '%s', Match '%s', Map Acc '%s', Count is %s",
598 fullname, imapInfo->head, imapInfo->category, imapInfo->match_string, map_fullname, imapInfo->count);
600 gtk_tree_store_set (GTK_TREE_STORE(imap_dialog->model), iter,
601 SOURCE_FULL_ACC, fullname, SOURCE_ACCOUNT, imapInfo->source_account,
603 MATCH_STRING, imapInfo->match_string,
604 MAP_FULL_ACC, map_fullname, MAP_ACCOUNT, imapInfo->map_account,
605 HEAD, imapInfo->head, CATEGORY, imapInfo->category, COUNT, imapInfo->count,
609 g_free (map_fullname);
613 get_imap_info (
ImapDialog *imap_dialog,
Account *acc,
const gchar *category,
const gchar *text)
615 GtkTreeIter toplevel, child;
616 GList *imap_list, *node;
617 gchar *acc_name = NULL;
621 PINFO(
"Source Acc '%s', Based on '%s', Path Head '%s'", acc_name, text, category);
623 if (category == NULL)
628 if (category == NULL)
629 head = IMAP_FRAME_BAYES;
635 PINFO(
"List length is %d", g_list_length (imap_list));
638 gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &toplevel, NULL);
639 gtk_tree_store_set (GTK_TREE_STORE(imap_dialog->model), &toplevel,
640 SOURCE_ACCOUNT, acc, SOURCE_FULL_ACC, acc_name,
641 HEAD, head, CATEGORY, category, BASED_ON, text, FILTER, TRUE, -1);
643 for (node = imap_list; node; node = g_list_next (node))
648 gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &child, &toplevel);
649 add_to_store (imap_dialog, &child, text, imapInfo);
662 if (gtk_tree_model_get_iter_first (imap_dialog->model, &iter))
665 path = gtk_tree_path_new_first ();
666 gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(imap_dialog->view), path, NULL, TRUE, 0.0, 0.0);
667 gtk_tree_path_free (path);
672 get_account_info_bayes (
ImapDialog *imap_dialog, GList *accts)
677 for (ptr = accts; ptr; ptr = g_list_next (ptr))
681 get_imap_info (imap_dialog, acc, NULL, _(
"Bayesian"));
686 get_account_info_nbayes (
ImapDialog *imap_dialog, GList *accts)
691 for (ptr = accts; ptr; ptr = g_list_next (ptr))
696 get_imap_info (imap_dialog, acc, IMAP_FRAME_DESC, _(
"Description Field"));
699 get_imap_info (imap_dialog, acc, IMAP_FRAME_MEMO, _(
"Memo Field"));
702 get_imap_info (imap_dialog, acc, IMAP_FRAME_CSV, _(
"CSV Account Map"));
707 add_online_entry_to_store (
ImapDialog *imap_dialog, GtkTreeIter *toplevel,
711 gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), toplevel, NULL);
712 add_to_store (imap_dialog, toplevel, based_on, imapInfo);
714 imapInfo->map_account = NULL;
721 gchar *head =
"online_id";
728 imapInfo->source_account = acc;
729 imapInfo->head = head;
732 imapInfo->map_account = imapInfo->source_account;
734 imapInfo->match_string = text;
736 add_online_entry_to_store (imap_dialog, toplevel, _(
"Online Id"), imapInfo);
745 gchar *head =
"hbci";
749 if (!hbci_account_id || !hbci_bank_code)
752 gchar *text = g_strconcat (hbci_bank_code,
",", hbci_account_id, NULL);
755 imapInfo->source_account = acc;
756 imapInfo->head = head;
759 imapInfo->map_account = imapInfo->source_account;
761 imapInfo->match_string = text;
763 add_online_entry_to_store (imap_dialog, toplevel, _(
"Online HBCI"), imapInfo);
765 g_free (hbci_account_id);
766 g_free (hbci_bank_code);
774 gchar *head =
"ofx/associated-income-account";
783 imapInfo->source_account = acc;
784 imapInfo->head = head;
789 imapInfo->match_string = text;
791 add_online_entry_to_store (imap_dialog, toplevel, _(
"OFX Income Account"), imapInfo);
793 guid_free (acct_guid);
798 get_account_info_online (
ImapDialog *imap_dialog, GList *accts)
801 GtkTreeIter toplevel;
805 imapInfo.map_account = NULL;
806 imapInfo.source_account = NULL;
807 imapInfo.category =
" ";
808 imapInfo.count =
" ";
811 for (ptr = accts; ptr; ptr = g_list_next (ptr))
816 check_online_id (imap_dialog, &toplevel, acc, &imapInfo);
819 check_hbci (imap_dialog, &toplevel, acc, &imapInfo);
822 check_ofx_account (imap_dialog, &toplevel, acc, &imapInfo);
827 show_filter_option (
ImapDialog *imap_dialog, gboolean show)
831 gtk_widget_show (imap_dialog->filter_text_entry);
832 gtk_widget_show (imap_dialog->filter_button);
833 gtk_widget_show (imap_dialog->filter_label);
834 gtk_widget_show (imap_dialog->expand_button);
835 gtk_widget_show (imap_dialog->collapse_button);
839 gtk_widget_hide (imap_dialog->filter_text_entry);
840 gtk_widget_hide (imap_dialog->filter_button);
841 gtk_widget_hide (imap_dialog->filter_label);
842 gtk_widget_hide (imap_dialog->expand_button);
843 gtk_widget_hide (imap_dialog->collapse_button);
852 GtkTreeModel *fmodel;
856 root = gnc_book_get_root_account (gnc_get_current_book());
859 imap_dialog->tot_entries = 0;
860 imap_dialog->tot_invalid_maps = 0;
862 fmodel = gtk_tree_view_get_model (GTK_TREE_VIEW(imap_dialog->view));
864 imap_dialog->model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(fmodel));
867 g_object_ref (G_OBJECT(imap_dialog->model));
868 gtk_tree_view_set_model (GTK_TREE_VIEW(imap_dialog->view), NULL);
871 gtk_tree_store_clear (GTK_TREE_STORE(imap_dialog->model));
874 gtk_entry_set_text (GTK_ENTRY(imap_dialog->filter_text_entry),
"");
875 imap_dialog->apply_selection_filter = FALSE;
878 show_count_column (imap_dialog, FALSE);
881 show_filter_option (imap_dialog, TRUE);
883 if (imap_dialog->type == BAYES)
885 get_account_info_bayes (imap_dialog, accts);
888 show_count_column (imap_dialog, TRUE);
890 else if (imap_dialog->type == NBAYES)
891 get_account_info_nbayes (imap_dialog, accts);
892 else if (imap_dialog->type == ONLINE)
895 show_filter_option (imap_dialog, FALSE);
896 get_account_info_online (imap_dialog, accts);
899 fmodel = gtk_tree_model_filter_new (GTK_TREE_MODEL(imap_dialog->model), NULL);
900 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER(fmodel), FILTER);
901 g_object_unref (G_OBJECT(imap_dialog->model));
903 gtk_tree_view_set_model (GTK_TREE_VIEW(imap_dialog->view), fmodel);
904 g_object_unref (G_OBJECT(fmodel));
907 show_first_row (imap_dialog);
910 total = g_strdup_printf (
"%s %d", _(
"Total Entries"), imap_dialog->tot_entries);
911 gtk_label_set_text (GTK_LABEL(imap_dialog->total_entries_label), total);
912 gtk_widget_show (imap_dialog->total_entries_label);
915 if (imap_dialog->tot_invalid_maps > 0)
916 gtk_widget_show (imap_dialog->remove_button);
918 gtk_widget_hide (imap_dialog->remove_button);
924 view_selection_function (GtkTreeSelection *selection,
927 gboolean path_currently_selected,
933 if (!imap_dialog->apply_selection_filter)
937 if (gtk_tree_model_get_iter (model, &iter, path))
942 gtk_tree_model_get (model, &iter, MATCH_STRING, &match_string, -1);
945 if (match_string == NULL)
947 g_free (match_string);
953 gnc_imap_dialog_create (GtkWidget *parent,
ImapDialog *imap_dialog)
957 GtkTreeModel *filter;
958 GtkTreeSelection *selection;
961 builder = gtk_builder_new();
962 gnc_builder_add_from_file (builder,
"dialog-imap-editor.glade",
"tree-store");
963 gnc_builder_add_from_file (builder,
"dialog-imap-editor.glade",
"treemodelfilter");
964 gnc_builder_add_from_file (builder,
"dialog-imap-editor.glade",
"import_map_dialog");
966 dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"import_map_dialog"));
967 imap_dialog->dialog = dialog;
970 gtk_widget_set_name (GTK_WIDGET(dialog),
"gnc-id-import-map");
972 imap_dialog->session = gnc_get_current_session();
973 imap_dialog->type = BAYES;
977 gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(parent));
980 imap_dialog->radio_bayes = GTK_WIDGET(gtk_builder_get_object (builder,
"radio-bayes"));
981 imap_dialog->radio_nbayes = GTK_WIDGET(gtk_builder_get_object (builder,
"radio-nbayes"));
982 imap_dialog->radio_online = GTK_WIDGET(gtk_builder_get_object (builder,
"radio-online"));
983 g_signal_connect (imap_dialog->radio_bayes,
"toggled",
984 G_CALLBACK(list_type_selected_cb), (gpointer)imap_dialog);
985 g_signal_connect (imap_dialog->radio_nbayes,
"toggled",
986 G_CALLBACK(list_type_selected_cb), (gpointer)imap_dialog);
988 imap_dialog->total_entries_label = GTK_WIDGET(gtk_builder_get_object (builder,
"total_entries_label"));
989 imap_dialog->filter_text_entry = GTK_WIDGET(gtk_builder_get_object (builder,
"filter-text-entry"));
990 imap_dialog->filter_label = GTK_WIDGET(gtk_builder_get_object (builder,
"filter-label"));
991 imap_dialog->filter_button = GTK_WIDGET(gtk_builder_get_object (builder,
"filter-button"));
992 g_signal_connect (imap_dialog->filter_button,
"clicked",
993 G_CALLBACK(filter_button_cb), (gpointer)imap_dialog);
995 imap_dialog->expand_button = GTK_WIDGET(gtk_builder_get_object (builder,
"expand-button"));
996 g_signal_connect (imap_dialog->expand_button,
"clicked",
997 G_CALLBACK(expand_button_cb), (gpointer)imap_dialog);
999 imap_dialog->collapse_button = GTK_WIDGET(gtk_builder_get_object (builder,
"collapse-button"));
1000 g_signal_connect (imap_dialog->collapse_button,
"clicked",
1001 G_CALLBACK(collapse_button_cb), (gpointer)imap_dialog);
1003 imap_dialog->view = GTK_WIDGET(gtk_builder_get_object (builder,
"treeview"));
1005 imap_dialog->remove_button = GTK_WIDGET(gtk_builder_get_object (builder,
"remove_button"));
1008 filter = gtk_tree_view_get_model (GTK_TREE_VIEW(imap_dialog->view));
1009 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER(filter), FILTER);
1012 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(imap_dialog->view), gnc_tree_view_get_grid_lines_pref ());
1015 gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
1017 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(imap_dialog->view));
1018 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
1021 gtk_tree_selection_set_select_function (selection,
1022 view_selection_function,
1026 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, imap_dialog);
1028 g_object_unref (G_OBJECT(builder));
1030 gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(imap_dialog->dialog), GTK_WINDOW(parent));
1031 get_account_info (imap_dialog);
1037 close_handler (gpointer user_data)
1042 gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(imap_dialog->dialog));
1043 gtk_widget_destroy (GTK_WIDGET(imap_dialog->dialog));
1048 refresh_handler (GHashTable *changes, gpointer user_data)
1055 show_handler (
const char *klass, gint component_id,
1056 gpointer user_data, gpointer iter_data)
1063 LEAVE(
"No data structure");
1066 gtk_window_present (GTK_WINDOW(imap_dialog->dialog));
1079 gnc_imap_dialog (GtkWidget *parent)
1085 if (gnc_forall_gui_components (DIALOG_IMAP_CM_CLASS, show_handler, NULL))
1087 LEAVE(
"Existing dialog raised");
1092 gnc_imap_dialog_create (parent, imap_dialog);
1094 component_id = gnc_register_gui_component (DIALOG_IMAP_CM_CLASS,
1095 refresh_handler, close_handler,
1098 gnc_gui_component_set_session (component_id, imap_dialog->session);
1100 gtk_widget_show (imap_dialog->dialog);
1101 gtk_widget_hide (imap_dialog->remove_button);
1102 gnc_imap_invalid_maps_dialog (imap_dialog);
gchar * gnc_account_get_map_entry(Account *acc, const char *head, const char *category)
Returns the text string pointed to by head and category for the Account, free the returned text...
void gnc_account_imap_info_destroy(GncImapInfo *imapInfo)
Clean destructor for the imap_info structure of Bayesian mappings.
GList * gnc_account_get_descendants_sorted(const Account *account)
This function returns a GList containing all the descendants of the specified account, sorted at each level.
void gnc_account_delete_map_entry(Account *acc, char *head, char *category, char *match_string, gboolean empty)
Delete the entry for Account pointed to by head,category and match_string, if empty is TRUE then use ...
utility functions for the GnuCash UI
#define PINFO(format, args...)
Print an informational note.
#define ENTER(format, args...)
Print a function entry debugging message.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
Account handling public routines.
void gnc_account_delete_all_bayes_maps(Account *acc)
Delete all bayes entries for Account.
GList * gnc_account_imap_get_info_bayes(Account *acc)
Returns a GList of structure imap_info of all Bayesian mappings for required Account.
GList * gnc_account_imap_get_info(Account *acc, const char *category)
Returns a GList of structure imap_info of all Non Bayesian mappings for required Account.
gchar * guid_to_string(const GncGUID *guid)
The guid_to_string() routine returns a null-terminated string encoding of the id. ...
#define LEAVE(format, args...)
Print a function exit debugging message.
gint gnc_list_length_cmp(const GList *list, size_t len)
Scans the GList elements the minimum number of iterations required to test it against a specified siz...
The type used to store guids in C.
GncGUID * gnc_account_get_map_guid_entry(Account *acc, const char *head, const char *category)
Returns the guid pointed to by head and category for the Account, free the returned guid...
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...