[Gnucash-changes] r13486 - gnucash/trunk - Move/fix the callbacks
function that kills any open registers for an
David Hampton
hampton at cvs.gnucash.org
Sat Mar 4 20:29:44 EST 2006
Author: hampton
Date: 2006-03-04 20:29:43 -0500 (Sat, 04 Mar 2006)
New Revision: 13486
Trac: http://svn.gnucash.org/trac/changeset/13486
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/gnome/gnc-plugin-page-register.c
gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c
gnucash/trunk/src/register/ledger-core/gnc-ledger-display.h
gnucash/trunk/src/register/ledger-core/split-register.c
Log:
Move/fix the callbacks function that kills any open registers for an
account that has had "extreme" changes made to it in the "edit
account" dialog. Fixes 331415.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-03-05 00:55:10 UTC (rev 13485)
+++ gnucash/trunk/ChangeLog 2006-03-05 01:29:43 UTC (rev 13486)
@@ -1,5 +1,12 @@
2006-03-04 David Hampton <hampton at employees.org>
+ * src/register/ledger-core/gnc-ledger-display.[ch]:
+ * src/register/ledger-core/split-register.c:
+ * src/gnome/gnc-plugin-page-register.c: Move/fix the callbacks
+ function that kills any open registers for an account that has had
+ "extreme" changes made to it in the "edit account" dialog. Fixes
+ 331415.
+
* src/pixmaps/*
* src/gnome-utils/Makefile.am:
* src/gnome-utils/gnc-icons.[ch]:
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register.c 2006-03-05 00:55:10 UTC (rev 13485)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register.c 2006-03-05 01:29:43 UTC (rev 13486)
@@ -149,6 +149,7 @@
static void gnc_plugin_page_register_refresh_cb (GHashTable *changes, gpointer user_data);
static void gnc_plugin_page_register_update_split_button (SplitRegister *reg, GncPluginPageRegister *page);
+static void gppr_account_destroy_cb (Account *account);
/************************************************************/
/* Actions */
@@ -506,6 +507,8 @@
gnc_plugin_class->update_edit_menu_actions = gnc_plugin_page_register_update_edit_menu;
g_type_class_add_private(klass, sizeof(GncPluginPageRegisterPrivate));
+
+ gnc_ui_register_account_destroy_callback (gppr_account_destroy_cb);
}
static void
@@ -2717,5 +2720,49 @@
}
}
+/** This function is called when an account has been edited and an
+ * "extreme" change has been made to it. (E.G. Changing from a
+ * credit card account to an expense account. This rouine is
+ * responsible for finding all open registers containing the account
+ * and closing them.
+ *
+ * @param accoung A pointer to the account that was changed.
+ */
+static void
+gppr_account_destroy_cb (Account *account)
+{
+ GncPluginPageRegister *page;
+ GncPluginPageRegisterPrivate *priv;
+ GNCLedgerDisplayType ledger_type;
+ const GUID *acct_guid;
+ const GList *citem;
+ GList *item, *kill = NULL;
+
+ acct_guid = xaccAccountGetGUID(account);
+
+ /* Find all windows that need to be killed. Don't kill them yet, as
+ * that would affect the list being walked.*/
+ citem = gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_REGISTER_NAME);
+ for ( ; citem; citem = g_list_next(citem)) {
+ page = (GncPluginPageRegister *)citem->data;
+ priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
+ ledger_type = gnc_ledger_display_type (priv->ledger);
+ if (ledger_type == LD_GL) {
+ kill = g_list_append(kill, page);
+ /* kill it */
+ } else if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT)) {
+ if (guid_compare(acct_guid, &priv->key) == 0) {
+ kill = g_list_append(kill, page);
+ }
+ }
+ }
+
+ /* Now kill them. */
+ for (item = kill; item; item = g_list_next(item)) {
+ page = (GncPluginPageRegister *)item->data;
+ gnc_main_window_close_page(GNC_PLUGIN_PAGE(page));
+ }
+}
+
/** @} */
/** @} */
Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c 2006-03-05 00:55:10 UTC (rev 13485)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c 2006-03-05 01:29:43 UTC (rev 13486)
@@ -168,25 +168,6 @@
}
static gboolean
-find_by_account (gpointer find_data, gpointer user_data)
-{
- Account *account = find_data;
- GNCLedgerDisplay *ld = user_data;
-
- if (!account || !ld)
- return FALSE;
-
- if (account == gnc_ledger_display_leader (ld))
- return TRUE;
-
- if (ld->ld_type == LD_SINGLE)
- return FALSE;
-
- /* Hack. */
- return TRUE;
-}
-
-static gboolean
find_by_query (gpointer find_data, gpointer user_data)
{
Query *q = find_data;
@@ -891,42 +872,7 @@
}
}
-/********************************************************************\
- * xaccDestroyLedgerDisplay()
-\********************************************************************/
-
-static void
-gnc_destroy_ledger_display_class (Account *account,
- const char *component_class)
-{
- GList *list;
- GList *node;
-
- list = gnc_find_gui_components (component_class, find_by_account, account);
-
- for (node = list; node; node = node->next)
- {
- GNCLedgerDisplay *ld = node->data;
-
- gnc_close_gui_component (ld->component_id);
- }
-
- g_list_free (list);
-}
-
void
-gnc_ledger_display_destroy_by_account (Account *account)
-{
- if (!account)
- return;
-
- gnc_destroy_ledger_display_class (account, REGISTER_SINGLE_CM_CLASS);
- gnc_destroy_ledger_display_class (account, REGISTER_SUBACCOUNT_CM_CLASS);
- gnc_destroy_ledger_display_class (account, REGISTER_GL_CM_CLASS);
- /* no TEMPLATE_CM_CLASS, because it doesn't correspond to any account */
-}
-
-void
gnc_ledger_display_close (GNCLedgerDisplay *ld)
{
if (!ld)
Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display.h 2006-03-05 00:55:10 UTC (rev 13485)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display.h 2006-03-05 01:29:43 UTC (rev 13486)
@@ -119,9 +119,6 @@
/* close the window */
void gnc_ledger_display_close (GNCLedgerDisplay * ledger_display);
-/* close all ledger windows containing this account. */
-void gnc_ledger_display_destroy_by_account (Account *account);
-
/* Returns a boolean of whether this display should be single or double lined
* mode by default */
gboolean gnc_ledger_display_default_double_line (GNCLedgerDisplay *gld);
Modified: gnucash/trunk/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.c 2006-03-05 00:55:10 UTC (rev 13485)
+++ gnucash/trunk/src/register/ledger-core/split-register.c 2006-03-05 01:29:43 UTC (rev 13486)
@@ -2229,7 +2229,6 @@
TableControl *control;
/* Register 'destroy' callback */
- gnc_ui_register_account_destroy_callback (gnc_ledger_display_destroy_by_account);
gnc_gconf_general_register_cb(KEY_ACCOUNTING_LABELS,
split_register_gconf_changed,
reg);
More information about the gnucash-changes
mailing list