Manage account trees with CM.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3373 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-01-02 08:37:25 +00:00
parent 81f33862b7
commit 7a23cb473b
6 changed files with 61 additions and 133 deletions

View File

@ -28,14 +28,14 @@
/* ------------------------------------------------------ */
void
static void
xaccAccountWindowDestroySimple (Account *account)
{
xaccDestroyLedgerDisplay (account);
}
/* ------------------------------------------------------ */
void
static void
xaccAccountWindowDestroy (Account *account)
{
AccountGroup *account_children;

View File

@ -27,8 +27,6 @@
#include "Account.h"
#include "Group.h"
void xaccAccountWindowDestroy (Account *acc);
void xaccAccountWindowDestroySimple (Account *acc);
void xaccGroupWindowDestroy (AccountGroup *grp);

View File

@ -32,12 +32,15 @@
#include "FileDialog.h"
#include "account-tree.h"
#include "dialog-utils.h"
#include "gnc-component-manager.h"
#include "gnc-engine-util.h"
#include "gnc-ui-util.h"
#include "gnucash.h"
#include "messages.h"
#include "window-main.h"
#define ACCOUNT_TREE_CM_CLASS "account-tree"
/* Signal codes */
enum
{
@ -51,7 +54,6 @@ enum
/** Static Globals ****************************************************/
static GtkCTreeClass *parent_class = NULL;
static guint account_tree_signals[LAST_SIGNAL];
static GSList *account_trees = NULL;
/** Static function declarations **************************************/
@ -80,7 +82,7 @@ static void gnc_account_tree_destroy(GtkObject *object);
GtkType
gnc_account_tree_get_type()
gnc_account_tree_get_type (void)
{
static GtkType gnc_account_tree_type = 0;
@ -106,6 +108,14 @@ gnc_account_tree_get_type()
}
static void
refresh_handler (GHashTable *changes, gpointer user_data)
{
GNCAccountTree *tree = user_data;
gnc_account_tree_refresh (tree);
}
/********************************************************************\
* gnc_account_tree_new *
* creates the account tree *
@ -113,13 +123,20 @@ gnc_account_tree_get_type()
* Returns: the account tree widget, or NULL if there was a problem.*
\********************************************************************/
GtkWidget *
gnc_account_tree_new()
gnc_account_tree_new (void)
{
GtkWidget *tree;
gint component_id;
tree = GTK_WIDGET(gtk_type_new(gnc_account_tree_get_type()));
account_trees = g_slist_prepend(account_trees, tree);
component_id = gnc_register_gui_component (ACCOUNT_TREE_CM_CLASS,
refresh_handler, NULL,
tree);
gnc_gui_component_watch_entity_type (component_id,
GNC_ID_ACCOUNT,
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
return tree;
}
@ -137,21 +154,21 @@ gnc_account_tree_new()
\********************************************************************/
GtkWidget *
gnc_account_tree_new_with_root(Account * root)
gnc_account_tree_new_with_root (Account * root)
{
GNCAccountTree *tree;
tree = GNC_ACCOUNT_TREE(gnc_account_tree_new());
tree->root_account = root;
tree = GNC_ACCOUNT_TREE (gnc_account_tree_new ());
tree->root_account = *xaccAccountGetGUID (root);
return GTK_WIDGET(tree);
return GTK_WIDGET (tree);
}
static void
gnc_account_tree_init(GNCAccountTree *tree)
gnc_account_tree_init (GNCAccountTree *tree)
{
tree->root_account = NULL;
tree->root_account = *xaccGUIDNULL ();
tree->current_accounts = NULL;
tree->ignore_unselect = FALSE;
tree->filter = NULL;
@ -328,6 +345,7 @@ gnc_account_tree_refresh(GNCAccountTree * tree)
GList *current_accounts;
GtkAdjustment *adjustment;
gfloat save_value = 0.0;
Account *root_account;
adjustment = gtk_clist_get_vadjustment(GTK_CLIST(tree));
if (adjustment != NULL)
@ -341,9 +359,11 @@ gnc_account_tree_refresh(GNCAccountTree * tree)
gtk_clist_clear(clist);
root_account = xaccAccountLookup (&tree->root_account);
gnc_account_tree_fill(tree, expanded_accounts,
gnc_account_tree_insert_row(tree, NULL, NULL,
tree->root_account),
root_account),
gncGetCurrentGroup());
gtk_clist_columns_autosize(clist);
@ -366,26 +386,6 @@ gnc_account_tree_refresh(GNCAccountTree * tree)
}
static void
refresh_helper(gpointer tree, gpointer unused)
{
gnc_account_tree_refresh(GNC_ACCOUNT_TREE(tree));
}
/********************************************************************\
* gnc_account_tree_refresh_all *
* refreshes the account tree *
* *
* Args: none *
* Returns: nothing *
\********************************************************************/
void
gnc_account_tree_refresh_all()
{
g_slist_foreach(account_trees, refresh_helper, NULL);
}
/********************************************************************\
* gnc_account_tree_set_view_info *
* installs a new view information and refreshes the tree *
@ -593,63 +593,6 @@ gnc_account_tree_select_accounts(GNCAccountTree *tree,
}
/********************************************************************\
* gnc_account_tree_remove_account *
* removes an account from the tree *
* *
* Args: tree - tree to be modified *
* account - account to be inserted *
* Returns: nothing *
\********************************************************************/
void
gnc_account_tree_remove_account(GNCAccountTree *tree, Account *account)
{
GtkCTreeNode *node;
node = gtk_ctree_find_by_row_data(GTK_CTREE(tree),
NULL, account);
if (node != NULL)
gtk_ctree_remove_node(GTK_CTREE(tree), node);
}
static void
remove_helper(gpointer tree, gpointer account)
{
gnc_account_tree_remove_account(GNC_ACCOUNT_TREE(tree), account);
}
/********************************************************************\
* gnc_account_tree_remove_account_all *
* removes an account from all account trees *
* *
* Args: account - account to be inserted *
* Returns: nothing *
\********************************************************************/
void
gnc_account_tree_remove_account_all(Account *account)
{
g_slist_foreach(account_trees, remove_helper, account);
}
/********************************************************************\
* gnc_account_tree_insert_account *
* inserts a new account into the tree *
* *
* Args: tree - tree to insert account *
* account - account to be inserted *
* Returns: nothing *
\********************************************************************/
void
gnc_account_tree_insert_account(GNCAccountTree *tree, Account *account)
{
/* for now, just punt. Maybe we'll do it faster later. */
gnc_account_tree_refresh(tree);
}
/********************************************************************\
* gnc_account_tree_show_income_expense *
* shows the income/expense accounts in a tree *
@ -1067,7 +1010,7 @@ gnc_account_tree_destroy(GtkObject *object)
{
GNCAccountTree *tree = GNC_ACCOUNT_TREE(object);
account_trees = g_slist_remove(account_trees, tree);
gnc_unregister_gui_component_by_data (ACCOUNT_TREE_CM_CLASS, tree);
if (tree->deficit_style != NULL)
{

View File

@ -60,18 +60,18 @@ struct _GNCAccountTree
AccountViewInfo avi;
gint num_columns;
gint balance_column;
gint total_column;
gint column_fields[NUM_ACCOUNT_FIELDS];
gint num_columns;
gint balance_column;
gint total_column;
gint column_fields[NUM_ACCOUNT_FIELDS];
const gchar * column_headings[NUM_ACCOUNT_FIELDS + 1];
GtkStyle *deficit_style;
Account *root_account;
GUID root_account;
GList *current_accounts;
GList * current_accounts;
gboolean ignore_unselect;
};
@ -102,8 +102,6 @@ GtkWidget * gnc_account_tree_new_with_root (Account *account);
void gnc_account_tree_refresh (GNCAccountTree *tree);
void gnc_account_tree_refresh_all (void);
void gnc_account_tree_set_view_info(GNCAccountTree *tree,
AccountViewInfo *info);
@ -121,14 +119,6 @@ void gnc_account_tree_expand_account (GNCAccountTree *tree,
void gnc_account_tree_toggle_account_expansion (GNCAccountTree *tree,
Account *account);
void gnc_account_tree_insert_account (GNCAccountTree *tree,
Account *account);
void gnc_account_tree_remove_account (GNCAccountTree *tree,
Account *account);
void gnc_account_tree_remove_account_all(Account *account);
void gnc_account_tree_show_income_expense (GNCAccountTree *tree);
void gnc_account_tree_hide_income_expense (GNCAccountTree *tree);

View File

@ -106,7 +106,7 @@ gnc_ui_new_account_window_internal (Account *base_account,
static void make_account_changes(GHashTable *change_currency,
GHashTable *change_security,
GHashTable *change_type);
static void gnc_ui_refresh_edit_account_window (AccountWindow *aw);
static void gnc_ui_refresh_account_window (AccountWindow *aw);
/** Implementation *******************************************************/
@ -1476,7 +1476,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
}
}
gnc_ui_refresh_edit_account_window (aw);
gnc_ui_refresh_account_window (aw);
}
@ -1500,6 +1500,8 @@ gnc_ui_new_account_window_internal (Account *base_account,
else
aw->type = last_used_account_type;
gnc_suspend_gui_refresh ();
if (subaccount_names)
{
GList *node;
@ -1511,8 +1513,6 @@ gnc_ui_new_account_window_internal (Account *base_account,
node->data = g_strdup (node->data);
}
gnc_suspend_gui_refresh ();
gnc_account_window_create (aw);
gnc_account_to_ui (aw);
@ -1758,14 +1758,14 @@ gnc_ui_destroy_account_add_windows (void)
/********************************************************************\
* gnc_ui_refresh_edit_account_window *
* gnc_ui_refresh_account_window *
* refreshes the edit window *
* *
* Args: aw - the account window to refresh *
* Return: none *
\********************************************************************/
static void
gnc_ui_refresh_edit_account_window (AccountWindow *aw)
gnc_ui_refresh_account_window (AccountWindow *aw)
{
if (aw == NULL)
return;

View File

@ -454,7 +454,7 @@ gnc_ui_refresh_statusbar (void)
}
static void
gnc_refresh_main_window_title()
gnc_refresh_main_window_title (void)
{
GtkWidget *main_window;
GNCBook *book;
@ -480,13 +480,12 @@ gnc_refresh_main_window_title()
}
void
gnc_refresh_main_window()
gnc_refresh_main_window (void)
{
xaccRecomputeGroupBalance(gncGetCurrentGroup());
gnc_ui_refresh_statusbar();
gnc_history_update_menu();
gnc_account_tree_refresh_all();
gnc_refresh_main_window_title();
xaccRecomputeGroupBalance (gncGetCurrentGroup());
gnc_ui_refresh_statusbar ();
gnc_history_update_menu ();
gnc_refresh_main_window_title ();
}
static void
@ -542,8 +541,6 @@ gnc_ui_add_account (GtkWidget *widget, gpointer data)
static void
gnc_ui_delete_account (Account *account)
{
xaccAccountWindowDestroy (account);
gnc_suspend_gui_refresh ();
xaccRemoveAccount (account);
@ -668,12 +665,12 @@ gnc_ui_mainWindow_transfer(GtkWidget *widget, gpointer data)
static void
gnc_ui_mainWindow_scrub(GtkWidget *widget, gpointer data)
{
Account *account = gnc_get_current_account();
Account *account = gnc_get_current_account ();
if (account == NULL)
{
const char *message = _("You must select an account to scrub.");
gnc_error_dialog(message);
gnc_error_dialog (message);
return;
}
@ -689,7 +686,7 @@ gnc_ui_mainWindow_scrub(GtkWidget *widget, gpointer data)
static void
gnc_ui_mainWindow_scrub_sub(GtkWidget *widget, gpointer data)
{
Account *account = gnc_get_current_account();
Account *account = gnc_get_current_account ();
if (account == NULL)
{
@ -710,7 +707,7 @@ gnc_ui_mainWindow_scrub_sub(GtkWidget *widget, gpointer data)
static void
gnc_ui_mainWindow_scrub_all(GtkWidget *widget, gpointer data)
{
AccountGroup *group = gncGetCurrentGroup();
AccountGroup *group = gncGetCurrentGroup ();
gnc_suspend_gui_refresh ();
@ -1387,7 +1384,6 @@ mainWindow()
{
GNCMainInfo *main_info;
GtkWidget *app = gnc_get_ui_data();
GtkWidget *account_tree;
GtkWidget *statusbar;
int width = 0;
int height = 0;
@ -1448,9 +1444,8 @@ mainWindow()
/* create scrolled window */
account_tree = gnc_mainwin_account_tree_new();
main_info->account_tree = account_tree;
gnome_app_set_contents(GNOME_APP(app), account_tree);
main_info->account_tree = gnc_mainwin_account_tree_new();
gnome_app_set_contents(GNOME_APP(app), main_info->account_tree);
gnc_main_create_menus(GNOME_APP(app), main_info->account_tree, main_info);
@ -1484,7 +1479,9 @@ mainWindow()
gnc_configure_account_tree(NULL);
gnc_refresh_main_window();
gnc_refresh_main_window ();
gnc_account_tree_refresh
(GNC_MAINWIN_ACCOUNT_TREE (main_info->account_tree)->acc_tree);
gnc_account_set_sensititives(main_info, FALSE);