[Gnucash-changes] r13297 - gnucash/trunk - Implement
new-hierarchy-druid placeholder-value merge policy as
discussed on -devel.
Joshua Sled
jsled at cvs.gnucash.org
Sun Feb 19 11:36:08 EST 2006
Author: jsled
Date: 2006-02-19 11:36:08 -0500 (Sun, 19 Feb 2006)
New Revision: 13297
Trac: http://svn.gnucash.org/trac/changeset/13297
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/app-utils/gnc-account-merge.c
gnucash/trunk/src/app-utils/gnc-account-merge.h
gnucash/trunk/src/gnome/druid-hierarchy.c
Log:
Implement new-hierarchy-druid placeholder-value merge policy as discussed on -devel.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-02-19 16:32:49 UTC (rev 13296)
+++ gnucash/trunk/ChangeLog 2006-02-19 16:36:08 UTC (rev 13297)
@@ -1,3 +1,13 @@
+2006-02-19 Joshua Sled <jsled at asynchronous.org>
+
+ * src/app-utils/gnc-account-merge.[ch]: Remove placeholder-difference
+ "ERROR" merge state.
+
+ * src/gnome/druid-hierarchy.c (placeholder_cell_data_func)
+ (on_final_account_prepare): Remove use of default
+ account-tree-model placeholder column, and substitute a column
+ that reflects the post-merge value.
+
2006-02-19 Derek Atkins <derek at ihtfp.com>
* src/engine/TransLog.c: use TABS not SPACES for column separators
Modified: gnucash/trunk/src/app-utils/gnc-account-merge.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-account-merge.c 2006-02-19 16:32:49 UTC (rev 13296)
+++ gnucash/trunk/src/app-utils/gnc-account-merge.c 2006-02-19 16:36:08 UTC (rev 13297)
@@ -12,10 +12,6 @@
if (existing_acct == NULL)
return GNC_ACCOUNT_MERGE_DISPOSITION_CREATE_NEW;
- if (xaccAccountGetPlaceholder(existing_acct) != xaccAccountGetPlaceholder(new_acct))
-/* return GNC_ACCOUNT_MERGE_DISPOSITION_ERROR;*/
- return GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING;
-
return GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING;
}
@@ -33,40 +29,6 @@
return determine_account_merge_disposition(existing_acct, new_acct);
}
-static void
-_account_merge_error_detection(AccountGroup *existing_grp, AccountGroup *new_grp, GList **error_accum)
-{
- AccountList *accts;
- for (accts = xaccGroupGetAccountList(new_grp); accts; accts = accts->next)
- {
- Account *new_acct, *existing_acct;
- GncAccountMergeDisposition disp;
-
- new_acct = (Account*)accts->data;
- existing_acct = xaccGetAccountFromName(existing_grp, xaccAccountGetName(new_acct));
- disp = determine_account_merge_disposition(existing_acct, new_acct);
- if (disp == GNC_ACCOUNT_MERGE_DISPOSITION_ERROR)
- {
- GncAccountMergeError *err = g_new0(GncAccountMergeError, 1);
- err->existing_acct = existing_acct;
- err->new_acct = new_acct;
- err->disposition = disp;
- *error_accum = g_list_append(*error_accum, err);
- }
- _account_merge_error_detection(xaccAccountGetChildren(existing_acct),
- xaccAccountGetChildren(new_acct),
- error_accum);
- }
-}
-
-GList*
-account_merge_error_detection(AccountGroup *existing_grp, AccountGroup *new_grp)
-{
- GList *errors = NULL;
- _account_merge_error_detection(existing_grp, new_grp, &errors);
- return errors;
-}
-
void
account_group_merge(AccountGroup *existing_grp, AccountGroup *new_grp)
{
@@ -89,9 +51,6 @@
existing_named = xaccGetAccountFromName(existing_grp, name);
switch (determine_account_merge_disposition(existing_named, new_acct))
{
- case GNC_ACCOUNT_MERGE_DISPOSITION_ERROR:
- g_assert_not_reached();
- return;
case GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING:
/* recurse */
account_group_merge(xaccAccountGetChildren(existing_named),
Modified: gnucash/trunk/src/app-utils/gnc-account-merge.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-account-merge.h 2006-02-19 16:32:49 UTC (rev 13296)
+++ gnucash/trunk/src/app-utils/gnc-account-merge.h 2006-02-19 16:36:08 UTC (rev 13297)
@@ -7,7 +7,6 @@
#include "Group.h"
typedef enum {
- GNC_ACCOUNT_MERGE_DISPOSITION_ERROR,
GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING,
GNC_ACCOUNT_MERGE_DISPOSITION_CREATE_NEW
} GncAccountMergeDisposition;
@@ -21,9 +20,6 @@
GncAccountMergeDisposition determine_account_merge_disposition(Account *existing_acct, Account *new_acct);
GncAccountMergeDisposition determine_merge_disposition(AccountGroup *existing_root, Account *new_acct);
-/** @return GList<GncAccountMergeError> **/
-GList* account_merge_error_detection(AccountGroup *existing_grp, AccountGroup *new_grp);
-
void account_group_merge(AccountGroup *existing_grp, AccountGroup *new_grp);
#endif /* GNC_ACCOUNT_MERGE_H */
Modified: gnucash/trunk/src/gnome/druid-hierarchy.c
===================================================================
--- gnucash/trunk/src/gnome/druid-hierarchy.c 2006-02-19 16:32:49 UTC (rev 13296)
+++ gnucash/trunk/src/gnome/druid-hierarchy.c 2006-02-19 16:36:08 UTC (rev 13297)
@@ -651,6 +651,42 @@
}
static void
+placeholder_cell_data_func (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ Account *account;
+ gboolean willbe_placeholder = FALSE;
+ GncAccountMergeDisposition disp;
+
+ g_return_if_fail (GTK_TREE_MODEL (model));
+ account = gnc_tree_view_account_get_account_from_iter (model, iter);
+ disp = determine_merge_disposition(gnc_book_get_group(gnc_get_current_book()), account);
+ switch (disp)
+ {
+ case GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING: {
+ /* find the existing account, do whatever it is. */
+ const char sep_char = '.';
+ gchar *full_name;
+ Account *existing_acct;
+ AccountGroup *root_group = gnc_book_get_group(gnc_get_current_book());
+ full_name = xaccAccountGetFullName(account, sep_char);
+ existing_acct = xaccGetAccountFromFullName(root_group, full_name, sep_char);
+ willbe_placeholder = xaccAccountGetPlaceholder(existing_acct);
+ g_free(full_name);
+ } break;
+ case GNC_ACCOUNT_MERGE_DISPOSITION_CREATE_NEW:
+ willbe_placeholder = xaccAccountGetPlaceholder(account);
+ break;
+ }
+
+ gtk_cell_renderer_toggle_set_active(GTK_CELL_RENDERER_TOGGLE(cell), willbe_placeholder);
+}
+
+
+static void
use_existing_account_data_func(GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
@@ -674,9 +710,6 @@
disposition = determine_merge_disposition(real_root, new_acct);
switch (disposition)
{
- case GNC_ACCOUNT_MERGE_DISPOSITION_ERROR:
- to_user = "error: placeholders different";
- break;
case GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING:
to_user = "yes";
break;
@@ -736,28 +769,48 @@
gtk_tree_view_set_headers_visible (tree_view, TRUE);
gnc_tree_view_configure_columns (GNC_TREE_VIEW(data->final_account_tree),
- "type", "placeholder", NULL);
+ "type", /*"placeholder", */ NULL);
gnc_tree_view_set_show_column_menu (GNC_TREE_VIEW(data->final_account_tree),
FALSE);
selection = gtk_tree_view_get_selection (tree_view);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (G_OBJECT (renderer),
- "xalign", 1.0,
- (char *)NULL);
- g_signal_connect (G_OBJECT (renderer), "edited",
- G_CALLBACK (balance_cell_edited),
- data);
- column = gtk_tree_view_column_new_with_attributes (_("Opening Balance"),
- renderer,
- NULL);
- gtk_tree_view_column_set_cell_data_func (column, renderer,
- balance_cell_data_func,
- (gpointer)data, NULL);
- gnc_tree_view_append_column (GNC_TREE_VIEW(tree_view), column);
+ // This is a re-definition of the placeholder that the account-tree model
+ // provides, reflecting the to-be-created state of the account tree
+ // post-merge.
+ {
+ renderer = gtk_cell_renderer_toggle_new();
+ g_object_set(G_OBJECT (renderer),
+ "activatable", FALSE,
+ "sensitive", FALSE,
+ NULL);
+ column = gtk_tree_view_column_new_with_attributes(_("Placeholder"),
+ renderer, NULL);
+ gtk_tree_view_column_set_cell_data_func (column, renderer,
+ placeholder_cell_data_func,
+ (gpointer)data, NULL);
+ gnc_tree_view_append_column (GNC_TREE_VIEW(tree_view), column);
+ }
+
+ {
+ renderer = gtk_cell_renderer_text_new ();
+ g_object_set (G_OBJECT (renderer),
+ "xalign", 1.0,
+ (char *)NULL);
+ g_signal_connect (G_OBJECT (renderer), "edited",
+ G_CALLBACK (balance_cell_edited),
+ data);
+ column = gtk_tree_view_column_new_with_attributes (_("Opening Balance"),
+ renderer,
+ NULL);
+ gtk_tree_view_column_set_cell_data_func (column, renderer,
+ balance_cell_data_func,
+ (gpointer)data, NULL);
+ gnc_tree_view_append_column (GNC_TREE_VIEW(tree_view), column);
+ }
+
// only in the case where there *are* existing accounts...
if (xaccGroupGetNumSubAccounts(gnc_book_get_group(gnc_get_current_book())) > 0)
{
More information about the gnucash-changes
mailing list