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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13486 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/register-rewrite
David Hampton 21 years ago
parent f2b29cdf76
commit 35a8b15f41

@ -1,5 +1,12 @@
2006-03-04 David Hampton <hampton@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]:

@ -149,6 +149,7 @@ static void gnc_plugin_page_help_changed_cb( GNCSplitReg *gsr, GncPluginPageRegi
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_page_register_class_init (GncPluginPageRegisterClass *klass)
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 @@ gnc_plugin_page_register_refresh_cb (GHashTable *changes, gpointer user_data)
}
}
/** 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));
}
}
/** @} */
/** @} */

@ -167,25 +167,6 @@ find_by_leader (gpointer find_data, gpointer user_data)
return (account == gnc_ledger_display_leader (ld));
}
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)
{
@ -891,41 +872,6 @@ gnc_ledger_display_refresh_by_split_register (SplitRegister *reg)
}
}
/********************************************************************\
* 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)
{

@ -119,9 +119,6 @@ void gnc_ledger_display_refresh_by_split_register (SplitRegister *reg);
/* 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);

@ -2229,7 +2229,6 @@ gnc_split_register_init (SplitRegister *reg,
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);

Loading…
Cancel
Save