mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Use the CM to refresh the reconcile & account windows.
More work on refresh arch. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3366 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -40,14 +40,6 @@ AccountWindow * gnc_ui_edit_account_window (Account *account);
|
||||
|
||||
Account * gnc_ui_new_accounts_from_name_window (const char *name);
|
||||
|
||||
|
||||
/* The xaccDestroyEditAccWindow() subroutine can be called from
|
||||
* anywhere to shut down the Register window. Used primarily when
|
||||
* destroying the underlying account. */
|
||||
void gnc_ui_destroy_edit_account_window (Account *account);
|
||||
|
||||
void gnc_ui_refresh_edit_account_window (Account *account);
|
||||
|
||||
void gnc_ui_set_default_new_account_currency (const char *currency);
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "AccWindow.h"
|
||||
#include "Destroy.h"
|
||||
#include "Group.h"
|
||||
#include "MultiLedger.h"
|
||||
@@ -33,8 +32,6 @@ void
|
||||
xaccAccountWindowDestroySimple (Account *account)
|
||||
{
|
||||
xaccDestroyLedgerDisplay (account);
|
||||
xaccDestroyRecnWindow (account);
|
||||
gnc_ui_destroy_edit_account_window (account);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
||||
@@ -37,12 +37,6 @@ typedef struct _RecnWindow RecnWindow;
|
||||
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
void recnRefresh (Account * account);
|
||||
RecnWindow *recnWindow (gncUIWidget parent, Account *account);
|
||||
|
||||
/* The xaccDestroyRecnWindow() subroutine can be called from anywhere
|
||||
* to shut down the Register window. Used primarily when destroying
|
||||
* the underlying account. */
|
||||
void xaccDestroyRecnWindow (Account *account);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,24 +53,13 @@ gnc_account_ui_refresh(Account *account)
|
||||
}
|
||||
|
||||
xaccAccountDisplayRefresh(account);
|
||||
recnRefresh(account);
|
||||
gnc_ui_refresh_edit_account_window(account);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
void
|
||||
gnc_account_glist_ui_refresh(GList *accounts)
|
||||
{
|
||||
GList *node;
|
||||
|
||||
xaccAccGListDisplayRefresh(accounts);
|
||||
|
||||
node = accounts;
|
||||
while (node != NULL)
|
||||
{
|
||||
recnRefresh(node->data);
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
@@ -99,24 +88,10 @@ gnc_group_ui_refresh(AccountGroup *group)
|
||||
void
|
||||
gnc_transaction_ui_refresh(Transaction *trans)
|
||||
{
|
||||
Account *account;
|
||||
Split *split;
|
||||
int i, num_splits;
|
||||
|
||||
if (trans == NULL)
|
||||
return;
|
||||
|
||||
xaccTransDisplayRefresh(trans);
|
||||
|
||||
num_splits = xaccTransCountSplits(trans);
|
||||
|
||||
for (i = 0; i < num_splits; i++)
|
||||
{
|
||||
split = xaccTransGetSplit(trans, i);
|
||||
account = xaccSplitGetAccount(split);
|
||||
|
||||
recnRefresh(account);
|
||||
}
|
||||
}
|
||||
|
||||
/************************** END OF FILE *************************/
|
||||
|
||||
+73
-9
@@ -113,6 +113,7 @@
|
||||
#include "Scrub.h"
|
||||
#include "SplitLedger.h"
|
||||
#include "global-options.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-ui.h"
|
||||
@@ -159,6 +160,9 @@ struct _SRInfo
|
||||
* in ledger mode. Meaningless in other modes. */
|
||||
gboolean trans_expanded;
|
||||
|
||||
/* set to TRUE after register is loaded */
|
||||
gboolean reg_loaded;
|
||||
|
||||
/* The default account where new splits are added */
|
||||
Account *default_source_account;
|
||||
|
||||
@@ -897,6 +901,9 @@ LedgerMoveCursor (Table *table, VirtualLocation *p_new_virt_loc)
|
||||
}
|
||||
|
||||
info->hint_set_by_traverse = FALSE;
|
||||
info->reg_loaded = FALSE;
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* commit the contents of the cursor into the database */
|
||||
saved = xaccSRSaveRegEntry (reg, old_trans != new_trans);
|
||||
@@ -912,17 +919,23 @@ LedgerMoveCursor (Table *table, VirtualLocation *p_new_virt_loc)
|
||||
saved = TRUE;
|
||||
}
|
||||
|
||||
if (saved)
|
||||
{
|
||||
info->cursor_hint_trans = new_trans;
|
||||
info->cursor_hint_split = new_split;
|
||||
info->cursor_hint_trans_split = new_trans_split;
|
||||
info->cursor_hint_cursor_class = new_class;
|
||||
}
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
/* redrawing the register can muck everything up */
|
||||
if (saved)
|
||||
{
|
||||
VirtualCellLocation vcell_loc;
|
||||
|
||||
info->cursor_hint_trans = new_trans;
|
||||
info->cursor_hint_split = new_split;
|
||||
info->cursor_hint_trans_split = new_trans_split;
|
||||
info->cursor_hint_cursor_class = new_class;
|
||||
|
||||
xaccSRRedrawRegEntry (reg);
|
||||
if (!info->reg_loaded)
|
||||
xaccSRRedrawReg (reg);
|
||||
|
||||
/* if the split we were going to is still in the register,
|
||||
* then it may have moved. Find out where it is now. */
|
||||
@@ -1087,6 +1100,10 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
||||
if (auto_trans == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* now perform the completion */
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
gnc_copy_trans_onto_trans (auto_trans, trans, FALSE, FALSE);
|
||||
|
||||
@@ -1142,6 +1159,8 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
|
||||
|
||||
g_list_free(refresh_accounts);
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
/* now move to the non-empty amount column */
|
||||
amount = xaccSplitGetShareAmount (blank_split);
|
||||
cell_type = (gnc_numeric_negative_p (amount)) ? CRED_CELL : DEBT_CELL;
|
||||
@@ -1517,6 +1536,8 @@ LedgerDestroy (SplitRegister *reg)
|
||||
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
|
||||
Transaction *trans;
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* be sure to destroy the "blank split" */
|
||||
if (blank_split != NULL) {
|
||||
/* split destroy will automatically remove it
|
||||
@@ -1548,6 +1569,8 @@ LedgerDestroy (SplitRegister *reg)
|
||||
}
|
||||
|
||||
xaccSRDestroyRegisterData(reg);
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
}
|
||||
|
||||
/* ======================================================== */
|
||||
@@ -1878,6 +1901,8 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
|
||||
if (!changed && ((split == NULL) || (split == blank_split)))
|
||||
return NULL;
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* If the cursor has been edited, we are going to have to commit
|
||||
* it before we can duplicate. Make sure the user wants to do that. */
|
||||
if (changed)
|
||||
@@ -1890,7 +1915,10 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
|
||||
message, GNC_VERIFY_OK);
|
||||
|
||||
if (result == GNC_VERIFY_CANCEL)
|
||||
{
|
||||
gnc_resume_gui_refresh ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xaccSRSaveRegEntry(reg, TRUE);
|
||||
|
||||
@@ -1937,7 +1965,10 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
|
||||
|
||||
/* we should *always* find the split, but be paranoid */
|
||||
if (split_index < 0)
|
||||
{
|
||||
gnc_resume_gui_refresh ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_trans = xaccMallocTransaction();
|
||||
|
||||
@@ -1963,6 +1994,7 @@ xaccSRDuplicateCurrent (SplitRegister *reg)
|
||||
/* Refresh the GUI. */
|
||||
gnc_refresh_main_window();
|
||||
gnc_transaction_ui_refresh(trans);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
return return_split;
|
||||
}
|
||||
@@ -2160,6 +2192,8 @@ xaccSRPasteCurrent (SplitRegister *reg)
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
accounts = gnc_trans_prepend_account_list(trans, NULL);
|
||||
|
||||
if (split == NULL)
|
||||
@@ -2196,6 +2230,8 @@ xaccSRPasteCurrent (SplitRegister *reg)
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
accounts = gnc_trans_prepend_account_list(trans, NULL);
|
||||
|
||||
/* in pasting, the old split is deleted. */
|
||||
@@ -2235,6 +2271,7 @@ xaccSRPasteCurrent (SplitRegister *reg)
|
||||
/* Refresh the GUI. */
|
||||
gnc_refresh_main_window();
|
||||
gnc_account_glist_ui_refresh(accounts);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
g_list_free(accounts);
|
||||
}
|
||||
@@ -2266,6 +2303,8 @@ xaccSRDeleteCurrentSplit (SplitRegister *reg)
|
||||
return;
|
||||
}
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* make a copy of all of the accounts that will be
|
||||
* affected by this deletion, so that we can update
|
||||
* their register windows after the deletion. */
|
||||
@@ -2290,6 +2329,7 @@ xaccSRDeleteCurrentSplit (SplitRegister *reg)
|
||||
|
||||
gnc_refresh_main_window ();
|
||||
gnc_account_glist_ui_refresh(accounts);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
g_list_free(accounts);
|
||||
}
|
||||
@@ -2327,6 +2367,8 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
|
||||
pending_trans = NULL;
|
||||
}
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransDestroy (trans);
|
||||
xaccTransCommitEdit (trans);
|
||||
@@ -2335,9 +2377,12 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
|
||||
blank_split = NULL;
|
||||
|
||||
xaccAccountDisplayRefresh(account);
|
||||
gnc_resume_gui_refresh ();
|
||||
return;
|
||||
}
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* make a copy of all of the accounts that will be
|
||||
* affected by this deletion, so that we can update
|
||||
* their register windows after the deletion. */
|
||||
@@ -2358,6 +2403,7 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
|
||||
|
||||
gnc_refresh_main_window ();
|
||||
gnc_account_glist_ui_refresh(accounts);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
g_list_free(accounts);
|
||||
}
|
||||
@@ -2397,6 +2443,8 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
|
||||
pending_trans = NULL;
|
||||
}
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
xaccTransDestroy (trans);
|
||||
xaccTransCommitEdit (trans);
|
||||
@@ -2405,9 +2453,12 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
|
||||
blank_split = NULL;
|
||||
|
||||
xaccAccountDisplayRefresh(account);
|
||||
gnc_resume_gui_refresh ();
|
||||
return;
|
||||
}
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* make a copy of all of the accounts that will be
|
||||
* affected by this deletion, so that we can update
|
||||
* their register windows after the deletion. */
|
||||
@@ -2431,6 +2482,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
|
||||
|
||||
gnc_refresh_main_window ();
|
||||
gnc_account_glist_ui_refresh(accounts);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
g_list_free(accounts);
|
||||
g_list_free(splits);
|
||||
@@ -2484,6 +2536,8 @@ xaccSRCancelCursorTransChanges (SplitRegister *reg)
|
||||
if (!pending_trans)
|
||||
return;
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
accounts = gnc_trans_prepend_account_list (pending_trans, NULL);
|
||||
|
||||
xaccTransRollbackEdit (pending_trans);
|
||||
@@ -2497,12 +2551,14 @@ xaccSRCancelCursorTransChanges (SplitRegister *reg)
|
||||
info->pending_trans_guid = *xaccGUIDNULL ();
|
||||
|
||||
gnc_refresh_main_window ();
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
}
|
||||
|
||||
/* ======================================================== */
|
||||
|
||||
void
|
||||
xaccSRRedrawRegEntry (SplitRegister *reg)
|
||||
xaccSRRedrawReg (SplitRegister *reg)
|
||||
{
|
||||
Transaction *trans;
|
||||
|
||||
@@ -2710,6 +2766,8 @@ xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit)
|
||||
|
||||
ENTER ("xaccSRSaveRegEntry(): save split is %p \n", split);
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* determine whether we should commit the pending transaction */
|
||||
if (pending_trans != trans) {
|
||||
if (xaccTransIsOpen (pending_trans))
|
||||
@@ -2799,6 +2857,8 @@ xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit)
|
||||
g_list_free(refresh_accounts);
|
||||
}
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -3248,8 +3308,8 @@ get_trans_last_split (SplitRegister *reg, Transaction *trans)
|
||||
GList *node;
|
||||
Account *account;
|
||||
Split *last_split = NULL;
|
||||
SRInfo *info = xaccSRGetInfo (reg);
|
||||
|
||||
SRInfo *info = xaccSRGetInfo(reg);
|
||||
account = info->default_source_account;
|
||||
|
||||
if (!account)
|
||||
@@ -4249,6 +4309,8 @@ xaccSRLoadRegister (SplitRegister *reg, GList * slist,
|
||||
{
|
||||
Transaction *trans;
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
trans = xaccMallocTransaction ();
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
@@ -4258,8 +4320,9 @@ xaccSRLoadRegister (SplitRegister *reg, GList * slist,
|
||||
xaccTransCommitEdit (trans);
|
||||
|
||||
info->blank_split_guid = *xaccSplitGetGUID (blank_split);
|
||||
|
||||
info->blank_split_edited = FALSE;
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
}
|
||||
|
||||
info->default_source_account = default_source_acc;
|
||||
@@ -4496,6 +4559,7 @@ xaccSRLoadRegister (SplitRegister *reg, GList * slist,
|
||||
info->traverse_to_new = FALSE;
|
||||
info->exact_traversal = FALSE;
|
||||
info->first_pass = FALSE;
|
||||
info->reg_loaded = TRUE;
|
||||
|
||||
gnc_table_refresh_gui (table);
|
||||
|
||||
|
||||
+2
-2
@@ -166,14 +166,14 @@ void xaccSRLoadRegister (SplitRegister *reg, GList * slist,
|
||||
* The method returns TRUE if something was changed. */
|
||||
gboolean xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit);
|
||||
|
||||
/* The xaccSRRedrawRegEntry() method should be called soon
|
||||
/* The xaccSRRedrawReg() method should be called soon
|
||||
* after the xaccSRSaveRegEntry() method. It checks the
|
||||
* change flag for the current entry/split, and if it
|
||||
* has been modified, it causes a redraw of any register
|
||||
* window that could be affected. That is, it causes
|
||||
* a redraw of any window showing this split, or any
|
||||
* other split that belongs to this same tansaction. */
|
||||
void xaccSRRedrawRegEntry (SplitRegister *reg);
|
||||
void xaccSRRedrawReg (SplitRegister *reg);
|
||||
|
||||
/* The xaccSRHasPendingChanges() method returns TRUE if the register
|
||||
* has changed cells that have not been committed. */
|
||||
|
||||
@@ -72,6 +72,8 @@ static short module = MOD_GUI;
|
||||
|
||||
/** Prototypes ******************************************************/
|
||||
static void gnc_gui_refresh_internal (gboolean force);
|
||||
static GList * find_component_ids_by_class (const char *component_class);
|
||||
static gboolean got_events = FALSE;
|
||||
|
||||
|
||||
/** Implementations *************************************************/
|
||||
@@ -223,10 +225,15 @@ gnc_cm_event_handler (GUID *entity,
|
||||
GNCEngineEventType event_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
#ifdef CM_DEBUG
|
||||
add_event (&changes, entity, event_type, TRUE);
|
||||
got_events = TRUE;
|
||||
|
||||
#if CM_DEBUG
|
||||
fprintf (stderr, "event: %d\n", event_type);
|
||||
#endif
|
||||
|
||||
if (suspend_counter == 0)
|
||||
gnc_gui_refresh_internal (FALSE);
|
||||
}
|
||||
|
||||
static gint handler_id;
|
||||
@@ -391,6 +398,15 @@ gnc_gui_component_watch_entity_type (gint component_id,
|
||||
add_event_type (&ci->watch_info, entity_type, event_mask, FALSE);
|
||||
}
|
||||
|
||||
const EventInfo *
|
||||
gnc_gui_get_entity_events (GHashTable *changes, GUID *entity)
|
||||
{
|
||||
if (!changes || !entity)
|
||||
return GNC_EVENT_NONE;
|
||||
|
||||
return g_hash_table_lookup (changes, entity);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_gui_component_clear_watches (gint component_id)
|
||||
{
|
||||
@@ -541,14 +557,67 @@ changes_match (ComponentEventInfo *cei)
|
||||
return big_cei->match;
|
||||
}
|
||||
|
||||
static void
|
||||
compile_helper (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
GUID *guid = key;
|
||||
EventInfo *info = value;
|
||||
ComponentEventInfo *cei = user_data;
|
||||
GNCIdType id_type;
|
||||
|
||||
id_type = xaccGUIDType (guid);
|
||||
switch (id_type)
|
||||
{
|
||||
case GNC_ID_TRANS:
|
||||
cei->trans_event_mask |= info->event_mask;
|
||||
break;
|
||||
|
||||
case GNC_ID_ACCOUNT:
|
||||
cei->account_event_mask |= info->event_mask;
|
||||
break;
|
||||
|
||||
case GNC_ID_NONE:
|
||||
break;
|
||||
|
||||
default:
|
||||
PERR ("unexpected id type: %d", id_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
compile_changes (ComponentEventInfo *cei)
|
||||
{
|
||||
if (!cei)
|
||||
return;
|
||||
|
||||
g_hash_table_foreach (cei->entity_events, compile_helper, cei);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_gui_refresh_internal (gboolean force)
|
||||
{
|
||||
GList *list;
|
||||
GList *node;
|
||||
|
||||
for (node = components; node; node = node->next)
|
||||
#if CM_DEBUG
|
||||
fprintf (stderr, "refresh!\n");
|
||||
#endif
|
||||
|
||||
if (!got_events)
|
||||
return;
|
||||
|
||||
if (!force)
|
||||
compile_changes (&changes);
|
||||
|
||||
list = find_component_ids_by_class (NULL);
|
||||
|
||||
for (node = list; node; node = node->next)
|
||||
{
|
||||
ComponentInfo *ci = node->data;
|
||||
ComponentInfo *ci = find_component (GPOINTER_TO_INT (node->data));
|
||||
|
||||
if (!ci)
|
||||
continue;
|
||||
|
||||
if (!ci->refresh_handler)
|
||||
continue;
|
||||
@@ -560,6 +629,9 @@ gnc_gui_refresh_internal (gboolean force)
|
||||
}
|
||||
|
||||
clear_event_info (&changes);
|
||||
got_events = FALSE;
|
||||
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -63,8 +63,8 @@ typedef struct
|
||||
*
|
||||
* user_data: user_data supplied when component was registered.
|
||||
*/
|
||||
typedef gboolean (*GNCComponentRefreshHandler) (GHashTable *changes,
|
||||
gpointer user_data);
|
||||
typedef void (*GNCComponentRefreshHandler) (GHashTable *changes,
|
||||
gpointer user_data);
|
||||
|
||||
/* GNCComponentCloseHandler
|
||||
* Handler invoked to close the component.
|
||||
@@ -168,6 +168,19 @@ void gnc_gui_component_watch_entity_type (gint component_id,
|
||||
GNCIdType entity_type,
|
||||
GNCEngineEventType event_mask);
|
||||
|
||||
/* gnc_gui_get_entity_events
|
||||
* Return the event info of the events which have been generated by
|
||||
* the given entity.
|
||||
*
|
||||
* changes: a hash of changes as in the refresh handler
|
||||
* entity: the GUID of the entity to get the event mask for
|
||||
*
|
||||
* Returns: the event info of the entity, or NULL
|
||||
* if it is not found.
|
||||
*/
|
||||
const EventInfo * gnc_gui_get_entity_events (GHashTable *changes,
|
||||
GUID *entity);
|
||||
|
||||
/* gnc_gui_component_clear_watches
|
||||
* Clear all watches for the component.
|
||||
*
|
||||
|
||||
+170
-88
@@ -64,7 +64,7 @@ struct _AccountWindow
|
||||
|
||||
AccountDialogType dialog_type;
|
||||
|
||||
Account *account;
|
||||
GUID account;
|
||||
Account *top_level_account;
|
||||
Account *created_account;
|
||||
|
||||
@@ -104,44 +104,61 @@ static void gnc_account_window_set_name (AccountWindow *aw);
|
||||
static AccountWindow *
|
||||
gnc_ui_new_account_window_internal (Account *base_account,
|
||||
GList *subaccount_names);
|
||||
static void make_account_changes(GHashTable *change_currency,
|
||||
GHashTable *change_security,
|
||||
GHashTable *change_type);
|
||||
static void gnc_ui_refresh_edit_account_window (AccountWindow *aw);
|
||||
|
||||
|
||||
/** Implementation *******************************************************/
|
||||
|
||||
static Account *
|
||||
aw_get_account (AccountWindow *aw)
|
||||
{
|
||||
if (!aw)
|
||||
return NULL;
|
||||
|
||||
return xaccAccountLookup (&aw->account);
|
||||
}
|
||||
|
||||
/* Copy the account values to the GUI widgets */
|
||||
static void
|
||||
gnc_account_to_ui(AccountWindow *aw)
|
||||
{
|
||||
Account *account = aw_get_account (aw);
|
||||
const gnc_commodity * commodity;
|
||||
const char *string;
|
||||
gboolean tax_related;
|
||||
gint pos = 0;
|
||||
|
||||
string = xaccAccountGetName (aw->account);
|
||||
if (!account)
|
||||
return;
|
||||
|
||||
string = xaccAccountGetName (account);
|
||||
gtk_entry_set_text(GTK_ENTRY(aw->name_entry), string);
|
||||
|
||||
string = xaccAccountGetDescription (aw->account);
|
||||
string = xaccAccountGetDescription (account);
|
||||
gtk_entry_set_text(GTK_ENTRY(aw->description_entry), string);
|
||||
|
||||
commodity = xaccAccountGetCurrency (aw->account);
|
||||
commodity = xaccAccountGetCurrency (account);
|
||||
gnc_commodity_edit_set_commodity (GNC_COMMODITY_EDIT (aw->currency_edit),
|
||||
commodity);
|
||||
|
||||
commodity = xaccAccountGetSecurity (aw->account);
|
||||
commodity = xaccAccountGetSecurity (account);
|
||||
gnc_commodity_edit_set_commodity (GNC_COMMODITY_EDIT (aw->security_edit),
|
||||
commodity);
|
||||
|
||||
string = xaccAccountGetCode (aw->account);
|
||||
string = xaccAccountGetCode (account);
|
||||
gtk_entry_set_text(GTK_ENTRY(aw->code_entry), string);
|
||||
|
||||
string = xaccAccountGetNotes (aw->account);
|
||||
string = xaccAccountGetNotes (account);
|
||||
if (string == NULL) string = "";
|
||||
|
||||
gtk_editable_delete_text (GTK_EDITABLE (aw->notes_text), 0, -1);
|
||||
gtk_editable_insert_text (GTK_EDITABLE (aw->notes_text), string,
|
||||
strlen(string), &pos);
|
||||
|
||||
tax_related = xaccAccountGetTaxRelated (aw->account);
|
||||
tax_related = xaccAccountGetTaxRelated (account);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (aw->tax_related_button),
|
||||
tax_related);
|
||||
|
||||
@@ -150,11 +167,10 @@ gnc_account_to_ui(AccountWindow *aw)
|
||||
|
||||
{
|
||||
/* we'll let GetPriceSrc handle the account type checking... */
|
||||
const char* price_src = xaccAccountGetPriceSrc(aw->account);
|
||||
if (price_src) {
|
||||
gtk_option_menu_set_history(GTK_OPTION_MENU(aw->source_menu),
|
||||
gnc_get_source_code(price_src));
|
||||
}
|
||||
const char* price_src = xaccAccountGetPriceSrc (account);
|
||||
if (price_src)
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (aw->source_menu),
|
||||
gnc_get_source_code (price_src));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,45 +179,49 @@ gnc_account_to_ui(AccountWindow *aw)
|
||||
static void
|
||||
gnc_ui_to_account(AccountWindow *aw)
|
||||
{
|
||||
Account *account = aw_get_account (aw);
|
||||
const gnc_commodity *commodity;
|
||||
Account *parent_account;
|
||||
const char *old_string;
|
||||
const char *string;
|
||||
gboolean tax_related;
|
||||
|
||||
xaccAccountBeginEdit (aw->account);
|
||||
if (!account)
|
||||
return;
|
||||
|
||||
if (aw->type != xaccAccountGetType (aw->account))
|
||||
xaccAccountSetType (aw->account, aw->type);
|
||||
xaccAccountBeginEdit (account);
|
||||
|
||||
if (aw->type != xaccAccountGetType (account))
|
||||
xaccAccountSetType (account, aw->type);
|
||||
|
||||
string = gtk_entry_get_text (GTK_ENTRY(aw->name_entry));
|
||||
old_string = xaccAccountGetName (aw->account);
|
||||
old_string = xaccAccountGetName (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetName (aw->account, string);
|
||||
xaccAccountSetName (account, string);
|
||||
|
||||
string = gtk_entry_get_text (GTK_ENTRY(aw->description_entry));
|
||||
old_string = xaccAccountGetDescription (aw->account);
|
||||
old_string = xaccAccountGetDescription (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetDescription (aw->account, string);
|
||||
xaccAccountSetDescription (account, string);
|
||||
|
||||
commodity =
|
||||
gnc_commodity_edit_get_commodity (GNC_COMMODITY_EDIT (aw->currency_edit));
|
||||
if (commodity &&
|
||||
!gnc_commodity_equiv(commodity, xaccAccountGetCurrency(aw->account)))
|
||||
xaccAccountSetCurrency (aw->account, commodity);
|
||||
!gnc_commodity_equiv(commodity, xaccAccountGetCurrency(account)))
|
||||
xaccAccountSetCurrency (account, commodity);
|
||||
|
||||
string = gtk_entry_get_text (GTK_ENTRY(aw->code_entry));
|
||||
old_string = xaccAccountGetCode (aw->account);
|
||||
old_string = xaccAccountGetCode (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetCode (aw->account, string);
|
||||
xaccAccountSetCode (account, string);
|
||||
|
||||
if ((STOCK == aw->type) || (MUTUAL == aw->type) || (CURRENCY == aw->type))
|
||||
{
|
||||
commodity = gnc_commodity_edit_get_commodity
|
||||
(GNC_COMMODITY_EDIT (aw->security_edit));
|
||||
if (commodity &&
|
||||
!gnc_commodity_equiv(commodity, xaccAccountGetSecurity(aw->account)))
|
||||
xaccAccountSetSecurity (aw->account, commodity);
|
||||
!gnc_commodity_equiv (commodity, xaccAccountGetSecurity(account)))
|
||||
xaccAccountSetSecurity (account, commodity);
|
||||
|
||||
if ((STOCK == aw->type) || (MUTUAL == aw->type))
|
||||
{
|
||||
@@ -209,20 +229,20 @@ gnc_ui_to_account(AccountWindow *aw)
|
||||
|
||||
code = gnc_option_menu_get_active (aw->source_menu);
|
||||
string = gnc_get_source_code_name (code);
|
||||
old_string = xaccAccountGetPriceSrc (aw->account);
|
||||
old_string = xaccAccountGetPriceSrc (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetPriceSrc(aw->account, string);
|
||||
xaccAccountSetPriceSrc (account, string);
|
||||
}
|
||||
}
|
||||
|
||||
string = gtk_editable_get_chars (GTK_EDITABLE(aw->notes_text), 0, -1);
|
||||
old_string = xaccAccountGetNotes (aw->account);
|
||||
old_string = xaccAccountGetNotes (account);
|
||||
if (safe_strcmp (string, old_string) != 0)
|
||||
xaccAccountSetNotes (aw->account, string);
|
||||
xaccAccountSetNotes (account, string);
|
||||
|
||||
tax_related =
|
||||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (aw->tax_related_button));
|
||||
xaccAccountSetTaxRelated (aw->account, tax_related);
|
||||
xaccAccountSetTaxRelated (account, tax_related);
|
||||
|
||||
parent_account =
|
||||
gnc_account_tree_get_current_account (GNC_ACCOUNT_TREE(aw->parent_tree));
|
||||
@@ -233,21 +253,27 @@ gnc_ui_to_account(AccountWindow *aw)
|
||||
|
||||
if (parent_account != NULL)
|
||||
{
|
||||
if (parent_account != xaccAccountGetParentAccount (aw->account))
|
||||
xaccAccountInsertSubAccount (parent_account, aw->account);
|
||||
if (parent_account != xaccAccountGetParentAccount (account))
|
||||
xaccAccountInsertSubAccount (parent_account, account);
|
||||
}
|
||||
else
|
||||
xaccGroupInsertAccount (gncGetCurrentGroup(), aw->account);
|
||||
xaccGroupInsertAccount (gncGetCurrentGroup(), account);
|
||||
|
||||
xaccAccountCommitEdit (parent_account);
|
||||
xaccAccountCommitEdit (aw->account);
|
||||
xaccAccountCommitEdit (account);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_finish_ok (AccountWindow *aw)
|
||||
gnc_finish_ok (AccountWindow *aw,
|
||||
GHashTable *change_currency,
|
||||
GHashTable *change_security,
|
||||
GHashTable *change_type)
|
||||
{
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* make the account changes */
|
||||
make_account_changes(change_currency, change_security, change_type);
|
||||
gnc_ui_to_account (aw);
|
||||
|
||||
/* Refresh all registers so they have this account in their lists */
|
||||
@@ -256,18 +282,24 @@ gnc_finish_ok (AccountWindow *aw)
|
||||
/* Refresh the main window. This will also refresh all account lists. */
|
||||
gnc_refresh_main_window ();
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
/* do it all again, if needed */
|
||||
if (aw->dialog_type == NEW_ACCOUNT && aw->subaccount_names)
|
||||
{
|
||||
const gnc_commodity *commodity;
|
||||
Account *parent;
|
||||
Account *account;
|
||||
GList *node;
|
||||
|
||||
parent = aw->account;
|
||||
aw->account = xaccMallocAccount ();
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
parent = aw_get_account (aw);
|
||||
account = xaccMallocAccount ();
|
||||
aw->account = *xaccAccountGetGUID (account);
|
||||
aw->type = xaccAccountGetType (parent);
|
||||
|
||||
xaccAccountSetName (aw->account, aw->subaccount_names->data);
|
||||
xaccAccountSetName (account, aw->subaccount_names->data);
|
||||
|
||||
node = aw->subaccount_names;
|
||||
aw->subaccount_names = g_list_remove_link (aw->subaccount_names, node);
|
||||
@@ -289,14 +321,16 @@ gnc_finish_ok (AccountWindow *aw)
|
||||
gnc_account_tree_select_account (GNC_ACCOUNT_TREE(aw->parent_tree),
|
||||
parent, TRUE);
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* save for posterity */
|
||||
aw->created_account = aw->account;
|
||||
aw->created_account = aw_get_account (aw);
|
||||
|
||||
/* so it doesn't get freed on close */
|
||||
aw->account = NULL;
|
||||
aw->account = *xaccGUIDNULL ();
|
||||
|
||||
gnc_close_gui_component (aw->component_id);
|
||||
}
|
||||
@@ -635,7 +669,9 @@ extra_change_verify(AccountWindow *aw,
|
||||
if (aw == NULL)
|
||||
return FALSE;
|
||||
|
||||
account = aw->account;
|
||||
account = aw_get_account (aw);
|
||||
if (!account)
|
||||
return FALSE;
|
||||
|
||||
titles[0] = _("Account");
|
||||
titles[1] = _("Field");
|
||||
@@ -712,17 +748,21 @@ static gboolean
|
||||
gnc_filter_parent_accounts (Account *account, gpointer data)
|
||||
{
|
||||
AccountWindow *aw = data;
|
||||
Account *aw_account = aw_get_account (aw);
|
||||
|
||||
if (account == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (aw_account == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (account == aw->top_level_account)
|
||||
return TRUE;
|
||||
|
||||
if (account == aw->account)
|
||||
if (account == aw_account)
|
||||
return FALSE;
|
||||
|
||||
if (xaccAccountHasAncestor(account, aw->account))
|
||||
if (xaccAccountHasAncestor(account, aw_account))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@@ -802,7 +842,9 @@ gnc_edit_account_ok(AccountWindow *aw)
|
||||
}
|
||||
|
||||
|
||||
account = aw->account;
|
||||
account = aw_get_account (aw);
|
||||
if (!account)
|
||||
return;
|
||||
|
||||
change_currency = g_hash_table_new(NULL, NULL);
|
||||
change_security = g_hash_table_new(NULL, NULL);
|
||||
@@ -874,11 +916,9 @@ gnc_edit_account_ok(AccountWindow *aw)
|
||||
|
||||
if (current_type != aw->type)
|
||||
/* Just refreshing won't work. */
|
||||
xaccDestroyLedgerDisplay(account);
|
||||
xaccDestroyLedgerDisplay (account);
|
||||
|
||||
make_account_changes(change_currency, change_security, change_type);
|
||||
|
||||
gnc_finish_ok (aw);
|
||||
gnc_finish_ok (aw, change_currency, change_security, change_type);
|
||||
|
||||
g_hash_table_destroy (change_currency);
|
||||
g_hash_table_destroy (change_security);
|
||||
@@ -976,7 +1016,7 @@ gnc_new_account_ok (AccountWindow *aw)
|
||||
return;
|
||||
}
|
||||
|
||||
gnc_finish_ok (aw);
|
||||
gnc_finish_ok (aw, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -1034,14 +1074,19 @@ static int
|
||||
gnc_account_window_destroy_cb (GtkObject *object, gpointer data)
|
||||
{
|
||||
AccountWindow *aw = data;
|
||||
Account *account;
|
||||
|
||||
account = aw_get_account (aw);
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
switch (aw->dialog_type)
|
||||
{
|
||||
case NEW_ACCOUNT:
|
||||
if (aw->account != NULL)
|
||||
if (account != NULL)
|
||||
{
|
||||
xaccFreeAccount (aw->account);
|
||||
aw->account = NULL;
|
||||
xaccFreeAccount (account);
|
||||
aw->account = *xaccGUIDNULL ();
|
||||
}
|
||||
|
||||
DEBUG ("account add window destroyed\n");
|
||||
@@ -1052,6 +1097,7 @@ gnc_account_window_destroy_cb (GtkObject *object, gpointer data)
|
||||
|
||||
default:
|
||||
PERR ("unexpected dialog type\n");
|
||||
gnc_resume_gui_refresh ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1060,6 +1106,8 @@ gnc_account_window_destroy_cb (GtkObject *object, gpointer data)
|
||||
xaccFreeAccount (aw->top_level_account);
|
||||
aw->top_level_account = NULL;
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
if (aw->subaccount_names)
|
||||
{
|
||||
GList *node;
|
||||
@@ -1156,7 +1204,7 @@ gnc_account_type_list_create(AccountWindow *aw)
|
||||
aw->type = last_used_account_type;
|
||||
break;
|
||||
case EDIT_ACCOUNT:
|
||||
aw->type = xaccAccountGetType(aw->account);
|
||||
aw->type = xaccAccountGetType (aw_get_account (aw));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1291,7 +1339,7 @@ gnc_account_window_create(AccountWindow *aw)
|
||||
gtk_box_pack_start(GTK_BOX(box), aw->security_edit, TRUE, TRUE, 0);
|
||||
|
||||
box = gtk_object_get_data(awo, "source_box");
|
||||
aw->source_menu = gnc_ui_source_menu_create(aw->account);
|
||||
aw->source_menu = gnc_ui_source_menu_create(aw_get_account (aw));
|
||||
gtk_box_pack_start(GTK_BOX(box), aw->source_menu, TRUE, TRUE, 0);
|
||||
|
||||
aw->type_list = gtk_object_get_data(awo, "type_list");
|
||||
@@ -1370,6 +1418,9 @@ gnc_account_window_set_name (AccountWindow *aw)
|
||||
char *fullname;
|
||||
char *title;
|
||||
|
||||
if (!aw || !aw->parent_tree)
|
||||
return;
|
||||
|
||||
fullname = get_ui_fullname (aw);
|
||||
|
||||
if (aw->dialog_type == EDIT_ACCOUNT)
|
||||
@@ -1404,20 +1455,49 @@ close_handler (gpointer user_data)
|
||||
gnome_dialog_close (GNOME_DIALOG (aw->dialog));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
{
|
||||
AccountWindow *aw = user_data;
|
||||
const EventInfo *info;
|
||||
Account *account;
|
||||
|
||||
account = aw_get_account (aw);
|
||||
if (!account)
|
||||
{
|
||||
gnc_close_gui_component (aw->component_id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (changes)
|
||||
{
|
||||
info = gnc_gui_get_entity_events (changes, &aw->account);
|
||||
if (info && (info->event_mask & GNC_EVENT_DESTROY))
|
||||
{
|
||||
gnc_close_gui_component (aw->component_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gnc_ui_refresh_edit_account_window (aw);
|
||||
}
|
||||
|
||||
|
||||
static AccountWindow *
|
||||
gnc_ui_new_account_window_internal (Account *base_account,
|
||||
GList *subaccount_names)
|
||||
{
|
||||
const gnc_commodity *commodity;
|
||||
AccountWindow *aw;
|
||||
Account *account;
|
||||
|
||||
aw = g_new0 (AccountWindow, 1);
|
||||
|
||||
aw->dialog_type = NEW_ACCOUNT;
|
||||
aw->account = xaccMallocAccount ();
|
||||
|
||||
aw->component_id = gnc_register_gui_component (DIALOG_NEW_ACCOUNT_CM_CLASS,
|
||||
NULL, close_handler, aw);
|
||||
account = xaccMallocAccount ();
|
||||
aw->account = *xaccAccountGetGUID (account);
|
||||
|
||||
if (base_account)
|
||||
aw->type = xaccAccountGetType (base_account);
|
||||
@@ -1428,18 +1508,19 @@ gnc_ui_new_account_window_internal (Account *base_account,
|
||||
{
|
||||
GList *node;
|
||||
|
||||
xaccAccountSetName (aw->account, subaccount_names->data);
|
||||
xaccAccountSetName (account, subaccount_names->data);
|
||||
|
||||
aw->subaccount_names = g_list_copy (subaccount_names->next);
|
||||
for (node = aw->subaccount_names; node; node = node->next)
|
||||
node->data = g_strdup (node->data);
|
||||
}
|
||||
|
||||
gnc_account_window_create (aw);
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
gnc_account_window_create (aw);
|
||||
gnc_account_to_ui (aw);
|
||||
|
||||
gnc_account_window_set_name (aw);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
commodity = gnc_lookup_currency_option ("International",
|
||||
"Default Currency",
|
||||
@@ -1455,6 +1536,15 @@ gnc_ui_new_account_window_internal (Account *base_account,
|
||||
|
||||
gnc_window_adjust_for_screen (GTK_WINDOW(aw->dialog));
|
||||
|
||||
gnc_account_window_set_name (aw);
|
||||
|
||||
aw->component_id = gnc_register_gui_component (DIALOG_NEW_ACCOUNT_CM_CLASS,
|
||||
refresh_handler,
|
||||
close_handler, aw);
|
||||
|
||||
gnc_gui_component_watch_entity_type (aw->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
return aw;
|
||||
}
|
||||
|
||||
@@ -1587,7 +1677,7 @@ find_by_account (gpointer find_data, gpointer user_data)
|
||||
if (!aw)
|
||||
return FALSE;
|
||||
|
||||
return (aw->account == account);
|
||||
return guid_equal (&aw->account, xaccAccountGetGUID (account));
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@@ -1614,17 +1704,15 @@ gnc_ui_edit_account_window(Account *account)
|
||||
aw = g_new0 (AccountWindow, 1);
|
||||
|
||||
aw->dialog_type = EDIT_ACCOUNT;
|
||||
aw->account = account;
|
||||
aw->account = *xaccAccountGetGUID (account);
|
||||
aw->subaccount_names = NULL;
|
||||
|
||||
aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
|
||||
NULL, close_handler, aw);
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
gnc_account_window_create (aw);
|
||||
|
||||
gnc_account_to_ui (aw);
|
||||
|
||||
gnc_account_window_set_name (aw);
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
gtk_widget_show_all (aw->dialog);
|
||||
|
||||
@@ -1634,8 +1722,18 @@ gnc_ui_edit_account_window(Account *account)
|
||||
gnc_account_tree_select_account(GNC_ACCOUNT_TREE(aw->parent_tree),
|
||||
parent, TRUE);
|
||||
|
||||
gnc_account_window_set_name (aw);
|
||||
|
||||
gnc_window_adjust_for_screen(GTK_WINDOW(aw->dialog));
|
||||
|
||||
aw->component_id = gnc_register_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
|
||||
refresh_handler,
|
||||
close_handler, aw);
|
||||
|
||||
gnc_gui_component_watch_entity_type (aw->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
|
||||
return aw;
|
||||
}
|
||||
|
||||
@@ -1667,37 +1765,21 @@ gnc_ui_destroy_account_add_windows (void)
|
||||
* gnc_ui_refresh_edit_account_window *
|
||||
* refreshes the edit window *
|
||||
* *
|
||||
* Args: account - the account of the window to refresh *
|
||||
* Args: aw - the account window to refresh *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_ui_refresh_edit_account_window (Account *account)
|
||||
static void
|
||||
gnc_ui_refresh_edit_account_window (AccountWindow *aw)
|
||||
{
|
||||
AccountWindow *aw;
|
||||
|
||||
aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
|
||||
find_by_account, account);
|
||||
if (aw == NULL)
|
||||
return;
|
||||
|
||||
gnc_account_tree_refresh (GNC_ACCOUNT_TREE(aw->parent_tree));
|
||||
|
||||
gnc_account_window_set_name (aw);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnc_ui_destroy_edit_account_window (Account * account)
|
||||
{
|
||||
AccountWindow *aw;
|
||||
|
||||
aw = gnc_find_first_gui_component (DIALOG_EDIT_ACCOUNT_CM_CLASS,
|
||||
find_by_account, account);
|
||||
if (aw == NULL)
|
||||
return;
|
||||
|
||||
gnc_close_gui_component (aw->component_id);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_ui_edit_account_window_raise *
|
||||
* shows and raises an account editing window *
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "FileBox.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "query-user.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "gnc-ui-util.h"
|
||||
|
||||
#include <g-wrap-runtime-guile.h>
|
||||
@@ -1199,7 +1200,9 @@ gnc_ui_qif_import_finish_cb(GnomeDruidPage * gpage,
|
||||
|
||||
/* get the default currency */
|
||||
char * currname = gtk_entry_get_text(GTK_ENTRY(wind->currency_entry));
|
||||
|
||||
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
/* busy cursor */
|
||||
gnc_set_busy_cursor(NULL);
|
||||
|
||||
@@ -1230,7 +1233,8 @@ gnc_ui_qif_import_finish_cb(GnomeDruidPage * gpage,
|
||||
gh_call2(save_map_prefs, wind->acct_map_info, wind->cat_map_info);
|
||||
|
||||
gnc_unset_busy_cursor(NULL);
|
||||
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
gnc_ui_qif_import_druid_destroy(wind);
|
||||
}
|
||||
|
||||
|
||||
+106
-77
@@ -63,8 +63,8 @@
|
||||
/** STRUCTS *********************************************************/
|
||||
struct _RecnWindow
|
||||
{
|
||||
Account *account; /* The account that we are reconciling */
|
||||
gnc_numeric new_ending; /* The new ending balance */
|
||||
GUID account; /* The account that we are reconciling */
|
||||
gnc_numeric new_ending; /* The new ending balance */
|
||||
time_t statement_date; /* The statement date */
|
||||
gboolean use_shares; /* Use share balances */
|
||||
|
||||
@@ -127,7 +127,7 @@ static gboolean find_by_account (gpointer find_data, gpointer user_data);
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
/* static short module = MOD_GUI; */
|
||||
|
||||
|
||||
/** IMPLEMENTATIONS *************************************************/
|
||||
@@ -140,13 +140,9 @@ static short module = MOD_GUI;
|
||||
* Args: account - the account of the reconcile window to refresh *
|
||||
* Return: none *
|
||||
\********************************************************************/
|
||||
void
|
||||
recnRefresh (Account *account)
|
||||
static void
|
||||
recnRefresh (RecnWindow *recnData)
|
||||
{
|
||||
RecnWindow *recnData;
|
||||
|
||||
recnData = gnc_find_first_gui_component (WINDOW_RECONCILE_CM_CLASS,
|
||||
find_by_account, account);
|
||||
if (recnData == NULL)
|
||||
return;
|
||||
|
||||
@@ -163,6 +159,15 @@ recnRefresh (Account *account)
|
||||
}
|
||||
|
||||
|
||||
static Account *
|
||||
recn_get_account (RecnWindow *recnData)
|
||||
{
|
||||
if (!recnData)
|
||||
return NULL;
|
||||
|
||||
return xaccAccountLookup (&recnData->account);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* recnRecalculateBalance *
|
||||
* refreshes the balances in the reconcile window *
|
||||
@@ -174,6 +179,7 @@ recnRefresh (Account *account)
|
||||
static gnc_numeric
|
||||
recnRecalculateBalance(RecnWindow *recnData)
|
||||
{
|
||||
Account *account;
|
||||
const char *amount;
|
||||
gnc_numeric debit;
|
||||
gnc_numeric credit;
|
||||
@@ -184,18 +190,22 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
GNCPrintAmountInfo print_info;
|
||||
gboolean reverse_balance;
|
||||
|
||||
reverse_balance = gnc_reverse_balance(recnData->account);
|
||||
account = recn_get_account (recnData);
|
||||
if (!account)
|
||||
return gnc_numeric_zero ();
|
||||
|
||||
reverse_balance = gnc_reverse_balance(account);
|
||||
|
||||
/* update the starting balance */
|
||||
if (recnData->use_shares)
|
||||
{
|
||||
starting = xaccAccountGetShareReconciledBalance(recnData->account);
|
||||
print_info = gnc_account_quantity_print_info (recnData->account, TRUE);
|
||||
starting = xaccAccountGetShareReconciledBalance(account);
|
||||
print_info = gnc_account_quantity_print_info (account, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
starting = xaccAccountGetReconciledBalance(recnData->account);
|
||||
print_info = gnc_account_value_print_info (recnData->account, TRUE);
|
||||
starting = xaccAccountGetReconciledBalance(account);
|
||||
print_info = gnc_account_value_print_info (account, TRUE);
|
||||
}
|
||||
|
||||
if (reverse_balance)
|
||||
@@ -390,7 +400,7 @@ startRecnWindow(GtkWidget *parent, Account *account,
|
||||
gtk_widget_grab_focus(end_value);
|
||||
}
|
||||
|
||||
while (1)
|
||||
while (TRUE)
|
||||
{
|
||||
result = gnome_dialog_run(GNOME_DIALOG(dialog));
|
||||
|
||||
@@ -458,12 +468,12 @@ gnc_reconcile_window_double_click_cb(GNCReconcileList *list, Split *split,
|
||||
if (split == NULL)
|
||||
return;
|
||||
|
||||
regData = regWindowSimple(recnData->account);
|
||||
regData = regWindowSimple (recn_get_account (recnData));
|
||||
if (regData == NULL)
|
||||
return;
|
||||
|
||||
gnc_register_raise(regData);
|
||||
gnc_register_jump_to_split_amount(regData, split);
|
||||
gnc_register_raise (regData);
|
||||
gnc_register_jump_to_split_amount (regData, split);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -666,11 +676,11 @@ gnc_ui_reconcile_window_help_cb(GtkWidget *widget, gpointer data)
|
||||
static void
|
||||
gnc_ui_reconcile_window_change_cb(GtkButton *button, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = (RecnWindow *) data;
|
||||
RecnWindow *recnData = data;
|
||||
gnc_numeric new_ending = recnData->new_ending;
|
||||
time_t statement_date = recnData->statement_date;
|
||||
|
||||
if (startRecnWindow(recnData->window, recnData->account,
|
||||
if (startRecnWindow(recnData->window, recn_get_account (recnData),
|
||||
&new_ending, &statement_date))
|
||||
{
|
||||
recnData->new_ending = new_ending;
|
||||
@@ -682,15 +692,15 @@ gnc_ui_reconcile_window_change_cb(GtkButton *button, gpointer data)
|
||||
static void
|
||||
gnc_ui_reconcile_window_new_cb(GtkButton *button, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = (RecnWindow *) data;
|
||||
RecnWindow *recnData = data;
|
||||
RegWindow *regData;
|
||||
|
||||
regData = regWindowSimple(recnData->account);
|
||||
regData = regWindowSimple (recn_get_account (recnData));
|
||||
if (regData == NULL)
|
||||
return;
|
||||
|
||||
gnc_register_raise(regData);
|
||||
gnc_register_jump_to_blank(regData);
|
||||
gnc_register_raise (regData);
|
||||
gnc_register_jump_to_blank (regData);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -753,17 +763,17 @@ gnc_ui_reconcile_window_edit_cb(GtkButton *button, gpointer data)
|
||||
RegWindow *regData;
|
||||
Split *split;
|
||||
|
||||
split = gnc_reconcile_window_get_current_split(recnData);
|
||||
split = gnc_reconcile_window_get_current_split (recnData);
|
||||
/* This should never be true, but be paranoid */
|
||||
if (split == NULL)
|
||||
return;
|
||||
|
||||
regData = regWindowSimple(recnData->account);
|
||||
regData = regWindowSimple (recn_get_account (recnData));
|
||||
if (regData == NULL)
|
||||
return;
|
||||
|
||||
gnc_register_raise(regData);
|
||||
gnc_register_jump_to_split_amount(regData, split);
|
||||
gnc_register_raise (regData);
|
||||
gnc_register_jump_to_split_amount (regData, split);
|
||||
}
|
||||
|
||||
|
||||
@@ -786,62 +796,65 @@ gnc_recn_set_window_name(RecnWindow *recnData)
|
||||
{
|
||||
char *title;
|
||||
|
||||
title = gnc_recn_make_window_name(recnData->account);
|
||||
title = gnc_recn_make_window_name (recn_get_account (recnData));
|
||||
|
||||
gtk_window_set_title(GTK_WINDOW(recnData->window), title);
|
||||
gtk_window_set_title (GTK_WINDOW (recnData->window), title);
|
||||
|
||||
g_free(title);
|
||||
g_free (title);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_recn_edit_account_cb(GtkWidget * w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
Account *account = recnData->account;
|
||||
Account *account = recn_get_account (recnData);
|
||||
|
||||
if (account == NULL)
|
||||
return;
|
||||
|
||||
gnc_ui_edit_account_window(account);
|
||||
gnc_ui_edit_account_window (account);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_recn_xfer_cb(GtkWidget * w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
Account *account = recnData->account;
|
||||
Account *account = recn_get_account (recnData);
|
||||
|
||||
if (account == NULL)
|
||||
return;
|
||||
|
||||
gnc_xfer_dialog(recnData->window, account);
|
||||
gnc_xfer_dialog (recnData->window, account);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_recn_scrub_cb(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
Account *account = recnData->account;
|
||||
Account *account = recn_get_account (recnData);
|
||||
|
||||
if (account == NULL)
|
||||
return;
|
||||
|
||||
xaccAccountTreeScrubOrphans(account);
|
||||
xaccAccountTreeScrubImbalance(account);
|
||||
xaccAccountTreeScrubOrphans (account);
|
||||
xaccAccountTreeScrubImbalance (account);
|
||||
|
||||
gnc_account_ui_refresh(account);
|
||||
gnc_refresh_main_window();
|
||||
gnc_account_ui_refresh (account);
|
||||
gnc_refresh_main_window ();
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_recn_open_cb(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
Account *account = recnData->account;
|
||||
Account *account = recn_get_account (recnData);
|
||||
RegWindow *regData;
|
||||
|
||||
regData = regWindowSimple(account);
|
||||
gnc_register_raise(regData);
|
||||
if (!account)
|
||||
return;
|
||||
|
||||
regData = regWindowSimple (account);
|
||||
gnc_register_raise (regData);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1288,7 +1301,34 @@ find_by_account (gpointer find_data, gpointer user_data)
|
||||
if (!recnData)
|
||||
return FALSE;
|
||||
|
||||
return (recnData->account == account);
|
||||
return guid_equal (&recnData->account, xaccAccountGetGUID (account));
|
||||
}
|
||||
|
||||
static void
|
||||
refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
{
|
||||
RecnWindow *recnData = user_data;
|
||||
const EventInfo *info;
|
||||
Account *account;
|
||||
|
||||
account = recn_get_account (recnData);
|
||||
if (!account)
|
||||
{
|
||||
gnc_close_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData);
|
||||
return;
|
||||
}
|
||||
|
||||
if (changes)
|
||||
{
|
||||
info = gnc_gui_get_entity_events (changes, &recnData->account);
|
||||
if (info && (info->event_mask & GNC_EVENT_DESTROY))
|
||||
{
|
||||
gnc_close_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
recnRefresh (recnData);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1319,6 +1359,7 @@ recnWindow (GtkWidget *parent, Account *account)
|
||||
gnc_numeric new_ending;
|
||||
time_t statement_date;
|
||||
GNCAccountType type;
|
||||
gint component_id;
|
||||
|
||||
if (account == NULL)
|
||||
return NULL;
|
||||
@@ -1330,10 +1371,15 @@ recnWindow (GtkWidget *parent, Account *account)
|
||||
|
||||
recnData = g_new0 (RecnWindow, 1);
|
||||
|
||||
recnData->account = account;
|
||||
recnData->account = *xaccAccountGetGUID (account);
|
||||
|
||||
gnc_register_gui_component (WINDOW_RECONCILE_CM_CLASS,
|
||||
NULL, close_handler, recnData);
|
||||
component_id = gnc_register_gui_component (WINDOW_RECONCILE_CM_CLASS,
|
||||
refresh_handler, close_handler,
|
||||
recnData);
|
||||
|
||||
gnc_gui_component_watch_entity (component_id,
|
||||
xaccAccountGetGUID (account),
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
|
||||
type = xaccAccountGetType(account);
|
||||
recnData->use_shares = ((type == STOCK) || (type == MUTUAL) ||
|
||||
@@ -1519,7 +1565,7 @@ recnWindow (GtkWidget *parent, Account *account)
|
||||
}
|
||||
|
||||
/* Set up the data */
|
||||
recnRefresh(account);
|
||||
recnRefresh (recnData);
|
||||
|
||||
/* Clamp down on the size */
|
||||
{
|
||||
@@ -1591,26 +1637,6 @@ gnc_ui_reconcile_window_raise(RecnWindow * recnData)
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* Don't delete any structures -- the close callback will handle this *
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
xaccDestroyRecnWindow (Account *account)
|
||||
{
|
||||
RecnWindow *recnData = NULL;
|
||||
|
||||
DEBUG("Destroying reconcile window\n");
|
||||
|
||||
recnData = gnc_find_first_gui_component (WINDOW_RECONCILE_CM_CLASS,
|
||||
find_by_account, account);
|
||||
if (recnData == NULL)
|
||||
return;
|
||||
|
||||
gnc_close_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* recn_destroy_cb *
|
||||
* frees memory allocated for an recnWindow, and other cleanup *
|
||||
@@ -1629,13 +1655,13 @@ recn_destroy_cb (GtkWidget *w, gpointer data)
|
||||
gnc_unregister_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData);
|
||||
|
||||
id = recnData->toolbar_change_cb_id;
|
||||
gnc_unregister_option_change_callback_id(id);
|
||||
gnc_unregister_option_change_callback_id (id);
|
||||
|
||||
id = recnData->title_change_cb_id;
|
||||
gnc_unregister_option_change_callback_id(id);
|
||||
gnc_unregister_option_change_callback_id (id);
|
||||
|
||||
if (recnData->delete_refresh)
|
||||
gnc_account_ui_refresh(recnData->account);
|
||||
gnc_account_ui_refresh (recn_get_account (recnData));
|
||||
|
||||
g_free (recnData);
|
||||
}
|
||||
@@ -1717,6 +1743,7 @@ recnFinishCB (GtkWidget *w, gpointer data)
|
||||
{
|
||||
RecnWindow *recnData = data;
|
||||
gboolean auto_payment;
|
||||
Account *account;
|
||||
time_t date;
|
||||
|
||||
if (!gnc_numeric_zero_p (recnRecalculateBalance(recnData)))
|
||||
@@ -1738,20 +1765,22 @@ recnFinishCB (GtkWidget *w, gpointer data)
|
||||
"Automatic credit card payments",
|
||||
TRUE);
|
||||
|
||||
account = recn_get_account (recnData);
|
||||
|
||||
if (auto_payment &&
|
||||
(xaccAccountGetType(recnData->account) == CREDIT) &&
|
||||
(xaccAccountGetType (account) == CREDIT) &&
|
||||
(gnc_numeric_negative_p (recnData->new_ending)))
|
||||
{
|
||||
Account *payment_account;
|
||||
XferDialog *xfer;
|
||||
Account *account;
|
||||
|
||||
xfer = gnc_xfer_dialog(NULL, recnData->account);
|
||||
xfer = gnc_xfer_dialog(NULL, account);
|
||||
|
||||
gnc_xfer_dialog_set_amount(xfer, gnc_numeric_neg (recnData->new_ending));
|
||||
|
||||
account = find_payment_account(recnData->account);
|
||||
if (account != NULL)
|
||||
gnc_xfer_dialog_select_from_account(xfer, account);
|
||||
payment_account = find_payment_account (account);
|
||||
if (payment_account != NULL)
|
||||
gnc_xfer_dialog_select_from_account (xfer, payment_account);
|
||||
}
|
||||
|
||||
gnc_close_gui_component_by_data (WINDOW_RECONCILE_CM_CLASS, recnData);
|
||||
|
||||
@@ -1015,8 +1015,8 @@ new_trans_cb(GtkWidget *widget, gpointer data)
|
||||
|
||||
if (xaccSRCheckReconciled (regData->ledger->reg))
|
||||
{
|
||||
if (xaccSRSaveRegEntry(regData->ledger->reg, TRUE))
|
||||
xaccSRRedrawRegEntry(regData->ledger->reg);
|
||||
if (xaccSRSaveRegEntry (regData->ledger->reg, TRUE))
|
||||
xaccSRRedrawReg (regData->ledger->reg);
|
||||
}
|
||||
else
|
||||
xaccSRCancelCursorTransChanges (regData->ledger->reg);
|
||||
@@ -2277,7 +2277,7 @@ recordCB(GtkWidget *w, gpointer data)
|
||||
if (trans != NULL)
|
||||
gnc_register_include_date(regData, xaccTransGetDate(trans));
|
||||
|
||||
xaccSRRedrawRegEntry(regData->ledger->reg);
|
||||
xaccSRRedrawReg (regData->ledger->reg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user