38 #include <glib/gi18n.h> 48 #include "dialog-transfer.h" 49 #include "dialog-utils.h" 50 #include "assistant-hierarchy.h" 51 #include "gnc-account-sel.h" 52 #include "gnc-component-manager.h" 56 #include "gnc-icons.h" 59 #include "gnc-session.h" 60 #include "gnc-split-reg.h" 67 #include "dialog-lot-viewer.h" 68 #include "window-reconcile.h" 69 #include "window-autoclear.h" 70 #include "window-main-summarybar.h" 72 #include "dialog-find-account.h" 76 static QofLogModule log_module = GNC_MOD_GUI;
85 typedef struct _delete_helper
88 gboolean has_ro_splits;
92 #define PLUGIN_PAGE_ACCT_TREE_CM_CLASS "plugin-page-acct-tree" 93 #define STATE_SECTION "Account Hierarchy" 95 #define DELETE_DIALOG_FILTER "filter" 96 #define DELETE_DIALOG_ACCOUNT "account" 97 #define DELETE_DIALOG_TRANS_MAS "trans_mas" 98 #define DELETE_DIALOG_SA_MAS "sa_mas" 99 #define DELETE_DIALOG_SA_TRANS_MAS "sa_trans_mas" 100 #define DELETE_DIALOG_SA_TRANS "sa_trans" 101 #define DELETE_DIALOG_SA_SPLITS "sa_has_split" 102 #define DELETE_DIALOG_OK_BUTTON "deletebutton" 113 GtkTreeView *tree_view;
118 #define GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(o) \ 119 ((GncPluginPageAccountTreePrivate*)gnc_plugin_page_account_tree_get_instance_private((GncPluginPageAccountTree*)o)) 121 static GObjectClass *parent_class = NULL;
129 static void gnc_plugin_page_account_tree_finalize (GObject *
object);
130 static void gnc_plugin_page_account_tree_selected (GObject *
object, gpointer user_data);
132 static gboolean gnc_plugin_page_account_tree_focus_widget (
GncPluginPage *plugin_page);
133 static GtkWidget *gnc_plugin_page_account_tree_create_widget (
GncPluginPage *plugin_page);
134 static void gnc_plugin_page_account_tree_destroy_widget (
GncPluginPage *plugin_page);
135 static void gnc_plugin_page_account_tree_save_page (
GncPluginPage *plugin_page, GKeyFile *file,
const gchar *group);
136 static GncPluginPage *gnc_plugin_page_account_tree_recreate_page (GtkWidget *window, GKeyFile *file,
const gchar *group);
139 static void gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data);
140 static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget,
141 GdkEventButton *event,
143 static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview,
145 GtkTreeViewColumn *col,
148 static void gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection,
150 void gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb, GtkWidget *dialog);
151 void gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b);
154 static void gnc_plugin_page_account_tree_cmd_new_account (GtkAction *action,
GncPluginPageAccountTree *plugin_page);
155 static void gnc_plugin_page_account_tree_cmd_file_new_hierarchy (GtkAction *action,
GncPluginPageAccountTree *plugin_page);
160 static void gnc_plugin_page_account_tree_cmd_find_account_popup (GtkAction *action,
GncPluginPageAccountTree *page);
163 static void gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action,
GncPluginPageAccountTree *plugin_page);
174 static void gnc_plugin_page_account_tree_cmd_cascade_account_properties (GtkAction *action,
GncPluginPageAccountTree *page);
180 static int confirm_delete_account (GtkAction *action,
189 static guint plugin_page_signals[LAST_SIGNAL] = { 0 };
192 static GtkActionEntry gnc_plugin_page_account_tree_actions [] =
195 {
"FakeToplevel", NULL,
"", NULL, NULL, NULL },
199 "FileNewAccountAction", GNC_ICON_NEW_ACCOUNT, N_(
"New _Account..."), NULL,
200 N_(
"Create a new Account"),
201 G_CALLBACK (gnc_plugin_page_account_tree_cmd_new_account)
204 "FileAddAccountHierarchyAssistantAction", GNC_ICON_NEW_ACCOUNT, N_(
"New Account _Hierarchy..."), NULL,
205 N_(
"Extend the current book by merging with new account type categories"),
206 G_CALLBACK (gnc_plugin_page_account_tree_cmd_file_new_hierarchy)
208 #ifdef REGISTER2_ENABLED 210 "FileOpenAccount2Action", GNC_ICON_OPEN_ACCOUNT, N_(
"Open _Account"), NULL,
211 N_(
"Open the selected account"),
212 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open2_account)
215 "FileOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_(
"Open _Old Style Register Account"), NULL,
216 N_(
"Open the old style register selected account"),
217 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_account)
221 "FileOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_(
"Open _Account"), NULL,
222 N_(
"Open the selected account"),
223 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_account)
227 #ifdef REGISTER2_ENABLED 229 "FileOpenSubaccounts2Action", GNC_ICON_OPEN_ACCOUNT, N_(
"Open _SubAccounts"), NULL,
230 N_(
"Open the selected account and all its subaccounts"),
231 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open2_subaccounts)
234 "FileOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_(
"Open Old St_yle Subaccounts"), NULL,
235 N_(
"Open the old style register selected account and all its subaccounts"),
236 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_subaccounts)
240 "FileOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_(
"Open _SubAccounts"), NULL,
241 N_(
"Open the selected account and all its subaccounts"),
242 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open_subaccounts)
248 "EditEditAccountAction", GNC_ICON_EDIT_ACCOUNT, N_(
"Edit _Account"),
"<primary>e",
249 N_(
"Edit the selected account"),
250 G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_account)
253 "EditDeleteAccountAction", GNC_ICON_DELETE_ACCOUNT, N_(
"_Delete Account..."),
"Delete",
254 N_(
"Delete selected account"),
255 G_CALLBACK (gnc_plugin_page_account_tree_cmd_delete_account)
258 "EditCascadeAccountAction", NULL, N_(
"_Cascade Account Properties..."), NULL,
259 N_(
"Cascade selected properties for account"),
260 G_CALLBACK (gnc_plugin_page_account_tree_cmd_cascade_account_properties)
263 "EditFindAccountAction",
"edit-find", N_(
"F_ind Account"),
"<primary>i",
264 N_(
"Find an account"),
265 G_CALLBACK (gnc_plugin_page_account_tree_cmd_find_account)
268 "EditFindAccountPopupAction",
"edit-find", N_(
"F_ind Account"),
"<primary>i",
269 N_(
"Find an account"),
270 G_CALLBACK (gnc_plugin_page_account_tree_cmd_find_account_popup)
273 "EditRenumberSubaccountsAction", NULL, N_(
"_Renumber Subaccounts..."), NULL,
274 N_(
"Renumber the children of the selected account"),
275 G_CALLBACK (gnc_plugin_page_account_tree_cmd_renumber_accounts)
278 "EditTaxOptionsAction", NULL,
281 N_(
"Ta_x Report Options"), NULL,
286 N_(
"Setup relevant accounts for tax reports, e.g. US income tax"),
287 G_CALLBACK (gnc_plugin_page_account_tree_cmd_edit_tax_options)
291 "ViewFilterByAction", NULL, N_(
"_Filter By..."), NULL, NULL,
292 G_CALLBACK (gnc_plugin_page_account_tree_cmd_view_filter_by)
295 "ViewRefreshAction",
"view-refresh", N_(
"_Refresh"),
"<primary>r",
296 N_(
"Refresh this window"),
297 G_CALLBACK (gnc_plugin_page_account_tree_cmd_refresh)
302 "ActionsReconcileAction", NULL, N_(
"_Reconcile..."), NULL,
303 N_(
"Reconcile the selected account"),
304 G_CALLBACK (gnc_plugin_page_account_tree_cmd_reconcile)
307 "ActionsAutoClearAction", NULL, N_(
"_Auto-clear..."), NULL,
308 N_(
"Automatically clear individual transactions, given a cleared amount"),
309 G_CALLBACK (gnc_plugin_page_account_tree_cmd_autoclear)
312 "ActionsTransferAction", NULL, N_(
"_Transfer..."),
"<primary>t",
313 N_(
"Transfer funds from one account to another"),
314 G_CALLBACK (gnc_plugin_page_account_tree_cmd_transfer)
317 "ActionsStockSplitAction", NULL, N_(
"Stoc_k Split..."), NULL,
318 N_(
"Record a stock split or a stock merger"),
319 G_CALLBACK (gnc_plugin_page_account_tree_cmd_stock_split)
322 "ActionsLotsAction", NULL, N_(
"View _Lots..."), NULL,
323 N_(
"Bring up the lot viewer/editor window"),
324 G_CALLBACK (gnc_plugin_page_account_tree_cmd_lots)
327 "ScrubAction", NULL, N_(
"Check & Repair A_ccount"), NULL,
328 N_(
"Check for and repair unbalanced transactions and orphan splits " "in this account"),
329 G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub)
332 "ScrubSubAction", NULL, N_(
"Check & Repair Su_baccounts"), NULL,
333 N_(
"Check for and repair unbalanced transactions and orphan splits " 334 "in this account and its subaccounts"),
335 G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_sub)
338 "ScrubAllAction", NULL, N_(
"Check & Repair A_ll"), NULL,
339 N_(
"Check for and repair unbalanced transactions and orphan splits " "in all accounts"),
340 G_CALLBACK (gnc_plugin_page_account_tree_cmd_scrub_all)
343 {
"Register2TestAction", NULL, N_(
"_Register2"), NULL, NULL, NULL },
345 "Register2TestAccountAction", GNC_ICON_OPEN_ACCOUNT, N_(
"Open _Account"), NULL,
346 N_(
"Open the selected account"),
347 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open2_account)
350 "Register2TestSubAccountAction", GNC_ICON_OPEN_ACCOUNT, N_(
"Open _SubAccounts"), NULL,
351 N_(
"Open the selected account and all its subaccounts"),
352 G_CALLBACK (gnc_plugin_page_account_tree_cmd_open2_subaccounts)
356 static guint gnc_plugin_page_account_tree_n_actions = G_N_ELEMENTS (gnc_plugin_page_account_tree_actions);
361 static const gchar *actions_requiring_account_rw[] =
363 "EditEditAccountAction",
364 "EditDeleteAccountAction",
365 "ActionsReconcileAction",
366 "ActionsAutoClearAction",
372 static const gchar *actions_requiring_subaccounts_rw[] =
374 "EditRenumberSubaccountsAction",
375 "EditCascadeAccountAction",
381 static const gchar *actions_requiring_account_always[] =
383 "FileOpenAccountAction",
384 #ifdef REGISTER2_ENABLED 385 "FileOpenAccount2Action",
387 "FileOpenSubaccountsAction",
393 static const gchar* readonly_inactive_actions[] =
395 "FileNewAccountAction",
396 "FileAddAccountHierarchyAssistantAction",
397 "EditEditAccountAction",
398 "EditDeleteAccountAction",
399 "ActionsTransferAction",
400 "ActionsReconcileAction",
401 "ActionsAutoClearAction",
402 "ActionsStockSplitAction",
412 {
"FileOpenAccountAction", N_(
"Open") },
413 #ifdef REGISTER2_ENABLED 414 {
"FileOpenAccount2Action", N_(
"Open2") },
416 {
"EditEditAccountAction", N_(
"Edit") },
417 {
"FileNewAccountAction", N_(
"New") },
418 {
"EditDeleteAccountAction", N_(
"Delete") },
428 plugin_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_ACCOUNT_TREE,
431 LEAVE(
"new account tree page %p", plugin_page);
432 return GNC_PLUGIN_PAGE (plugin_page);
437 static gboolean show_abort_verify = TRUE;
442 gnc_suspend_gui_refresh ();
447 finish_scrubbing (GncWindow *window, gulong handler_id)
449 g_signal_handler_disconnect (G_OBJECT(window), handler_id);
450 show_abort_verify = TRUE;
451 gnc_resume_gui_refresh ();
459 if (show_abort_verify)
462 (GNC_PLUGIN_PAGE(page))), FALSE,
463 _(
"'Check & Repair' is currently running, do you want to abort it?"));
465 show_abort_verify = FALSE;
474 if (gnc_get_abort_scrub ())
487 GObjectClass *object_class = G_OBJECT_CLASS (klass);
490 parent_class = g_type_class_peek_parent (klass);
492 object_class->finalize = gnc_plugin_page_account_tree_finalize;
494 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
495 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME;
496 gnc_plugin_class->
create_widget = gnc_plugin_page_account_tree_create_widget;
497 gnc_plugin_class->
destroy_widget = gnc_plugin_page_account_tree_destroy_widget;
498 gnc_plugin_class->
save_page = gnc_plugin_page_account_tree_save_page;
499 gnc_plugin_class->
recreate_page = gnc_plugin_page_account_tree_recreate_page;
501 gnc_plugin_class->
finish_pending = gnc_plugin_page_account_finish_pending;
503 plugin_page_signals[ACCOUNT_SELECTED] =
504 g_signal_new (
"account_selected",
505 G_OBJECT_CLASS_TYPE (object_class),
509 g_cclosure_marshal_VOID__POINTER,
517 GtkActionGroup *action_group;
520 const GList *page_list;
522 ENTER(
"page %p", plugin_page);
523 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(plugin_page);
526 parent = GNC_PLUGIN_PAGE(plugin_page);
527 #ifdef REGISTER2_ENABLED 528 g_object_set(G_OBJECT(plugin_page),
529 "page-name", _(
"Accounts"),
530 "page-uri",
"default:",
531 "ui-description",
"gnc-plugin-page-account-tree2-ui.xml",
534 g_object_set(G_OBJECT(plugin_page),
535 "page-name", _(
"Accounts"),
536 "page-uri",
"default:",
537 "ui-description",
"gnc-plugin-page-account-tree-ui.xml",
540 g_signal_connect (G_OBJECT (plugin_page),
"selected",
541 G_CALLBACK (gnc_plugin_page_account_tree_selected), plugin_page);
549 if (!page_list || plugin_page == page_list->data)
551 g_object_set_data(G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE,
558 "GncPluginPageAccountTreeActions");
559 gtk_action_group_add_actions(action_group,
560 gnc_plugin_page_account_tree_actions,
561 gnc_plugin_page_account_tree_n_actions,
566 priv->fd.visible_types = -1;
567 priv->fd.show_hidden = FALSE;
568 priv->fd.show_unused = TRUE;
569 priv->fd.show_zero_total = TRUE;
570 priv->fd.filter_override = g_hash_table_new (g_direct_hash, g_direct_equal);
572 LEAVE(
"page %p, priv %p, action group %p",
573 plugin_page, priv, action_group);
577 gnc_plugin_page_account_tree_finalize (GObject *
object)
582 ENTER(
"object %p",
object);
583 page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (
object);
584 g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
585 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
586 g_return_if_fail (priv != NULL);
588 G_OBJECT_CLASS (parent_class)->finalize (
object);
598 const GList *page_list;
609 for ( ; page_list; page_list = g_list_next(page_list))
611 plugin_page = GNC_PLUGIN_PAGE(page_list->data);
612 if (GTK_WINDOW(plugin_page->
window) == win)
617 plugin_page = GNC_PLUGIN_PAGE(page_list->data);
622 g_return_if_fail(plugin_page);
623 window = plugin_page->
window;
627 page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page);
628 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
632 Account *root_account = gnc_get_current_root_account ();
633 Account *parent_account = NULL;
634 Account *temp_account = account;
636 g_hash_table_insert (priv->fd.filter_override, account, account);
639 while (parent_account != root_account)
643 g_hash_table_insert (priv->fd.filter_override, parent_account, parent_account);
644 temp_account = parent_account;
657 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
658 ENTER(
"page %p (tree view %p)", page, priv->tree_view);
666 LEAVE(
"account %p", account);
675 gnc_plugin_page_account_tree_focus_widget (
GncPluginPage *account_plugin_page)
677 if (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(account_plugin_page))
680 GtkTreeView *view = GTK_TREE_VIEW(priv->tree_view);
682 if (!gtk_widget_is_focus (GTK_WIDGET(view)))
683 gtk_widget_grab_focus (GTK_WIDGET(view));
691 gnc_plugin_page_account_refresh_cb (GHashTable *changes, gpointer user_data)
696 g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
702 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
705 gtk_widget_queue_draw(priv->widget);
709 gnc_plugin_page_account_tree_close_cb (gpointer user_data)
720 "EditDeleteAccountAction");
723 gtk_action_set_sensitive (action, FALSE);
731 "EditDeleteAccountAction");
734 gtk_action_set_sensitive (action, TRUE);
738 gnc_plugin_page_account_tree_create_widget (
GncPluginPage *plugin_page)
742 GtkTreeSelection *selection;
743 GtkTreeView *tree_view;
744 GtkWidget *scrolled_window;
745 GtkTreeViewColumn *col;
747 ENTER(
"page %p", plugin_page);
748 page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page);
749 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
750 if (priv->widget != NULL)
752 LEAVE(
"widget = %p", priv->widget);
756 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
757 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
758 gtk_widget_show (priv->widget);
761 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-account-page");
763 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
764 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
765 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
766 gtk_widget_show (scrolled_window);
767 gtk_box_pack_start (GTK_BOX (priv->widget), scrolled_window,
772 GNC_TREE_VIEW(tree_view),
"description");
773 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
775 GNC_TREE_VIEW(tree_view),
"total");
776 g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
778 g_object_set(G_OBJECT(tree_view),
779 "state-section", STATE_SECTION,
780 "show-column-menu", TRUE,
785 gnc_tree_view_account_set_code_edited(GNC_TREE_VIEW_ACCOUNT(tree_view),
786 gnc_tree_view_account_code_edited_cb);
787 gnc_tree_view_account_set_description_edited(GNC_TREE_VIEW_ACCOUNT(tree_view),
788 gnc_tree_view_account_description_edited_cb);
789 gnc_tree_view_account_set_notes_edited(GNC_TREE_VIEW_ACCOUNT(tree_view),
790 gnc_tree_view_account_notes_edited_cb);
794 (GFunc)gnc_plugin_page_account_editing_started_cd, page);
796 (GFunc)gnc_plugin_page_account_editing_finished_cb, page);
798 priv->tree_view = tree_view;
799 selection = gtk_tree_view_get_selection(tree_view);
800 g_signal_connect (G_OBJECT (selection),
"changed",
801 G_CALLBACK (gnc_plugin_page_account_tree_selection_changed_cb), page);
802 g_signal_connect (G_OBJECT (tree_view),
"button-press-event",
803 G_CALLBACK (gnc_plugin_page_account_tree_button_press_cb), page);
804 g_signal_connect (G_OBJECT (tree_view),
"row-activated",
805 G_CALLBACK (gnc_plugin_page_account_tree_double_click_cb), page);
807 gtk_tree_view_set_headers_visible(tree_view, TRUE);
808 gnc_plugin_page_account_tree_selection_changed_cb (NULL, page);
809 gtk_widget_show (GTK_WIDGET (tree_view));
810 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
812 priv->fd.tree_view = GNC_TREE_VIEW_ACCOUNT(priv->tree_view);
814 GNC_TREE_VIEW_ACCOUNT(tree_view),
818 gnc_register_gui_component(PLUGIN_PAGE_ACCT_TREE_CM_CLASS,
819 gnc_plugin_page_account_refresh_cb,
820 gnc_plugin_page_account_tree_close_cb,
822 gnc_gui_component_set_session (priv->component_id,
823 gnc_get_current_session());
825 plugin_page->
summarybar = gnc_main_window_summary_new();
826 gtk_box_pack_start (GTK_BOX (priv->widget), plugin_page->
summarybar,
829 gnc_plugin_page_account_tree_summarybar_position_changed(NULL, NULL, page);
831 GNC_PREF_SUMMARYBAR_POSITION_TOP,
832 gnc_plugin_page_account_tree_summarybar_position_changed,
835 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
836 gnc_plugin_page_account_tree_summarybar_position_changed,
839 g_signal_connect (G_OBJECT(plugin_page),
"inserted",
844 gnc_tree_view_account_restore_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view), &priv->fd,
847 LEAVE(
"widget = %p", priv->widget);
852 gnc_plugin_page_account_tree_destroy_widget (
GncPluginPage *plugin_page)
857 ENTER(
"page %p", plugin_page);
858 page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (plugin_page);
859 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
862 GNC_PREF_SUMMARYBAR_POSITION_TOP,
863 gnc_plugin_page_account_tree_summarybar_position_changed,
866 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
867 gnc_plugin_page_account_tree_summarybar_position_changed,
871 gnc_tree_view_account_save_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view), &priv->fd,
875 g_hash_table_destroy(priv->fd.filter_override);
881 g_idle_remove_by_data (plugin_page);
885 g_object_unref(G_OBJECT(priv->widget));
889 if (priv->component_id)
891 gnc_unregister_gui_component(priv->component_id);
892 priv->component_id = 0;
895 LEAVE(
"widget destroyed");
898 static void update_inactive_actions(
GncPluginPage *plugin_page)
901 GtkActionGroup *action_group;
904 gboolean has_account = FALSE;
905 gboolean subaccounts = FALSE;
907 g_return_if_fail (plugin_page && GNC_IS_PLUGIN_PAGE(plugin_page));
909 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE (plugin_page);
911 if (gtk_tree_view_get_selection (priv->tree_view))
914 has_account = (account != NULL);
921 g_return_if_fail(GTK_IS_ACTION_GROUP (action_group));
925 "sensitive", allow_write);
927 "sensitive", allow_write && has_account);
929 "sensitive", has_account);
931 "sensitive", allow_write && subaccounts);
932 g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account);
939 static void gnc_plugin_page_account_tree_selected (GObject *
object, gpointer user_data)
942 g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
943 update_inactive_actions(plugin_page);
956 gnc_plugin_page_account_tree_save_page (
GncPluginPage *plugin_page,
958 const gchar *group_name)
963 g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(plugin_page));
964 g_return_if_fail (key_file != NULL);
965 g_return_if_fail (group_name != NULL);
967 ENTER(
"page %p, key_file %p, group_name %s", plugin_page, key_file,
970 account_page = GNC_PLUGIN_PAGE_ACCOUNT_TREE(plugin_page);
971 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(account_page);
973 gnc_tree_view_account_save(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
974 &priv->fd, key_file, group_name);
990 gnc_plugin_page_account_tree_recreate_page (GtkWidget *window,
992 const gchar *group_name)
998 g_return_val_if_fail(key_file, NULL);
999 g_return_val_if_fail(group_name, NULL);
1000 ENTER(
"key_file %p, group_name %s", key_file, group_name);
1004 account_page = GNC_PLUGIN_PAGE_ACCOUNT_TREE(page);
1005 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(account_page);
1010 gnc_tree_view_account_restore(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
1011 &priv->fd, key_file, group_name);
1020 gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data)
1025 GtkPositionType position = GTK_POS_BOTTOM;
1027 g_return_if_fail(user_data != NULL);
1029 plugin_page = GNC_PLUGIN_PAGE(user_data);
1030 page = GNC_PLUGIN_PAGE_ACCOUNT_TREE (user_data);
1031 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
1034 position = GTK_POS_TOP;
1036 gtk_box_reorder_child(GTK_BOX(priv->widget),
1038 (position == GTK_POS_TOP ? 0 : -1) );
1049 gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget,
1050 GdkEventButton *event,
1054 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
1056 ENTER(
"widget %p, event %p, page %p", widget, event, page);
1070 gboolean include_subs)
1075 if (account == NULL)
1078 window = GNC_PLUGIN_PAGE (page)->window;
1088 gboolean include_subs)
1093 if (account == NULL)
1096 window = GNC_PLUGIN_PAGE (page)->window;
1103 gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview,
1105 GtkTreeViewColumn *col,
1108 GtkTreeModel *model;
1111 g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
1112 g_return_if_fail (treeview);
1114 model = gtk_tree_view_get_model(treeview);
1115 if (gtk_tree_model_get_iter(model, &iter, path))
1123 if (gtk_tree_model_iter_has_child(model, &iter))
1127 if (gtk_tree_view_row_expanded(treeview, path))
1128 gtk_tree_view_collapse_row(treeview, path);
1130 gtk_tree_view_expand_row(treeview, path, FALSE);
1136 #ifdef REGISTER2_ENABLED 1137 gppat_open2_account_common (page, account, FALSE);
1139 gppat_open_account_common (page, account, FALSE);
1146 gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection,
1150 update_inactive_actions (plugin_page);
1167 gnc_ui_hierarchy_assistant(FALSE);
1171 gnc_plugin_page_account_tree_cmd_open_account (GtkAction *action,
1176 g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
1178 gppat_open_account_common (page, account, FALSE);
1182 gnc_plugin_page_account_tree_cmd_open_subaccounts (GtkAction *action,
1187 g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
1189 gppat_open_account_common (page, account, TRUE);
1196 gnc_plugin_page_account_tree_cmd_open2_account (GtkAction *action,
1201 g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
1203 gppat_open2_account_common (page, account, FALSE);
1207 gnc_plugin_page_account_tree_cmd_open2_subaccounts (GtkAction *action,
1212 g_return_if_fail (GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE (page));
1214 gppat_open2_account_common (page, account, TRUE);
1223 ENTER(
"action %p, page %p", action, page);
1226 g_return_if_fail (account != NULL);
1237 ENTER(
"action %p, page %p", action, page);
1241 gnc_find_account_dialog (window, NULL);
1251 ENTER(
"action %p, page %p", action, page);
1257 gnc_find_account_dialog (window, account);
1267 ENTER(
"action %p, page %p", action, page);
1273 if (account != NULL)
1274 gnc_account_cascade_properties_dialog (window, account);
1280 delete_account_helper (
Account * account, gpointer data)
1288 helper_res->has_splits = TRUE;
1291 Split *s = splits->data;
1295 helper_res->has_ro_splits = TRUE;
1298 splits = splits->next;
1302 return GINT_TO_POINTER (helper_res->has_splits || helper_res->has_ro_splits);
1310 set_ok_sensitivity(GtkWidget *dialog)
1313 GtkWidget *sa_mas, *trans_mas;
1314 gint sa_mas_cnt, trans_mas_cnt;
1317 sa_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_MAS);
1318 trans_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS);
1319 sa_mas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(sa_mas));
1320 trans_mas_cnt = gnc_account_sel_get_num_account(GNC_ACCOUNT_SEL(trans_mas));
1322 sensitive = (((NULL == sa_mas) ||
1323 (!gtk_widget_is_sensitive(sa_mas) || sa_mas_cnt)) &&
1324 ((NULL == trans_mas) ||
1325 (!gtk_widget_is_sensitive(trans_mas) || trans_mas_cnt)));
1327 button = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON);
1328 gtk_widget_set_sensitive(button, sensitive);
1332 gppat_populate_gas_list(GtkWidget *dialog,
1334 gboolean exclude_subaccounts)
1339 g_return_if_fail(GTK_IS_DIALOG(dialog));
1342 account = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_ACCOUNT);
1343 filter = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_FILTER);
1346 gnc_account_sel_set_acct_filters (gas, filter, NULL);
1349 gnc_account_sel_purge_account( gas, account, exclude_subaccounts);
1352 set_ok_sensitivity(dialog);
1356 gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb,
1359 GtkWidget *trans_mas;
1361 g_return_if_fail(GTK_IS_DIALOG(dialog));
1364 trans_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_TRANS_MAS);
1365 gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(trans_mas), !gtk_toggle_button_get_active(sa_mrb));
1374 gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b)
1376 GtkWidget *dialog = gtk_widget_get_toplevel(widget);
1377 GtkWidget *subaccount_trans = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_TRANS);
1378 GtkWidget *sa_mas = g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_MAS);
1379 gboolean have_splits = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(dialog), DELETE_DIALOG_SA_SPLITS));
1381 gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(b));
1384 if ((have_splits) && !gtk_widget_is_sensitive(sa_mas))
1385 gtk_widget_set_sensitive(subaccount_trans, TRUE);
1387 gtk_widget_set_sensitive(subaccount_trans, FALSE);
1389 set_ok_sensitivity(dialog);
1393 gppat_setup_account_selector (GtkBuilder *builder, GtkWidget *dialog,
1394 const gchar *hbox,
const gchar *sel_name)
1396 GtkWidget *selector = gnc_account_sel_new();
1397 GtkWidget *box = GTK_WIDGET(gtk_builder_get_object (builder, hbox));
1399 gtk_box_pack_start (GTK_BOX(box), selector, TRUE, TRUE, 0);
1400 gnc_account_sel_set_hexpand (GNC_ACCOUNT_SEL(selector), TRUE);
1401 g_object_set_data(G_OBJECT(dialog), sel_name, selector);
1403 gppat_populate_gas_list(dialog, GNC_ACCOUNT_SEL(selector), TRUE);
1404 gtk_widget_show_all(box);
1410 commodity_mismatch_dialog (
const Account* account, GtkWindow* parent)
1414 char* message = g_strdup_printf (
1415 _(
"Account %s does not have the same currency as the one you're " 1416 "moving transactions from.\nAre you sure you want to do this?"),
1418 GtkWidget* error_dialog =
1419 gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT,
1420 GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE,
1422 gtk_dialog_add_buttons (GTK_DIALOG(error_dialog),
1423 _(
"_Pick another account"), GTK_RESPONSE_CANCEL,
1424 _(
"_Do it anyway"), GTK_RESPONSE_ACCEPT,
1426 response = gtk_dialog_run (GTK_DIALOG (error_dialog));
1427 gtk_widget_destroy (error_dialog);
1438 gboolean for_account;
1442 adopter_set_account_and_match (
Adopter* adopter)
1444 if (!(adopter->selector &&
1445 gtk_widget_is_sensitive (GTK_WIDGET (adopter->selector))))
1447 adopter->new_account = gnc_account_sel_get_account(adopter->selector);
1449 if (!adopter->for_account && adopter->old_account && adopter->new_account)
1456 adopter_init (
Adopter* adopter, GtkWidget *selector,
Account* account,
1457 gboolean for_account)
1459 adopter->selector = GNC_ACCOUNT_SEL (selector);
1460 adopter->new_account = NULL;
1461 adopter->old_account = account;
1462 adopter->match = TRUE;
1463 adopter->for_account = for_account;
1467 adopter_match (
Adopter* adopter, GtkWindow *parent)
1470 if (adopter->match || adopter->for_account)
1472 result = commodity_mismatch_dialog (adopter->new_account, parent);
1473 return (result == GTK_RESPONSE_ACCEPT);
1485 account_subaccount (
Account* account)
1490 subaccount = subs->data;
1496 account_delete_dialog (
Account *account, GtkWindow *parent,
Adopters* adopt)
1498 GtkWidget *dialog = NULL;
1499 GtkWidget *widget = NULL;
1500 gchar *title = NULL;
1501 GtkBuilder *builder = gtk_builder_new();
1507 acct_name = g_strdup (_(
"(no name)"));
1509 gnc_builder_add_from_file (builder,
"dialog-account.glade",
"account_delete_dialog");
1511 dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"account_delete_dialog"));
1512 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
1515 g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_FILTER, filter);
1516 g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_ACCOUNT, account);
1517 widget = GTK_WIDGET(gtk_builder_get_object (builder,
"header"));
1518 title = g_strdup_printf(_(
"Deleting account %s"), acct_name);
1519 gtk_label_set_text(GTK_LABEL(widget), title);
1523 widget = GTK_WIDGET(gtk_builder_get_object (builder, DELETE_DIALOG_OK_BUTTON));
1524 g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_OK_BUTTON, widget);
1528 adopter_init (&adopt->trans,
1529 gppat_setup_account_selector (builder, dialog,
1531 DELETE_DIALOG_TRANS_MAS),
1539 delete_account_helper(account, &delete_res2);
1540 if (delete_res2.has_ro_splits)
1542 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"trans_rw")));
1543 widget = GTK_WIDGET(gtk_builder_get_object (builder,
"trans_drb"));
1544 gtk_widget_set_sensitive(widget, FALSE);
1547 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"trans_ro")));
1551 gtk_widget_set_sensitive (GTK_WIDGET(gtk_builder_get_object (builder,
"transactions")), FALSE);
1552 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"trans_ro")));
1556 adopter_init (&adopt->subacct,
1557 gppat_setup_account_selector (builder, dialog,
1559 DELETE_DIALOG_SA_MAS),
1563 adopter_init (&adopt->subtrans,
1564 gppat_setup_account_selector (builder, dialog,
1565 "sa_trans_mas_hbox",
1566 DELETE_DIALOG_SA_TRANS_MAS),
1567 account_subaccount (account), FALSE);
1568 g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_TRANS,
1569 GTK_WIDGET(gtk_builder_get_object (builder,
"subaccount_trans")));
1575 &adopt->delete_res);
1576 if (adopt->delete_res.has_splits)
1578 if (adopt->delete_res.has_ro_splits)
1580 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"sa_trans_rw")));
1581 widget = GTK_WIDGET(gtk_builder_get_object (builder,
"sa_trans_drb"));
1582 gtk_widget_set_sensitive(widget, FALSE);
1585 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"sa_trans_ro")));
1587 g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_SPLITS, GINT_TO_POINTER(1));
1591 g_object_set_data(G_OBJECT(dialog), DELETE_DIALOG_SA_SPLITS, GINT_TO_POINTER(0));
1592 gtk_widget_set_sensitive (GTK_WIDGET(gtk_builder_get_object (builder,
"subaccount_trans")), FALSE);
1593 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"sa_trans_ro")));
1598 gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (builder,
"subaccounts")), FALSE);
1599 gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object (builder,
"subaccount_trans")), FALSE);
1600 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"sa_trans_ro")));
1604 gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
1606 gtk_builder_connect_signals(builder, dialog);
1607 g_object_unref(G_OBJECT(builder));
1621 GList *filter = NULL;
1622 GtkWidget *dialog = NULL;
1624 if (account == NULL)
1627 memset (&adopt, 0,
sizeof (adopt));
1633 #define EXPLANATION _("The list below shows objects which make use of the account which you want to delete.\nBefore you can delete it, you must either delete those objects or else modify them so they make use\nof another account") 1635 gnc_ui_object_references_show(EXPLANATION, list);
1643 acct_name = g_strdup (_(
"(no name)"));
1646 gchar* message = g_strdup_printf(_(
"The account \"%s\" has more than one subaccount.\n\nMove the subaccounts or delete them before attempting to delete this account."), acct_name);
1647 gnc_error_dialog(GTK_WINDOW(window),
"%s", message);
1657 do_delete_account (account, NULL, NULL, NULL);
1661 dialog = account_delete_dialog (account, GTK_WINDOW (window), &adopt);
1665 response = gtk_dialog_run(GTK_DIALOG(dialog));
1667 if (response != GTK_RESPONSE_ACCEPT)
1670 filter = g_object_get_data (G_OBJECT (dialog),
1671 DELETE_DIALOG_FILTER);
1672 gtk_widget_destroy(dialog);
1673 g_list_free(filter);
1676 adopter_set_account_and_match (&adopt.trans);
1677 adopter_set_account_and_match (&adopt.subacct);
1678 adopter_set_account_and_match (&adopt.subtrans);
1680 if (adopter_match (&adopt.trans, GTK_WINDOW (window)) &&
1681 adopter_match (&adopt.subacct, GTK_WINDOW (window)) &&
1682 adopter_match (&adopt.subtrans, GTK_WINDOW (window)))
1685 filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER);
1686 gtk_widget_destroy(dialog);
1687 g_list_free(filter);
1688 if (confirm_delete_account (action, page, adopt.trans.new_account,
1689 adopt.subtrans.new_account,
1690 adopt.subacct.new_account,
1691 adopt.delete_res) == GTK_RESPONSE_ACCEPT)
1693 do_delete_account (account, adopt.subacct.new_account,
1694 adopt.subtrans.new_account, adopt.trans.new_account);
1708 char *lines[6] = {0};
1714 lines[i] = g_strdup_printf (_(
"The account %s will be deleted."),
1723 lines[++i] = g_strdup_printf (_(
"All transactions in this account " 1724 "will be moved to the account %s."),
1730 lines[++i] = g_strdup_printf (_(
"All transactions in this account " 1731 "will be deleted."));
1739 lines[++i] = g_strdup_printf (_(
"Its sub-account will be " 1740 "moved to the account %s."), name);
1745 lines[++i] = g_strdup_printf (_(
"Its subaccount will be deleted."));
1749 lines[++i] = g_strdup_printf (_(
"All sub-account transactions " 1750 "will be moved to the " 1751 "account %s."), name);
1754 else if (delete_res.has_splits)
1756 lines[++i] = g_strdup_printf(_(
"All sub-account transactions " 1757 "will be deleted."));
1762 lines[++i] = _(
"Are you sure you want to do this?");
1764 message = g_strjoinv(
" ", lines);
1765 for (
int j = 0; j < i; ++j)
1768 dialog = gtk_message_dialog_new(GTK_WINDOW(window),
1769 GTK_DIALOG_DESTROY_WITH_PARENT,
1770 GTK_MESSAGE_QUESTION,
1774 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
1775 _(
"_Cancel"), GTK_RESPONSE_CANCEL,
1776 _(
"_Delete"), GTK_RESPONSE_ACCEPT,
1778 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
1779 response = gtk_dialog_run(GTK_DIALOG(dialog));
1780 gtk_widget_destroy(dialog);
1786 GList *acct_list, *ptr;
1790 gnc_set_busy_cursor(NULL, TRUE);
1791 gnc_suspend_gui_refresh ();
1799 for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
1801 g_list_free(acct_list);
1822 for (ptr = acct_list; ptr; ptr = g_list_next(ptr))
1828 g_list_free(acct_list);
1842 gnc_resume_gui_refresh ();
1843 gnc_unset_busy_cursor(NULL);
1847 gnc_plugin_page_account_tree_cmd_renumber_accounts (GtkAction *action,
1855 if (!window || !account)
1858 gnc_account_renumber_create_dialog(window, account);
1862 gnc_plugin_page_account_tree_cmd_refresh (GtkAction *action,
1867 g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
1869 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
1872 gtk_widget_queue_draw (priv->widget);
1878 gnc_plugin_page_account_tree_cmd_view_filter_by (GtkAction *action,
1883 g_return_if_fail(GNC_IS_PLUGIN_PAGE_ACCOUNT_TREE(page));
1884 ENTER(
"(action %p, page %p)", action, page);
1886 priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(page);
1887 account_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page));
1892 gnc_plugin_page_account_tree_cmd_reconcile (GtkAction *action,
1897 RecnWindow *recnData;
1900 g_return_if_fail (account != NULL);
1902 window = GNC_PLUGIN_PAGE (page)->window;
1903 recnData = recnWindow (window, account);
1904 gnc_ui_reconcile_window_raise (recnData);
1908 gnc_plugin_page_account_tree_cmd_autoclear (GtkAction *action,
1913 AutoClearWindow *autoClearData;
1916 g_return_if_fail (account != NULL);
1918 window = GNC_PLUGIN_PAGE (page)->window;
1919 autoClearData = autoClearWindow (window, account);
1920 gnc_ui_autoclear_window_raise (autoClearData);
1924 gnc_plugin_page_account_tree_cmd_transfer (GtkAction *action,
1931 window = GNC_PLUGIN_PAGE (page)->window;
1932 gnc_xfer_dialog (window, account);
1936 gnc_plugin_page_account_tree_cmd_stock_split (GtkAction *action,
1943 window = GNC_PLUGIN_PAGE (page)->window;
1944 gnc_stock_split_dialog (window, account);
1948 gnc_plugin_page_account_tree_cmd_edit_tax_options (GtkAction *action,
1955 window = GNC_PLUGIN_PAGE (page)->window;
1956 gnc_tax_info_dialog (window, account);
1960 gnc_plugin_page_account_tree_cmd_lots (GtkAction *action,
1964 GtkWidget *window = GNC_PLUGIN_PAGE (page)->window;
1965 gnc_lot_viewer_dialog (GTK_WINDOW(window), account);
1968 static gboolean scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data)
1970 if (event->length == 0)
return FALSE;
1972 switch (event->keyval)
1974 case GDK_KEY_Escape:
1976 gboolean abort_scrub = gnc_verify_dialog (GTK_WINDOW(widget), FALSE,
1977 _(
"'Check & Repair' is currently running, do you want to abort it?"));
1995 gulong scrub_kp_handler_ID;
1997 g_return_if_fail (account != NULL);
1999 prepare_scrubbing ();
2001 window = GNC_WINDOW(GNC_PLUGIN_PAGE (page)->window);
2002 scrub_kp_handler_ID = g_signal_connect (G_OBJECT(window),
"key-press-event",
2003 G_CALLBACK(scrub_kp_handler), NULL);
2004 gnc_window_set_progressbar_window (window);
2007 xaccAccountScrubImbalance (account, gnc_window_show_progress);
2010 if (g_getenv(
"GNC_AUTO_SCRUB_LOTS") != NULL)
2015 finish_scrubbing (window, scrub_kp_handler_ID);
2023 gulong scrub_kp_handler_ID;
2025 g_return_if_fail (account != NULL);
2027 prepare_scrubbing ();
2029 window = GNC_WINDOW(GNC_PLUGIN_PAGE (page)->window);
2030 scrub_kp_handler_ID = g_signal_connect (G_OBJECT(window),
"key-press-event",
2031 G_CALLBACK(scrub_kp_handler), NULL);
2032 gnc_window_set_progressbar_window (window);
2035 xaccAccountTreeScrubImbalance (account, gnc_window_show_progress);
2038 if (g_getenv(
"GNC_AUTO_SCRUB_LOTS") != NULL)
2039 xaccAccountTreeScrubLots(account);
2043 finish_scrubbing (window, scrub_kp_handler_ID);
2049 Account *root = gnc_get_current_root_account ();
2051 gulong scrub_kp_handler_ID;
2053 prepare_scrubbing ();
2055 window = GNC_WINDOW(GNC_PLUGIN_PAGE (page)->window);
2056 scrub_kp_handler_ID = g_signal_connect (G_OBJECT(window),
"key-press-event",
2057 G_CALLBACK(scrub_kp_handler), NULL);
2058 gnc_window_set_progressbar_window (window);
2061 xaccAccountTreeScrubImbalance (root, gnc_window_show_progress);
2063 if (g_getenv(
"GNC_AUTO_SCRUB_LOTS") != NULL)
2064 xaccAccountTreeScrubLots(root);
2068 finish_scrubbing (window, scrub_kp_handler_ID);
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
GncPluginPage * gnc_plugin_page_register_new(Account *account, gboolean subaccounts)
Create a new "register" plugin page, given a pointer to an account.
Account * gnc_plugin_page_account_tree_get_current_account(GncPluginPageAccountTree *page)
Given a pointer to an account tree plugin page, return the selected account (if any).
Functions to load, save and get gui state.
High-Level API for imposing Lot constraints.
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
Retrieve a pointer to the GncMainWindow (GtkWindow) containing this page.
const gchar * tab_icon
The relative name of the icon that should be shown on the tab for this page.
gboolean(* focus_page_function)(GncPluginPage *plugin_page)
This function performs specific actions to set the focus on a specific widget.
void gnc_account_append_child(Account *new_parent, Account *child)
This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent.
The instance data structure for a content plugin.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
gboolean gnc_main_window_button_press_cb(GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page)
Callback function invoked when the user clicks in the content of any Gnucash window.
SplitList * xaccAccountGetSplitList(const Account *acc)
The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account...
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
void gnc_plugin_page_account_tree_open(Account *account, GtkWindow *win)
Given a pointer to an account, the account tree will open and the account will be selected (if any)...
This file contains the functions to present a gui to the user for creating a new account or editing a...
void gnc_account_foreach_descendant(const Account *acc, AccountCb thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling 'func' on each...
GncPluginPage * gnc_plugin_page_account_tree_new(void)
Create a new "account tree" plugin page.
void gnc_tree_view_account_set_editing_finished_cb(GncTreeViewAccount *view, GFunc editing_finished_cb, gpointer editing_cb_data)
Setup the callback for when the user finishes editing the account tree so actions can be enabled like...
gboolean gnc_get_ongoing_scrub(void)
The gnc_get_ongoing_scrub () method returns TRUE if a scrub operation is ongoing. ...
utility functions for the GnuCash UI
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
GncPluginPage *(* recreate_page)(GtkWidget *window, GKeyFile *file, const gchar *group)
Create a new page based on the information saved during a previous instantiation of gnucash...
gint gnc_state_drop_sections_for(const gchar *partial_name)
Drop all sections from the state file whose name contains partial_name.
const char * xaccTransGetReadOnly(Transaction *trans)
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text...
Functions that are supported by all types of windows.
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling 'func' on each...
GncPluginPage * gnc_plugin_page_register2_new(Account *account, gboolean subaccounts)
Create a new "register" plugin page, given a pointer to an account.
GtkWidget * window
The window that contains the display widget for this plugin.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
void xaccAccountScrubLots(Account *acc)
The xaccAccountScrubLots() routine makes sure that every split in the account is assigned to a lot...
void xaccAccountMoveAllSplits(Account *accfrom, Account *accto)
The xaccAccountMoveAllSplits() routine reassigns each of the splits in accfrom to accto...
void gnc_tree_view_account_set_editing_started_cb(GncTreeViewAccount *view, GFunc editing_started_cb, gpointer editing_cb_data)
Setup the callback for when the user starts editing the account tree so actions can be disabled like ...
GtkActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GtkActionGroup object associated with this page.
GtkTreeViewColumn * gnc_tree_view_find_column_by_name(GncTreeView *view, const gchar *wanted)
Find a tree column given the "pref name" used with saved state.
#define ENTER(format, args...)
Print a function entry debugging message.
Cleanup functions for business objects.
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
This file contains the functions to present a dialog box with a list of object references and an expl...
void gnc_ui_edit_account_window(GtkWindow *parent, Account *account)
Display a window for editing the attributes of an existing account.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
void(* destroy_widget)(GncPluginPage *plugin_page)
Function called to destroy the display widget for a particular type of plugin.
void xaccAccountDestroy(Account *acc)
The xaccAccountDestroy() routine can be used to get rid of an account.
#define xaccAccountGetGUID(X)
void gnc_set_abort_scrub(gboolean abort)
The gnc_set_abort_scrub () method causes a currently running scrub operation to stop, if abort is TRUE; gnc_set_abort_scrub(FALSE) must be called before any scrubbing operation.
convert single-entry accounts to clean double-entry
void gnc_tree_view_account_set_filter(GncTreeViewAccount *view, gnc_tree_view_account_filter_func func, gpointer data, GSourceFunc destroy)
This function attaches a filter function to the given account tree.
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...
Functions providing a register page for the GnuCash UI.
The class data structure for a content plugin.
void gnc_tree_view_account_refilter(GncTreeViewAccount *view)
This function forces the account tree filter to be evaluated.
GtkTreeView implementation for gnucash account tree.
void xaccAccountTreeScrubOrphans(Account *acc, QofPercentageFunc percentagefunc)
The xaccAccountTreeScrubOrphans() method performs this scrub for the indicated account and its childr...
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
void gnc_plugin_page_disconnect_page_changed(GncPluginPage *page)
Disconnect the page_changed_id signal callback.
GtkTreeView * gnc_tree_view_account_new(gboolean show_root)
Create a new account tree view.
void gnc_tree_view_configure_columns(GncTreeView *view)
Make all the correct columns visible, respecting their default visibility setting, their "always" visibility setting, and the last saved state if available.
gboolean gnc_plugin_page_account_tree_filter_accounts(Account *account, gpointer user_data)
This function tells the account tree view whether or not to filter out a particular account...
const gchar * plugin_name
The textual name of this plugin.
void gncScrubBusinessAccount(Account *acc, QofPercentageFunc percentagefunc)
The gncScrubBusinessAccount() function will call all scrub functions relevant for a given account on ...
void gnc_tree_view_account_clear_model_cache(GncTreeViewAccount *view)
This function clears the tree model account cache so the values will be updated/refreshed.
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
Function called to create the display widget for a particular type of plugin.
Account * gnc_tree_view_account_get_account_from_path(GncTreeViewAccount *view, GtkTreePath *s_path)
This function returns the account associated with the specified path.
void xaccAccountScrubOrphans(Account *acc, QofPercentageFunc percentagefunc)
The xaccAccountScrubOrphans() method performs this scrub only for the indicated account, and not for any of its children.
Gnome specific utility functions.
gint gnc_account_n_children(const Account *account)
Return the number of children of the specified account.
gboolean(* finish_pending)(GncPluginPage *plugin_page)
This function vector is called to finish any outstanding activities.
All type declarations for the whole Gnucash engine.
void gnc_ui_new_account_window(GtkWindow *parent, QofBook *book, Account *parent_acct)
Display a window for creating a new account.
void(* save_page)(GncPluginPage *page, GKeyFile *file, const gchar *group)
Save enough information about this page so that it can be recreated next time the user starts gnucash...
GtkTreeModel implementation to display account types in a GtkTreeView.
GList * qof_instance_get_referring_object_list(const QofInstance *inst)
Returns a list of objects which refer to a specific object.
const gchar * gnc_tree_view_get_state_section(GncTreeView *view)
Get the name of the state section this tree view is associated with.
Generic api to store and retrieve preferences.
Functions providing a chart of account page.
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
GList * gnc_account_get_children(const Account *account)
This routine returns a GList of all children accounts of the specified account.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Provide the menus to create a chart of account page.
void gnc_plugin_page_inserted_cb(GncPluginPage *page, gpointer user_data)
Set up the page_changed callback for when the current page is changed.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
Account * gnc_tree_view_account_get_selected_account(GncTreeViewAccount *view)
This function returns the account associated with the selected item in the account tree view...
#define LEAVE(format, args...)
Print a function exit debugging message.
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
Add a book reference to the specified page.
GtkActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
Create the GtkActionGroup object associated with this page.
void gncScrubBusinessAccountTree(Account *acc, QofPercentageFunc percentagefunc)
The gncScrubBusinessAccountTreeLots() function will call gncScrubBusinessAccount() on the given accou...
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...
API for Transactions and Splits (journal entries)
The type used to store guids in C.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
GtkAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *name)
Find action in main window.
GtkWidget * summarybar
The summary bar widget (if any) that is associated with this plugin.
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when the given preference changed.