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 get_account_info_online (
ImapDialog *imap_dialog, GList *accts)
710 GtkTreeIter toplevel;
715 for (ptr = accts; ptr; ptr = g_list_next (ptr))
717 gchar *hbci_account_id = NULL;
718 gchar *hbci_bank_code = NULL;
728 imapInfo.source_account = acc;
729 imapInfo.head =
"online_id";
730 imapInfo.category =
" ";
732 if (g_strcmp0 (text,
"") == 0)
733 imapInfo.map_account = NULL;
735 imapInfo.map_account = imapInfo.source_account;
737 imapInfo.match_string = text;
738 imapInfo.count =
" ";
741 gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &toplevel, NULL);
742 add_to_store (imap_dialog, &toplevel, _(
"Online Id"), &imapInfo);
749 text = g_strconcat (hbci_bank_code,
",", hbci_account_id, NULL);
751 if ((hbci_account_id != NULL) || (hbci_bank_code != NULL))
754 imapInfo.source_account = acc;
755 imapInfo.head =
"hbci";
756 imapInfo.category =
" ";
758 if (g_strcmp0 (text,
"") == 0)
759 imapInfo.map_account = NULL;
761 imapInfo.map_account = imapInfo.source_account;
763 imapInfo.match_string = text;
764 imapInfo.count =
" ";
767 gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &toplevel, NULL);
768 add_to_store (imap_dialog, &toplevel, _(
"Online HBCI"), &imapInfo);
770 g_free (hbci_account_id);
771 g_free (hbci_bank_code);
777 show_filter_option (
ImapDialog *imap_dialog, gboolean show)
781 gtk_widget_show (imap_dialog->filter_text_entry);
782 gtk_widget_show (imap_dialog->filter_button);
783 gtk_widget_show (imap_dialog->filter_label);
784 gtk_widget_show (imap_dialog->expand_button);
785 gtk_widget_show (imap_dialog->collapse_button);
789 gtk_widget_hide (imap_dialog->filter_text_entry);
790 gtk_widget_hide (imap_dialog->filter_button);
791 gtk_widget_hide (imap_dialog->filter_label);
792 gtk_widget_hide (imap_dialog->expand_button);
793 gtk_widget_hide (imap_dialog->collapse_button);
802 GtkTreeModel *fmodel;
806 root = gnc_book_get_root_account (gnc_get_current_book());
809 imap_dialog->tot_entries = 0;
810 imap_dialog->tot_invalid_maps = 0;
812 fmodel = gtk_tree_view_get_model (GTK_TREE_VIEW(imap_dialog->view));
814 imap_dialog->model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER(fmodel));
817 g_object_ref (G_OBJECT(imap_dialog->model));
818 gtk_tree_view_set_model (GTK_TREE_VIEW(imap_dialog->view), NULL);
821 gtk_tree_store_clear (GTK_TREE_STORE(imap_dialog->model));
824 gtk_entry_set_text (GTK_ENTRY(imap_dialog->filter_text_entry),
"");
825 imap_dialog->apply_selection_filter = FALSE;
828 show_count_column (imap_dialog, FALSE);
831 show_filter_option (imap_dialog, TRUE);
833 if (imap_dialog->type == BAYES)
835 get_account_info_bayes (imap_dialog, accts);
838 show_count_column (imap_dialog, TRUE);
840 else if (imap_dialog->type == NBAYES)
841 get_account_info_nbayes (imap_dialog, accts);
842 else if (imap_dialog->type == ONLINE)
845 show_filter_option (imap_dialog, FALSE);
846 get_account_info_online (imap_dialog, accts);
849 fmodel = gtk_tree_model_filter_new (GTK_TREE_MODEL(imap_dialog->model), NULL);
850 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER(fmodel), FILTER);
851 g_object_unref (G_OBJECT(imap_dialog->model));
853 gtk_tree_view_set_model (GTK_TREE_VIEW(imap_dialog->view), fmodel);
854 g_object_unref (G_OBJECT(fmodel));
857 show_first_row (imap_dialog);
860 total = g_strdup_printf (
"%s %d", _(
"Total Entries"), imap_dialog->tot_entries);
861 gtk_label_set_text (GTK_LABEL(imap_dialog->total_entries_label), total);
862 gtk_widget_show (imap_dialog->total_entries_label);
865 if (imap_dialog->tot_invalid_maps > 0)
866 gtk_widget_show (imap_dialog->remove_button);
868 gtk_widget_hide (imap_dialog->remove_button);
874 view_selection_function (GtkTreeSelection *selection,
877 gboolean path_currently_selected,
883 if (!imap_dialog->apply_selection_filter)
887 if (gtk_tree_model_get_iter (model, &iter, path))
892 gtk_tree_model_get (model, &iter, MATCH_STRING, &match_string, -1);
895 if (match_string == NULL)
897 g_free (match_string);
903 gnc_imap_dialog_create (GtkWidget *parent,
ImapDialog *imap_dialog)
907 GtkTreeModel *filter;
908 GtkTreeSelection *selection;
911 builder = gtk_builder_new();
912 gnc_builder_add_from_file (builder,
"dialog-imap-editor.glade",
"tree-store");
913 gnc_builder_add_from_file (builder,
"dialog-imap-editor.glade",
"treemodelfilter");
914 gnc_builder_add_from_file (builder,
"dialog-imap-editor.glade",
"import_map_dialog");
916 dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"import_map_dialog"));
917 imap_dialog->dialog = dialog;
920 gtk_widget_set_name (GTK_WIDGET(dialog),
"gnc-id-import-map");
922 imap_dialog->session = gnc_get_current_session();
923 imap_dialog->type = BAYES;
927 gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(parent));
930 imap_dialog->radio_bayes = GTK_WIDGET(gtk_builder_get_object (builder,
"radio-bayes"));
931 imap_dialog->radio_nbayes = GTK_WIDGET(gtk_builder_get_object (builder,
"radio-nbayes"));
932 imap_dialog->radio_online = GTK_WIDGET(gtk_builder_get_object (builder,
"radio-online"));
933 g_signal_connect (imap_dialog->radio_bayes,
"toggled",
934 G_CALLBACK(list_type_selected_cb), (gpointer)imap_dialog);
935 g_signal_connect (imap_dialog->radio_nbayes,
"toggled",
936 G_CALLBACK(list_type_selected_cb), (gpointer)imap_dialog);
938 imap_dialog->total_entries_label = GTK_WIDGET(gtk_builder_get_object (builder,
"total_entries_label"));
939 imap_dialog->filter_text_entry = GTK_WIDGET(gtk_builder_get_object (builder,
"filter-text-entry"));
940 imap_dialog->filter_label = GTK_WIDGET(gtk_builder_get_object (builder,
"filter-label"));
941 imap_dialog->filter_button = GTK_WIDGET(gtk_builder_get_object (builder,
"filter-button"));
942 g_signal_connect (imap_dialog->filter_button,
"clicked",
943 G_CALLBACK(filter_button_cb), (gpointer)imap_dialog);
945 imap_dialog->expand_button = GTK_WIDGET(gtk_builder_get_object (builder,
"expand-button"));
946 g_signal_connect (imap_dialog->expand_button,
"clicked",
947 G_CALLBACK(expand_button_cb), (gpointer)imap_dialog);
949 imap_dialog->collapse_button = GTK_WIDGET(gtk_builder_get_object (builder,
"collapse-button"));
950 g_signal_connect (imap_dialog->collapse_button,
"clicked",
951 G_CALLBACK(collapse_button_cb), (gpointer)imap_dialog);
953 imap_dialog->view = GTK_WIDGET(gtk_builder_get_object (builder,
"treeview"));
955 imap_dialog->remove_button = GTK_WIDGET(gtk_builder_get_object (builder,
"remove_button"));
958 filter = gtk_tree_view_get_model (GTK_TREE_VIEW(imap_dialog->view));
959 gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER(filter), FILTER);
962 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(imap_dialog->view), gnc_tree_view_get_grid_lines_pref ());
965 gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
967 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(imap_dialog->view));
968 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
971 gtk_tree_selection_set_select_function (selection,
972 view_selection_function,
976 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, imap_dialog);
978 g_object_unref (G_OBJECT(builder));
980 gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(imap_dialog->dialog), GTK_WINDOW(parent));
981 get_account_info (imap_dialog);
987 close_handler (gpointer user_data)
992 gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(imap_dialog->dialog));
993 gtk_widget_destroy (GTK_WIDGET(imap_dialog->dialog));
998 refresh_handler (GHashTable *changes, gpointer user_data)
1005 show_handler (
const char *klass, gint component_id,
1006 gpointer user_data, gpointer iter_data)
1013 LEAVE(
"No data structure");
1016 gtk_window_present (GTK_WINDOW(imap_dialog->dialog));
1029 gnc_imap_dialog (GtkWidget *parent)
1035 if (gnc_forall_gui_components (DIALOG_IMAP_CM_CLASS, show_handler, NULL))
1037 LEAVE(
"Existing dialog raised");
1042 gnc_imap_dialog_create (parent, imap_dialog);
1044 component_id = gnc_register_gui_component (DIALOG_IMAP_CM_CLASS,
1045 refresh_handler, close_handler,
1048 gnc_gui_component_set_session (component_id, imap_dialog->session);
1050 gtk_widget_show (imap_dialog->dialog);
1051 gtk_widget_hide (imap_dialog->remove_button);
1052 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.
#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...