r18790 - gnucash/trunk/src/register - Re-indentation of source code, next batch: src/register/*
Christian Stimming
cstim at code.gnucash.org
Tue Mar 2 16:41:40 EST 2010
Author: cstim
Date: 2010-03-02 16:41:39 -0500 (Tue, 02 Mar 2010)
New Revision: 18790
Trac: http://svn.gnucash.org/trac/changeset/18790
Modified:
gnucash/trunk/src/register/ledger-core/dialog-dup-trans.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-control.c
gnucash/trunk/src/register/ledger-core/split-register-layout.c
gnucash/trunk/src/register/ledger-core/split-register-layout.h
gnucash/trunk/src/register/ledger-core/split-register-load.c
gnucash/trunk/src/register/ledger-core/split-register-model-save.c
gnucash/trunk/src/register/ledger-core/split-register-model-save.h
gnucash/trunk/src/register/ledger-core/split-register-model.c
gnucash/trunk/src/register/ledger-core/split-register-model.h
gnucash/trunk/src/register/ledger-core/split-register-p.h
gnucash/trunk/src/register/ledger-core/split-register-util.c
gnucash/trunk/src/register/ledger-core/split-register.c
gnucash/trunk/src/register/ledger-core/split-register.h
gnucash/trunk/src/register/register-core/basiccell.c
gnucash/trunk/src/register/register-core/basiccell.h
gnucash/trunk/src/register/register-core/cell-factory.c
gnucash/trunk/src/register/register-core/cellblock.c
gnucash/trunk/src/register/register-core/cellblock.h
gnucash/trunk/src/register/register-core/checkboxcell.c
gnucash/trunk/src/register/register-core/checkboxcell.h
gnucash/trunk/src/register/register-core/combocell.h
gnucash/trunk/src/register/register-core/datecell.h
gnucash/trunk/src/register/register-core/formulacell.c
gnucash/trunk/src/register/register-core/formulacell.h
gnucash/trunk/src/register/register-core/gtable.c
gnucash/trunk/src/register/register-core/gtable.h
gnucash/trunk/src/register/register-core/numcell.c
gnucash/trunk/src/register/register-core/numcell.h
gnucash/trunk/src/register/register-core/pricecell.c
gnucash/trunk/src/register/register-core/pricecell.h
gnucash/trunk/src/register/register-core/quickfillcell.c
gnucash/trunk/src/register/register-core/quickfillcell.h
gnucash/trunk/src/register/register-core/recncell.c
gnucash/trunk/src/register/register-core/recncell.h
gnucash/trunk/src/register/register-core/register-common.c
gnucash/trunk/src/register/register-core/register-common.h
gnucash/trunk/src/register/register-core/table-allgui.c
gnucash/trunk/src/register/register-core/table-allgui.h
gnucash/trunk/src/register/register-core/table-control.c
gnucash/trunk/src/register/register-core/table-control.h
gnucash/trunk/src/register/register-core/table-layout.c
gnucash/trunk/src/register/register-core/table-layout.h
gnucash/trunk/src/register/register-core/table-model.c
gnucash/trunk/src/register/register-core/table-model.h
gnucash/trunk/src/register/register-core/test/test-link-module.c
gnucash/trunk/src/register/register-gnome/combocell-gnome.c
gnucash/trunk/src/register/register-gnome/datecell-gnome.c
gnucash/trunk/src/register/register-gnome/formulacell-gnome.c
gnucash/trunk/src/register/register-gnome/gnucash-color.c
gnucash/trunk/src/register/register-gnome/gnucash-cursor.c
gnucash/trunk/src/register/register-gnome/gnucash-cursor.h
gnucash/trunk/src/register/register-gnome/gnucash-date-picker.c
gnucash/trunk/src/register/register-gnome/gnucash-date-picker.h
gnucash/trunk/src/register/register-gnome/gnucash-grid.c
gnucash/trunk/src/register/register-gnome/gnucash-grid.h
gnucash/trunk/src/register/register-gnome/gnucash-header.c
gnucash/trunk/src/register/register-gnome/gnucash-header.h
gnucash/trunk/src/register/register-gnome/gnucash-item-edit.c
gnucash/trunk/src/register/register-gnome/gnucash-item-edit.h
gnucash/trunk/src/register/register-gnome/gnucash-item-list.c
gnucash/trunk/src/register/register-gnome/gnucash-item-list.h
gnucash/trunk/src/register/register-gnome/gnucash-scrolled-window.c
gnucash/trunk/src/register/register-gnome/gnucash-scrolled-window.h
gnucash/trunk/src/register/register-gnome/gnucash-sheet.c
gnucash/trunk/src/register/register-gnome/gnucash-sheet.h
gnucash/trunk/src/register/register-gnome/gnucash-style.c
gnucash/trunk/src/register/register-gnome/gnucash-style.h
gnucash/trunk/src/register/register-gnome/pricecell-gnome.c
gnucash/trunk/src/register/register-gnome/quickfillcell-gnome.c
gnucash/trunk/src/register/register-gnome/table-gnome.c
gnucash/trunk/src/register/register-gnome/test/test-link-module.c
Log:
Re-indentation of source code, next batch: src/register/*
This also strips trailing whitespaces from lines where they existed.
This re-indentation was done using astyle-1.24 using the following options:
astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none
Modified: gnucash/trunk/src/register/ledger-core/dialog-dup-trans.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/dialog-dup-trans.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/dialog-dup-trans.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -39,12 +39,12 @@
typedef struct
{
- GtkWidget * dialog;
+ GtkWidget * dialog;
- gboolean focus_out;
+ gboolean focus_out;
- GtkWidget * date_edit;
- GtkWidget * num_edit;
+ GtkWidget * date_edit;
+ GtkWidget * num_edit;
} DupTransDialog;
@@ -54,95 +54,95 @@
static gboolean
parse_num (const char *string, long int *num)
{
- long int number;
+ long int number;
- if (string == NULL)
- return FALSE;
+ if (string == NULL)
+ return FALSE;
- if (!gnc_strisnum(string))
- return FALSE;
+ if (!gnc_strisnum(string))
+ return FALSE;
- number = strtol(string, NULL, 10);
+ number = strtol(string, NULL, 10);
- if ((number == LONG_MIN) || (number == LONG_MAX))
- return FALSE;
+ if ((number == LONG_MIN) || (number == LONG_MAX))
+ return FALSE;
- if (num != NULL)
- *num = number;
+ if (num != NULL)
+ *num = number;
- return TRUE;
+ return TRUE;
}
static gboolean
gnc_dup_trans_output_cb(GtkSpinButton *spinbutton,
gpointer user_data)
{
- gboolean is_number;
- long int num;
- gchar *txt = gtk_editable_get_chars(GTK_EDITABLE(spinbutton), 0, -1);
- is_number = parse_num(txt, &num);
- g_free(txt);
- if (!is_number)
- gtk_entry_set_text(GTK_ENTRY(spinbutton), "");
- return !is_number;
+ gboolean is_number;
+ long int num;
+ gchar *txt = gtk_editable_get_chars(GTK_EDITABLE(spinbutton), 0, -1);
+ is_number = parse_num(txt, &num);
+ g_free(txt);
+ if (!is_number)
+ gtk_entry_set_text(GTK_ENTRY(spinbutton), "");
+ return !is_number;
}
static void
gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog,
time_t date, const char *num_str)
{
- GtkWidget *dialog;
- GladeXML *xml;
+ GtkWidget *dialog;
+ GladeXML *xml;
- xml = gnc_glade_xml_new ("register.glade", "Duplicate Transaction Dialog");
+ xml = gnc_glade_xml_new ("register.glade", "Duplicate Transaction Dialog");
- dialog = glade_xml_get_widget (xml, "Duplicate Transaction Dialog");
- dt_dialog->dialog = dialog;
+ dialog = glade_xml_get_widget (xml, "Duplicate Transaction Dialog");
+ dt_dialog->dialog = dialog;
- /* parent */
- if (parent != NULL)
- gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+ /* parent */
+ if (parent != NULL)
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
- /* date widget */
- {
- GtkWidget *date_edit;
- GtkWidget *hbox;
- GtkWidget *label;
+ /* date widget */
+ {
+ GtkWidget *date_edit;
+ GtkWidget *hbox;
+ GtkWidget *label;
- date_edit = gnc_date_edit_new (date, FALSE, FALSE);
- gnc_date_activates_default(GNC_DATE_EDIT(date_edit), TRUE);
- hbox = glade_xml_get_widget (xml, "date_hbox");
- gtk_widget_show (date_edit);
+ date_edit = gnc_date_edit_new (date, FALSE, FALSE);
+ gnc_date_activates_default(GNC_DATE_EDIT(date_edit), TRUE);
+ hbox = glade_xml_get_widget (xml, "date_hbox");
+ gtk_widget_show (date_edit);
- label = glade_xml_get_widget (xml, "date_label");
- gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date_edit), label);
+ label = glade_xml_get_widget (xml, "date_label");
+ gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date_edit), label);
- gtk_box_pack_end (GTK_BOX (hbox), date_edit, TRUE, TRUE, 0);
- dt_dialog->date_edit = date_edit;
- }
+ gtk_box_pack_end (GTK_BOX (hbox), date_edit, TRUE, TRUE, 0);
+ dt_dialog->date_edit = date_edit;
+ }
- {
- GtkWidget *num_spin;
- long int num;
+ {
+ GtkWidget *num_spin;
+ long int num;
- num_spin = glade_xml_get_widget (xml, "num_spin");
- dt_dialog->num_edit = num_spin;
+ num_spin = glade_xml_get_widget (xml, "num_spin");
+ dt_dialog->num_edit = num_spin;
- gtk_entry_set_activates_default(GTK_ENTRY(num_spin), TRUE);
- g_signal_connect(num_spin, "output",
- G_CALLBACK(gnc_dup_trans_output_cb), dt_dialog);
+ gtk_entry_set_activates_default(GTK_ENTRY(num_spin), TRUE);
+ g_signal_connect(num_spin, "output",
+ G_CALLBACK(gnc_dup_trans_output_cb), dt_dialog);
- if (num_str && parse_num (num_str, &num))
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (num_spin), num + 1);
- else
- gtk_entry_set_text (GTK_ENTRY (num_spin), "");
- }
+ if (num_str && parse_num (num_str, &num))
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (num_spin), num + 1);
+ else
+ gtk_entry_set_text (GTK_ENTRY (num_spin), "");
+ }
}
/********************************************************************\
* gnc_dup_trans_dialog *
* opens up a window to do an automatic transfer between accounts *
- * *
+ * *
* Args: parent - the parent of the window to be created *
* date - the initial date to use, and the output *
* parameter for the new date *
@@ -154,37 +154,37 @@
gnc_dup_trans_dialog (GtkWidget * parent, time_t *date_p,
const char *num, char **out_num)
{
- DupTransDialog *dt_dialog;
- GNCDateEdit *gde;
- GtkWidget *entry;
- gboolean ok;
- gint result;
+ DupTransDialog *dt_dialog;
+ GNCDateEdit *gde;
+ GtkWidget *entry;
+ gboolean ok;
+ gint result;
- if (!date_p || !out_num)
- return FALSE;
+ if (!date_p || !out_num)
+ return FALSE;
- dt_dialog = g_new0 (DupTransDialog, 1);
+ dt_dialog = g_new0 (DupTransDialog, 1);
- gnc_dup_trans_dialog_create (parent, dt_dialog, *date_p, num);
+ gnc_dup_trans_dialog_create (parent, dt_dialog, *date_p, num);
- gde = GNC_DATE_EDIT (dt_dialog->date_edit);
- entry = gde->date_entry;
+ gde = GNC_DATE_EDIT (dt_dialog->date_edit);
+ entry = gde->date_entry;
- gtk_widget_grab_focus (entry);
+ gtk_widget_grab_focus (entry);
- result = gtk_dialog_run (GTK_DIALOG (dt_dialog->dialog));
+ result = gtk_dialog_run (GTK_DIALOG (dt_dialog->dialog));
- if (result == GTK_RESPONSE_OK)
- {
- *date_p = gnc_date_edit_get_date (GNC_DATE_EDIT (dt_dialog->date_edit));
- *out_num = g_strdup (gtk_entry_get_text (GTK_ENTRY (dt_dialog->num_edit)));
- ok = TRUE;
- }
- else
- ok = FALSE;
+ if (result == GTK_RESPONSE_OK)
+ {
+ *date_p = gnc_date_edit_get_date (GNC_DATE_EDIT (dt_dialog->date_edit));
+ *out_num = g_strdup (gtk_entry_get_text (GTK_ENTRY (dt_dialog->num_edit)));
+ ok = TRUE;
+ }
+ else
+ ok = FALSE;
- gtk_widget_destroy(GTK_WIDGET(dt_dialog->dialog));
- g_free (dt_dialog);
+ gtk_widget_destroy(GTK_WIDGET(dt_dialog->dialog));
+ g_free (dt_dialog);
- return ok;
+ return ok;
}
Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -51,23 +51,23 @@
struct gnc_ledger_display
{
- GUID leader;
+ GUID leader;
- Query *query;
+ Query *query;
- GNCLedgerDisplayType ld_type;
+ GNCLedgerDisplayType ld_type;
- SplitRegister *reg;
+ SplitRegister *reg;
- gboolean loading;
- gboolean use_double_line_default;
+ gboolean loading;
+ gboolean use_double_line_default;
- GNCLedgerDisplayDestroy destroy;
- GNCLedgerDisplayGetParent get_parent;
+ GNCLedgerDisplayDestroy destroy;
+ GNCLedgerDisplayGetParent get_parent;
- gpointer user_data;
+ gpointer user_data;
- gint component_id;
+ gint component_id;
};
@@ -84,7 +84,7 @@
gboolean use_double_line,
gboolean is_template);
static void gnc_ledger_display_refresh_internal (GNCLedgerDisplay *ld,
- GList *splits);
+ GList *splits);
/** Implementations *************************************************/
@@ -92,37 +92,37 @@
Account *
gnc_ledger_display_leader (GNCLedgerDisplay *ld)
{
- if (!ld)
- return NULL;
+ if (!ld)
+ return NULL;
- return xaccAccountLookup (&ld->leader, gnc_get_current_book ());
+ return xaccAccountLookup (&ld->leader, gnc_get_current_book ());
}
GNCLedgerDisplayType
gnc_ledger_display_type (GNCLedgerDisplay *ld)
{
- if (!ld)
- return -1;
+ if (!ld)
+ return -1;
- return ld->ld_type;
+ return ld->ld_type;
}
void
gnc_ledger_display_set_user_data (GNCLedgerDisplay *ld, gpointer user_data)
{
- if (!ld)
- return;
+ if (!ld)
+ return;
- ld->user_data = user_data;
+ ld->user_data = user_data;
}
gpointer
gnc_ledger_display_get_user_data (GNCLedgerDisplay *ld)
{
- if (!ld)
- return NULL;
+ if (!ld)
+ return NULL;
- return ld->user_data;
+ return ld->user_data;
}
void
@@ -130,98 +130,99 @@
GNCLedgerDisplayDestroy destroy,
GNCLedgerDisplayGetParent get_parent)
{
- if (!ld)
- return;
+ if (!ld)
+ return;
- ld->destroy = destroy;
- ld->get_parent = get_parent;
+ ld->destroy = destroy;
+ ld->get_parent = get_parent;
}
SplitRegister *
gnc_ledger_display_get_split_register (GNCLedgerDisplay *ld)
{
- if (!ld)
- return NULL;
+ if (!ld)
+ return NULL;
- return ld->reg;
+ return ld->reg;
}
Query *
gnc_ledger_display_get_query (GNCLedgerDisplay *ld)
{
- if (!ld)
- return NULL;
+ if (!ld)
+ return NULL;
- return ld->query;
+ return ld->query;
}
static gboolean
find_by_leader (gpointer find_data, gpointer user_data)
{
- Account *account = find_data;
- GNCLedgerDisplay *ld = user_data;
+ Account *account = find_data;
+ GNCLedgerDisplay *ld = user_data;
- if (!account || !ld)
- return FALSE;
+ if (!account || !ld)
+ return FALSE;
- return (account == gnc_ledger_display_leader (ld));
+ return (account == gnc_ledger_display_leader (ld));
}
static gboolean
find_by_query (gpointer find_data, gpointer user_data)
{
- Query *q = find_data;
- GNCLedgerDisplay *ld = user_data;
+ Query *q = find_data;
+ GNCLedgerDisplay *ld = user_data;
- if (!q || !ld)
- return FALSE;
+ if (!q || !ld)
+ return FALSE;
- return ld->query == q;
+ return ld->query == q;
}
static gboolean
find_by_reg (gpointer find_data, gpointer user_data)
{
- SplitRegister *reg = find_data;
- GNCLedgerDisplay *ld = user_data;
+ SplitRegister *reg = find_data;
+ GNCLedgerDisplay *ld = user_data;
- if (!reg || !ld)
- return FALSE;
+ if (!reg || !ld)
+ return FALSE;
- return ld->reg == reg;
+ return ld->reg == reg;
}
static SplitRegisterStyle
gnc_get_default_register_style (GNCAccountType type)
{
- SplitRegisterStyle new_style = REG_STYLE_LEDGER;
- gchar *style_string;
+ SplitRegisterStyle new_style = REG_STYLE_LEDGER;
+ gchar *style_string;
- switch (type) {
+ switch (type)
+ {
#if 0
- case ACCT_TYPE_PAYABLE:
- case ACCT_TYPE_RECEIVABLE:
- new_style = REG_STYLE_LEDGER;
- break;
+ case ACCT_TYPE_PAYABLE:
+ case ACCT_TYPE_RECEIVABLE:
+ new_style = REG_STYLE_LEDGER;
+ break;
#endif
- default:
- style_string = gnc_gconf_get_string(GCONF_GENERAL_REGISTER,
- "default_style", NULL);
- if (safe_strcmp(style_string, "journal") == 0)
- new_style = REG_STYLE_JOURNAL;
- else if (safe_strcmp(style_string, "auto_ledger") == 0)
- new_style = REG_STYLE_AUTO_LEDGER;
- else
- new_style = REG_STYLE_LEDGER;
+ default:
+ style_string = gnc_gconf_get_string(GCONF_GENERAL_REGISTER,
+ "default_style", NULL);
+ if (safe_strcmp(style_string, "journal") == 0)
+ new_style = REG_STYLE_JOURNAL;
+ else if (safe_strcmp(style_string, "auto_ledger") == 0)
+ new_style = REG_STYLE_AUTO_LEDGER;
+ else
+ new_style = REG_STYLE_LEDGER;
- if (style_string != NULL)
- g_free(style_string);
+ if (style_string != NULL)
+ g_free(style_string);
- break;
- }
+ break;
+ }
- return new_style;
+ return new_style;
}
static gpointer
@@ -233,72 +234,72 @@
static SplitRegisterType
gnc_get_reg_type (Account *leader, GNCLedgerDisplayType ld_type)
{
- GNCAccountType account_type;
- SplitRegisterType reg_type;
+ GNCAccountType account_type;
+ SplitRegisterType reg_type;
- if (ld_type == LD_GL)
- return GENERAL_LEDGER;
+ if (ld_type == LD_GL)
+ return GENERAL_LEDGER;
- account_type = xaccAccountGetType (leader);
+ account_type = xaccAccountGetType (leader);
- if (ld_type == LD_SINGLE)
- {
- switch (account_type)
+ if (ld_type == LD_SINGLE)
{
- case ACCT_TYPE_BANK:
- return BANK_REGISTER;
+ switch (account_type)
+ {
+ case ACCT_TYPE_BANK:
+ return BANK_REGISTER;
- case ACCT_TYPE_CASH:
- return CASH_REGISTER;
+ case ACCT_TYPE_CASH:
+ return CASH_REGISTER;
- case ACCT_TYPE_ASSET:
- return ASSET_REGISTER;
+ case ACCT_TYPE_ASSET:
+ return ASSET_REGISTER;
- case ACCT_TYPE_CREDIT:
- return CREDIT_REGISTER;
+ case ACCT_TYPE_CREDIT:
+ return CREDIT_REGISTER;
- case ACCT_TYPE_LIABILITY:
- return LIABILITY_REGISTER;
+ case ACCT_TYPE_LIABILITY:
+ return LIABILITY_REGISTER;
- case ACCT_TYPE_PAYABLE:
- return PAYABLE_REGISTER;
+ case ACCT_TYPE_PAYABLE:
+ return PAYABLE_REGISTER;
- case ACCT_TYPE_RECEIVABLE:
- return RECEIVABLE_REGISTER;
+ case ACCT_TYPE_RECEIVABLE:
+ return RECEIVABLE_REGISTER;
- case ACCT_TYPE_STOCK:
- case ACCT_TYPE_MUTUAL:
- return STOCK_REGISTER;
+ case ACCT_TYPE_STOCK:
+ case ACCT_TYPE_MUTUAL:
+ return STOCK_REGISTER;
- case ACCT_TYPE_INCOME:
- return INCOME_REGISTER;
+ case ACCT_TYPE_INCOME:
+ return INCOME_REGISTER;
- case ACCT_TYPE_EXPENSE:
- return EXPENSE_REGISTER;
+ case ACCT_TYPE_EXPENSE:
+ return EXPENSE_REGISTER;
- case ACCT_TYPE_EQUITY:
- return EQUITY_REGISTER;
+ case ACCT_TYPE_EQUITY:
+ return EQUITY_REGISTER;
- case ACCT_TYPE_CURRENCY:
- return CURRENCY_REGISTER;
-
- case ACCT_TYPE_TRADING:
- return TRADING_REGISTER;
+ case ACCT_TYPE_CURRENCY:
+ return CURRENCY_REGISTER;
- default:
- PERR ("unknown account type %d\n", account_type);
+ case ACCT_TYPE_TRADING:
+ return TRADING_REGISTER;
+
+ default:
+ PERR ("unknown account type %d\n", account_type);
+ return BANK_REGISTER;
+ }
+ }
+
+ if (ld_type != LD_SUBACCOUNT)
+ {
+ PERR ("unknown ledger type %d\n", ld_type);
return BANK_REGISTER;
}
- }
- if (ld_type != LD_SUBACCOUNT)
- {
- PERR ("unknown ledger type %d\n", ld_type);
- return BANK_REGISTER;
- }
-
- switch (account_type)
- {
+ switch (account_type)
+ {
case ACCT_TYPE_BANK:
case ACCT_TYPE_CASH:
case ACCT_TYPE_ASSET:
@@ -307,40 +308,40 @@
case ACCT_TYPE_RECEIVABLE:
case ACCT_TYPE_PAYABLE:
{
- /* If any of the sub-accounts have ACCT_TYPE_STOCK or
- * ACCT_TYPE_MUTUAL types, then we must use the PORTFOLIO_LEDGER
- * ledger. Otherwise, a plain old GENERAL_LEDGER will do. */
- gpointer ret;
- reg_type = GENERAL_LEDGER;
+ /* If any of the sub-accounts have ACCT_TYPE_STOCK or
+ * ACCT_TYPE_MUTUAL types, then we must use the PORTFOLIO_LEDGER
+ * ledger. Otherwise, a plain old GENERAL_LEDGER will do. */
+ gpointer ret;
+ reg_type = GENERAL_LEDGER;
- ret = gnc_account_foreach_descendant_until(leader, look_for_portfolio_cb, NULL);
- if (ret) reg_type = PORTFOLIO_LEDGER;
- break;
+ ret = gnc_account_foreach_descendant_until(leader, look_for_portfolio_cb, NULL);
+ if (ret) reg_type = PORTFOLIO_LEDGER;
+ break;
}
case ACCT_TYPE_STOCK:
case ACCT_TYPE_MUTUAL:
case ACCT_TYPE_CURRENCY:
- reg_type = PORTFOLIO_LEDGER;
- break;
+ reg_type = PORTFOLIO_LEDGER;
+ break;
case ACCT_TYPE_INCOME:
case ACCT_TYPE_EXPENSE:
- reg_type = INCOME_LEDGER;
- break;
+ reg_type = INCOME_LEDGER;
+ break;
case ACCT_TYPE_EQUITY:
case ACCT_TYPE_TRADING:
- reg_type = GENERAL_LEDGER;
- break;
+ reg_type = GENERAL_LEDGER;
+ break;
default:
- PERR ("unknown account type:%d", account_type);
- reg_type = GENERAL_LEDGER;
- break;
- }
+ PERR ("unknown account type:%d", account_type);
+ reg_type = GENERAL_LEDGER;
+ break;
+ }
- return reg_type;
+ return reg_type;
}
/* Returns a boolean of whether this display should be single or double lined
@@ -348,38 +349,39 @@
gboolean
gnc_ledger_display_default_double_line (GNCLedgerDisplay *gld)
{
- return (gld->use_double_line_default ||
- gnc_gconf_get_bool(GCONF_GENERAL_REGISTER, "double_line_mode", NULL));
+ return (gld->use_double_line_default ||
+ gnc_gconf_get_bool(GCONF_GENERAL_REGISTER, "double_line_mode", NULL));
}
/* Opens up a register window to display a single account */
GNCLedgerDisplay *
gnc_ledger_display_simple (Account *account)
{
- SplitRegisterType reg_type;
- GNCAccountType acc_type = xaccAccountGetType (account);
- gboolean use_double_line;
- GNCLedgerDisplay *ld;
+ SplitRegisterType reg_type;
+ GNCAccountType acc_type = xaccAccountGetType (account);
+ gboolean use_double_line;
+ GNCLedgerDisplay *ld;
- ENTER("account=%p", account);
+ ENTER("account=%p", account);
- switch (acc_type) {
- case ACCT_TYPE_PAYABLE:
- case ACCT_TYPE_RECEIVABLE:
- use_double_line = TRUE;
- break;
- default:
- use_double_line = FALSE;
- break;
- }
+ switch (acc_type)
+ {
+ case ACCT_TYPE_PAYABLE:
+ case ACCT_TYPE_RECEIVABLE:
+ use_double_line = TRUE;
+ break;
+ default:
+ use_double_line = FALSE;
+ break;
+ }
- reg_type = gnc_get_reg_type (account, LD_SINGLE);
+ reg_type = gnc_get_reg_type (account, LD_SINGLE);
- ld = gnc_ledger_display_internal (account, NULL, LD_SINGLE, reg_type,
- gnc_get_default_register_style(acc_type),
- use_double_line, FALSE);
- LEAVE("%p", ld);
- return ld;
+ ld = gnc_ledger_display_internal (account, NULL, LD_SINGLE, reg_type,
+ gnc_get_default_register_style(acc_type),
+ use_double_line, FALSE);
+ LEAVE("%p", ld);
+ return ld;
}
/* Opens up a register window to display an account, and all of its
@@ -387,65 +389,65 @@
GNCLedgerDisplay *
gnc_ledger_display_subaccounts (Account *account)
{
- SplitRegisterType reg_type;
- GNCLedgerDisplay *ld;
+ SplitRegisterType reg_type;
+ GNCLedgerDisplay *ld;
- ENTER("account=%p", account);
+ ENTER("account=%p", account);
- reg_type = gnc_get_reg_type (account, LD_SUBACCOUNT);
+ reg_type = gnc_get_reg_type (account, LD_SUBACCOUNT);
- ld = gnc_ledger_display_internal (account, NULL, LD_SUBACCOUNT,
- reg_type, REG_STYLE_JOURNAL, FALSE,
- FALSE);
- LEAVE("%p", ld);
- return ld;
+ ld = gnc_ledger_display_internal (account, NULL, LD_SUBACCOUNT,
+ reg_type, REG_STYLE_JOURNAL, FALSE,
+ FALSE);
+ LEAVE("%p", ld);
+ return ld;
}
/* Opens up a general ledger window. */
GNCLedgerDisplay *
gnc_ledger_display_gl (void)
{
- Query *query;
- time_t start;
- struct tm tm;
- GNCLedgerDisplay *ld;
+ Query *query;
+ time_t start;
+ struct tm tm;
+ GNCLedgerDisplay *ld;
- ENTER(" ");
+ ENTER(" ");
- query = xaccMallocQuery ();
+ query = xaccMallocQuery ();
- xaccQuerySetBook (query, gnc_get_current_book());
+ xaccQuerySetBook (query, gnc_get_current_book());
- /* In lieu of not "mis-using" some portion of the infrastructure by writing
- * a bunch of new code, we just filter out the accounts of the template
- * transactions. While these are in a seperate Account trees just for this
- * reason, the query engine makes no distinction between Account trees.
- * See Gnome Bug 86302.
- * -- jsled */
- {
- Account *tRoot;
- GList *al;
-
- tRoot = gnc_book_get_template_root( gnc_get_current_book() );
- al = gnc_account_get_descendants( tRoot );
- xaccQueryAddAccountMatch( query, al, GUID_MATCH_NONE, QUERY_AND );
- g_list_free (al);
- al = NULL;
- tRoot = NULL;
- }
+ /* In lieu of not "mis-using" some portion of the infrastructure by writing
+ * a bunch of new code, we just filter out the accounts of the template
+ * transactions. While these are in a seperate Account trees just for this
+ * reason, the query engine makes no distinction between Account trees.
+ * See Gnome Bug 86302.
+ * -- jsled */
+ {
+ Account *tRoot;
+ GList *al;
- gnc_tm_get_today_start(&tm);
- tm.tm_mon--; /* Default the register to the last month's worth of transactions. */
- start = mktime (&tm);
- xaccQueryAddDateMatchTT (query,
- TRUE, start,
- FALSE, 0,
- QUERY_AND);
+ tRoot = gnc_book_get_template_root( gnc_get_current_book() );
+ al = gnc_account_get_descendants( tRoot );
+ xaccQueryAddAccountMatch( query, al, GUID_MATCH_NONE, QUERY_AND );
+ g_list_free (al);
+ al = NULL;
+ tRoot = NULL;
+ }
- ld = gnc_ledger_display_internal (NULL, query, LD_GL, GENERAL_LEDGER,
- REG_STYLE_JOURNAL, FALSE, FALSE);
- LEAVE("%p", ld);
- return ld;
+ gnc_tm_get_today_start(&tm);
+ tm.tm_mon--; /* Default the register to the last month's worth of transactions. */
+ start = mktime (&tm);
+ xaccQueryAddDateMatchTT (query,
+ TRUE, start,
+ FALSE, 0,
+ QUERY_AND);
+
+ ld = gnc_ledger_display_internal (NULL, query, LD_GL, GENERAL_LEDGER,
+ REG_STYLE_JOURNAL, FALSE, FALSE);
+ LEAVE("%p", ld);
+ return ld;
}
/**
@@ -459,160 +461,162 @@
GNCLedgerDisplay *
gnc_ledger_display_template_gl (char *id)
{
- QofBook *book;
- Query *q;
- GNCLedgerDisplay *ld;
- SplitRegister *sr;
- Account *root, *acct;
- gboolean isTemplateModeTrue;
+ QofBook *book;
+ Query *q;
+ GNCLedgerDisplay *ld;
+ SplitRegister *sr;
+ Account *root, *acct;
+ gboolean isTemplateModeTrue;
- ENTER("id=%s", id? id : "(null)");
+ ENTER("id=%s", id ? id : "(null)");
- acct = NULL;
- isTemplateModeTrue = TRUE;
+ acct = NULL;
+ isTemplateModeTrue = TRUE;
- q = xaccMallocQuery ();
+ q = xaccMallocQuery ();
- book = gnc_get_current_book ();
- xaccQuerySetBook (q, book);
+ book = gnc_get_current_book ();
+ xaccQuerySetBook (q, book);
- if ( id != NULL ) {
- root = gnc_book_get_template_root (book);
- acct = gnc_account_lookup_by_name(root, id);
- g_assert( acct );
- xaccQueryAddSingleAccountMatch (q, acct, QUERY_AND);
- }
+ if ( id != NULL )
+ {
+ root = gnc_book_get_template_root (book);
+ acct = gnc_account_lookup_by_name(root, id);
+ g_assert( acct );
+ xaccQueryAddSingleAccountMatch (q, acct, QUERY_AND);
+ }
- ld = gnc_ledger_display_internal (NULL, q, LD_GL,
- SEARCH_LEDGER,
- REG_STYLE_JOURNAL,
- FALSE,
- isTemplateModeTrue);
+ ld = gnc_ledger_display_internal (NULL, q, LD_GL,
+ SEARCH_LEDGER,
+ REG_STYLE_JOURNAL,
+ FALSE,
+ isTemplateModeTrue);
- sr = gnc_ledger_display_get_split_register (ld);
- if ( acct ) {
- gnc_split_register_set_template_account (sr, acct);
- }
+ sr = gnc_ledger_display_get_split_register (ld);
+ if ( acct )
+ {
+ gnc_split_register_set_template_account (sr, acct);
+ }
- LEAVE("%p", ld);
- return ld;
+ LEAVE("%p", ld);
+ return ld;
}
gncUIWidget
gnc_ledger_display_get_parent( GNCLedgerDisplay *ld )
{
- if ( ld == NULL )
- return NULL;
+ if ( ld == NULL )
+ return NULL;
- if ( ld->get_parent == NULL )
- return NULL;
+ if ( ld->get_parent == NULL )
+ return NULL;
- return ld->get_parent( ld );
+ return ld->get_parent( ld );
}
static gncUIWidget
gnc_ledger_display_parent (void *user_data)
{
- GNCLedgerDisplay *ld = user_data;
- return gnc_ledger_display_get_parent( ld );
+ GNCLedgerDisplay *ld = user_data;
+ return gnc_ledger_display_get_parent( ld );
}
static void
gnc_ledger_display_set_watches (GNCLedgerDisplay *ld, GList *splits)
{
- GList *node;
+ GList *node;
- gnc_gui_component_clear_watches (ld->component_id);
+ gnc_gui_component_clear_watches (ld->component_id);
- gnc_gui_component_watch_entity_type (ld->component_id,
- GNC_ID_ACCOUNT,
- QOF_EVENT_MODIFY | QOF_EVENT_DESTROY
- | GNC_EVENT_ITEM_CHANGED);
+ gnc_gui_component_watch_entity_type (ld->component_id,
+ GNC_ID_ACCOUNT,
+ QOF_EVENT_MODIFY | QOF_EVENT_DESTROY
+ | GNC_EVENT_ITEM_CHANGED);
- for (node = splits; node; node = node->next)
- {
- Split *split = node->data;
- Transaction *trans = xaccSplitGetParent (split);
+ for (node = splits; node; node = node->next)
+ {
+ Split *split = node->data;
+ Transaction *trans = xaccSplitGetParent (split);
- gnc_gui_component_watch_entity (ld->component_id,
- xaccTransGetGUID (trans),
- QOF_EVENT_MODIFY);
- }
+ gnc_gui_component_watch_entity (ld->component_id,
+ xaccTransGetGUID (trans),
+ QOF_EVENT_MODIFY);
+ }
}
static void
refresh_handler (GHashTable *changes, gpointer user_data)
{
- GNCLedgerDisplay *ld = user_data;
- const EventInfo *info;
- gboolean has_leader;
- GList *splits;
+ GNCLedgerDisplay *ld = user_data;
+ const EventInfo *info;
+ gboolean has_leader;
+ GList *splits;
- ENTER("changes=%p, user_data=%p", changes, user_data);
+ ENTER("changes=%p, user_data=%p", changes, user_data);
- if (ld->loading)
- {
- LEAVE("already loading");
- return;
- }
+ if (ld->loading)
+ {
+ LEAVE("already loading");
+ return;
+ }
- has_leader = (ld->ld_type == LD_SINGLE || ld->ld_type == LD_SUBACCOUNT);
+ has_leader = (ld->ld_type == LD_SINGLE || ld->ld_type == LD_SUBACCOUNT);
- if (has_leader)
- {
- Account *leader = gnc_ledger_display_leader (ld);
- if (!leader)
+ if (has_leader)
{
- gnc_close_gui_component (ld->component_id);
- LEAVE("no leader");
- return;
+ Account *leader = gnc_ledger_display_leader (ld);
+ if (!leader)
+ {
+ gnc_close_gui_component (ld->component_id);
+ LEAVE("no leader");
+ return;
+ }
}
- }
- if (changes && has_leader)
- {
- info = gnc_gui_get_entity_events (changes, &ld->leader);
- if (info && (info->event_mask & QOF_EVENT_DESTROY))
+ if (changes && has_leader)
{
- gnc_close_gui_component (ld->component_id);
- LEAVE("destroy");
- return;
+ info = gnc_gui_get_entity_events (changes, &ld->leader);
+ if (info && (info->event_mask & QOF_EVENT_DESTROY))
+ {
+ gnc_close_gui_component (ld->component_id);
+ LEAVE("destroy");
+ return;
+ }
}
- }
- /* Its not clear if we should re-run the query, or if we should
- * just use qof_query_last_run(). Its possible that the dates
- * changed, requiring a full new query. Similar considerations
- * needed for multi-user mode.
- */
- splits = qof_query_run (ld->query);
+ /* Its not clear if we should re-run the query, or if we should
+ * just use qof_query_last_run(). Its possible that the dates
+ * changed, requiring a full new query. Similar considerations
+ * needed for multi-user mode.
+ */
+ splits = qof_query_run (ld->query);
- gnc_ledger_display_set_watches (ld, splits);
+ gnc_ledger_display_set_watches (ld, splits);
- gnc_ledger_display_refresh_internal (ld, splits);
- LEAVE(" ");
+ gnc_ledger_display_refresh_internal (ld, splits);
+ LEAVE(" ");
}
static void
close_handler (gpointer user_data)
{
- GNCLedgerDisplay *ld = user_data;
+ GNCLedgerDisplay *ld = user_data;
- if (!ld)
- return;
+ if (!ld)
+ return;
- gnc_unregister_gui_component (ld->component_id);
+ gnc_unregister_gui_component (ld->component_id);
- if (ld->destroy)
- ld->destroy (ld);
+ if (ld->destroy)
+ ld->destroy (ld);
- gnc_split_register_destroy (ld->reg);
- ld->reg = NULL;
+ gnc_split_register_destroy (ld->reg);
+ ld->reg = NULL;
- xaccFreeQuery (ld->query);
- ld->query = NULL;
+ xaccFreeQuery (ld->query);
+ ld->query = NULL;
- g_free (ld);
+ g_free (ld);
}
static void
@@ -620,51 +624,51 @@
gint limit,
SplitRegisterType type)
{
- Account *leader;
- GList *accounts;
+ Account *leader;
+ GList *accounts;
- if (!ld)
- return;
+ if (!ld)
+ return;
- switch (ld->ld_type)
- {
+ switch (ld->ld_type)
+ {
case LD_SINGLE:
case LD_SUBACCOUNT:
- break;
+ break;
case LD_GL:
- return;
+ return;
default:
- PERR ("unknown ledger type: %d", ld->ld_type);
- return;
- }
+ PERR ("unknown ledger type: %d", ld->ld_type);
+ return;
+ }
- xaccFreeQuery (ld->query);
- ld->query = xaccMallocQuery ();
+ xaccFreeQuery (ld->query);
+ ld->query = xaccMallocQuery ();
- /* This is a bit of a hack. The number of splits should be
- * configurable, or maybe we should go back a time range instead
- * of picking a number, or maybe we should be able to exclude
- * based on reconciled status. Anyway, this works for now. */
- if ((limit != 0) && (type != SEARCH_LEDGER))
- xaccQuerySetMaxSplits (ld->query, limit);
+ /* This is a bit of a hack. The number of splits should be
+ * configurable, or maybe we should go back a time range instead
+ * of picking a number, or maybe we should be able to exclude
+ * based on reconciled status. Anyway, this works for now. */
+ if ((limit != 0) && (type != SEARCH_LEDGER))
+ xaccQuerySetMaxSplits (ld->query, limit);
- xaccQuerySetBook (ld->query, gnc_get_current_book());
+ xaccQuerySetBook (ld->query, gnc_get_current_book());
- leader = gnc_ledger_display_leader (ld);
+ leader = gnc_ledger_display_leader (ld);
- if (ld->ld_type == LD_SUBACCOUNT)
- accounts = gnc_account_get_descendants (leader);
- else
- accounts = NULL;
+ if (ld->ld_type == LD_SUBACCOUNT)
+ accounts = gnc_account_get_descendants (leader);
+ else
+ accounts = NULL;
- accounts = g_list_prepend (accounts, leader);
+ accounts = g_list_prepend (accounts, leader);
- xaccQueryAddAccountMatch (ld->query, accounts,
- GUID_MATCH_ANY, QUERY_AND);
+ xaccQueryAddAccountMatch (ld->query, accounts,
+ GUID_MATCH_ANY, QUERY_AND);
- g_list_free (accounts);
+ g_list_free (accounts);
}
/* Opens up a ledger window for an arbitrary query. */
@@ -672,14 +676,14 @@
gnc_ledger_display_query (Query *query, SplitRegisterType type,
SplitRegisterStyle style)
{
- GNCLedgerDisplay *ld;
+ GNCLedgerDisplay *ld;
- ENTER("query=%p", query);
+ ENTER("query=%p", query);
- ld = gnc_ledger_display_internal (NULL, query, LD_GL, type, style,
- FALSE, FALSE);
- LEAVE("%p", ld);
- return ld;
+ ld = gnc_ledger_display_internal (NULL, query, LD_GL, type, style,
+ FALSE, FALSE);
+ LEAVE("%p", ld);
+ return ld;
}
static GNCLedgerDisplay *
@@ -690,137 +694,137 @@
gboolean use_double_line,
gboolean is_template )
{
- GNCLedgerDisplay *ld;
- gint limit;
- const char *class;
- GList *splits;
+ GNCLedgerDisplay *ld;
+ gint limit;
+ const char *class;
+ GList *splits;
- switch (ld_type)
- {
+ switch (ld_type)
+ {
case LD_SINGLE:
- class = REGISTER_SINGLE_CM_CLASS;
+ class = REGISTER_SINGLE_CM_CLASS;
- if (reg_type >= NUM_SINGLE_REGISTER_TYPES)
- {
- PERR ("single-account register with wrong split register type");
- return NULL;
- }
+ if (reg_type >= NUM_SINGLE_REGISTER_TYPES)
+ {
+ PERR ("single-account register with wrong split register type");
+ return NULL;
+ }
- if (!lead_account)
- {
- PERR ("single-account register with no account specified");
- return NULL;
- }
+ if (!lead_account)
+ {
+ PERR ("single-account register with no account specified");
+ return NULL;
+ }
- if (q)
- {
- PWARN ("single-account register with external query");
- q = NULL;
- }
+ if (q)
+ {
+ PWARN ("single-account register with external query");
+ q = NULL;
+ }
- ld = gnc_find_first_gui_component (class, find_by_leader, lead_account);
- if (ld)
- return ld;
+ ld = gnc_find_first_gui_component (class, find_by_leader, lead_account);
+ if (ld)
+ return ld;
- break;
+ break;
case LD_SUBACCOUNT:
- class = REGISTER_SUBACCOUNT_CM_CLASS;
+ class = REGISTER_SUBACCOUNT_CM_CLASS;
- if (!lead_account)
- {
- PERR ("sub-account register with no lead account");
- return NULL;
- }
+ if (!lead_account)
+ {
+ PERR ("sub-account register with no lead account");
+ return NULL;
+ }
- if (q)
- {
- PWARN ("account register with external query");
- q = NULL;
- }
+ if (q)
+ {
+ PWARN ("account register with external query");
+ q = NULL;
+ }
- ld = gnc_find_first_gui_component (class, find_by_leader, lead_account);
- if (ld)
- return ld;
+ ld = gnc_find_first_gui_component (class, find_by_leader, lead_account);
+ if (ld)
+ return ld;
- break;
+ break;
case LD_GL:
- class = REGISTER_GL_CM_CLASS;
+ class = REGISTER_GL_CM_CLASS;
- if (!q)
- {
- PWARN ("general ledger with no query");
- }
+ if (!q)
+ {
+ PWARN ("general ledger with no query");
+ }
- break;
+ break;
default:
- PERR ("bad ledger type: %d", ld_type);
- return NULL;
+ PERR ("bad ledger type: %d", ld_type);
+ return NULL;
- }
+ }
- ld = g_new (GNCLedgerDisplay, 1);
+ ld = g_new (GNCLedgerDisplay, 1);
- ld->leader = *xaccAccountGetGUID (lead_account);
- ld->query = NULL;
- ld->ld_type = ld_type;
- ld->loading = FALSE;
- ld->destroy = NULL;
- ld->get_parent = NULL;
- ld->user_data = NULL;
+ ld->leader = *xaccAccountGetGUID (lead_account);
+ ld->query = NULL;
+ ld->ld_type = ld_type;
+ ld->loading = FALSE;
+ ld->destroy = NULL;
+ ld->get_parent = NULL;
+ ld->user_data = NULL;
- limit = gnc_gconf_get_float(GCONF_GENERAL_REGISTER, "max_transactions", NULL);
+ limit = gnc_gconf_get_float(GCONF_GENERAL_REGISTER, "max_transactions", NULL);
- /* set up the query filter */
- if (q)
- ld->query = xaccQueryCopy (q);
- else
- gnc_ledger_display_make_query (ld, limit, reg_type);
+ /* set up the query filter */
+ if (q)
+ ld->query = xaccQueryCopy (q);
+ else
+ gnc_ledger_display_make_query (ld, limit, reg_type);
- ld->component_id = gnc_register_gui_component (class,
- refresh_handler,
- close_handler, ld);
+ ld->component_id = gnc_register_gui_component (class,
+ refresh_handler,
+ close_handler, ld);
- /******************************************************************\
- * The main register window itself *
- \******************************************************************/
+ /******************************************************************\
+ * The main register window itself *
+ \******************************************************************/
- ld->use_double_line_default = use_double_line;
- ld->reg = gnc_split_register_new (reg_type, style, use_double_line,
- is_template);
+ ld->use_double_line_default = use_double_line;
+ ld->reg = gnc_split_register_new (reg_type, style, use_double_line,
+ is_template);
- gnc_split_register_set_data (ld->reg, ld, gnc_ledger_display_parent);
+ gnc_split_register_set_data (ld->reg, ld, gnc_ledger_display_parent);
- splits = qof_query_run (ld->query);
+ splits = qof_query_run (ld->query);
- gnc_ledger_display_set_watches (ld, splits);
+ gnc_ledger_display_set_watches (ld, splits);
- gnc_ledger_display_refresh_internal (ld, splits);
+ gnc_ledger_display_refresh_internal (ld, splits);
- return ld;
+ return ld;
}
void
gnc_ledger_display_set_query (GNCLedgerDisplay *ledger_display, Query *q)
{
- if (!ledger_display || !q)
- return;
+ if (!ledger_display || !q)
+ return;
- g_return_if_fail (ledger_display->ld_type == LD_GL);
+ g_return_if_fail (ledger_display->ld_type == LD_GL);
- xaccFreeQuery (ledger_display->query);
- ledger_display->query = xaccQueryCopy (q);
+ xaccFreeQuery (ledger_display->query);
+ ledger_display->query = xaccQueryCopy (q);
}
GNCLedgerDisplay *
gnc_ledger_display_find_by_query (Query *q)
{
- if (!q)
- return NULL;
+ if (!q)
+ return NULL;
- return gnc_find_first_gui_component (REGISTER_GL_CM_CLASS, find_by_query, q);
+ return gnc_find_first_gui_component (REGISTER_GL_CM_CLASS, find_by_query, q);
}
/********************************************************************\
@@ -830,86 +834,86 @@
static void
gnc_ledger_display_refresh_internal (GNCLedgerDisplay *ld, GList *splits)
{
- if (!ld || ld->loading)
- return;
+ if (!ld || ld->loading)
+ return;
- if (!gnc_split_register_full_refresh_ok (ld->reg))
- return;
+ if (!gnc_split_register_full_refresh_ok (ld->reg))
+ return;
- ld->loading = TRUE;
+ ld->loading = TRUE;
- gnc_split_register_load (ld->reg, splits,
- gnc_ledger_display_leader (ld));
+ gnc_split_register_load (ld->reg, splits,
+ gnc_ledger_display_leader (ld));
- ld->loading = FALSE;
+ ld->loading = FALSE;
}
void
gnc_ledger_display_refresh (GNCLedgerDisplay *ld)
{
- ENTER("ld=%p", ld);
+ ENTER("ld=%p", ld);
- if (!ld)
- {
- LEAVE("no display");
- return;
- }
+ if (!ld)
+ {
+ LEAVE("no display");
+ return;
+ }
- if (ld->loading)
- {
- LEAVE("already loading");
- return;
- }
+ if (ld->loading)
+ {
+ LEAVE("already loading");
+ return;
+ }
- gnc_ledger_display_refresh_internal (ld, xaccQueryGetSplits (ld->query));
- LEAVE(" ");
+ gnc_ledger_display_refresh_internal (ld, xaccQueryGetSplits (ld->query));
+ LEAVE(" ");
}
void
gnc_ledger_display_refresh_by_split_register (SplitRegister *reg)
{
- GNCLedgerDisplay *ld;
+ GNCLedgerDisplay *ld;
- if (!reg)
- return;
+ if (!reg)
+ return;
- ld = gnc_find_first_gui_component (REGISTER_SINGLE_CM_CLASS,
- find_by_reg, reg);
- if (ld)
- {
- gnc_ledger_display_refresh (ld);
- return;
- }
+ ld = gnc_find_first_gui_component (REGISTER_SINGLE_CM_CLASS,
+ find_by_reg, reg);
+ if (ld)
+ {
+ gnc_ledger_display_refresh (ld);
+ return;
+ }
- ld = gnc_find_first_gui_component (REGISTER_SUBACCOUNT_CM_CLASS,
- find_by_reg, reg);
- if (ld)
- {
- gnc_ledger_display_refresh (ld);
- return;
- }
+ ld = gnc_find_first_gui_component (REGISTER_SUBACCOUNT_CM_CLASS,
+ find_by_reg, reg);
+ if (ld)
+ {
+ gnc_ledger_display_refresh (ld);
+ return;
+ }
- ld = gnc_find_first_gui_component (REGISTER_GL_CM_CLASS,
- find_by_reg, reg);
- if (ld)
- {
- gnc_ledger_display_refresh (ld);
- return;
- }
+ ld = gnc_find_first_gui_component (REGISTER_GL_CM_CLASS,
+ find_by_reg, reg);
+ if (ld)
+ {
+ gnc_ledger_display_refresh (ld);
+ return;
+ }
- ld = gnc_find_first_gui_component (REGISTER_TEMPLATE_CM_CLASS,
- find_by_reg, reg );
- if (ld)
- {
- gnc_ledger_display_refresh (ld);
- }
+ ld = gnc_find_first_gui_component (REGISTER_TEMPLATE_CM_CLASS,
+ find_by_reg, reg );
+ if (ld)
+ {
+ gnc_ledger_display_refresh (ld);
+ }
}
void
gnc_ledger_display_close (GNCLedgerDisplay *ld)
{
- if (!ld)
- return;
+ if (!ld)
+ return;
- gnc_close_gui_component (ld->component_id);
+ gnc_close_gui_component (ld->component_id);
}
Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -44,13 +44,13 @@
typedef void (*GNCLedgerDisplayDestroy) (GNCLedgerDisplay *ld);
typedef gncUIWidget (*GNCLedgerDisplayGetParent) (GNCLedgerDisplay *ld);
typedef void (*GNCLedgerDisplaySetHelp) (GNCLedgerDisplay *ld,
- const char *help_str);
+ const char *help_str);
typedef enum
{
- LD_SINGLE,
- LD_SUBACCOUNT,
- LD_GL,
+ LD_SINGLE,
+ LD_SUBACCOUNT,
+ LD_GL,
} GNCLedgerDisplayType;
@@ -98,8 +98,8 @@
/* display a general ledger for an arbitrary query */
GNCLedgerDisplay * gnc_ledger_display_query (Query *query,
- SplitRegisterType type,
- SplitRegisterStyle style);
+ SplitRegisterType type,
+ SplitRegisterStyle style);
/* Set the query used for a register. */
void gnc_ledger_display_set_query (GNCLedgerDisplay *ledger_display,
Modified: gnucash/trunk/src/register/ledger-core/split-register-control.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-control.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-control.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -63,72 +63,74 @@
if (xaccTransIsBalanced (trans))
- return FALSE;
-
- if (xaccTransUseTradingAccounts (trans)) {
- MonetaryList *imbal_list;
- gnc_monetary *imbal_mon;
- imbal_list = xaccTransGetImbalance (trans);
-
- /* See if the imbalance is only in the transaction's currency */
- if (!imbal_list)
- /* Value imbalance, but not commodity imbalance. This shouldn't
- be something that scrubbing can cause to happen. Perhaps someone
- entered invalid splits. */
- multi_currency = TRUE;
- else {
- imbal_mon = imbal_list->data;
- if (!imbal_list->next &&
- gnc_commodity_equiv(gnc_monetary_commodity(*imbal_mon),
- xaccTransGetCurrency(trans)))
- multi_currency = FALSE;
- else
- multi_currency = TRUE;
- }
-
- /* We're done with the imbalance list, the real work will be done
- by xaccTransScrubImbalance which will get it again. */
- gnc_monetary_list_free(imbal_list);
+ return FALSE;
+
+ if (xaccTransUseTradingAccounts (trans))
+ {
+ MonetaryList *imbal_list;
+ gnc_monetary *imbal_mon;
+ imbal_list = xaccTransGetImbalance (trans);
+
+ /* See if the imbalance is only in the transaction's currency */
+ if (!imbal_list)
+ /* Value imbalance, but not commodity imbalance. This shouldn't
+ be something that scrubbing can cause to happen. Perhaps someone
+ entered invalid splits. */
+ multi_currency = TRUE;
+ else
+ {
+ imbal_mon = imbal_list->data;
+ if (!imbal_list->next &&
+ gnc_commodity_equiv(gnc_monetary_commodity(*imbal_mon),
+ xaccTransGetCurrency(trans)))
+ multi_currency = FALSE;
+ else
+ multi_currency = TRUE;
+ }
+
+ /* We're done with the imbalance list, the real work will be done
+ by xaccTransScrubImbalance which will get it again. */
+ gnc_monetary_list_free(imbal_list);
}
- else
- multi_currency = FALSE;
-
+ else
+ multi_currency = FALSE;
+
split = xaccTransGetSplit (trans, 0);
other_split = xaccSplitGetOtherSplit (split);
-
+
if (other_split == NULL)
{
- /* Attempt to handle the inverted many-to-one mapping */
- split = xaccTransGetSplit (trans, 1);
- if (split) other_split = xaccSplitGetOtherSplit (split);
- else split = xaccTransGetSplit (trans, 0);
+ /* Attempt to handle the inverted many-to-one mapping */
+ split = xaccTransGetSplit (trans, 1);
+ if (split) other_split = xaccSplitGetOtherSplit (split);
+ else split = xaccTransGetSplit (trans, 0);
}
if (other_split == NULL || multi_currency)
{
- two_accounts = FALSE;
- other_account = NULL;
+ two_accounts = FALSE;
+ other_account = NULL;
}
else
{
- two_accounts = TRUE;
- other_account = xaccSplitGetAccount (other_split);
+ two_accounts = TRUE;
+ other_account = xaccSplitGetAccount (other_split);
}
default_account = gnc_split_register_get_default_account (reg);
-
+
/* If the two pointers are the same, the account from other_split
* is actually the default account. We must make other_account
* the account from split instead. */
-
+
if (default_account == other_account)
- other_account = xaccSplitGetAccount (split);
+ other_account = xaccSplitGetAccount (split);
/* If the two pointers are still the same, we have two splits, but
* they both refer to the same account. While non-sensical, we don't
* object. */
if (default_account == other_account)
- two_accounts = FALSE;
+ two_accounts = FALSE;
radio_list = g_list_append (radio_list,
_("Balance it _manually"));
@@ -137,46 +139,46 @@
if (reg->type < NUM_SINGLE_REGISTER_TYPES && !multi_currency)
{
- radio_list = g_list_append (radio_list,
- _("Adjust current account _split total"));
+ radio_list = g_list_append (radio_list,
+ _("Adjust current account _split total"));
- default_value = 2;
- if (two_accounts)
- {
- radio_list = g_list_append (radio_list,
- _("Adjust _other account split total"));
- default_value = 3;
- }
+ default_value = 2;
+ if (two_accounts)
+ {
+ radio_list = g_list_append (radio_list,
+ _("Adjust _other account split total"));
+ default_value = 3;
+ }
}
else
- default_value = 0;
+ default_value = 0;
choice = gnc_choose_radio_option_dialog
- (gnc_split_register_get_parent (reg),
- title,
- message,
- _("_Rebalance"),
- default_value,
- radio_list);
+ (gnc_split_register_get_parent (reg),
+ title,
+ message,
+ _("_Rebalance"),
+ default_value,
+ radio_list);
g_list_free (radio_list);
root = gnc_account_get_root(default_account);
switch (choice)
{
- default:
- case 0:
+ default:
+ case 0:
break;
- case 1:
+ case 1:
xaccTransScrubImbalance (trans, root, NULL);
break;
- case 2:
+ case 2:
xaccTransScrubImbalance (trans, root, default_account);
break;
- case 3:
+ case 3:
xaccTransScrubImbalance (trans, root, other_account);
break;
}
@@ -187,534 +189,537 @@
static gboolean
gnc_split_register_old_split_empty_p (SplitRegister *reg, Split *split)
{
- BasicCell *cell;
- gnc_numeric amount;
- const char *string;
+ BasicCell *cell;
+ gnc_numeric amount;
+ const char *string;
- string = gnc_table_layout_get_cell_value (reg->table->layout, MEMO_CELL);
- if ((string != NULL) && (*string != '\0'))
- return FALSE;
+ string = gnc_table_layout_get_cell_value (reg->table->layout, MEMO_CELL);
+ if ((string != NULL) && (*string != '\0'))
+ return FALSE;
- string = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL);
- if ((string != NULL) && (*string != '\0'))
- return FALSE;
+ string = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL);
+ if ((string != NULL) && (*string != '\0'))
+ return FALSE;
- cell = gnc_table_layout_get_cell (reg->table->layout, CRED_CELL);
- if (cell) {
- amount = gnc_price_cell_get_value ((PriceCell *) cell);
- if (!gnc_numeric_zero_p (amount))
- return FALSE;
- }
+ cell = gnc_table_layout_get_cell (reg->table->layout, CRED_CELL);
+ if (cell)
+ {
+ amount = gnc_price_cell_get_value ((PriceCell *) cell);
+ if (!gnc_numeric_zero_p (amount))
+ return FALSE;
+ }
- cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL);
- if (cell) {
- amount = gnc_price_cell_get_value ((PriceCell *) cell);
- if (!gnc_numeric_zero_p (amount))
- return FALSE;
- }
+ cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL);
+ if (cell)
+ {
+ amount = gnc_price_cell_get_value ((PriceCell *) cell);
+ if (!gnc_numeric_zero_p (amount))
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/* Checks a cell for an account change and takes any necessary action if
* one has occurred. Returns TRUE if the check passes, FALSE if it fails. */
static gboolean
-gnc_split_register_check_account (SplitRegister *reg,
+gnc_split_register_check_account (SplitRegister *reg,
const char *cell_name)
{
- SRInfo *info;
- ComboCell *cell = NULL;
- PriceCell *rate_cell;
- Account* new_acct;
- char *name;
+ SRInfo *info;
+ ComboCell *cell = NULL;
+ PriceCell *rate_cell;
+ Account* new_acct;
+ char *name;
- g_return_val_if_fail(reg, TRUE);
+ g_return_val_if_fail(reg, TRUE);
- /* See if we are leaving an account field */
- if (gnc_cell_name_equal (cell_name, XFRM_CELL))
- {
- if (gnc_table_layout_get_cell_changed (reg->table->layout,
- XFRM_CELL, FALSE))
- cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout,
- XFRM_CELL);
- }
- else if (gnc_cell_name_equal (cell_name, MXFRM_CELL))
- {
- if (gnc_table_layout_get_cell_changed (reg->table->layout,
- MXFRM_CELL, FALSE))
- cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout,
- MXFRM_CELL);
- }
+ /* See if we are leaving an account field */
+ if (gnc_cell_name_equal (cell_name, XFRM_CELL))
+ {
+ if (gnc_table_layout_get_cell_changed (reg->table->layout,
+ XFRM_CELL, FALSE))
+ cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout,
+ XFRM_CELL);
+ }
+ else if (gnc_cell_name_equal (cell_name, MXFRM_CELL))
+ {
+ if (gnc_table_layout_get_cell_changed (reg->table->layout,
+ MXFRM_CELL, FALSE))
+ cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout,
+ MXFRM_CELL);
+ }
- if (!cell)
- return TRUE;
+ if (!cell)
+ return TRUE;
- /* The account has been changed. */
- name = cell->cell.value;
- DEBUG("Changed to %s", name ? name : "NULL");
- if (!name || *name == '\0' ||
- safe_strcmp (name, SPLIT_TRANS_STR) == 0 ||
- safe_strcmp (name, STOCK_SPLIT_STR) == 0)
- return TRUE;
+ /* The account has been changed. */
+ name = cell->cell.value;
+ DEBUG("Changed to %s", name ? name : "NULL");
+ if (!name || *name == '\0' ||
+ safe_strcmp (name, SPLIT_TRANS_STR) == 0 ||
+ safe_strcmp (name, STOCK_SPLIT_STR) == 0)
+ return TRUE;
- /* Create the account if necessary. Also checks for a placeholder. */
- info = gnc_split_register_get_info (reg);
- new_acct = gnc_split_register_get_account_by_name (reg,
- (BasicCell *) cell,
- cell->cell.value,
- &info->full_refresh);
- if (!new_acct)
- return FALSE;
+ /* Create the account if necessary. Also checks for a placeholder. */
+ info = gnc_split_register_get_info (reg);
+ new_acct = gnc_split_register_get_account_by_name (reg,
+ (BasicCell *) cell,
+ cell->cell.value,
+ &info->full_refresh);
+ if (!new_acct)
+ return FALSE;
- /* See if we need to reset the exchange rate. */
- rate_cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- RATE_CELL);
- if (rate_cell)
- {
- Split *split = gnc_split_register_get_current_split(reg);
- Account *orig_acct = xaccSplitGetAccount(split);
- gnc_commodity *orig_com = xaccAccountGetCommodity(orig_acct);
- gnc_commodity *last_com = xaccAccountGetCommodity(info->rate_account);
- gnc_commodity *new_com = xaccAccountGetCommodity(new_acct);
-
- if (gnc_commodity_equal(last_com? last_com : orig_com, new_com))
+ /* See if we need to reset the exchange rate. */
+ rate_cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ RATE_CELL);
+ if (rate_cell)
{
- DEBUG("Commodity is still %s. Leaving rate unchanged.",
- new_com ? gnc_commodity_get_mnemonic(new_com) : "NULL");
- }
- else if (!gnc_commodity_equal(orig_com, new_com))
- {
- /* The commodity has changed but is not the original. Reset the rate. */
- DEBUG("Commodity now %s (originally %s). Clearing rate.",
- new_com ? gnc_commodity_get_mnemonic(new_com) : "NULL",
- orig_com ? gnc_commodity_get_mnemonic(orig_com) : "NULL");
+ Split *split = gnc_split_register_get_current_split(reg);
+ Account *orig_acct = xaccSplitGetAccount(split);
+ gnc_commodity *orig_com = xaccAccountGetCommodity(orig_acct);
+ gnc_commodity *last_com = xaccAccountGetCommodity(info->rate_account);
+ gnc_commodity *new_com = xaccAccountGetCommodity(new_acct);
- gnc_price_cell_set_value (rate_cell, gnc_numeric_zero());
- info->rate_account = new_acct;
- info->rate_reset = TRUE;
- }
- else
- {
- /* Get the original rate from the split. */
- gnc_numeric amt = xaccSplitGetAmount(split);
- gnc_numeric val = xaccSplitGetValue(split);
- gnc_numeric orig_rate = gnc_numeric_div(amt, val, GNC_DENOM_AUTO,
- GNC_DENOM_REDUCE);
+ if (gnc_commodity_equal(last_com ? last_com : orig_com, new_com))
+ {
+ DEBUG("Commodity is still %s. Leaving rate unchanged.",
+ new_com ? gnc_commodity_get_mnemonic(new_com) : "NULL");
+ }
+ else if (!gnc_commodity_equal(orig_com, new_com))
+ {
+ /* The commodity has changed but is not the original. Reset the rate. */
+ DEBUG("Commodity now %s (originally %s). Clearing rate.",
+ new_com ? gnc_commodity_get_mnemonic(new_com) : "NULL",
+ orig_com ? gnc_commodity_get_mnemonic(orig_com) : "NULL");
- if (!gnc_numeric_check(orig_rate))
- {
- DEBUG("Using original rate of %s.",
- gnc_num_dbg_to_string(orig_rate));
- gnc_price_cell_set_value (rate_cell, orig_rate);
- info->rate_account = new_acct;
- info->rate_reset = FALSE;
- }
- else
- {
- DEBUG("Can't get rate. Using zero.");
- gnc_price_cell_set_value (rate_cell, gnc_numeric_zero());
- info->rate_account = new_acct;
- info->rate_reset = TRUE;
- }
+ gnc_price_cell_set_value (rate_cell, gnc_numeric_zero());
+ info->rate_account = new_acct;
+ info->rate_reset = TRUE;
+ }
+ else
+ {
+ /* Get the original rate from the split. */
+ gnc_numeric amt = xaccSplitGetAmount(split);
+ gnc_numeric val = xaccSplitGetValue(split);
+ gnc_numeric orig_rate = gnc_numeric_div(amt, val, GNC_DENOM_AUTO,
+ GNC_DENOM_REDUCE);
+
+ if (!gnc_numeric_check(orig_rate))
+ {
+ DEBUG("Using original rate of %s.",
+ gnc_num_dbg_to_string(orig_rate));
+ gnc_price_cell_set_value (rate_cell, orig_rate);
+ info->rate_account = new_acct;
+ info->rate_reset = FALSE;
+ }
+ else
+ {
+ DEBUG("Can't get rate. Using zero.");
+ gnc_price_cell_set_value (rate_cell, gnc_numeric_zero());
+ info->rate_account = new_acct;
+ info->rate_reset = TRUE;
+ }
+ }
}
- }
- return TRUE;
+ return TRUE;
}
static void
gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
gpointer user_data)
{
- VirtualLocation new_virt_loc = *p_new_virt_loc;
- VirtualCellLocation old_trans_split_loc;
- SplitRegister *reg = user_data;
- Transaction *pending_trans;
- Transaction *new_trans;
- Transaction *old_trans;
- Split *old_trans_split;
- Split *new_trans_split;
- Split *new_split;
- Split *old_split;
- CursorClass new_class;
- CursorClass old_class;
- gboolean exact_traversal;
- gboolean do_refresh;
- gboolean saved;
- SRInfo *info;
+ VirtualLocation new_virt_loc = *p_new_virt_loc;
+ VirtualCellLocation old_trans_split_loc;
+ SplitRegister *reg = user_data;
+ Transaction *pending_trans;
+ Transaction *new_trans;
+ Transaction *old_trans;
+ Split *old_trans_split;
+ Split *new_trans_split;
+ Split *new_split;
+ Split *old_split;
+ CursorClass new_class;
+ CursorClass old_class;
+ gboolean exact_traversal;
+ gboolean do_refresh;
+ gboolean saved;
+ SRInfo *info;
- ENTER("reg=%p, p_new_virt_loc=%p (%d, %d)",
- reg, p_new_virt_loc,
- new_virt_loc.vcell_loc.virt_row,
- new_virt_loc.vcell_loc.virt_col);
+ ENTER("reg=%p, p_new_virt_loc=%p (%d, %d)",
+ reg, p_new_virt_loc,
+ new_virt_loc.vcell_loc.virt_row,
+ new_virt_loc.vcell_loc.virt_col);
- if (!reg)
- {
- LEAVE("no register");
- return;
- }
+ if (!reg)
+ {
+ LEAVE("no register");
+ return;
+ }
- info = gnc_split_register_get_info (reg);
+ info = gnc_split_register_get_info (reg);
- /* The transaction we are coming from */
- old_split = gnc_split_register_get_current_split (reg);
- old_trans = gnc_split_register_get_current_trans (reg);
- old_trans_split =
- gnc_split_register_get_current_trans_split (reg, &old_trans_split_loc);
- old_class = gnc_split_register_get_current_cursor_class (reg);
+ /* The transaction we are coming from */
+ old_split = gnc_split_register_get_current_split (reg);
+ old_trans = gnc_split_register_get_current_trans (reg);
+ old_trans_split =
+ gnc_split_register_get_current_trans_split (reg, &old_trans_split_loc);
+ old_class = gnc_split_register_get_current_cursor_class (reg);
- exact_traversal = info->exact_traversal;
+ exact_traversal = info->exact_traversal;
- if (info->traverse_to_new)
- {
- if (old_class == CURSOR_CLASS_SPLIT)
- new_trans = old_trans;
- else
- new_trans = NULL;
+ if (info->traverse_to_new)
+ {
+ if (old_class == CURSOR_CLASS_SPLIT)
+ new_trans = old_trans;
+ else
+ new_trans = NULL;
- new_split = NULL;
- new_trans_split = NULL;
- new_class = CURSOR_CLASS_NONE;
- }
- else if (!info->hint_set_by_traverse)
- {
- /* The transaction where we are moving to */
- new_trans = gnc_split_register_get_trans (reg, new_virt_loc.vcell_loc);
+ new_split = NULL;
+ new_trans_split = NULL;
+ new_class = CURSOR_CLASS_NONE;
+ }
+ else if (!info->hint_set_by_traverse)
+ {
+ /* The transaction where we are moving to */
+ new_trans = gnc_split_register_get_trans (reg, new_virt_loc.vcell_loc);
- /* The split we are moving to */
- new_split = gnc_split_register_get_split (reg, new_virt_loc.vcell_loc);
+ /* The split we are moving to */
+ new_split = gnc_split_register_get_split (reg, new_virt_loc.vcell_loc);
- /* The split at the transaction line we are moving to */
- new_trans_split = gnc_split_register_get_trans_split
- (reg, new_virt_loc.vcell_loc, NULL);
+ /* The split at the transaction line we are moving to */
+ new_trans_split = gnc_split_register_get_trans_split
+ (reg, new_virt_loc.vcell_loc, NULL);
- new_class = gnc_split_register_get_cursor_class (reg,
- new_virt_loc.vcell_loc);
- }
- else
- {
- new_trans = info->cursor_hint_trans;
- new_split = info->cursor_hint_split;
- new_trans_split = info->cursor_hint_trans_split;
- new_class = info->cursor_hint_cursor_class;
- }
+ new_class = gnc_split_register_get_cursor_class (reg,
+ new_virt_loc.vcell_loc);
+ }
+ else
+ {
+ new_trans = info->cursor_hint_trans;
+ new_split = info->cursor_hint_split;
+ new_trans_split = info->cursor_hint_trans_split;
+ new_class = info->cursor_hint_cursor_class;
+ }
- info->hint_set_by_traverse = FALSE;
- info->reg_loaded = FALSE;
+ info->hint_set_by_traverse = FALSE;
+ info->reg_loaded = FALSE;
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- /* commit the contents of the cursor into the database */
- saved = gnc_split_register_save (reg, old_trans != new_trans);
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
- gnc_get_current_book ());
- if ((old_class == CURSOR_CLASS_SPLIT) &&
- old_split &&
- (old_split != new_split) &&
- gnc_split_register_old_split_empty_p(reg, old_split))
- {
- int current_row;
+ /* commit the contents of the cursor into the database */
+ saved = gnc_split_register_save (reg, old_trans != new_trans);
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
+ if ((old_class == CURSOR_CLASS_SPLIT) &&
+ old_split &&
+ (old_split != new_split) &&
+ gnc_split_register_old_split_empty_p(reg, old_split))
+ {
+ int current_row;
- xaccSplitDestroy(old_split);
- old_split = NULL;
+ xaccSplitDestroy(old_split);
+ old_split = NULL;
- /*
- * If the user is moving down a row, we've just thrown off the
- * numbers by deleting a split. Correct for that.
- */
- current_row = reg->table->current_cursor_loc.vcell_loc.virt_row;
- if (new_virt_loc.vcell_loc.virt_row > current_row)
- new_virt_loc.vcell_loc.virt_row--;
- }
- else if ((pending_trans != NULL) &&
- (pending_trans == old_trans) &&
- (old_trans != new_trans))
- {
- if (gnc_split_register_balance_trans (reg, pending_trans))
+ /*
+ * If the user is moving down a row, we've just thrown off the
+ * numbers by deleting a split. Correct for that.
+ */
+ current_row = reg->table->current_cursor_loc.vcell_loc.virt_row;
+ if (new_virt_loc.vcell_loc.virt_row > current_row)
+ new_virt_loc.vcell_loc.virt_row--;
+ }
+ else if ((pending_trans != NULL) &&
+ (pending_trans == old_trans) &&
+ (old_trans != new_trans))
{
- /* Trans was unbalanced. */
- new_trans = old_trans;
- new_split = old_split;
- new_trans_split = old_trans_split;
- new_class = old_class;
- new_virt_loc = reg->table->current_cursor_loc;
+ if (gnc_split_register_balance_trans (reg, pending_trans))
+ {
+ /* Trans was unbalanced. */
+ new_trans = old_trans;
+ new_split = old_split;
+ new_trans_split = old_trans_split;
+ new_class = old_class;
+ new_virt_loc = reg->table->current_cursor_loc;
+ }
+ else
+ {
+ /* Trans was balanced. Let it go. */
+ info->pending_trans_guid = *guid_null ();
+ if (xaccTransIsOpen (pending_trans))
+ xaccTransCommitEdit (pending_trans);
+ else g_assert_not_reached();
+
+ pending_trans = NULL;
+ saved = TRUE;
+ }
}
- else
+ else if (old_trans &&
+ (old_trans != new_trans) &&
+ !xaccTransHasReconciledSplits(old_trans) &&
+ !info->first_pass &&
+ gnc_split_register_balance_trans (reg, old_trans))
{
- /* Trans was balanced. Let it go. */
- info->pending_trans_guid = *guid_null ();
- if (xaccTransIsOpen (pending_trans))
- xaccTransCommitEdit (pending_trans);
- else g_assert_not_reached();
+ /* no matter what, stay there so the user can see what happened */
+ new_trans = old_trans;
+ new_split = old_split;
+ new_trans_split = old_trans_split;
+ new_class = old_class;
+ new_virt_loc = reg->table->current_cursor_loc;
+ }
- pending_trans = NULL;
- 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;
}
- }
- else if (old_trans &&
- (old_trans != new_trans) &&
- !xaccTransHasReconciledSplits(old_trans) &&
- !info->first_pass &&
- gnc_split_register_balance_trans (reg, old_trans))
- {
- /* no matter what, stay there so the user can see what happened */
- new_trans = old_trans;
- new_split = old_split;
- new_trans_split = old_trans_split;
- new_class = old_class;
- new_virt_loc = reg->table->current_cursor_loc;
- }
- 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;
- }
+ if (old_split != new_split)
+ {
+ info->change_confirmed = FALSE;
+ info->rate_account = NULL;
+ info->rate_reset = FALSE;
+ }
- if (old_split != new_split)
- {
- info->change_confirmed = FALSE;
- info->rate_account = NULL;
- info->rate_reset = FALSE;
- }
+ gnc_resume_gui_refresh ();
- gnc_resume_gui_refresh ();
+ /* redrawing the register can muck everything up */
+ if (saved)
+ {
+ VirtualCellLocation vcell_loc;
- /* redrawing the register can muck everything up */
- if (saved)
- {
- VirtualCellLocation vcell_loc;
+ if (!info->reg_loaded)
+ gnc_split_register_redraw (reg);
- if (!info->reg_loaded)
- gnc_split_register_redraw (reg);
+ /* if the split we were going to is still in the register,
+ * then it may have moved. Find out where it is now. */
+ if (gnc_split_register_find_split (reg, new_trans, new_trans_split,
+ new_split, new_class, &vcell_loc))
+ {
+ VirtualCell *vcell;
- /* if the split we were going to is still in the register,
- * then it may have moved. Find out where it is now. */
- if (gnc_split_register_find_split (reg, new_trans, new_trans_split,
- new_split, new_class, &vcell_loc))
- {
- VirtualCell *vcell;
+ vcell = gnc_table_get_virtual_cell (reg->table, vcell_loc);
- vcell = gnc_table_get_virtual_cell (reg->table, vcell_loc);
+ new_virt_loc.vcell_loc = vcell_loc;
+ }
+ else
+ new_virt_loc.vcell_loc = reg->table->current_cursor_loc.vcell_loc;
- new_virt_loc.vcell_loc = vcell_loc;
+ new_trans = gnc_split_register_get_trans (reg, new_virt_loc.vcell_loc);
+ new_split = gnc_split_register_get_split (reg, new_virt_loc.vcell_loc);
+ new_trans_split = gnc_split_register_get_trans_split(
+ reg, new_virt_loc.vcell_loc, NULL);
+ new_class = gnc_split_register_get_cursor_class (reg,
+ new_virt_loc.vcell_loc);
}
- else
- new_virt_loc.vcell_loc = reg->table->current_cursor_loc.vcell_loc;
+ else if (info->traverse_to_new)
+ {
+ new_trans = info->cursor_hint_trans;
+ new_split = info->cursor_hint_split;
+ new_trans_split = info->cursor_hint_trans_split;
+ new_class = info->cursor_hint_cursor_class;
+ }
- new_trans = gnc_split_register_get_trans (reg, new_virt_loc.vcell_loc);
- new_split = gnc_split_register_get_split (reg, new_virt_loc.vcell_loc);
- new_trans_split = gnc_split_register_get_trans_split(
- reg, new_virt_loc.vcell_loc, NULL);
- new_class = gnc_split_register_get_cursor_class (reg,
- new_virt_loc.vcell_loc);
- }
- else if (info->traverse_to_new)
- {
- new_trans = info->cursor_hint_trans;
- new_split = info->cursor_hint_split;
- new_trans_split = info->cursor_hint_trans_split;
- new_class = info->cursor_hint_cursor_class;
- }
+ gnc_table_find_close_valid_cell (reg->table, &new_virt_loc, exact_traversal);
- gnc_table_find_close_valid_cell (reg->table, &new_virt_loc, exact_traversal);
+ *p_new_virt_loc = new_virt_loc;
- *p_new_virt_loc = new_virt_loc;
+ PINFO ("after move %d %d \n",
+ new_virt_loc.vcell_loc.virt_row,
+ new_virt_loc.vcell_loc.virt_col);
- PINFO ("after move %d %d \n",
- new_virt_loc.vcell_loc.virt_row,
- new_virt_loc.vcell_loc.virt_col);
+ /* if the register was reloaded, then everything should be fine :)
+ * otherwise, we may need to change some visibility settings. */
+ if (saved)
+ {
+ gnc_split_register_set_cell_fractions (reg, new_split);
- /* if the register was reloaded, then everything should be fine :)
- * otherwise, we may need to change some visibility settings. */
- if (saved)
- {
- gnc_split_register_set_cell_fractions (reg, new_split);
+ LEAVE("saved");
+ return;
+ }
- LEAVE("saved");
- return;
- }
+ /* in the mult-line and dynamic modes, we need to hide the old
+ * and show the new. */
+ if (((REG_STYLE_AUTO_LEDGER == reg->style) ||
+ (REG_STYLE_JOURNAL == reg->style) ||
+ info->trans_expanded) &&
+ (old_trans_split != new_trans_split))
+ {
+ VirtualCellLocation vc_loc;
- /* in the mult-line and dynamic modes, we need to hide the old
- * and show the new. */
- if (((REG_STYLE_AUTO_LEDGER == reg->style) ||
- (REG_STYLE_JOURNAL == reg->style) ||
- info->trans_expanded) &&
- (old_trans_split != new_trans_split))
- {
- VirtualCellLocation vc_loc;
+ vc_loc = old_trans_split_loc;
+ gnc_table_set_virt_cell_cursor(
+ reg->table, vc_loc, gnc_split_register_get_passive_cursor (reg));
+ gnc_split_register_set_trans_visible (reg, vc_loc, FALSE,
+ reg->style == REG_STYLE_JOURNAL);
- vc_loc = old_trans_split_loc;
- gnc_table_set_virt_cell_cursor(
- reg->table, vc_loc, gnc_split_register_get_passive_cursor (reg));
- gnc_split_register_set_trans_visible (reg, vc_loc, FALSE,
- reg->style == REG_STYLE_JOURNAL);
+ if ((REG_STYLE_AUTO_LEDGER == reg->style) ||
+ (REG_STYLE_JOURNAL == reg->style))
+ {
+ gnc_split_register_get_trans_split (reg, new_virt_loc.vcell_loc,
+ &vc_loc);
+ gnc_table_set_virt_cell_cursor
+ (reg->table, vc_loc, gnc_split_register_get_active_cursor (reg));
+ gnc_split_register_set_trans_visible (reg, vc_loc, TRUE,
+ reg->style == REG_STYLE_JOURNAL);
+ }
- if ((REG_STYLE_AUTO_LEDGER == reg->style) ||
- (REG_STYLE_JOURNAL == reg->style))
- {
- gnc_split_register_get_trans_split (reg, new_virt_loc.vcell_loc,
- &vc_loc);
- gnc_table_set_virt_cell_cursor
- (reg->table, vc_loc, gnc_split_register_get_active_cursor (reg));
- gnc_split_register_set_trans_visible (reg, vc_loc, TRUE,
- reg->style == REG_STYLE_JOURNAL);
+ info->trans_expanded = FALSE;
+
+ do_refresh = TRUE;
}
+ else
+ do_refresh = FALSE;
- info->trans_expanded = FALSE;
+ 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;
- do_refresh = TRUE;
- }
- else
- do_refresh = FALSE;
+ gnc_split_register_set_cell_fractions (reg, new_split);
- 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_table_find_close_valid_cell (reg->table, p_new_virt_loc,
+ exact_traversal);
- gnc_split_register_set_cell_fractions (reg, new_split);
+ if (do_refresh)
+ {
+ VirtualCellLocation vc_loc;
- gnc_table_find_close_valid_cell (reg->table, p_new_virt_loc,
- exact_traversal);
+ gnc_table_refresh_gui (reg->table, FALSE);
+ gnc_table_leave_update (reg->table, reg->table->current_cursor_loc);
- if (do_refresh)
- {
- VirtualCellLocation vc_loc;
+ gnc_split_register_get_trans_split (reg, p_new_virt_loc->vcell_loc,
+ &vc_loc);
+ gnc_split_register_show_trans (reg, vc_loc);
+ }
- gnc_table_refresh_gui (reg->table, FALSE);
- gnc_table_leave_update (reg->table, reg->table->current_cursor_loc);
-
- gnc_split_register_get_trans_split (reg, p_new_virt_loc->vcell_loc,
- &vc_loc);
- gnc_split_register_show_trans (reg, vc_loc);
- }
-
- LEAVE(" ");
+ LEAVE(" ");
}
static Split *
gnc_find_split_in_trans_by_memo (Transaction *trans, const char *memo,
gboolean unit_price)
{
- int i = 0;
- Split *split;
+ int i = 0;
+ Split *split;
- while ((split = xaccTransGetSplit(trans, i)) != NULL) {
- i++;
- if (unit_price)
+ while ((split = xaccTransGetSplit(trans, i)) != NULL)
{
- gnc_numeric price = xaccSplitGetSharePrice (split);
- if (!gnc_numeric_equal (price, gnc_numeric_create (1, 1)))
- continue;
+ i++;
+ if (unit_price)
+ {
+ gnc_numeric price = xaccSplitGetSharePrice (split);
+ if (!gnc_numeric_equal (price, gnc_numeric_create (1, 1)))
+ continue;
+ }
+
+ if (safe_strcmp (memo, xaccSplitGetMemo (split)) == 0)
+ return split;
}
- if (safe_strcmp (memo, xaccSplitGetMemo (split)) == 0)
- return split;
- }
-
- return NULL;
+ return NULL;
}
static Split *
gnc_find_split_in_account_by_memo (Account *account, const char *memo,
gboolean unit_price)
{
- GList *slp;
+ GList *slp;
- if (account == NULL) return NULL;
+ if (account == NULL) return NULL;
- for (slp = g_list_last (xaccAccountGetSplitList (account));
- slp;
- slp = slp->prev)
- {
- Split *split = slp->data;
- Transaction *trans = xaccSplitGetParent (split);
+ for (slp = g_list_last (xaccAccountGetSplitList (account));
+ slp;
+ slp = slp->prev)
+ {
+ Split *split = slp->data;
+ Transaction *trans = xaccSplitGetParent (split);
- split = gnc_find_split_in_trans_by_memo (trans, memo, unit_price);
+ split = gnc_find_split_in_trans_by_memo (trans, memo, unit_price);
- if (split) return split;
- }
+ if (split) return split;
+ }
- return NULL;
+ return NULL;
}
static Split *
gnc_find_split_in_reg_by_memo (SplitRegister *reg, const char *memo,
gboolean unit_price)
{
- int virt_row, virt_col;
- int num_rows, num_cols;
- Transaction *last_trans;
+ int virt_row, virt_col;
+ int num_rows, num_cols;
+ Transaction *last_trans;
- if (!reg || !reg->table)
- return NULL;
+ if (!reg || !reg->table)
+ return NULL;
- num_rows = reg->table->num_virt_rows;
- num_cols = reg->table->num_virt_cols;
+ num_rows = reg->table->num_virt_rows;
+ num_cols = reg->table->num_virt_cols;
- last_trans = NULL;
+ last_trans = NULL;
- for (virt_row = num_rows - 1; virt_row >= 0; virt_row--)
- for (virt_col = num_cols - 1; virt_col >= 0; virt_col--)
- {
- Split *split;
- Transaction *trans;
- VirtualCellLocation vcell_loc = { virt_row, virt_col };
+ for (virt_row = num_rows - 1; virt_row >= 0; virt_row--)
+ for (virt_col = num_cols - 1; virt_col >= 0; virt_col--)
+ {
+ Split *split;
+ Transaction *trans;
+ VirtualCellLocation vcell_loc = { virt_row, virt_col };
- split = gnc_split_register_get_split (reg, vcell_loc);
- trans = xaccSplitGetParent (split);
+ split = gnc_split_register_get_split (reg, vcell_loc);
+ trans = xaccSplitGetParent (split);
- if (trans == last_trans)
- continue;
+ if (trans == last_trans)
+ continue;
- split = gnc_find_split_in_trans_by_memo (trans, memo, unit_price);
- if (split != NULL)
- return split;
+ split = gnc_find_split_in_trans_by_memo (trans, memo, unit_price);
+ if (split != NULL)
+ return split;
- last_trans = trans;
- }
+ last_trans = trans;
+ }
- return NULL;
+ return NULL;
}
static Transaction *
gnc_find_trans_in_reg_by_desc (SplitRegister *reg, const char *description)
{
- int virt_row, virt_col;
- int num_rows, num_cols;
- Transaction *last_trans;
+ int virt_row, virt_col;
+ int num_rows, num_cols;
+ Transaction *last_trans;
- if (!reg || !reg->table)
- return NULL;
+ if (!reg || !reg->table)
+ return NULL;
- num_rows = reg->table->num_virt_rows;
- num_cols = reg->table->num_virt_cols;
+ num_rows = reg->table->num_virt_rows;
+ num_cols = reg->table->num_virt_cols;
- last_trans = NULL;
+ last_trans = NULL;
- for (virt_row = num_rows - 1; virt_row >= 0; virt_row--)
- for (virt_col = num_cols - 1; virt_col >= 0; virt_col--)
- {
- Split *split;
- Transaction *trans;
- VirtualCellLocation vcell_loc = { virt_row, virt_col };
+ for (virt_row = num_rows - 1; virt_row >= 0; virt_row--)
+ for (virt_col = num_cols - 1; virt_col >= 0; virt_col--)
+ {
+ Split *split;
+ Transaction *trans;
+ VirtualCellLocation vcell_loc = { virt_row, virt_col };
- split = gnc_split_register_get_split (reg, vcell_loc);
- trans = xaccSplitGetParent(split);
+ split = gnc_split_register_get_split (reg, vcell_loc);
+ trans = xaccSplitGetParent(split);
- if (trans == last_trans)
- continue;
+ if (trans == last_trans)
+ continue;
- if (safe_strcmp (description, xaccTransGetDescription (trans)) == 0)
- return trans;
+ if (safe_strcmp (description, xaccTransGetDescription (trans)) == 0)
+ return trans;
- last_trans = trans;
- }
+ last_trans = trans;
+ }
- return NULL;
+ return NULL;
}
/* This function determines if auto-completion is appropriate and,
@@ -724,114 +729,116 @@
gncTableTraversalDir dir,
VirtualLocation *p_new_virt_loc)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- VirtualLocation new_virt_loc;
- CursorClass cursor_class;
- Transaction *pending_trans;
- Transaction *blank_trans;
- const char *cell_name;
- Transaction *trans;
- Split *blank_split;
- gnc_numeric amount;
- BasicCell *cell;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ VirtualLocation new_virt_loc;
+ CursorClass cursor_class;
+ Transaction *pending_trans;
+ Transaction *blank_trans;
+ const char *cell_name;
+ Transaction *trans;
+ Split *blank_split;
+ gnc_numeric amount;
+ BasicCell *cell;
+ Split *split;
- if (!reg->do_auto_complete)
- return FALSE;
+ if (!reg->do_auto_complete)
+ return FALSE;
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
- blank_trans = xaccSplitGetParent (blank_split);
-
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_book ());
+ blank_trans = xaccSplitGetParent (blank_split);
- /* auto-completion is only triggered by a tab out */
- if (dir != GNC_TABLE_TRAVERSE_RIGHT)
- return FALSE;
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- split = gnc_split_register_get_current_split (reg);
- trans = gnc_split_register_get_current_trans (reg);
- if (trans == NULL)
- return FALSE;
+ /* auto-completion is only triggered by a tab out */
+ if (dir != GNC_TABLE_TRAVERSE_RIGHT)
+ return FALSE;
- cursor_class = gnc_split_register_get_current_cursor_class (reg);
- cell_name = gnc_table_get_current_cell_name (reg->table);
+ split = gnc_split_register_get_current_split (reg);
+ trans = gnc_split_register_get_current_trans (reg);
+ if (trans == NULL)
+ return FALSE;
- switch (cursor_class)
- {
+ cursor_class = gnc_split_register_get_current_cursor_class (reg);
+ cell_name = gnc_table_get_current_cell_name (reg->table);
+
+ switch (cursor_class)
+ {
case CURSOR_CLASS_TRANS:
- {
+ {
Transaction *auto_trans;
const char *desc;
/* there must be a blank transaction * */
if (blank_trans == NULL)
- return FALSE;
+ return FALSE;
/* we must be on the blank split */
if (trans != blank_trans)
- return FALSE;
+ return FALSE;
/* and leaving the description cell */
if (!gnc_cell_name_equal (cell_name, DESC_CELL))
- return FALSE;
+ return FALSE;
/* nothing but the date, num, and description should be changed */
/* FIXME, this should be refactored. */
if (gnc_table_layout_get_cell_changed (reg->table->layout,
XFRM_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- MXFRM_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- PRIC_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- SHRS_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- DEBT_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- CRED_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- NOTES_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- RECN_CELL, TRUE))
- return FALSE;
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ MXFRM_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ PRIC_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ SHRS_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ DEBT_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ CRED_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ NOTES_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ RECN_CELL, TRUE))
+ return FALSE;
/* and the description should be changed */
if (!gnc_table_layout_get_cell_changed (reg->table->layout,
DESC_CELL, TRUE))
- return FALSE;
+ return FALSE;
/* to a non-empty value */
desc = gnc_table_layout_get_cell_value (reg->table->layout, DESC_CELL);
if ((desc == NULL) || (*desc == '\0'))
- return FALSE;
+ return FALSE;
/* find a transaction to auto-complete on */
if (gnc_split_register_get_default_account (reg) != NULL)
{
- Account *account = gnc_split_register_get_default_account (reg);
+ Account *account = gnc_split_register_get_default_account (reg);
- auto_trans = xaccAccountFindTransByDesc(account, desc);
+ auto_trans = xaccAccountFindTransByDesc(account, desc);
}
else
- auto_trans = gnc_find_trans_in_reg_by_desc(reg, desc);
+ auto_trans = gnc_find_trans_in_reg_by_desc(reg, desc);
if (auto_trans == NULL)
- return FALSE;
+ return FALSE;
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
/* We are guaranteed to be on the blank trans, so we can
discount the possibility that the current transaction is
being edited in another register. */
/* now perform the completion */
- if (pending_trans != trans) {
+ if (pending_trans != trans)
+ {
if (!xaccTransIsOpen(trans))
xaccTransBeginEdit(trans);
/* This is now the pending transaction */
info->pending_trans_guid = *xaccTransGetGUID(trans);
- if (pending_trans != NULL) {
+ if (pending_trans != NULL)
+ {
if (xaccTransIsOpen (pending_trans))
xaccTransCommitEdit (pending_trans);
else g_assert_not_reached();
@@ -847,24 +854,26 @@
if (gnc_split_register_get_default_account (reg) != NULL)
{
- Account *default_account;
- Split *s;
- int i = 0;
+ Account *default_account;
+ Split *s;
+ int i = 0;
- default_account = gnc_split_register_get_default_account (reg);
+ default_account = gnc_split_register_get_default_account (reg);
- while ((s = xaccTransGetSplit(trans, i)) != NULL) {
- if (default_account == xaccSplitGetAccount(s))
+ while ((s = xaccTransGetSplit(trans, i)) != NULL)
{
- blank_split = s;
- info->blank_split_guid = *xaccSplitGetGUID(blank_split);
- break;
+ if (default_account == xaccSplitGetAccount(s))
+ {
+ blank_split = s;
+ info->blank_split_guid = *xaccSplitGetGUID(blank_split);
+ break;
+ }
+ i++;
}
- i++;
- }
}
- if (blank_split == NULL) {
+ if (blank_split == NULL)
+ {
blank_split = xaccTransGetSplit(trans, 0);
info->blank_split_guid = *xaccSplitGetGUID(blank_split);
}
@@ -873,35 +882,35 @@
info->blank_split_edited = TRUE;
{
- SRSaveData *sd;
+ SRSaveData *sd;
- sd = gnc_split_register_save_data_new(
- trans, blank_split, (info->trans_expanded ||
- reg->style == REG_STYLE_AUTO_LEDGER ||
- reg->style == REG_STYLE_JOURNAL));
- gnc_table_save_cells (reg->table, sd);
- gnc_split_register_save_data_destroy (sd);
+ sd = gnc_split_register_save_data_new(
+ trans, blank_split, (info->trans_expanded ||
+ reg->style == REG_STYLE_AUTO_LEDGER ||
+ reg->style == REG_STYLE_JOURNAL));
+ gnc_table_save_cells (reg->table, sd);
+ gnc_split_register_save_data_destroy (sd);
}
gnc_resume_gui_refresh ();
/* now move to the non-empty amount column unless config setting says not */
if ( !gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
- "tab_includes_transfer_on_memorised", NULL) )
+ "tab_includes_transfer_on_memorised", NULL) )
{
- amount = xaccSplitGetAmount (blank_split);
- cell_name = (gnc_numeric_negative_p (amount)) ? CRED_CELL : DEBT_CELL;
-
- if (gnc_table_get_current_cell_location (reg->table, cell_name,
- &new_virt_loc))
- *p_new_virt_loc = new_virt_loc;
+ amount = xaccSplitGetAmount (blank_split);
+ cell_name = (gnc_numeric_negative_p (amount)) ? CRED_CELL : DEBT_CELL;
+
+ if (gnc_table_get_current_cell_location (reg->table, cell_name,
+ &new_virt_loc))
+ *p_new_virt_loc = new_virt_loc;
}
- }
+ }
break;
case CURSOR_CLASS_SPLIT:
- {
+ {
char *account_name;
const char *memo;
gboolean unit_price;
@@ -909,54 +918,54 @@
/* we must be on a blank split of a transaction */
if (split != NULL)
- return FALSE;
+ return FALSE;
/* and leaving the memo cell */
if (!gnc_cell_name_equal (cell_name, MEMO_CELL))
- return FALSE;
+ return FALSE;
/* nothing but the action, memo, and amounts should be changed */
/* FIXME. This should be refactored. */
if (gnc_table_layout_get_cell_changed (reg->table->layout,
XFRM_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- MXFRM_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- PRIC_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- SHRS_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- RECN_CELL, TRUE))
- return FALSE;
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ MXFRM_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ PRIC_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ SHRS_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ RECN_CELL, TRUE))
+ return FALSE;
/* and the memo should be changed */
if (!gnc_table_layout_get_cell_changed (reg->table->layout,
MEMO_CELL, TRUE))
- return FALSE;
+ return FALSE;
/* to a non-empty value */
memo = gnc_table_layout_get_cell_value (reg->table->layout, MEMO_CELL);
if ((memo == NULL) || (*memo == '\0'))
- return FALSE;
+ return FALSE;
/* if there is no price field, only auto-complete from splits with
* a unit share price. */
unit_price = !gnc_table_get_current_cell_location (reg->table,
- PRIC_CELL, NULL);
+ PRIC_CELL, NULL);
/* find a split to auto-complete on */
if (gnc_split_register_get_default_account (reg) != NULL)
{
- Account *account = gnc_split_register_get_default_account (reg);
+ Account *account = gnc_split_register_get_default_account (reg);
- auto_split = gnc_find_split_in_account_by_memo (account, memo,
- unit_price);
+ auto_split = gnc_find_split_in_account_by_memo (account, memo,
+ unit_price);
}
else
- auto_split = gnc_find_split_in_reg_by_memo (reg, memo, unit_price);
+ auto_split = gnc_find_split_in_reg_by_memo (reg, memo, unit_price);
if (auto_split == NULL)
- return FALSE;
+ return FALSE;
/* the auto-complete code below is taken from xaccSRGetEntryHandler */
@@ -964,9 +973,9 @@
if (!gnc_table_layout_get_cell_changed (reg->table->layout,
ACTN_CELL, TRUE))
{
- cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL);
- gnc_combo_cell_set_value ((ComboCell *) cell,
- xaccSplitGetAction (auto_split));
+ cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL);
+ gnc_combo_cell_set_value ((ComboCell *) cell,
+ xaccSplitGetAction (auto_split));
}
/* auto-complete the account name */
@@ -980,25 +989,25 @@
if (!gnc_table_layout_get_cell_changed (reg->table->layout,
DEBT_CELL, TRUE) &&
- !gnc_table_layout_get_cell_changed (reg->table->layout,
- CRED_CELL, TRUE))
+ !gnc_table_layout_get_cell_changed (reg->table->layout,
+ CRED_CELL, TRUE))
{
- BasicCell *debit_cell;
- BasicCell *credit_cell;
+ BasicCell *debit_cell;
+ BasicCell *credit_cell;
- amount = xaccSplitGetValue (auto_split);
+ amount = xaccSplitGetValue (auto_split);
- debit_cell = gnc_table_layout_get_cell (reg->table->layout,
- DEBT_CELL);
- credit_cell = gnc_table_layout_get_cell (reg->table->layout,
- CRED_CELL);
+ debit_cell = gnc_table_layout_get_cell (reg->table->layout,
+ DEBT_CELL);
+ credit_cell = gnc_table_layout_get_cell (reg->table->layout,
+ CRED_CELL);
- gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell,
- (PriceCell *) credit_cell,
- amount);
+ gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell,
+ (PriceCell *) credit_cell,
+ amount);
- gnc_basic_cell_set_changed (debit_cell, TRUE);
- gnc_basic_cell_set_changed (credit_cell, TRUE);
+ gnc_basic_cell_set_changed (debit_cell, TRUE);
+ gnc_basic_cell_set_changed (credit_cell, TRUE);
}
/* and refresh the gui */
@@ -1009,90 +1018,92 @@
cell_name = (gnc_numeric_negative_p (amount)) ? CRED_CELL : DEBT_CELL;
if (gnc_table_get_current_cell_location (reg->table, cell_name,
- &new_virt_loc))
- *p_new_virt_loc = new_virt_loc;
- }
+ &new_virt_loc))
+ *p_new_virt_loc = new_virt_loc;
+ }
break;
default:
- break;
- }
+ break;
+ }
- return TRUE;
+ return TRUE;
}
static void
-gnc_split_register_check_stock_action (SplitRegister *reg,
+gnc_split_register_check_stock_action (SplitRegister *reg,
const char *cell_name)
{
- BasicCell *cell;
- gnc_numeric shares;
- gboolean buy, sell;
- const char *name;
+ BasicCell *cell;
+ gnc_numeric shares;
+ gboolean buy, sell;
+ const char *name;
- if (!gnc_cell_name_equal (cell_name, ACTN_CELL) ||
- !gnc_table_layout_get_cell_changed (reg->table->layout,
- ACTN_CELL, FALSE))
- return;
+ if (!gnc_cell_name_equal (cell_name, ACTN_CELL) ||
+ !gnc_table_layout_get_cell_changed (reg->table->layout,
+ ACTN_CELL, FALSE))
+ return;
- cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL);
- if (!cell)
- return;
- name = ((ComboCell *)cell)->cell.value;
- if ((name == NULL) || (*name == '\0'))
- return;
+ cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL);
+ if (!cell)
+ return;
+ name = ((ComboCell *)cell)->cell.value;
+ if ((name == NULL) || (*name == '\0'))
+ return;
- buy = safe_strcmp (name, ACTION_BUY_STR) == 0;
- sell = safe_strcmp (name, ACTION_SELL_STR) == 0;
- if (!buy && !sell)
- return;
+ buy = safe_strcmp (name, ACTION_BUY_STR) == 0;
+ sell = safe_strcmp (name, ACTION_SELL_STR) == 0;
+ if (!buy && !sell)
+ return;
- cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
- if (!cell)
- return;
- shares = gnc_price_cell_get_value ((PriceCell *) cell);
+ cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
+ if (!cell)
+ return;
+ shares = gnc_price_cell_get_value ((PriceCell *) cell);
- if ((buy && !gnc_numeric_positive_p (shares)) ||
- (sell && gnc_numeric_positive_p (shares))) {
- gnc_price_cell_set_value ((PriceCell *)cell, gnc_numeric_neg (shares));
- gnc_basic_cell_set_changed (cell, TRUE);
- }
+ if ((buy && !gnc_numeric_positive_p (shares)) ||
+ (sell && gnc_numeric_positive_p (shares)))
+ {
+ gnc_price_cell_set_value ((PriceCell *)cell, gnc_numeric_neg (shares));
+ gnc_basic_cell_set_changed (cell, TRUE);
+ }
}
static void
-gnc_split_register_check_stock_shares (SplitRegister *reg,
+gnc_split_register_check_stock_shares (SplitRegister *reg,
const char *cell_name)
{
- BasicCell *cell;
- gnc_numeric shares;
- gboolean buy;
- const char *name;
+ BasicCell *cell;
+ gnc_numeric shares;
+ gboolean buy;
+ const char *name;
- if (!gnc_cell_name_equal (cell_name, SHRS_CELL) ||
- !gnc_table_layout_get_cell_changed (reg->table->layout,
- SHRS_CELL, FALSE))
- return;
+ if (!gnc_cell_name_equal (cell_name, SHRS_CELL) ||
+ !gnc_table_layout_get_cell_changed (reg->table->layout,
+ SHRS_CELL, FALSE))
+ return;
- cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
- if (!cell)
- return;
- shares = gnc_price_cell_get_value ((PriceCell *) cell);
- if (gnc_numeric_zero_p (shares))
- return;
- buy = gnc_numeric_positive_p (shares);
+ cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
+ if (!cell)
+ return;
+ shares = gnc_price_cell_get_value ((PriceCell *) cell);
+ if (gnc_numeric_zero_p (shares))
+ return;
+ buy = gnc_numeric_positive_p (shares);
- cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL);
- if (!cell)
- return;
- name = ((ComboCell *)cell)->cell.value;
+ cell = gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL);
+ if (!cell)
+ return;
+ name = ((ComboCell *)cell)->cell.value;
- if (!safe_strcmp(name, "") ||
- !safe_strcmp(name, buy ? ACTION_SELL_STR : ACTION_BUY_STR)) {
- gnc_combo_cell_set_value((ComboCell *)cell,
- buy ? ACTION_BUY_STR : ACTION_SELL_STR);
- gnc_basic_cell_set_changed (cell, TRUE);
- }
+ if (!safe_strcmp(name, "") ||
+ !safe_strcmp(name, buy ? ACTION_SELL_STR : ACTION_BUY_STR))
+ {
+ gnc_combo_cell_set_value((ComboCell *)cell,
+ buy ? ACTION_BUY_STR : ACTION_SELL_STR);
+ gnc_basic_cell_set_changed (cell, TRUE);
+ }
}
/* This function checks a cell for changes and takes appropriate action if a
@@ -1103,76 +1114,77 @@
gboolean
gnc_split_register_check_cell (SplitRegister *reg, const char *cell_name)
{
- ENTER("reg=%p, cell_name=%s", reg, cell_name? cell_name : "NULL");
+ ENTER("reg=%p, cell_name=%s", reg, cell_name ? cell_name : "NULL");
- /* See if we are leaving an account field. */
- if (!gnc_split_register_check_account (reg, cell_name))
- {
- LEAVE("account check failed");
- return FALSE;
- }
+ /* See if we are leaving an account field. */
+ if (!gnc_split_register_check_account (reg, cell_name))
+ {
+ LEAVE("account check failed");
+ return FALSE;
+ }
- /* See if we are leaving an action field */
- if ((reg->type == STOCK_REGISTER) ||
- (reg->type == PORTFOLIO_LEDGER) ||
- (reg->type == CURRENCY_REGISTER))
- {
- gnc_split_register_check_stock_action (reg, cell_name);
- gnc_split_register_check_stock_shares (reg, cell_name);
- }
+ /* See if we are leaving an action field */
+ if ((reg->type == STOCK_REGISTER) ||
+ (reg->type == PORTFOLIO_LEDGER) ||
+ (reg->type == CURRENCY_REGISTER))
+ {
+ gnc_split_register_check_stock_action (reg, cell_name);
+ gnc_split_register_check_stock_shares (reg, cell_name);
+ }
- LEAVE(" ");
- return TRUE;
+ LEAVE(" ");
+ return TRUE;
}
static Account *
-gnc_split_register_get_account_always (SplitRegister *reg,
+gnc_split_register_get_account_always (SplitRegister *reg,
const char * cell_name)
{
- BasicCell *cell;
- const char *name;
- gboolean dummy;
+ BasicCell *cell;
+ const char *name;
+ gboolean dummy;
- cell = gnc_table_layout_get_cell (reg->table->layout, cell_name);
- if (!cell)
- return NULL;
- name = gnc_basic_cell_get_value (cell);
+ cell = gnc_table_layout_get_cell (reg->table->layout, cell_name);
+ if (!cell)
+ return NULL;
+ name = gnc_basic_cell_get_value (cell);
- /* If 'name' is "-- Split Transaction --" then return NULL or the
- register acct */
- if (!safe_strcmp (name, SPLIT_TRANS_STR)) {
- return NULL;
- }
+ /* If 'name' is "-- Split Transaction --" then return NULL or the
+ register acct */
+ if (!safe_strcmp (name, SPLIT_TRANS_STR))
+ {
+ return NULL;
+ }
- return gnc_split_register_get_account_by_name (reg, cell, name, &dummy);
+ return gnc_split_register_get_account_by_name (reg, cell, name, &dummy);
}
static const char *
gnc_split_register_get_cell_string (SplitRegister *reg, const char *cell_name)
{
- BasicCell *cell;
+ BasicCell *cell;
- cell = gnc_table_layout_get_cell (reg->table->layout, cell_name);
- if (!cell)
- return "";
+ cell = gnc_table_layout_get_cell (reg->table->layout, cell_name);
+ if (!cell)
+ return "";
- return gnc_basic_cell_get_value (cell);
+ return gnc_basic_cell_get_value (cell);
}
static Timespec
gnc_split_register_get_cell_date (SplitRegister *reg, const char *cell_name)
{
- DateCell *cell;
- Timespec ts;
+ DateCell *cell;
+ Timespec ts;
- cell = (DateCell*) gnc_table_layout_get_cell (reg->table->layout, cell_name);
+ cell = (DateCell*) gnc_table_layout_get_cell (reg->table->layout, cell_name);
- if (cell)
- gnc_date_cell_get_date (cell, &ts);
- else
- timespecFromTime_t (&ts, time (NULL));
+ if (cell)
+ gnc_date_cell_get_date (cell, &ts);
+ else
+ timespecFromTime_t (&ts, time (NULL));
- return ts;
+ return ts;
}
/* Creates a transfer dialog and fills its values from register cells (if
@@ -1182,60 +1194,60 @@
gnc_split_register_xfer_dialog(SplitRegister *reg, Transaction *txn,
Split *split)
{
- XferDialog *xfer;
- CellBlock *cur;
- BasicCell *cell;
+ XferDialog *xfer;
+ CellBlock *cur;
+ BasicCell *cell;
- g_return_val_if_fail(reg, NULL);
- g_return_val_if_fail(reg->table, NULL);
- cur = reg->table->current_cursor;
+ g_return_val_if_fail(reg, NULL);
+ g_return_val_if_fail(reg->table, NULL);
+ cur = reg->table->current_cursor;
- /* Create the exchange rate dialog. */
- xfer = gnc_xfer_dialog(NULL, NULL);
- g_return_val_if_fail(xfer, NULL);
+ /* Create the exchange rate dialog. */
+ xfer = gnc_xfer_dialog(NULL, NULL);
+ g_return_val_if_fail(xfer, NULL);
- /* Set the description. */
- cell = gnc_cellblock_get_cell_by_name(cur, DESC_CELL, NULL, NULL);
- if (cell)
- gnc_xfer_dialog_set_description(xfer, gnc_basic_cell_get_value(cell));
- else
- {
- const char *str = xaccTransGetDescription(txn);
- gnc_xfer_dialog_set_description(xfer, str? str : "");
- }
+ /* Set the description. */
+ cell = gnc_cellblock_get_cell_by_name(cur, DESC_CELL, NULL, NULL);
+ if (cell)
+ gnc_xfer_dialog_set_description(xfer, gnc_basic_cell_get_value(cell));
+ else
+ {
+ const char *str = xaccTransGetDescription(txn);
+ gnc_xfer_dialog_set_description(xfer, str ? str : "");
+ }
- /* Set the memo. */
- cell = gnc_cellblock_get_cell_by_name(cur, MEMO_CELL, NULL, NULL);
- if (cell)
- gnc_xfer_dialog_set_memo(xfer, gnc_basic_cell_get_value(cell));
- else
- {
- const char *str = xaccSplitGetMemo(split);
- gnc_xfer_dialog_set_memo(xfer, str? str : "");
- }
+ /* Set the memo. */
+ cell = gnc_cellblock_get_cell_by_name(cur, MEMO_CELL, NULL, NULL);
+ if (cell)
+ gnc_xfer_dialog_set_memo(xfer, gnc_basic_cell_get_value(cell));
+ else
+ {
+ const char *str = xaccSplitGetMemo(split);
+ gnc_xfer_dialog_set_memo(xfer, str ? str : "");
+ }
- /* Set the num. */
- cell = gnc_cellblock_get_cell_by_name(cur, NUM_CELL, NULL, NULL);
- if (cell)
- gnc_xfer_dialog_set_num(xfer, gnc_basic_cell_get_value(cell));
- else
- {
- const char *str = xaccTransGetNum(txn);
- gnc_xfer_dialog_set_num(xfer, str? str : "");
- }
+ /* Set the num. */
+ cell = gnc_cellblock_get_cell_by_name(cur, NUM_CELL, NULL, NULL);
+ if (cell)
+ gnc_xfer_dialog_set_num(xfer, gnc_basic_cell_get_value(cell));
+ else
+ {
+ const char *str = xaccTransGetNum(txn);
+ gnc_xfer_dialog_set_num(xfer, str ? str : "");
+ }
- /* Set the date. */
- cell = gnc_cellblock_get_cell_by_name(cur, DATE_CELL, NULL, NULL);
- if (cell)
- {
- Timespec ts;
- gnc_date_cell_get_date((DateCell*) cell, &ts);
- gnc_xfer_dialog_set_date(xfer, timespecToTime_t(ts));
- }
- else
- gnc_xfer_dialog_set_date(xfer, xaccTransGetDate(txn));
+ /* Set the date. */
+ cell = gnc_cellblock_get_cell_by_name(cur, DATE_CELL, NULL, NULL);
+ if (cell)
+ {
+ Timespec ts;
+ gnc_date_cell_get_date((DateCell*) cell, &ts);
+ gnc_xfer_dialog_set_date(xfer, timespecToTime_t(ts));
+ }
+ else
+ gnc_xfer_dialog_set_date(xfer, xaccTransGetDate(txn));
- return xfer;
+ return xfer;
}
/* This function checks to see if we need to determine an exchange rate.
@@ -1246,261 +1258,267 @@
gboolean
gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog)
{
- SRInfo *info;
- Transaction *txn;
- Split *split, *osplit;
- Account *xfer_acc, *reg_acc;
- gnc_commodity *txn_cur, *xfer_com, *reg_com;
- gnc_numeric amount, exch_rate;
- XferDialog *xfer;
- gboolean expanded = FALSE;
- PriceCell *rate_cell;
- const char *message;
- CursorClass cursor_class;
-
- ENTER("reg=%p, force_dialog=%s", reg, force_dialog ? "TRUE" : "FALSE" );
+ SRInfo *info;
+ Transaction *txn;
+ Split *split, *osplit;
+ Account *xfer_acc, *reg_acc;
+ gnc_commodity *txn_cur, *xfer_com, *reg_com;
+ gnc_numeric amount, exch_rate;
+ XferDialog *xfer;
+ gboolean expanded = FALSE;
+ PriceCell *rate_cell;
+ const char *message;
+ CursorClass cursor_class;
- /* Make sure we NEED this for this type of register */
- if (!gnc_split_reg_has_rate_cell (reg->type))
- {
- if (force_dialog)
+ ENTER("reg=%p, force_dialog=%s", reg, force_dialog ? "TRUE" : "FALSE" );
+
+ /* Make sure we NEED this for this type of register */
+ if (!gnc_split_reg_has_rate_cell (reg->type))
{
- message = _("This register does not support editing exchange rates.");
- gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ if (force_dialog)
+ {
+ message = _("This register does not support editing exchange rates.");
+ gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ }
+ LEAVE("no rate cell");
+ return FALSE;
}
- LEAVE("no rate cell");
- return FALSE;
- }
- rate_cell = (PriceCell*) gnc_table_layout_get_cell(
- reg->table->layout, RATE_CELL);
- if (!rate_cell)
- {
- if (force_dialog)
+ rate_cell = (PriceCell*) gnc_table_layout_get_cell(
+ reg->table->layout, RATE_CELL);
+ if (!rate_cell)
{
- message = _("This register does not support editing exchange rates.");
- gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ if (force_dialog)
+ {
+ message = _("This register does not support editing exchange rates.");
+ gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ }
+ LEAVE("null rate cell");
+ return FALSE;
}
- LEAVE("null rate cell");
- return FALSE;
- }
- /* See if we already have an exchange rate... */
- exch_rate = gnc_price_cell_get_value (rate_cell);
- if (!gnc_numeric_zero_p(exch_rate) && !force_dialog)
- {
- LEAVE("rate already non-zero");
- return FALSE;
- }
+ /* See if we already have an exchange rate... */
+ exch_rate = gnc_price_cell_get_value (rate_cell);
+ if (!gnc_numeric_zero_p(exch_rate) && !force_dialog)
+ {
+ LEAVE("rate already non-zero");
+ return FALSE;
+ }
- /* Are we expanded? */
- expanded = gnc_split_register_current_trans_expanded (reg);
- cursor_class = gnc_split_register_get_current_cursor_class (reg);
+ /* Are we expanded? */
+ expanded = gnc_split_register_current_trans_expanded (reg);
+ cursor_class = gnc_split_register_get_current_cursor_class (reg);
- /* If we're expanded AND a transaction cursor, there is nothing to do */
- if (expanded && cursor_class == CURSOR_CLASS_TRANS)
- {
- if (force_dialog)
+ /* If we're expanded AND a transaction cursor, there is nothing to do */
+ if (expanded && cursor_class == CURSOR_CLASS_TRANS)
{
- message = _("You need to select a split in order to modify its exchange "
- "rate.");
- gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ if (force_dialog)
+ {
+ message = _("You need to select a split in order to modify its exchange "
+ "rate.");
+ gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ }
+ LEAVE("expanded with transaction cursor; nothing to do");
+ return FALSE;
}
- LEAVE("expanded with transaction cursor; nothing to do");
- return FALSE;
- }
- /* Grab the xfer account */
- xfer_acc = gnc_split_register_get_account_always(
- reg, expanded ? XFRM_CELL : MXFRM_CELL);
+ /* Grab the xfer account */
+ xfer_acc = gnc_split_register_get_account_always(
+ reg, expanded ? XFRM_CELL : MXFRM_CELL);
- /* If this is an un-expanded, multi-split transaction, then warn the user */
- if (force_dialog && !expanded && !xfer_acc) {
- message = _("You need to expand the transaction in order to modify its "
- "exchange rates.");
- gnc_error_dialog (gnc_split_register_get_parent (reg), "%s", message);
- LEAVE("%s", message);
- return TRUE;
- }
+ /* If this is an un-expanded, multi-split transaction, then warn the user */
+ if (force_dialog && !expanded && !xfer_acc)
+ {
+ message = _("You need to expand the transaction in order to modify its "
+ "exchange rates.");
+ gnc_error_dialog (gnc_split_register_get_parent (reg), "%s", message);
+ LEAVE("%s", message);
+ return TRUE;
+ }
- /* No account -- don't run the dialog */
- if (!xfer_acc)
- {
- if (force_dialog)
+ /* No account -- don't run the dialog */
+ if (!xfer_acc)
{
- message = _("The entered account could not be found.");
- gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ if (force_dialog)
+ {
+ message = _("The entered account could not be found.");
+ gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ }
+ LEAVE("no xfer account");
+ return FALSE;
}
- LEAVE("no xfer account");
- return FALSE;
- }
- /* Grab the txn currency and xfer commodity */
- txn = gnc_split_register_get_current_trans (reg);
- txn_cur = xaccTransGetCurrency (txn);
- xfer_com = xaccAccountGetCommodity (xfer_acc);
+ /* Grab the txn currency and xfer commodity */
+ txn = gnc_split_register_get_current_trans (reg);
+ txn_cur = xaccTransGetCurrency (txn);
+ xfer_com = xaccAccountGetCommodity (xfer_acc);
- /* Grab the register account and commodity (may be used later) */
- reg_acc = gnc_split_register_get_default_account (reg);
- reg_com = xaccAccountGetCommodity (reg_acc);
+ /* Grab the register account and commodity (may be used later) */
+ reg_acc = gnc_split_register_get_default_account (reg);
+ reg_com = xaccAccountGetCommodity (reg_acc);
- /* Grab the split and perhaps the "other" split (if it is a two-split txn) */
- split = gnc_split_register_get_current_split (reg);
- osplit = xaccSplitGetOtherSplit (split);
+ /* Grab the split and perhaps the "other" split (if it is a two-split txn) */
+ split = gnc_split_register_get_current_split (reg);
+ osplit = xaccSplitGetOtherSplit (split);
- /* Check if the txn- and xfer- commodities are the same */
- if (gnc_commodity_equal (txn_cur, xfer_com)) {
- /* If we're not forcing the dialog, then there is no reason to
- * go on. We're using the correct accounts.
+ /* Check if the txn- and xfer- commodities are the same */
+ if (gnc_commodity_equal (txn_cur, xfer_com))
+ {
+ /* If we're not forcing the dialog, then there is no reason to
+ * go on. We're using the correct accounts.
+ */
+ if (!force_dialog)
+ {
+ LEAVE("txn and account currencies match, and not forcing");
+ return FALSE;
+ }
+
+ /* Only proceed with two-split, basic, non-expanded registers */
+ if (expanded || osplit == NULL)
+ {
+ message = _("The two currencies involved equal each other.");
+ gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ LEAVE("register is expanded or osplit == NULL; not forcing dialog");
+ return FALSE;
+ }
+
+ /* If we're forcing, then compare the current account
+ * commodity to the transaction currency.
+ */
+ xfer_acc = reg_acc;
+ xfer_com = reg_com;
+ if (gnc_commodity_equal (txn_cur, xfer_com))
+ {
+ message = _("The two currencies involved equal each other.");
+ gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ LEAVE("reg commodity == txn commodity; not forcing");
+ return FALSE;
+ }
+ }
+
+ /* If this is a non-expanded, two-split txn where BOTH splits need
+ * conversion rates, then require the user to actually expand the
+ * transaction in order to edit it.
*/
- if (!force_dialog)
+ if (!expanded && osplit &&
+ gnc_split_register_split_needs_amount (reg, split) &&
+ gnc_split_register_split_needs_amount (reg, osplit))
{
- LEAVE("txn and account currencies match, and not forcing");
- return FALSE;
+ message = _("You need to expand the transaction in order to modify its "
+ "exchange rates.");
+ if (force_dialog)
+ {
+ gnc_error_dialog (gnc_split_register_get_parent (reg), "%s", message);
+ }
+ LEAVE("%s", message);
+ return TRUE;
}
- /* Only proceed with two-split, basic, non-expanded registers */
- if (expanded || osplit == NULL)
+ /* Strangely, if we're in a two-split, non-expanded txn, we need
+ * to do something really special with the exchange rate! In
+ * particular, we have to pick it up from the _other_ split --
+ * right?
+ * XXX: perhaps I should pop up an error here? Or maybe require the
+ * user to go into expanded-mode?
+ */
+ if (!expanded && osplit && !gnc_commodity_equal(reg_com, txn_cur) &&
+ !gnc_commodity_equal(reg_com, xfer_com))
{
- message = _("The two currencies involved equal each other.");
- gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
- LEAVE("register is expanded or osplit == NULL; not forcing dialog");
- return FALSE;
+ gnc_numeric amt = xaccSplitGetAmount (osplit);
+ gnc_numeric val = xaccSplitGetValue (osplit);
+ exch_rate = gnc_numeric_div (amt, val, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
}
- /* If we're forcing, then compare the current account
- * commodity to the transaction currency.
+ /* Ok, we need to grab the exchange rate */
+ amount = gnc_split_register_debcred_cell_value (reg);
+
+ /*
+ * If "amount" is zero then we don't need an exchange-rate.. Return
+ * FALSE to let the user continue on.
*/
- xfer_acc = reg_acc;
- xfer_com = reg_com;
- if (gnc_commodity_equal (txn_cur, xfer_com))
+ if (gnc_numeric_zero_p (amount))
{
- message = _("The two currencies involved equal each other.");
- gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
- LEAVE("reg commodity == txn commodity; not forcing");
- return FALSE;
+ if (force_dialog)
+ {
+ message = _("The split's amount is zero, so no exchange rate is needed.");
+ gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ }
+ LEAVE("amount is zero; no exchange rate needed");
+ return FALSE;
}
- }
- /* If this is a non-expanded, two-split txn where BOTH splits need
- * conversion rates, then require the user to actually expand the
- * transaction in order to edit it.
- */
- if (!expanded && osplit &&
- gnc_split_register_split_needs_amount (reg, split) &&
- gnc_split_register_split_needs_amount (reg, osplit)) {
- message = _("You need to expand the transaction in order to modify its "
- "exchange rates.");
- if (force_dialog)
+ /* If the exch_rate is zero, we're not forcing the dialog, and this is
+ * _not_ the blank split, then return FALSE -- this is a "special"
+ * gain/loss stock transaction.
+ */
+ info = gnc_split_register_get_info (reg);
+ if (gnc_numeric_zero_p(exch_rate) && !force_dialog && split &&
+ !info->rate_reset &&
+ split != gnc_split_register_get_blank_split (reg))
{
- gnc_error_dialog (gnc_split_register_get_parent (reg), "%s", message);
+ LEAVE("gain/loss split; no exchange rate needed");
+ return FALSE;
}
- LEAVE("%s", message);
- return TRUE;
- }
- /* Strangely, if we're in a two-split, non-expanded txn, we need
- * to do something really special with the exchange rate! In
- * particular, we have to pick it up from the _other_ split --
- * right?
- * XXX: perhaps I should pop up an error here? Or maybe require the
- * user to go into expanded-mode?
- */
- if (!expanded && osplit && !gnc_commodity_equal(reg_com, txn_cur) &&
- !gnc_commodity_equal(reg_com, xfer_com)) {
- gnc_numeric amt = xaccSplitGetAmount (osplit);
- gnc_numeric val = xaccSplitGetValue (osplit);
- exch_rate = gnc_numeric_div (amt, val, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
- }
-
- /* Ok, we need to grab the exchange rate */
- amount = gnc_split_register_debcred_cell_value (reg);
-
- /*
- * If "amount" is zero then we don't need an exchange-rate.. Return
- * FALSE to let the user continue on.
- */
- if (gnc_numeric_zero_p (amount))
- {
- if (force_dialog)
+ /* Show the exchange-rate dialog */
+ xfer = gnc_split_register_xfer_dialog(reg, txn, split);
+ gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate);
+ if (gnc_xfer_dialog_run_exchange_dialog(
+ xfer, &exch_rate, amount, reg_acc, txn, xfer_com))
{
- message = _("The split's amount is zero, so no exchange rate is needed.");
- gnc_error_dialog(gnc_split_register_get_parent(reg), "%s", message);
+ /* FIXME: How should the dialog be destroyed? */
+ LEAVE("leaving rate unchanged");
+ return TRUE;
}
- LEAVE("amount is zero; no exchange rate needed");
- return FALSE;
- }
+ /* FIXME: How should the dialog be destroyed? */
- /* If the exch_rate is zero, we're not forcing the dialog, and this is
- * _not_ the blank split, then return FALSE -- this is a "special"
- * gain/loss stock transaction.
- */
- info = gnc_split_register_get_info (reg);
- if (gnc_numeric_zero_p(exch_rate) && !force_dialog && split &&
- !info->rate_reset &&
- split != gnc_split_register_get_blank_split (reg))
- {
- LEAVE("gain/loss split; no exchange rate needed");
+ /* Set the RATE_CELL on this cursor and mark it changed */
+ gnc_price_cell_set_value (rate_cell, exch_rate);
+ gnc_basic_cell_set_changed (&rate_cell->cell, TRUE);
+ info->rate_account = xfer_acc;
+ info->rate_reset = FALSE;
+ LEAVE("set rate=%s", gnc_num_dbg_to_string(exch_rate));
return FALSE;
- }
-
- /* Show the exchange-rate dialog */
- xfer = gnc_split_register_xfer_dialog(reg, txn, split);
- gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate);
- if (gnc_xfer_dialog_run_exchange_dialog(
- xfer, &exch_rate, amount, reg_acc, txn, xfer_com))
- {
- /* FIXME: How should the dialog be destroyed? */
- LEAVE("leaving rate unchanged");
- return TRUE;
- }
- /* FIXME: How should the dialog be destroyed? */
-
- /* Set the RATE_CELL on this cursor and mark it changed */
- gnc_price_cell_set_value (rate_cell, exch_rate);
- gnc_basic_cell_set_changed (&rate_cell->cell, TRUE);
- info->rate_account = xfer_acc;
- info->rate_reset = FALSE;
- LEAVE("set rate=%s", gnc_num_dbg_to_string(exch_rate));
- return FALSE;
}
/* Returns FALSE if dialog was canceled. */
-static gboolean
-transaction_changed_confirm(VirtualLocation *p_new_virt_loc,
+static gboolean
+transaction_changed_confirm(VirtualLocation *p_new_virt_loc,
VirtualLocation *virt_loc,
- SplitRegister *reg, Transaction *new_trans,
+ SplitRegister *reg, Transaction *new_trans,
gboolean exact_traversal)
{
GtkWidget *dialog, *window;
gint response;
const char *title = _("Save the changed transaction?");
const char *message =
- _("The current transaction has been changed. Would you like to "
- "record the changes before moving to a new transaction, discard the "
- "changes, or return to the changed transaction?");
+ _("The current transaction has been changed. Would you like to "
+ "record the changes before moving to a new transaction, discard the "
+ "changes, or return to the changed transaction?");
window = gnc_split_register_get_parent(reg);
dialog = gtk_message_dialog_new(GTK_WINDOW(window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- "%s", title);
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ "%s", title);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- "%s", message);
+ "%s", message);
gtk_dialog_add_buttons(GTK_DIALOG(dialog),
- _("_Discard Changes"), GTK_RESPONSE_REJECT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- _("_Record Changes"), GTK_RESPONSE_ACCEPT,
- NULL);
+ _("_Discard Changes"), GTK_RESPONSE_REJECT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("_Record Changes"), GTK_RESPONSE_ACCEPT,
+ NULL);
response = gnc_dialog_run(GTK_DIALOG(dialog), "transaction_changed");
gtk_widget_destroy(dialog);
- switch (response) {
+ switch (response)
+ {
case GTK_RESPONSE_ACCEPT:
break;
- case GTK_RESPONSE_REJECT: {
+ case GTK_RESPONSE_REJECT:
+ {
VirtualCellLocation vcell_loc;
Split *new_split;
Split *trans_split;
@@ -1508,23 +1526,23 @@
new_split = gnc_split_register_get_split (reg, virt_loc->vcell_loc);
trans_split = gnc_split_register_get_trans_split (reg,
- virt_loc->vcell_loc,
- NULL);
+ virt_loc->vcell_loc,
+ NULL);
new_class = gnc_split_register_get_cursor_class (reg,
- virt_loc->vcell_loc);
+ virt_loc->vcell_loc);
gnc_split_register_cancel_cursor_trans_changes (reg);
if (gnc_split_register_find_split (reg, new_trans, trans_split,
new_split, new_class, &vcell_loc))
- virt_loc->vcell_loc = vcell_loc;
+ virt_loc->vcell_loc = vcell_loc;
gnc_table_find_close_valid_cell (reg->table, virt_loc,
exact_traversal);
*p_new_virt_loc = *virt_loc;
}
- break;
+ break;
case GTK_RESPONSE_CANCEL:
default:
@@ -1551,241 +1569,245 @@
gncTableTraversalDir dir,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *pending_trans;
- VirtualLocation virt_loc;
- Transaction *trans, *new_trans;
- gboolean changed;
- SRInfo *info;
- Split *split;
- const char *cell_name;
+ SplitRegister *reg = user_data;
+ Transaction *pending_trans;
+ VirtualLocation virt_loc;
+ Transaction *trans, *new_trans;
+ gboolean changed;
+ SRInfo *info;
+ Split *split;
+ const char *cell_name;
- g_return_val_if_fail(p_new_virt_loc, TRUE);
+ g_return_val_if_fail(p_new_virt_loc, TRUE);
- ENTER("reg=%p, p_new_virt_loc=%p (%d,%d), dir=%d",
- reg, p_new_virt_loc, (*p_new_virt_loc).vcell_loc.virt_row,
- (*p_new_virt_loc).vcell_loc.virt_col, dir);
+ ENTER("reg=%p, p_new_virt_loc=%p (%d,%d), dir=%d",
+ reg, p_new_virt_loc, (*p_new_virt_loc).vcell_loc.virt_row,
+ (*p_new_virt_loc).vcell_loc.virt_col, dir);
- if (!reg)
- {
- LEAVE("no register");
- return FALSE;
- }
+ if (!reg)
+ {
+ LEAVE("no register");
+ return FALSE;
+ }
- info = gnc_split_register_get_info (reg);
+ info = gnc_split_register_get_info (reg);
- if (info->first_pass)
- {
- LEAVE("first pass");
- return FALSE;
- }
+ if (info->first_pass)
+ {
+ LEAVE("first pass");
+ return FALSE;
+ }
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
- gnc_get_current_book ());
- virt_loc = *p_new_virt_loc;
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
+ virt_loc = *p_new_virt_loc;
- info->exact_traversal = (dir == GNC_TABLE_TRAVERSE_POINTER);
+ info->exact_traversal = (dir == GNC_TABLE_TRAVERSE_POINTER);
- split = gnc_split_register_get_current_split (reg);
- trans = gnc_split_register_get_current_trans (reg);
- if (trans == NULL)
- {
- LEAVE("no transaction");
- return FALSE;
- }
+ split = gnc_split_register_get_current_split (reg);
+ trans = gnc_split_register_get_current_trans (reg);
+ if (trans == NULL)
+ {
+ LEAVE("no transaction");
+ return FALSE;
+ }
- /* no changes, make sure we aren't going off the end */
- changed = gnc_table_current_cursor_changed (reg->table, FALSE);
- if (!changed && (pending_trans != trans))
- {
- gnc_table_find_close_valid_cell (reg->table, &virt_loc,
- info->exact_traversal);
+ /* no changes, make sure we aren't going off the end */
+ changed = gnc_table_current_cursor_changed (reg->table, FALSE);
+ if (!changed && (pending_trans != trans))
+ {
+ gnc_table_find_close_valid_cell (reg->table, &virt_loc,
+ info->exact_traversal);
- *p_new_virt_loc = virt_loc;
+ *p_new_virt_loc = virt_loc;
- LEAVE("no changes");
- return FALSE;
- }
+ LEAVE("no changes");
+ return FALSE;
+ }
- /* Get the current cell-name and check it for changes. */
- cell_name = gnc_table_get_current_cell_name (reg->table);
- if (!gnc_split_register_check_cell (reg, cell_name))
- {
- LEAVE("check cell");
- return TRUE;
- }
+ /* Get the current cell-name and check it for changes. */
+ cell_name = gnc_table_get_current_cell_name (reg->table);
+ if (!gnc_split_register_check_cell (reg, cell_name))
+ {
+ LEAVE("check cell");
+ return TRUE;
+ }
- /* See if we are tabbing off the end of the very last line */
- do {
- VirtualLocation virt_loc;
+ /* See if we are tabbing off the end of the very last line */
+ do
+ {
+ VirtualLocation virt_loc;
- if (!changed && !info->blank_split_edited)
- break;
+ if (!changed && !info->blank_split_edited)
+ break;
- if (dir != GNC_TABLE_TRAVERSE_RIGHT)
- break;
+ if (dir != GNC_TABLE_TRAVERSE_RIGHT)
+ break;
- virt_loc = reg->table->current_cursor_loc;
- if (gnc_table_move_vertical_position (reg->table, &virt_loc, 1))
- break;
+ virt_loc = reg->table->current_cursor_loc;
+ if (gnc_table_move_vertical_position (reg->table, &virt_loc, 1))
+ break;
- virt_loc = reg->table->current_cursor_loc;
- if (gnc_table_move_tab (reg->table, &virt_loc, TRUE))
- break;
+ virt_loc = reg->table->current_cursor_loc;
+ if (gnc_table_move_tab (reg->table, &virt_loc, TRUE))
+ break;
- /* Deal with the exchange-rate */
- if (gnc_split_register_handle_exchange (reg, FALSE))
- {
- LEAVE("no exchange rate");
- return TRUE;
- }
+ /* Deal with the exchange-rate */
+ if (gnc_split_register_handle_exchange (reg, FALSE))
+ {
+ LEAVE("no exchange rate");
+ return TRUE;
+ }
- *p_new_virt_loc = reg->table->current_cursor_loc;
- (p_new_virt_loc->vcell_loc.virt_row)++;
- p_new_virt_loc->phys_row_offset = 0;
- p_new_virt_loc->phys_col_offset = 0;
+ *p_new_virt_loc = reg->table->current_cursor_loc;
+ (p_new_virt_loc->vcell_loc.virt_row)++;
+ p_new_virt_loc->phys_row_offset = 0;
+ p_new_virt_loc->phys_col_offset = 0;
- info->traverse_to_new = TRUE;
+ info->traverse_to_new = TRUE;
- LEAVE("off end of last line");
- return FALSE;
+ LEAVE("off end of last line");
+ return FALSE;
- } while (FALSE);
+ }
+ while (FALSE);
- /* Now see if we are changing cursors. If not, we may be able to
- * auto-complete. */
- if (!gnc_table_virtual_cell_out_of_bounds (reg->table, virt_loc.vcell_loc))
- {
- if (gnc_split_register_auto_completion (reg, dir, p_new_virt_loc))
+ /* Now see if we are changing cursors. If not, we may be able to
+ * auto-complete. */
+ if (!gnc_table_virtual_cell_out_of_bounds (reg->table, virt_loc.vcell_loc))
{
- LEAVE("auto-complete");
- return FALSE;
+ if (gnc_split_register_auto_completion (reg, dir, p_new_virt_loc))
+ {
+ LEAVE("auto-complete");
+ return FALSE;
+ }
}
- }
- /* See if we are tabbing off the end of a blank split */
- do {
- VirtualLocation virt_loc;
- int old_virt_row;
+ /* See if we are tabbing off the end of a blank split */
+ do
+ {
+ VirtualLocation virt_loc;
+ int old_virt_row;
- if (!changed)
- break;
+ if (!changed)
+ break;
- if (split)
- break;
+ if (split)
+ break;
- if (dir != GNC_TABLE_TRAVERSE_RIGHT)
- break;
+ if (dir != GNC_TABLE_TRAVERSE_RIGHT)
+ break;
- virt_loc = reg->table->current_cursor_loc;
- old_virt_row = virt_loc.vcell_loc.virt_row;
+ virt_loc = reg->table->current_cursor_loc;
+ old_virt_row = virt_loc.vcell_loc.virt_row;
- if (gnc_table_move_tab (reg->table, &virt_loc, TRUE) &&
- old_virt_row == virt_loc.vcell_loc.virt_row)
- break;
+ if (gnc_table_move_tab (reg->table, &virt_loc, TRUE) &&
+ old_virt_row == virt_loc.vcell_loc.virt_row)
+ break;
- /* If we are here, then: (a) the current cursor has been
- * edited, and (b) we are on the blank split of a multi-line
- * transaction, and (c) we are tabbing out of the last cell
- * on the line. Thus, we want to go ahead and add the new
- * split and end up on the new blank split of the current
- * transaction. */
+ /* If we are here, then: (a) the current cursor has been
+ * edited, and (b) we are on the blank split of a multi-line
+ * transaction, and (c) we are tabbing out of the last cell
+ * on the line. Thus, we want to go ahead and add the new
+ * split and end up on the new blank split of the current
+ * transaction. */
- /* Deal with the exchange-rate */
- if (gnc_split_register_handle_exchange (reg, FALSE))
- {
- LEAVE("no exchange rate");
- return TRUE;
- }
+ /* Deal with the exchange-rate */
+ if (gnc_split_register_handle_exchange (reg, FALSE))
+ {
+ LEAVE("no exchange rate");
+ return TRUE;
+ }
- info->cursor_hint_trans = trans;
- info->cursor_hint_split = split;
- info->cursor_hint_trans_split =
- gnc_split_register_get_current_trans_split (reg, NULL);
- info->cursor_hint_cursor_class = CURSOR_CLASS_SPLIT;
- info->hint_set_by_traverse = TRUE;
+ info->cursor_hint_trans = trans;
+ info->cursor_hint_split = split;
+ info->cursor_hint_trans_split =
+ gnc_split_register_get_current_trans_split (reg, NULL);
+ info->cursor_hint_cursor_class = CURSOR_CLASS_SPLIT;
+ info->hint_set_by_traverse = TRUE;
- LEAVE("off end of blank split");
- return FALSE;
+ LEAVE("off end of blank split");
+ return FALSE;
- } while(FALSE);
+ }
+ while (FALSE);
- {
- int old_virt_row = reg->table->current_cursor_loc.vcell_loc.virt_row;
-
- /* Check for going off the end */
- gnc_table_find_close_valid_cell (reg->table, &virt_loc,
- info->exact_traversal);
+ {
+ int old_virt_row = reg->table->current_cursor_loc.vcell_loc.virt_row;
+ /* Check for going off the end */
+ gnc_table_find_close_valid_cell (reg->table, &virt_loc,
+ info->exact_traversal);
- /* Did we change vertical position? */
- if (virt_loc.vcell_loc.virt_row != old_virt_row)
- /* Deal with the exchange-rate */
- if (gnc_split_register_handle_exchange (reg, FALSE))
- {
- LEAVE("no exchange rate");
- return TRUE;
- }
- }
+ /* Did we change vertical position? */
+ if (virt_loc.vcell_loc.virt_row != old_virt_row)
+ /* Deal with the exchange-rate */
+ if (gnc_split_register_handle_exchange (reg, FALSE))
+ {
+ LEAVE("no exchange rate");
+ return TRUE;
+ }
+ }
- /* Same transaction, no problem */
- new_trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
- if (trans == new_trans)
- {
- *p_new_virt_loc = virt_loc;
+
+ /* Same transaction, no problem */
+ new_trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
+ if (trans == new_trans)
{
- LEAVE("staying within txn");
- return FALSE;
+ *p_new_virt_loc = virt_loc;
+ {
+ LEAVE("staying within txn");
+ return FALSE;
+ }
}
- }
- /* Ok, we are changing transactions and the current transaction has
- * changed. See what the user wants to do. */
- LEAVE("txn change");
- return transaction_changed_confirm(p_new_virt_loc, &virt_loc, reg,
- new_trans, info->exact_traversal);
+ /* Ok, we are changing transactions and the current transaction has
+ * changed. See what the user wants to do. */
+ LEAVE("txn change");
+ return transaction_changed_confirm(p_new_virt_loc, &virt_loc, reg,
+ new_trans, info->exact_traversal);
}
TableControl *
gnc_split_register_control_new (void)
{
- TableControl *control = gnc_table_control_new();
+ TableControl *control = gnc_table_control_new();
- control->move_cursor = gnc_split_register_move_cursor;
- control->traverse = gnc_split_register_traverse;
+ control->move_cursor = gnc_split_register_move_cursor;
+ control->traverse = gnc_split_register_traverse;
- return control;
+ return control;
}
gboolean
gnc_split_register_recn_cell_confirm (char old_flag, gpointer data)
{
- SplitRegister *reg = data;
- GtkWidget *dialog, *window;
- gint response;
- const gchar *title = _("Mark split as unreconciled?");
- const gchar *message =
- _("You are about to mark a reconciled split as unreconciled. Doing "
- "so might make future reconciliation difficult! Continue "
- "with this change?");
+ SplitRegister *reg = data;
+ GtkWidget *dialog, *window;
+ gint response;
+ const gchar *title = _("Mark split as unreconciled?");
+ const gchar *message =
+ _("You are about to mark a reconciled split as unreconciled. Doing "
+ "so might make future reconciliation difficult! Continue "
+ "with this change?");
- if (old_flag != YREC)
- return TRUE;
+ if (old_flag != YREC)
+ return TRUE;
- /* Does the user want to be warned? */
- window = gnc_split_register_get_parent(reg);
- dialog =
- gtk_message_dialog_new(GTK_WINDOW(window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- "%s", title);
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- "%s", message);
- gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Unreconcile"),
- GTK_RESPONSE_YES);
- response = gnc_dialog_run(GTK_DIALOG(dialog), "mark_split_unreconciled");
- gtk_widget_destroy(dialog);
- return (response == GTK_RESPONSE_YES);
+ /* Does the user want to be warned? */
+ window = gnc_split_register_get_parent(reg);
+ dialog =
+ gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+ "%s", message);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Unreconcile"),
+ GTK_RESPONSE_YES);
+ response = gnc_dialog_run(GTK_DIALOG(dialog), "mark_split_unreconciled");
+ gtk_widget_destroy(dialog);
+ return (response == GTK_RESPONSE_YES);
}
Modified: gnucash/trunk/src/register/ledger-core/split-register-layout.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-layout.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-layout.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -43,47 +43,47 @@
gboolean expandable,
gboolean span)
{
- BasicCell *cell;
+ BasicCell *cell;
- g_return_if_fail (layout != NULL);
- g_return_if_fail (cell_type_name != NULL);
+ g_return_if_fail (layout != NULL);
+ g_return_if_fail (cell_type_name != NULL);
- cell = gnc_register_make_cell (cell_type_name);
+ cell = gnc_register_make_cell (cell_type_name);
- gnc_basic_cell_set_name (cell, cell_name);
- gnc_basic_cell_set_sample_text (cell, sample_text);
- gnc_basic_cell_set_alignment (cell, alignment);
- gnc_basic_cell_set_expandable (cell, expandable);
- gnc_basic_cell_set_span (cell, span);
+ gnc_basic_cell_set_name (cell, cell_name);
+ gnc_basic_cell_set_sample_text (cell, sample_text);
+ gnc_basic_cell_set_alignment (cell, alignment);
+ gnc_basic_cell_set_expandable (cell, expandable);
+ gnc_basic_cell_set_span (cell, span);
- gnc_table_layout_add_cell (layout, cell);
+ gnc_table_layout_add_cell (layout, cell);
}
static void
copy_cursor_row (TableLayout *layout, CellBlock *to, CellBlock *from, int row)
{
- int col;
+ int col;
- for (col = 0; col < from->num_cols; col++)
- {
- BasicCell *cell;
+ for (col = 0; col < from->num_cols; col++)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (from, row, col);
- if (!cell || !cell->cell_name)
- continue;
+ cell = gnc_cellblock_get_cell (from, row, col);
+ if (!cell || !cell->cell_name)
+ continue;
- gnc_table_layout_set_cell (layout, to, cell->cell_name, row, col);
- }
+ gnc_table_layout_set_cell (layout, to, cell->cell_name, row, col);
+ }
}
static void
gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
{
- CellBlock *curs;
- CellBlock *curs_last;
+ CellBlock *curs;
+ CellBlock *curs_last;
- switch (reg->type)
- {
+ switch (reg->type)
+ {
case BANK_REGISTER:
case CASH_REGISTER:
case ASSET_REGISTER:
@@ -93,7 +93,7 @@
case EXPENSE_REGISTER:
case EQUITY_REGISTER:
case TRADING_REGISTER:
- {
+ {
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SINGLE_LEDGER);
@@ -104,13 +104,13 @@
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
if (reg->is_template)
{
- gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
}
else
{
- gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
}
gnc_table_layout_set_cell (layout, curs, BALN_CELL, 0, 7);
gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
@@ -154,23 +154,23 @@
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
if (reg->is_template)
{
- gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
}
else
{
- gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
}
gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
break;
- }
- /* --------------------------------------------------------- */
+ }
+ /* --------------------------------------------------------- */
case PAYABLE_REGISTER:
case RECEIVABLE_REGISTER:
- {
+ {
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SINGLE_LEDGER);
@@ -224,13 +224,13 @@
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 7);
break;
- }
+ }
- /* --------------------------------------------------------- */
+ /* --------------------------------------------------------- */
case INCOME_LEDGER:
case GENERAL_LEDGER:
case SEARCH_LEDGER:
- {
+ {
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SINGLE_LEDGER);
@@ -241,16 +241,16 @@
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
if (reg->is_template)
{
- gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
- gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
+ gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
}
else
{
- gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
- gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
- gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
+ gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
+ gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
}
curs_last = curs;
@@ -272,10 +272,11 @@
gnc_table_layout_set_cell (layout, curs, TDEBT_CELL, 0, 5);
gnc_table_layout_set_cell (layout, curs, TCRED_CELL, 0, 6);
if (reg->is_template)
- gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
- else {
- gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
- gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
+ gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
+ else
+ {
+ gnc_table_layout_set_cell (layout, curs, RBALN_CELL, 0, 7);
+ gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
}
curs_last = curs;
@@ -296,24 +297,24 @@
gnc_table_layout_set_cell (layout, curs, RECN_CELL, 0, 4);
if (reg->is_template)
{
- gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
- gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
+ gnc_table_layout_set_cell (layout, curs, FDEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, FCRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 7);
}
else
{
- gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
- gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
- gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
+ gnc_table_layout_set_cell (layout, curs, DEBT_CELL, 0, 5);
+ gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 6);
+ gnc_table_layout_set_cell (layout, curs, RATE_CELL, 0, 8);
}
break;
- }
+ }
- /* --------------------------------------------------------- */
+ /* --------------------------------------------------------- */
case STOCK_REGISTER:
case CURRENCY_REGISTER:
- {
+ {
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SINGLE_LEDGER);
@@ -371,11 +372,11 @@
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
break;
- }
+ }
- /* --------------------------------------------------------- */
+ /* --------------------------------------------------------- */
case PORTFOLIO_LEDGER:
- {
+ {
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SINGLE_LEDGER);
@@ -431,24 +432,24 @@
gnc_table_layout_set_cell (layout, curs, CRED_CELL, 0, 8);
break;
- }
+ }
- /* --------------------------------------------------------- */
+ /* --------------------------------------------------------- */
default:
- PERR ("unknown register type %d \n", reg->type);
- break;
- }
+ PERR ("unknown register type %d \n", reg->type);
+ break;
+ }
}
static void
gnc_split_register_layout_add_cursors (SplitRegister *reg,
TableLayout *layout)
{
- CellBlock *cursor;
- int num_cols;
+ CellBlock *cursor;
+ int num_cols;
- switch (reg->type)
- {
+ switch (reg->type)
+ {
case BANK_REGISTER:
case CASH_REGISTER:
case ASSET_REGISTER:
@@ -458,284 +459,284 @@
case EXPENSE_REGISTER:
case EQUITY_REGISTER:
case TRADING_REGISTER:
- num_cols = 9;
- break;
+ num_cols = 9;
+ break;
case PAYABLE_REGISTER:
case RECEIVABLE_REGISTER:
- num_cols = 9;
- break;
+ num_cols = 9;
+ break;
case INCOME_LEDGER:
case GENERAL_LEDGER:
case SEARCH_LEDGER:
- if (reg->is_template)
- num_cols = 8;
- else
- num_cols = 9;
- break;
+ if (reg->is_template)
+ num_cols = 8;
+ else
+ num_cols = 9;
+ break;
case STOCK_REGISTER:
case CURRENCY_REGISTER:
- num_cols = 10;
- break;
+ num_cols = 10;
+ break;
case PORTFOLIO_LEDGER:
- num_cols = 9;
- break;
+ num_cols = 9;
+ break;
default:
- PERR("Bad register type");
- g_assert (FALSE);
- return;
- }
+ PERR("Bad register type");
+ g_assert (FALSE);
+ return;
+ }
- cursor = gnc_cellblock_new (1, num_cols, CURSOR_HEADER);
- gnc_table_layout_add_cursor (layout, cursor);
+ cursor = gnc_cellblock_new (1, num_cols, CURSOR_HEADER);
+ gnc_table_layout_add_cursor (layout, cursor);
- /* cursors used in ledger mode */
- cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_LEDGER);
- gnc_table_layout_add_cursor (layout, cursor);
+ /* cursors used in ledger mode */
+ cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_LEDGER);
+ gnc_table_layout_add_cursor (layout, cursor);
- gnc_table_layout_set_primary_cursor (layout, cursor);
+ gnc_table_layout_set_primary_cursor (layout, cursor);
- cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_LEDGER);
- gnc_table_layout_add_cursor (layout, cursor);
+ cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_LEDGER);
+ gnc_table_layout_add_cursor (layout, cursor);
- /* cursors used for journal mode */
- cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_JOURNAL);
- gnc_table_layout_add_cursor (layout, cursor);
+ /* cursors used for journal mode */
+ cursor = gnc_cellblock_new (1, num_cols, CURSOR_SINGLE_JOURNAL);
+ gnc_table_layout_add_cursor (layout, cursor);
- cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_JOURNAL);
- gnc_table_layout_add_cursor (layout, cursor);
+ cursor = gnc_cellblock_new (2, num_cols, CURSOR_DOUBLE_JOURNAL);
+ gnc_table_layout_add_cursor (layout, cursor);
- cursor = gnc_cellblock_new (1, num_cols, CURSOR_SPLIT);
- gnc_table_layout_add_cursor (layout, cursor);
+ cursor = gnc_cellblock_new (1, num_cols, CURSOR_SPLIT);
+ gnc_table_layout_add_cursor (layout, cursor);
}
static void
gnc_split_register_layout_add_cells (SplitRegister *reg,
TableLayout *layout)
{
- gnc_register_add_cell (layout,
- DATE_CELL,
- DATE_CELL_TYPE_NAME,
- N_("sample:12/12/2000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ DATE_CELL,
+ DATE_CELL_TYPE_NAME,
+ N_("sample:12/12/2000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- DDUE_CELL,
- DATE_CELL_TYPE_NAME,
- N_("sample:12/12/2000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ DDUE_CELL,
+ DATE_CELL_TYPE_NAME,
+ N_("sample:12/12/2000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- NUM_CELL,
- NUM_CELL_TYPE_NAME,
- /* Translators: The 'sample:' items are
- strings which are not displayed, but only
- used to estimate widths. Please only
- translate the portion after the ':' and
- leave the rest ("sample:") as is. */
- N_("sample:99999") + 7,
- CELL_ALIGN_LEFT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ NUM_CELL,
+ NUM_CELL_TYPE_NAME,
+ /* Translators: The 'sample:' items are
+ strings which are not displayed, but only
+ used to estimate widths. Please only
+ translate the portion after the ':' and
+ leave the rest ("sample:") as is. */
+ N_("sample:99999") + 7,
+ CELL_ALIGN_LEFT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- DESC_CELL,
- QUICKFILL_CELL_TYPE_NAME,
- N_("sample:Description of a transaction") + 7,
- CELL_ALIGN_LEFT,
- TRUE,
- FALSE);
+ gnc_register_add_cell (layout,
+ DESC_CELL,
+ QUICKFILL_CELL_TYPE_NAME,
+ N_("sample:Description of a transaction") + 7,
+ CELL_ALIGN_LEFT,
+ TRUE,
+ FALSE);
- gnc_register_add_cell (layout,
- RATE_CELL,
- PRICE_CELL_TYPE_NAME,
- NULL,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ RATE_CELL,
+ PRICE_CELL_TYPE_NAME,
+ NULL,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- RECN_CELL,
- RECN_CELL_TYPE_NAME,
- N_("Reconciled:R") + 11,
- CELL_ALIGN_CENTER,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ RECN_CELL,
+ RECN_CELL_TYPE_NAME,
+ N_("Reconciled:R") + 11,
+ CELL_ALIGN_CENTER,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- BALN_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ BALN_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- XFRM_CELL,
- COMBO_CELL_TYPE_NAME,
- N_("Transfer"),
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ XFRM_CELL,
+ COMBO_CELL_TYPE_NAME,
+ N_("Transfer"),
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- MXFRM_CELL,
- COMBO_CELL_TYPE_NAME,
- N_("sample:Expenses:Automobile:Gasoline") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ MXFRM_CELL,
+ COMBO_CELL_TYPE_NAME,
+ N_("sample:Expenses:Automobile:Gasoline") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- ACTN_CELL,
- COMBO_CELL_TYPE_NAME,
- N_("sample:Expenses:Automobile:Gasoline") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ ACTN_CELL,
+ COMBO_CELL_TYPE_NAME,
+ N_("sample:Expenses:Automobile:Gasoline") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- MEMO_CELL,
- QUICKFILL_CELL_TYPE_NAME,
- N_("sample:Memo field sample text string") + 7,
- CELL_ALIGN_LEFT,
- FALSE,
- TRUE);
+ gnc_register_add_cell (layout,
+ MEMO_CELL,
+ QUICKFILL_CELL_TYPE_NAME,
+ N_("sample:Memo field sample text string") + 7,
+ CELL_ALIGN_LEFT,
+ FALSE,
+ TRUE);
- gnc_register_add_cell (layout,
- DEBT_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ DEBT_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- CRED_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ CRED_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- SHRS_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ SHRS_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- /* Price cell must come after shares cell, as its callback performs
- * a computation on the value set by the shares cell callback. */
- gnc_register_add_cell (layout,
- PRIC_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ /* Price cell must come after shares cell, as its callback performs
+ * a computation on the value set by the shares cell callback. */
+ gnc_register_add_cell (layout,
+ PRIC_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- TDEBT_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ TDEBT_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- TCRED_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ TCRED_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- TSHRS_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ TSHRS_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- TBALN_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ TBALN_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- TYPE_CELL,
- RECN_CELL_TYPE_NAME,
- N_("Type:T") + 5,
- CELL_ALIGN_LEFT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ TYPE_CELL,
+ RECN_CELL_TYPE_NAME,
+ N_("Type:T") + 5,
+ CELL_ALIGN_LEFT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- NOTES_CELL,
- QUICKFILL_CELL_TYPE_NAME,
- N_("sample:Notes field sample text string") + 7,
- CELL_ALIGN_LEFT,
- FALSE,
- TRUE);
+ gnc_register_add_cell (layout,
+ NOTES_CELL,
+ QUICKFILL_CELL_TYPE_NAME,
+ N_("sample:Notes field sample text string") + 7,
+ CELL_ALIGN_LEFT,
+ FALSE,
+ TRUE);
- gnc_register_add_cell (layout,
- VNOTES_CELL,
- BASIC_CELL_TYPE_NAME,
- N_("sample:No Particular Reason") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- TRUE);
+ gnc_register_add_cell (layout,
+ VNOTES_CELL,
+ BASIC_CELL_TYPE_NAME,
+ N_("sample:No Particular Reason") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ TRUE);
- gnc_register_add_cell (layout,
- FCRED_CELL,
- FORMULA_CELL_TYPE_NAME,
- N_("sample:(x + 0.33 * y + (x+y) )") + 7,
- CELL_ALIGN_LEFT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ FCRED_CELL,
+ FORMULA_CELL_TYPE_NAME,
+ N_("sample:(x + 0.33 * y + (x+y) )") + 7,
+ CELL_ALIGN_LEFT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- FDEBT_CELL,
- FORMULA_CELL_TYPE_NAME,
- N_("sample:(x + 0.33 * y + (x+y) )") + 7,
- CELL_ALIGN_LEFT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ FDEBT_CELL,
+ FORMULA_CELL_TYPE_NAME,
+ N_("sample:(x + 0.33 * y + (x+y) )") + 7,
+ CELL_ALIGN_LEFT,
+ FALSE,
+ FALSE);
- gnc_register_add_cell (layout,
- RBALN_CELL,
- PRICE_CELL_TYPE_NAME,
- N_("sample:999,999.000") + 7,
- CELL_ALIGN_RIGHT,
- FALSE,
- FALSE);
+ gnc_register_add_cell (layout,
+ RBALN_CELL,
+ PRICE_CELL_TYPE_NAME,
+ N_("sample:999,999.000") + 7,
+ CELL_ALIGN_RIGHT,
+ FALSE,
+ FALSE);
}
TableLayout *
gnc_split_register_layout_new (SplitRegister *reg)
{
- TableLayout *layout;
+ TableLayout *layout;
- layout = gnc_table_layout_new ();
+ layout = gnc_table_layout_new ();
- gnc_split_register_layout_add_cells (reg, layout);
- gnc_split_register_layout_add_cursors (reg, layout);
- gnc_split_register_set_cells (reg, layout);
+ gnc_split_register_layout_add_cells (reg, layout);
+ gnc_split_register_layout_add_cursors (reg, layout);
+ gnc_split_register_set_cells (reg, layout);
- return layout;
+ return layout;
}
Modified: gnucash/trunk/src/register/ledger-core/split-register-layout.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-layout.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-layout.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -31,16 +31,16 @@
/** @file split-register-layout.h
* @brief Create the actual register visual layout
* @author Copyright (C) 1998, 2004 Linas Vepstas <linas at linas.org>
- * Pick specific cell types to sit in specific columns, and add
- * connections so that user can tab from one field to the next.
+ * Pick specific cell types to sit in specific columns, and add
+ * connections so that user can tab from one field to the next.
*
* The actual layout depends on the register type, but, typically,
* all of the registers have the date cell on the left, description
* in the middle, and monetary totals on the right.
- *
+ *
* This implementation hard-codes the layout in C, although the
- * original intent was that the layout would be fetched from a
- * config file that could be tweaked for a specific, non-GnuCash
+ * original intent was that the layout would be fetched from a
+ * config file that could be tweaked for a specific, non-GnuCash
* application.
*/
Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -44,42 +44,42 @@
static void gnc_split_register_load_xfer_cells (SplitRegister *reg,
- Account *base_account);
+ Account *base_account);
static void
gnc_split_register_load_recn_cells (SplitRegister *reg)
{
- RecnCell *cell;
- const char * s;
+ RecnCell *cell;
+ const char * s;
- if (!reg) return;
+ if (!reg) return;
- cell = (RecnCell *)
- gnc_table_layout_get_cell (reg->table->layout, RECN_CELL);
+ cell = (RecnCell *)
+ gnc_table_layout_get_cell (reg->table->layout, RECN_CELL);
- if (!cell) return;
+ if (!cell) return;
- s = gnc_get_reconcile_valid_flags ();
- gnc_recn_cell_set_valid_flags (cell, s, *s);
- gnc_recn_cell_set_flag_order (cell, gnc_get_reconcile_flag_order ());
- gnc_recn_cell_set_string_getter (cell, gnc_get_reconcile_str);
+ s = gnc_get_reconcile_valid_flags ();
+ gnc_recn_cell_set_valid_flags (cell, s, *s);
+ gnc_recn_cell_set_flag_order (cell, gnc_get_reconcile_flag_order ());
+ gnc_recn_cell_set_string_getter (cell, gnc_get_reconcile_str);
}
static void
gnc_split_register_load_type_cells (SplitRegister *reg)
{
- RecnCell *cell;
+ RecnCell *cell;
- if (!reg) return;
+ if (!reg) return;
- cell = (RecnCell *)
- gnc_table_layout_get_cell (reg->table->layout, TYPE_CELL);
+ cell = (RecnCell *)
+ gnc_table_layout_get_cell (reg->table->layout, TYPE_CELL);
- if (!cell) return;
+ if (!cell) return;
- /* FIXME: These should get moved to an i18n function */
- gnc_recn_cell_set_valid_flags (cell, "IP?", 'I');
- gnc_recn_cell_set_flag_order (cell, "IP");
+ /* FIXME: These should get moved to an i18n function */
+ gnc_recn_cell_set_valid_flags (cell, "IP?", 'I');
+ gnc_recn_cell_set_flag_order (cell, "IP");
}
/** Add a transaction to the register.
@@ -159,519 +159,528 @@
int *new_split_row,
VirtualCellLocation *vcell_loc)
{
- GList *node;
+ GList *node;
- g_return_if_fail(reg);
- g_return_if_fail(vcell_loc);
+ g_return_if_fail(reg);
+ g_return_if_fail(vcell_loc);
- if (split == find_split)
- *new_split_row = vcell_loc->virt_row;
+ if (split == find_split)
+ *new_split_row = vcell_loc->virt_row;
- /* Set the "leading" virtual cell. */
- gnc_table_set_vcell (reg->table, lead_cursor, xaccSplitGetGUID (split),
- TRUE, start_primary_color, *vcell_loc);
- vcell_loc->virt_row++;
+ /* Set the "leading" virtual cell. */
+ gnc_table_set_vcell (reg->table, lead_cursor, xaccSplitGetGUID (split),
+ TRUE, start_primary_color, *vcell_loc);
+ vcell_loc->virt_row++;
- /* Continue setting up virtual cells in a column, using a row for each
- * split in the transaction. */
- for (node = xaccTransGetSplitList (trans); node; node = node->next) {
- Split *secondary = node->data;
+ /* Continue setting up virtual cells in a column, using a row for each
+ * split in the transaction. */
+ for (node = xaccTransGetSplitList (trans); node; node = node->next)
+ {
+ Split *secondary = node->data;
- if (!xaccTransStillHasSplit(trans, secondary)) continue;
- if (secondary == find_split && find_class == CURSOR_CLASS_SPLIT)
- *new_split_row = vcell_loc->virt_row;
+ if (!xaccTransStillHasSplit(trans, secondary)) continue;
+ if (secondary == find_split && find_class == CURSOR_CLASS_SPLIT)
+ *new_split_row = vcell_loc->virt_row;
- gnc_table_set_vcell (reg->table, split_cursor,
- xaccSplitGetGUID (secondary),
- visible_splits, TRUE, *vcell_loc);
- vcell_loc->virt_row++;
- }
+ gnc_table_set_vcell (reg->table, split_cursor,
+ xaccSplitGetGUID (secondary),
+ visible_splits, TRUE, *vcell_loc);
+ vcell_loc->virt_row++;
+ }
- /* If requested, add an empty split row at the end. */
- if (add_empty) {
- if (find_trans == trans && find_split == NULL &&
- find_class == CURSOR_CLASS_SPLIT)
- *new_split_row = vcell_loc->virt_row;
+ /* If requested, add an empty split row at the end. */
+ if (add_empty)
+ {
+ if (find_trans == trans && find_split == NULL &&
+ find_class == CURSOR_CLASS_SPLIT)
+ *new_split_row = vcell_loc->virt_row;
- gnc_table_set_vcell(reg->table, split_cursor, xaccSplitGetGUID(NULL),
- FALSE, TRUE, *vcell_loc);
- vcell_loc->virt_row++;
- }
+ gnc_table_set_vcell(reg->table, split_cursor, xaccSplitGetGUID(NULL),
+ FALSE, TRUE, *vcell_loc);
+ vcell_loc->virt_row++;
+ }
}
static gint
_find_split_with_parent_txn(gconstpointer a, gconstpointer b)
{
- Split *split = (Split*)a;
- Transaction *txn = (Transaction*)b;
+ Split *split = (Split*)a;
+ Transaction *txn = (Transaction*)b;
- return xaccSplitGetParent(split) == txn ? 0 : 1;
+ return xaccSplitGetParent(split) == txn ? 0 : 1;
}
static void add_quickfill_completions(TableLayout *layout, Transaction *trans,
gboolean has_last_num)
{
- Split *s;
- int i = 0;
+ Split *s;
+ int i = 0;
- gnc_quickfill_cell_add_completion(
- (QuickFillCell *) gnc_table_layout_get_cell(layout, DESC_CELL),
- xaccTransGetDescription(trans));
+ gnc_quickfill_cell_add_completion(
+ (QuickFillCell *) gnc_table_layout_get_cell(layout, DESC_CELL),
+ xaccTransGetDescription(trans));
- gnc_quickfill_cell_add_completion(
- (QuickFillCell *) gnc_table_layout_get_cell(layout, NOTES_CELL),
- xaccTransGetNotes(trans));
+ gnc_quickfill_cell_add_completion(
+ (QuickFillCell *) gnc_table_layout_get_cell(layout, NOTES_CELL),
+ xaccTransGetNotes(trans));
- if (!has_last_num)
- gnc_num_cell_set_last_num(
- (NumCell *) gnc_table_layout_get_cell(layout, NUM_CELL),
- xaccTransGetNum(trans));
+ if (!has_last_num)
+ gnc_num_cell_set_last_num(
+ (NumCell *) gnc_table_layout_get_cell(layout, NUM_CELL),
+ xaccTransGetNum(trans));
- while ((s = xaccTransGetSplit(trans, i)) != NULL) {
- gnc_quickfill_cell_add_completion(
- (QuickFillCell *) gnc_table_layout_get_cell(layout, MEMO_CELL),
- xaccSplitGetMemo(s));
- i++;
- }
+ while ((s = xaccTransGetSplit(trans, i)) != NULL)
+ {
+ gnc_quickfill_cell_add_completion(
+ (QuickFillCell *) gnc_table_layout_get_cell(layout, MEMO_CELL),
+ xaccSplitGetMemo(s));
+ i++;
+ }
}
void
gnc_split_register_load (SplitRegister *reg, GList * slist,
Account *default_account)
{
- SRInfo *info;
- Transaction *pending_trans;
- CursorBuffer *cursor_buffer;
- GHashTable *trans_table = NULL;
- CellBlock *cursor_header;
- CellBlock *lead_cursor;
- CellBlock *split_cursor;
- Transaction *blank_trans;
- Transaction *find_trans;
- Transaction *trans;
- CursorClass find_class;
- Split *find_trans_split;
- Split *blank_split;
- Split *find_split;
- Split *split;
- Table *table;
- GList *node;
+ SRInfo *info;
+ Transaction *pending_trans;
+ CursorBuffer *cursor_buffer;
+ GHashTable *trans_table = NULL;
+ CellBlock *cursor_header;
+ CellBlock *lead_cursor;
+ CellBlock *split_cursor;
+ Transaction *blank_trans;
+ Transaction *find_trans;
+ Transaction *trans;
+ CursorClass find_class;
+ Split *find_trans_split;
+ Split *blank_split;
+ Split *find_split;
+ Split *split;
+ Table *table;
+ GList *node;
- gboolean start_primary_color = TRUE;
- gboolean found_pending = FALSE;
- gboolean found_divider = FALSE;
- gboolean has_last_num = FALSE;
- gboolean multi_line;
- gboolean dynamic;
- gboolean we_own_slist = FALSE;
+ gboolean start_primary_color = TRUE;
+ gboolean found_pending = FALSE;
+ gboolean found_divider = FALSE;
+ gboolean has_last_num = FALSE;
+ gboolean multi_line;
+ gboolean dynamic;
+ gboolean we_own_slist = FALSE;
- VirtualCellLocation vcell_loc;
- VirtualLocation save_loc;
+ VirtualCellLocation vcell_loc;
+ VirtualLocation save_loc;
- int new_trans_split_row = -1;
- int new_trans_row = -1;
- int new_split_row = -1;
- time_t present;
+ int new_trans_split_row = -1;
+ int new_trans_row = -1;
+ int new_split_row = -1;
+ time_t present;
- g_return_if_fail(reg);
- table = reg->table;
- g_return_if_fail(table);
- info = gnc_split_register_get_info (reg);
- g_return_if_fail(info);
+ g_return_if_fail(reg);
+ table = reg->table;
+ g_return_if_fail(table);
+ info = gnc_split_register_get_info (reg);
+ g_return_if_fail(info);
- ENTER("reg=%p, slist=%p, default_account=%p", reg, slist, default_account);
+ ENTER("reg=%p, slist=%p, default_account=%p", reg, slist, default_account);
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
-
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_book ());
- /* make sure we have a blank split */
- if (blank_split == NULL)
- {
- Transaction *new_trans;
- gnc_commodity * currency = NULL;
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- /* Determine the proper currency to use for this transaction.
- * if default_account != NULL and default_account->commodity is
- * a currency, then use that. Otherwise use the default currency.
- */
- if (default_account != NULL) {
- gnc_commodity * commodity = xaccAccountGetCommodity (default_account);
- if (gnc_commodity_is_currency(commodity))
- currency = commodity;
- else {
- Account *parent_account = default_account;
- /* Account commodity is not a currency, walk up the tree until
- * we find a parent account that is a currency account and use
- * it's currency.
+ /* make sure we have a blank split */
+ if (blank_split == NULL)
+ {
+ Transaction *new_trans;
+ gnc_commodity * currency = NULL;
+
+ /* Determine the proper currency to use for this transaction.
+ * if default_account != NULL and default_account->commodity is
+ * a currency, then use that. Otherwise use the default currency.
*/
- do {
- parent_account = gnc_account_get_parent (parent_account);
- if (parent_account)
- {
- commodity = xaccAccountGetCommodity (parent_account);
+ if (default_account != NULL)
+ {
+ gnc_commodity * commodity = xaccAccountGetCommodity (default_account);
if (gnc_commodity_is_currency(commodity))
+ currency = commodity;
+ else
{
- currency = commodity;
- break;
+ Account *parent_account = default_account;
+ /* Account commodity is not a currency, walk up the tree until
+ * we find a parent account that is a currency account and use
+ * it's currency.
+ */
+ do
+ {
+ parent_account = gnc_account_get_parent (parent_account);
+ if (parent_account)
+ {
+ commodity = xaccAccountGetCommodity (parent_account);
+ if (gnc_commodity_is_currency(commodity))
+ {
+ currency = commodity;
+ break;
+ }
+ }
+ }
+ while (parent_account && !currency);
}
- }
- } while (parent_account && !currency);
- }
- /* If we don't have a currency then pop up a warning dialog */
- if (!currency)
- {
- gnc_info_dialog(NULL, "%s",
- _("Could not determine the account currency. "
- "Using the default currency provided by your system."));
- }
- }
+ /* If we don't have a currency then pop up a warning dialog */
+ if (!currency)
+ {
+ gnc_info_dialog(NULL, "%s",
+ _("Could not determine the account currency. "
+ "Using the default currency provided by your system."));
+ }
+ }
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- new_trans = xaccMallocTransaction (gnc_get_current_book ());
+ new_trans = xaccMallocTransaction (gnc_get_current_book ());
- xaccTransBeginEdit (new_trans);
- xaccTransSetCurrency (new_trans,
- currency ? currency : gnc_default_currency());
- xaccTransSetDateSecs (new_trans, info->last_date_entered);
- blank_split = xaccMallocSplit (gnc_get_current_book ());
- xaccSplitSetParent(blank_split, new_trans);
- /* We don't want to commit this transaction yet, because the split
- doesn't even belong to an account yet. But, we don't want to
- set this transaction as the pending transaction either, because
- we want to pretend that it hasn't been changed. We depend on
- some other code (somewhere) to commit this transaction if we
- really edit it, even though it's not marked as the pending
- transaction. */
+ xaccTransBeginEdit (new_trans);
+ xaccTransSetCurrency (new_trans,
+ currency ? currency : gnc_default_currency());
+ xaccTransSetDateSecs (new_trans, info->last_date_entered);
+ blank_split = xaccMallocSplit (gnc_get_current_book ());
+ xaccSplitSetParent(blank_split, new_trans);
+ /* We don't want to commit this transaction yet, because the split
+ doesn't even belong to an account yet. But, we don't want to
+ set this transaction as the pending transaction either, because
+ we want to pretend that it hasn't been changed. We depend on
+ some other code (somewhere) to commit this transaction if we
+ really edit it, even though it's not marked as the pending
+ transaction. */
- /* Wouldn't it be a bug to open this transaction if there was already a
- pending transaction? */
- g_assert(pending_trans == NULL);
+ /* Wouldn't it be a bug to open this transaction if there was already a
+ pending transaction? */
+ g_assert(pending_trans == NULL);
- info->blank_split_guid = *xaccSplitGetGUID (blank_split);
- info->blank_split_edited = FALSE;
- DEBUG("created new blank_split=%p", blank_split);
+ info->blank_split_guid = *xaccSplitGetGUID (blank_split);
+ info->blank_split_edited = FALSE;
+ DEBUG("created new blank_split=%p", blank_split);
- gnc_resume_gui_refresh ();
- }
+ gnc_resume_gui_refresh ();
+ }
- blank_trans = xaccSplitGetParent (blank_split);
+ blank_trans = xaccSplitGetParent (blank_split);
- DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p",
- blank_split, blank_trans, pending_trans);
+ DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p",
+ blank_split, blank_trans, pending_trans);
- info->default_account = *xaccAccountGetGUID (default_account);
+ info->default_account = *xaccAccountGetGUID (default_account);
- // gnc_table_leave_update (table, table->current_cursor_loc);
+ // gnc_table_leave_update (table, table->current_cursor_loc);
- multi_line = (reg->style == REG_STYLE_JOURNAL);
- dynamic = (reg->style == REG_STYLE_AUTO_LEDGER);
+ multi_line = (reg->style == REG_STYLE_JOURNAL);
+ dynamic = (reg->style == REG_STYLE_AUTO_LEDGER);
- lead_cursor = gnc_split_register_get_passive_cursor (reg);
- split_cursor = gnc_table_layout_get_cursor (table->layout, CURSOR_SPLIT);
+ lead_cursor = gnc_split_register_get_passive_cursor (reg);
+ split_cursor = gnc_table_layout_get_cursor (table->layout, CURSOR_SPLIT);
- /* figure out where we are going to. */
- if (info->traverse_to_new)
- {
- find_trans = blank_trans;
- find_split = NULL;
- find_trans_split = blank_split;
- find_class = CURSOR_CLASS_SPLIT;
- }
- else
- {
- find_trans = info->cursor_hint_trans;
- find_split = info->cursor_hint_split;
- find_trans_split = info->cursor_hint_trans_split;
- find_class = info->cursor_hint_cursor_class;
- }
+ /* figure out where we are going to. */
+ if (info->traverse_to_new)
+ {
+ find_trans = blank_trans;
+ find_split = NULL;
+ find_trans_split = blank_split;
+ find_class = CURSOR_CLASS_SPLIT;
+ }
+ else
+ {
+ find_trans = info->cursor_hint_trans;
+ find_split = info->cursor_hint_split;
+ find_trans_split = info->cursor_hint_trans_split;
+ find_class = info->cursor_hint_cursor_class;
+ }
- save_loc = table->current_cursor_loc;
+ save_loc = table->current_cursor_loc;
- /* If the current cursor has changed we save the values for later
- * possible restoration. */
- if (gnc_table_current_cursor_changed (table, TRUE) &&
- (find_split == gnc_split_register_get_current_split (reg)))
- {
- cursor_buffer = gnc_cursor_buffer_new ();
- gnc_table_save_current_cursor (table, cursor_buffer);
- }
- else
- cursor_buffer = NULL;
+ /* If the current cursor has changed we save the values for later
+ * possible restoration. */
+ if (gnc_table_current_cursor_changed (table, TRUE) &&
+ (find_split == gnc_split_register_get_current_split (reg)))
+ {
+ cursor_buffer = gnc_cursor_buffer_new ();
+ gnc_table_save_current_cursor (table, cursor_buffer);
+ }
+ else
+ cursor_buffer = NULL;
- /* disable move callback -- we don't want the cascade of
- * callbacks while we are fiddling with loading the register */
- gnc_table_control_allow_move (table->control, FALSE);
+ /* disable move callback -- we don't want the cascade of
+ * callbacks while we are fiddling with loading the register */
+ gnc_table_control_allow_move (table->control, FALSE);
- /* invalidate the cursor */
- {
- VirtualLocation virt_loc;
+ /* invalidate the cursor */
+ {
+ VirtualLocation virt_loc;
- gnc_virtual_location_init(&virt_loc);
- gnc_table_move_cursor_gui (table, virt_loc);
- }
+ gnc_virtual_location_init(&virt_loc);
+ gnc_table_move_cursor_gui (table, virt_loc);
+ }
- /* make sure that the header is loaded */
- vcell_loc.virt_row = 0;
- vcell_loc.virt_col = 0;
- cursor_header = gnc_table_layout_get_cursor (table->layout, CURSOR_HEADER);
- gnc_table_set_vcell (table, cursor_header, NULL, TRUE, TRUE, vcell_loc);
- vcell_loc.virt_row++;
+ /* make sure that the header is loaded */
+ vcell_loc.virt_row = 0;
+ vcell_loc.virt_col = 0;
+ cursor_header = gnc_table_layout_get_cursor (table->layout, CURSOR_HEADER);
+ gnc_table_set_vcell (table, cursor_header, NULL, TRUE, TRUE, vcell_loc);
+ vcell_loc.virt_row++;
- /* get the current time and reset the dividing row */
- present = gnc_timet_get_today_end ();
+ /* get the current time and reset the dividing row */
+ present = gnc_timet_get_today_end ();
- if (info->first_pass)
- {
- if (default_account)
+ if (info->first_pass)
{
- const char *last_num = xaccAccountGetLastNum (default_account);
+ if (default_account)
+ {
+ const char *last_num = xaccAccountGetLastNum (default_account);
- if (last_num)
- {
- NumCell *cell;
+ if (last_num)
+ {
+ NumCell *cell;
- cell = (NumCell *) gnc_table_layout_get_cell(table->layout, NUM_CELL);
- gnc_num_cell_set_last_num (cell, last_num);
- has_last_num = TRUE;
- }
+ cell = (NumCell *) gnc_table_layout_get_cell(table->layout, NUM_CELL);
+ gnc_num_cell_set_last_num (cell, last_num);
+ has_last_num = TRUE;
+ }
+ }
+
+ /* load up account names into the transfer combobox menus */
+ gnc_split_register_load_xfer_cells (reg, default_account);
+ gnc_split_register_load_recn_cells (reg);
+ gnc_split_register_load_type_cells (reg);
}
- /* load up account names into the transfer combobox menus */
- gnc_split_register_load_xfer_cells (reg, default_account);
- gnc_split_register_load_recn_cells (reg);
- gnc_split_register_load_type_cells (reg);
- }
+ if (info->separator_changed)
+ {
+ info->separator_changed = FALSE;
- if (info->separator_changed) {
- info->separator_changed = FALSE;
+ /* set the completion character for the xfer cells */
+ gnc_combo_cell_set_complete_char(
+ (ComboCell *) gnc_table_layout_get_cell(table->layout, MXFRM_CELL),
+ gnc_get_account_separator());
- /* set the completion character for the xfer cells */
- gnc_combo_cell_set_complete_char(
- (ComboCell *) gnc_table_layout_get_cell(table->layout, MXFRM_CELL),
- gnc_get_account_separator());
+ gnc_combo_cell_set_complete_char(
+ (ComboCell *) gnc_table_layout_get_cell(table->layout, XFRM_CELL),
+ gnc_get_account_separator());
- gnc_combo_cell_set_complete_char(
- (ComboCell *) gnc_table_layout_get_cell(table->layout, XFRM_CELL),
- gnc_get_account_separator());
+ /* set the confirmation callback for the reconcile cell */
+ gnc_recn_cell_set_confirm_cb(
+ (RecnCell *) gnc_table_layout_get_cell(table->layout, RECN_CELL),
+ gnc_split_register_recn_cell_confirm, reg);
+ }
- /* set the confirmation callback for the reconcile cell */
- gnc_recn_cell_set_confirm_cb(
- (RecnCell *) gnc_table_layout_get_cell(table->layout, RECN_CELL),
- gnc_split_register_recn_cell_confirm, reg);
- }
+ table->model->dividing_row = -1;
- table->model->dividing_row = -1;
-
- // Ensure that the transaction and splits being edited are in the split
- // list we're about to load.
- if (pending_trans != NULL)
- {
- for (node = xaccTransGetSplitList(pending_trans); node; node = node->next)
+ // Ensure that the transaction and splits being edited are in the split
+ // list we're about to load.
+ if (pending_trans != NULL)
{
- Split *pending_split = (Split*)node->data;
- if (!xaccTransStillHasSplit(pending_trans, pending_split)) continue;
- if (g_list_find(slist, pending_split) != NULL)
- continue;
+ for (node = xaccTransGetSplitList(pending_trans); node; node = node->next)
+ {
+ Split *pending_split = (Split*)node->data;
+ if (!xaccTransStillHasSplit(pending_trans, pending_split)) continue;
+ if (g_list_find(slist, pending_split) != NULL)
+ continue;
- if (g_list_find_custom(slist, pending_trans,
- _find_split_with_parent_txn) != NULL)
- continue;
+ if (g_list_find_custom(slist, pending_trans,
+ _find_split_with_parent_txn) != NULL)
+ continue;
- if (!we_own_slist)
- { // lazy-copy
- slist = g_list_copy(slist);
- we_own_slist = TRUE;
- }
- slist = g_list_append(slist, pending_split);
+ if (!we_own_slist)
+ {
+ // lazy-copy
+ slist = g_list_copy(slist);
+ we_own_slist = TRUE;
+ }
+ slist = g_list_append(slist, pending_split);
+ }
}
- }
- if (multi_line)
- trans_table = g_hash_table_new (g_direct_hash, g_direct_equal);
+ if (multi_line)
+ trans_table = g_hash_table_new (g_direct_hash, g_direct_equal);
- /* populate the table */
- for (node = slist; node; node = node->next)
- {
- split = node->data;
- trans = xaccSplitGetParent (split);
+ /* populate the table */
+ for (node = slist; node; node = node->next)
+ {
+ split = node->data;
+ trans = xaccSplitGetParent (split);
- if (!xaccTransStillHasSplit(trans, split))
- continue;
+ if (!xaccTransStillHasSplit(trans, split))
+ continue;
- if (pending_trans == trans)
- found_pending = TRUE;
+ if (pending_trans == trans)
+ found_pending = TRUE;
- /* Do not load splits from the blank transaction. */
- if (trans == blank_trans)
- continue;
+ /* Do not load splits from the blank transaction. */
+ if (trans == blank_trans)
+ continue;
- if (multi_line)
- {
- /* Skip this split if its transaction has already been loaded. */
- if (g_hash_table_lookup (trans_table, trans))
- continue;
+ if (multi_line)
+ {
+ /* Skip this split if its transaction has already been loaded. */
+ if (g_hash_table_lookup (trans_table, trans))
+ continue;
- g_hash_table_insert (trans_table, trans, trans);
- }
+ g_hash_table_insert (trans_table, trans, trans);
+ }
- if (info->show_present_divider &&
- !found_divider &&
- (present < xaccTransGetDate (trans)))
- {
- table->model->dividing_row = vcell_loc.virt_row;
- found_divider = TRUE;
- }
+ if (info->show_present_divider &&
+ !found_divider &&
+ (present < xaccTransGetDate (trans)))
+ {
+ table->model->dividing_row = vcell_loc.virt_row;
+ found_divider = TRUE;
+ }
- /* If this is the first load of the register,
- * fill up the quickfill cells. */
- if (info->first_pass)
- add_quickfill_completions(reg->table->layout, trans, has_last_num);
+ /* If this is the first load of the register,
+ * fill up the quickfill cells. */
+ if (info->first_pass)
+ add_quickfill_completions(reg->table->layout, trans, has_last_num);
- if (trans == find_trans)
- new_trans_row = vcell_loc.virt_row;
+ if (trans == find_trans)
+ new_trans_row = vcell_loc.virt_row;
- if (split == find_trans_split)
- new_trans_split_row = vcell_loc.virt_row;
+ if (split == find_trans_split)
+ new_trans_split_row = vcell_loc.virt_row;
- gnc_split_register_add_transaction (reg, trans, split,
- lead_cursor, split_cursor,
- multi_line, start_primary_color,
- TRUE,
- find_trans, find_split, find_class,
- &new_split_row, &vcell_loc);
+ gnc_split_register_add_transaction (reg, trans, split,
+ lead_cursor, split_cursor,
+ multi_line, start_primary_color,
+ TRUE,
+ find_trans, find_split, find_class,
+ &new_split_row, &vcell_loc);
- if (!multi_line)
- start_primary_color = !start_primary_color;
- }
+ if (!multi_line)
+ start_primary_color = !start_primary_color;
+ }
- if (multi_line)
- g_hash_table_destroy (trans_table);
+ if (multi_line)
+ g_hash_table_destroy (trans_table);
- /* add the blank split at the end. */
- if (pending_trans == blank_trans)
- found_pending = TRUE;
+ /* add the blank split at the end. */
+ if (pending_trans == blank_trans)
+ found_pending = TRUE;
- if (blank_trans == find_trans)
- new_trans_row = vcell_loc.virt_row;
+ if (blank_trans == find_trans)
+ new_trans_row = vcell_loc.virt_row;
- if (blank_split == find_trans_split)
- new_trans_split_row = vcell_loc.virt_row;
+ if (blank_split == find_trans_split)
+ new_trans_split_row = vcell_loc.virt_row;
- /* If we didn't find the pending transaction, it was removed
- * from the account. */
- if (!found_pending)
- {
- info->pending_trans_guid = *guid_null ();
- if (xaccTransIsOpen (pending_trans))
- xaccTransCommitEdit (pending_trans);
- else if (pending_trans)
- g_assert_not_reached();
+ /* If we didn't find the pending transaction, it was removed
+ * from the account. */
+ if (!found_pending)
+ {
+ info->pending_trans_guid = *guid_null ();
+ if (xaccTransIsOpen (pending_trans))
+ xaccTransCommitEdit (pending_trans);
+ else if (pending_trans)
+ g_assert_not_reached();
- pending_trans = NULL;
- }
+ pending_trans = NULL;
+ }
- /* go to blank on first pass */
- if (info->first_pass)
- {
- new_split_row = -1;
- new_trans_split_row = -1;
- new_trans_row = -1;
+ /* go to blank on first pass */
+ if (info->first_pass)
+ {
+ new_split_row = -1;
+ new_trans_split_row = -1;
+ new_trans_row = -1;
- save_loc.vcell_loc = vcell_loc;
- save_loc.phys_row_offset = 0;
- save_loc.phys_col_offset = 0;
- }
+ save_loc.vcell_loc = vcell_loc;
+ save_loc.phys_row_offset = 0;
+ save_loc.phys_col_offset = 0;
+ }
- gnc_split_register_add_transaction (reg, blank_trans, blank_split,
- lead_cursor, split_cursor,
- multi_line, start_primary_color,
- info->blank_split_edited, find_trans,
- find_split, find_class, &new_split_row,
- &vcell_loc);
+ gnc_split_register_add_transaction (reg, blank_trans, blank_split,
+ lead_cursor, split_cursor,
+ multi_line, start_primary_color,
+ info->blank_split_edited, find_trans,
+ find_split, find_class, &new_split_row,
+ &vcell_loc);
- /* resize the table to the sizes we just counted above */
- /* num_virt_cols is always one. */
- gnc_table_set_size (table, vcell_loc.virt_row, 1);
+ /* resize the table to the sizes we just counted above */
+ /* num_virt_cols is always one. */
+ gnc_table_set_size (table, vcell_loc.virt_row, 1);
- /* restore the cursor to its rightful position */
- {
- VirtualLocation trans_split_loc;
- Split *trans_split;
+ /* restore the cursor to its rightful position */
+ {
+ VirtualLocation trans_split_loc;
+ Split *trans_split;
- if (new_split_row > 0)
- save_loc.vcell_loc.virt_row = new_split_row;
- else if (new_trans_split_row > 0)
- save_loc.vcell_loc.virt_row = new_trans_split_row;
- else if (new_trans_row > 0)
- save_loc.vcell_loc.virt_row = new_trans_row;
+ if (new_split_row > 0)
+ save_loc.vcell_loc.virt_row = new_split_row;
+ else if (new_trans_split_row > 0)
+ save_loc.vcell_loc.virt_row = new_trans_split_row;
+ else if (new_trans_row > 0)
+ save_loc.vcell_loc.virt_row = new_trans_row;
- trans_split_loc = save_loc;
+ trans_split_loc = save_loc;
- trans_split =
- gnc_split_register_get_trans_split (reg, save_loc.vcell_loc,
- &trans_split_loc.vcell_loc);
+ trans_split =
+ gnc_split_register_get_trans_split (reg, save_loc.vcell_loc,
+ &trans_split_loc.vcell_loc);
- if (dynamic || multi_line || info->trans_expanded)
- {
- gnc_table_set_virt_cell_cursor(
- table, trans_split_loc.vcell_loc,
- gnc_split_register_get_active_cursor (reg));
- gnc_split_register_set_trans_visible (reg, trans_split_loc.vcell_loc,
- TRUE, multi_line);
+ if (dynamic || multi_line || info->trans_expanded)
+ {
+ gnc_table_set_virt_cell_cursor(
+ table, trans_split_loc.vcell_loc,
+ gnc_split_register_get_active_cursor (reg));
+ gnc_split_register_set_trans_visible (reg, trans_split_loc.vcell_loc,
+ TRUE, multi_line);
- info->trans_expanded = (reg->style == REG_STYLE_LEDGER);
- }
- else
- {
- save_loc = trans_split_loc;
- info->trans_expanded = FALSE;
- }
+ info->trans_expanded = (reg->style == REG_STYLE_LEDGER);
+ }
+ else
+ {
+ save_loc = trans_split_loc;
+ info->trans_expanded = FALSE;
+ }
- if (gnc_table_find_close_valid_cell (table, &save_loc, FALSE))
- {
- gnc_table_move_cursor_gui (table, save_loc);
- new_split_row = save_loc.vcell_loc.virt_row;
+ if (gnc_table_find_close_valid_cell (table, &save_loc, FALSE))
+ {
+ gnc_table_move_cursor_gui (table, save_loc);
+ new_split_row = save_loc.vcell_loc.virt_row;
- if (find_split == gnc_split_register_get_current_split (reg))
- gnc_table_restore_current_cursor (table, cursor_buffer);
+ if (find_split == gnc_split_register_get_current_split (reg))
+ gnc_table_restore_current_cursor (table, cursor_buffer);
+ }
+
+ gnc_cursor_buffer_destroy (cursor_buffer);
+ cursor_buffer = NULL;
}
- gnc_cursor_buffer_destroy (cursor_buffer);
- cursor_buffer = NULL;
- }
+ /* Set up the hint transaction, split, transaction split, and column. */
+ info->cursor_hint_trans = gnc_split_register_get_current_trans (reg);
+ info->cursor_hint_split = gnc_split_register_get_current_split (reg);
+ info->cursor_hint_trans_split =
+ gnc_split_register_get_current_trans_split (reg, NULL);
+ info->cursor_hint_cursor_class =
+ gnc_split_register_get_current_cursor_class (reg);
+ info->hint_set_by_traverse = FALSE;
+ info->traverse_to_new = FALSE;
+ info->exact_traversal = FALSE;
+ info->first_pass = FALSE;
+ info->reg_loaded = TRUE;
- /* Set up the hint transaction, split, transaction split, and column. */
- info->cursor_hint_trans = gnc_split_register_get_current_trans (reg);
- info->cursor_hint_split = gnc_split_register_get_current_split (reg);
- info->cursor_hint_trans_split =
- gnc_split_register_get_current_trans_split (reg, NULL);
- info->cursor_hint_cursor_class =
- gnc_split_register_get_current_cursor_class (reg);
- info->hint_set_by_traverse = FALSE;
- info->traverse_to_new = FALSE;
- info->exact_traversal = FALSE;
- info->first_pass = FALSE;
- info->reg_loaded = TRUE;
+ gnc_split_register_set_cell_fractions(
+ reg, gnc_split_register_get_current_split (reg));
- gnc_split_register_set_cell_fractions(
- reg, gnc_split_register_get_current_split (reg));
+ gnc_table_refresh_gui (table, TRUE);
- gnc_table_refresh_gui (table, TRUE);
+ gnc_split_register_show_trans (reg, table->current_cursor_loc.vcell_loc);
- gnc_split_register_show_trans (reg, table->current_cursor_loc.vcell_loc);
+ /* enable callback for cursor user-driven moves */
+ gnc_table_control_allow_move (table->control, TRUE);
- /* enable callback for cursor user-driven moves */
- gnc_table_control_allow_move (table->control, TRUE);
+ if (we_own_slist)
+ g_list_free(slist);
- if (we_own_slist)
- g_list_free(slist);
-
- LEAVE(" ");
+ LEAVE(" ");
}
/* ===================================================================== */
@@ -681,40 +690,40 @@
static gboolean
skip_cb (Account *account, gpointer x)
{
- /* commented out as per Bug#340885 Comments 1 and 2, option (2).
- if (xaccAccountIsHidden(account))
- return TRUE;
- */
- return xaccAccountGetPlaceholder (account);
+ /* commented out as per Bug#340885 Comments 1 and 2, option (2).
+ if (xaccAccountIsHidden(account))
+ return TRUE;
+ */
+ return xaccAccountGetPlaceholder (account);
}
static void
gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
{
- Account *root = NULL;
- QuickFill *qf;
- ComboCell *cell;
- GtkListStore *store;
+ Account *root = NULL;
+ QuickFill *qf;
+ ComboCell *cell;
+ GtkListStore *store;
- if (base_account)
- root = gnc_account_get_root(base_account);
- if (root == NULL)
- root = gnc_get_current_root_account();
- if (root == NULL)
- return;
+ if (base_account)
+ root = gnc_account_get_root(base_account);
+ if (root == NULL)
+ root = gnc_get_current_root_account();
+ if (root == NULL)
+ return;
- qf = gnc_get_shared_account_name_quickfill (root, QKEY, skip_cb, NULL);
- store = gnc_get_shared_account_name_list_store (root, QKEY, skip_cb, NULL);
+ qf = gnc_get_shared_account_name_quickfill (root, QKEY, skip_cb, NULL);
+ store = gnc_get_shared_account_name_list_store (root, QKEY, skip_cb, NULL);
- cell = (ComboCell *)
- gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
- gnc_combo_cell_use_quickfill_cache (cell, qf);
- gnc_combo_cell_use_list_store_cache (cell, store);
+ cell = (ComboCell *)
+ gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
+ gnc_combo_cell_use_quickfill_cache (cell, qf);
+ gnc_combo_cell_use_list_store_cache (cell, store);
- cell = (ComboCell *)
- gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
- gnc_combo_cell_use_quickfill_cache (cell, qf);
- gnc_combo_cell_use_list_store_cache (cell, store);
+ cell = (ComboCell *)
+ gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
+ gnc_combo_cell_use_quickfill_cache (cell, qf);
+ gnc_combo_cell_use_list_store_cache (cell, store);
}
/* ====================== END OF FILE ================================== */
Modified: gnucash/trunk/src/register/ledger-core/split-register-model-save.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model-save.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-model-save.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -37,12 +37,12 @@
struct sr_save_data
{
- Transaction *trans;
- Split *split;
+ Transaction *trans;
+ Split *split;
- gboolean handled_dc; /* We have already handled the debit/credit cells. */
- gboolean do_scrub; /* Scrub other split at the end. */
- gboolean reg_expanded; /* Register is in expanded (split) mode */
+ gboolean handled_dc; /* We have already handled the debit/credit cells. */
+ gboolean do_scrub; /* Scrub other split at the end. */
+ gboolean reg_expanded; /* Register is in expanded (split) mode */
};
/* This static indicates the debugging module that this .o belongs to. */
@@ -54,37 +54,37 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- const char *value;
- Timespec ts;
+ SRSaveData *sd = save_data;
+ const char *value;
+ Timespec ts;
- g_return_if_fail (gnc_basic_cell_has_name (cell, DATE_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, DATE_CELL));
- value = gnc_basic_cell_get_value (cell);
+ value = gnc_basic_cell_get_value (cell);
- /* commit any pending changes */
- gnc_date_cell_commit ((DateCell *) cell);
+ /* commit any pending changes */
+ gnc_date_cell_commit ((DateCell *) cell);
- DEBUG ("DATE: %s", value ? value : "(null)");
+ DEBUG ("DATE: %s", value ? value : "(null)");
- gnc_date_cell_get_date ((DateCell *) cell, &ts);
+ gnc_date_cell_get_date ((DateCell *) cell, &ts);
- xaccTransSetDatePostedTS (sd->trans, &ts);
+ xaccTransSetDatePostedTS (sd->trans, &ts);
}
static void
gnc_split_register_save_type_cell (BasicCell * cell,
- gpointer save_data,
- gpointer user_data)
+ gpointer save_data,
+ gpointer user_data)
{
- SRSaveData *sd = save_data;
- char value;
+ SRSaveData *sd = save_data;
+ char value;
- g_return_if_fail (gnc_basic_cell_has_name (cell, TYPE_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, TYPE_CELL));
- value = gnc_recn_cell_get_flag ((RecnCell *)cell);
+ value = gnc_recn_cell_get_flag ((RecnCell *)cell);
- xaccTransSetTxnType (sd->trans, value);
+ xaccTransSetTxnType (sd->trans, value);
}
static void
@@ -92,22 +92,22 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- const char *value;
- Timespec ts;
+ SRSaveData *sd = save_data;
+ const char *value;
+ Timespec ts;
- g_return_if_fail (gnc_basic_cell_has_name (cell, DDUE_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, DDUE_CELL));
- value = gnc_basic_cell_get_value (cell);
+ value = gnc_basic_cell_get_value (cell);
- /* commit any pending changes */
- gnc_date_cell_commit ((DateCell *) cell);
+ /* commit any pending changes */
+ gnc_date_cell_commit ((DateCell *) cell);
- DEBUG ("DATE: %s", value ? value : "(null)");
+ DEBUG ("DATE: %s", value ? value : "(null)");
- gnc_date_cell_get_date ((DateCell *) cell, &ts);
+ gnc_date_cell_get_date ((DateCell *) cell, &ts);
- xaccTransSetDateDueTS (sd->trans, &ts);
+ xaccTransSetDateDueTS (sd->trans, &ts);
}
static void
@@ -115,28 +115,28 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- SplitRegister *reg = user_data;
- const char *value;
+ SRSaveData *sd = save_data;
+ SplitRegister *reg = user_data;
+ const char *value;
- g_return_if_fail (gnc_basic_cell_has_name (cell, NUM_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, NUM_CELL));
- value = gnc_basic_cell_get_value (cell);
+ value = gnc_basic_cell_get_value (cell);
- DEBUG ("NUM: %s\n", value ? value : "(null)");
+ DEBUG ("NUM: %s\n", value ? value : "(null)");
- xaccTransSetNum (sd->trans, value);
+ xaccTransSetNum (sd->trans, value);
- if (gnc_num_cell_set_last_num ((NumCell *) cell, value))
- {
- SRInfo *info = gnc_split_register_get_info (reg);
- Split *blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
- Transaction *blank_trans = xaccSplitGetParent (blank_split);
+ if (gnc_num_cell_set_last_num ((NumCell *) cell, value))
+ {
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Split *blank_split = xaccSplitLookup (&info->blank_split_guid,
+ gnc_get_current_book ());
+ Transaction *blank_trans = xaccSplitGetParent (blank_split);
- if (sd->trans == blank_trans)
- gnc_split_register_set_last_num (reg, gnc_basic_cell_get_value (cell));
- }
+ if (sd->trans == blank_trans)
+ gnc_split_register_set_last_num (reg, gnc_basic_cell_get_value (cell));
+ }
}
static void
@@ -144,16 +144,16 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- const char *value;
+ SRSaveData *sd = save_data;
+ const char *value;
- g_return_if_fail (gnc_basic_cell_has_name (cell, DESC_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, DESC_CELL));
- value = gnc_basic_cell_get_value (cell);
+ value = gnc_basic_cell_get_value (cell);
- DEBUG ("DESC: %s", value ? value : "(null)");
+ DEBUG ("DESC: %s", value ? value : "(null)");
- xaccTransSetDescription (sd->trans, value);
+ xaccTransSetDescription (sd->trans, value);
}
static void
@@ -161,16 +161,16 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- const char *value;
+ SRSaveData *sd = save_data;
+ const char *value;
- g_return_if_fail (gnc_basic_cell_has_name (cell, NOTES_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, NOTES_CELL));
- value = gnc_basic_cell_get_value (cell);
+ value = gnc_basic_cell_get_value (cell);
- DEBUG ("NOTES: %s", value ? value : "(null)");
+ DEBUG ("NOTES: %s", value ? value : "(null)");
- xaccTransSetNotes (sd->trans, value);
+ xaccTransSetNotes (sd->trans, value);
}
static void
@@ -178,14 +178,14 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- RecnCell *cell = (RecnCell *) bcell;
+ SRSaveData *sd = save_data;
+ RecnCell *cell = (RecnCell *) bcell;
- g_return_if_fail (gnc_basic_cell_has_name (bcell, RECN_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (bcell, RECN_CELL));
- DEBUG ("RECN: %c", gnc_recn_cell_get_flag (cell));
+ DEBUG ("RECN: %c", gnc_recn_cell_get_flag (cell));
- xaccSplitSetReconcile (sd->split, gnc_recn_cell_get_flag (cell));
+ xaccSplitSetReconcile (sd->split, gnc_recn_cell_get_flag (cell));
}
static void
@@ -193,16 +193,16 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- const char *value;
+ SRSaveData *sd = save_data;
+ const char *value;
- g_return_if_fail (gnc_basic_cell_has_name (cell, ACTN_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, ACTN_CELL));
- value = gnc_basic_cell_get_value (cell);
+ value = gnc_basic_cell_get_value (cell);
- DEBUG ("ACTN: %s", value ? value : "(null)");
+ DEBUG ("ACTN: %s", value ? value : "(null)");
- xaccSplitSetAction (sd->split, value);
+ xaccSplitSetAction (sd->split, value);
}
static void
@@ -210,16 +210,16 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- const char *value;
+ SRSaveData *sd = save_data;
+ const char *value;
- g_return_if_fail (gnc_basic_cell_has_name (cell, MEMO_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, MEMO_CELL));
- value = gnc_basic_cell_get_value (cell);
+ value = gnc_basic_cell_get_value (cell);
- DEBUG ("MEMO: %s", value ? value : "(null)");
+ DEBUG ("MEMO: %s", value ? value : "(null)");
- xaccSplitSetMemo (sd->split, value);
+ xaccSplitSetMemo (sd->split, value);
}
/* OK, the handling of transfers gets complicated because it depends
@@ -232,19 +232,19 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- SplitRegister *reg = user_data;
- Account *old_acc;
- Account *new_acc;
+ SRSaveData *sd = save_data;
+ SplitRegister *reg = user_data;
+ Account *old_acc;
+ Account *new_acc;
- g_return_if_fail (gnc_basic_cell_has_name (cell, XFRM_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, XFRM_CELL));
- old_acc = xaccSplitGetAccount (sd->split);
+ old_acc = xaccSplitGetAccount (sd->split);
- new_acc = gnc_split_register_get_account (reg, XFRM_CELL);
+ new_acc = gnc_split_register_get_account (reg, XFRM_CELL);
- if ((new_acc != NULL) && (old_acc != new_acc))
- xaccAccountInsertSplit (new_acc, sd->split);
+ if ((new_acc != NULL) && (old_acc != new_acc))
+ xaccAccountInsertSplit (new_acc, sd->split);
}
static void
@@ -252,47 +252,47 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- SplitRegister *reg = user_data;
- Split * other_split;
+ SRSaveData *sd = save_data;
+ SplitRegister *reg = user_data;
+ Split * other_split;
- g_return_if_fail (gnc_basic_cell_has_name (cell, MXFRM_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, MXFRM_CELL));
- other_split = xaccSplitGetOtherSplit (sd->split);
+ other_split = xaccSplitGetOtherSplit (sd->split);
- /* other_split may be null for two very different reasons:
- * (1) the parent transaction has three or more splits in it,
- * and so the "other" split is ambiguous, and thus null.
- * (2) the parent transaction has only this one split as a child.
- * and "other" is null because there is no other.
- *
- * In the case (2), we want to create the other split, so that
- * the user's request to transfer actually works out. */
+ /* other_split may be null for two very different reasons:
+ * (1) the parent transaction has three or more splits in it,
+ * and so the "other" split is ambiguous, and thus null.
+ * (2) the parent transaction has only this one split as a child.
+ * and "other" is null because there is no other.
+ *
+ * In the case (2), we want to create the other split, so that
+ * the user's request to transfer actually works out. */
- if (!other_split)
- {
- other_split = xaccTransGetSplit (sd->trans, 1);
-
if (!other_split)
{
- other_split = xaccMallocSplit (gnc_get_current_book ());
- xaccTransAppendSplit (sd->trans, other_split);
+ other_split = xaccTransGetSplit (sd->trans, 1);
+
+ if (!other_split)
+ {
+ other_split = xaccMallocSplit (gnc_get_current_book ());
+ xaccTransAppendSplit (sd->trans, other_split);
+ }
}
- }
- if (other_split)
- {
- Account *old_acc;
- Account *new_acc;
+ if (other_split)
+ {
+ Account *old_acc;
+ Account *new_acc;
- /* Do some reparenting. Insertion into new account
- * will automatically delete from the old account. */
- old_acc = xaccSplitGetAccount (other_split);
- new_acc = gnc_split_register_get_account (reg, MXFRM_CELL);
+ /* Do some reparenting. Insertion into new account
+ * will automatically delete from the old account. */
+ old_acc = xaccSplitGetAccount (other_split);
+ new_acc = gnc_split_register_get_account (reg, MXFRM_CELL);
- if ((new_acc != NULL) && (old_acc != new_acc))
- xaccAccountInsertSplit (new_acc, other_split);
- }
+ if ((new_acc != NULL) && (old_acc != new_acc))
+ xaccAccountInsertSplit (new_acc, other_split);
+ }
}
static void
@@ -300,19 +300,19 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- PriceCell *cell = (PriceCell *) bcell;
- gnc_numeric amount;
+ SRSaveData *sd = save_data;
+ PriceCell *cell = (PriceCell *) bcell;
+ gnc_numeric amount;
- g_return_if_fail (gnc_basic_cell_has_name (bcell, SHRS_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (bcell, SHRS_CELL));
- amount = gnc_price_cell_get_value (cell);
+ amount = gnc_price_cell_get_value (cell);
- DEBUG ("SHRS");
+ DEBUG ("SHRS");
- xaccSplitSetAmount (sd->split, amount);
+ xaccSplitSetAmount (sd->split, amount);
- sd->do_scrub = TRUE;
+ sd->do_scrub = TRUE;
}
static void
@@ -320,166 +320,176 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- PriceCell *cell = (PriceCell *) bcell;
- gnc_numeric price;
+ SRSaveData *sd = save_data;
+ PriceCell *cell = (PriceCell *) bcell;
+ gnc_numeric price;
- g_return_if_fail (gnc_basic_cell_has_name (bcell, PRIC_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (bcell, PRIC_CELL));
- price = gnc_price_cell_get_value (cell);
+ price = gnc_price_cell_get_value (cell);
- DEBUG ("PRIC");
+ DEBUG ("PRIC");
- /* If we handled the Debcred cell then don't set the share price! */
- if (!sd->handled_dc)
- xaccSplitSetSharePrice (sd->split, price);
+ /* If we handled the Debcred cell then don't set the share price! */
+ if (!sd->handled_dc)
+ xaccSplitSetSharePrice (sd->split, price);
- sd->do_scrub = TRUE;
+ sd->do_scrub = TRUE;
}
gnc_numeric
gnc_split_register_debcred_cell_value (SplitRegister *reg)
{
- PriceCell *cell;
- gnc_numeric new_amount;
- gnc_numeric credit;
- gnc_numeric debit;
-
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- CRED_CELL);
- credit = gnc_price_cell_get_value (cell);
+ PriceCell *cell;
+ gnc_numeric new_amount;
+ gnc_numeric credit;
+ gnc_numeric debit;
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- DEBT_CELL);
- debit = gnc_price_cell_get_value (cell);
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ CRED_CELL);
+ credit = gnc_price_cell_get_value (cell);
- new_amount = gnc_numeric_sub_fixed (debit, credit);
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ DEBT_CELL);
+ debit = gnc_price_cell_get_value (cell);
- return new_amount;
+ new_amount = gnc_numeric_sub_fixed (debit, credit);
+
+ return new_amount;
}
static gnc_numeric
gnc_split_register_get_rate_cell (SplitRegister *reg, const char *cell_name)
{
- PriceCell *rate_cell;
+ PriceCell *rate_cell;
- rate_cell = (PriceCell*) gnc_table_layout_get_cell (reg->table->layout,
- cell_name);
- if (rate_cell)
- return gnc_price_cell_get_value (rate_cell);
+ rate_cell = (PriceCell*) gnc_table_layout_get_cell (reg->table->layout,
+ cell_name);
+ if (rate_cell)
+ return gnc_price_cell_get_value (rate_cell);
- /* Uhh, just return '1' */
- return gnc_numeric_create (100,100);
+ /* Uhh, just return '1' */
+ return gnc_numeric_create (100, 100);
}
gboolean
gnc_split_register_split_needs_amount (SplitRegister *reg, Split *split)
{
- Transaction *txn = xaccSplitGetParent (split);
- Account *acc = xaccSplitGetAccount (split);
+ Transaction *txn = xaccSplitGetParent (split);
+ Account *acc = xaccSplitGetAccount (split);
- return gnc_split_register_needs_conv_rate (reg, txn, acc);
+ return gnc_split_register_needs_conv_rate (reg, txn, acc);
}
static void
gnc_split_register_save_amount_values (SRSaveData *sd, SplitRegister *reg)
{
- Account *acc;
- gnc_numeric new_amount, convrate, amtconv, value;
- gnc_commodity *curr, *reg_com, *xfer_com;
- Account *xfer_acc;
+ Account *acc;
+ gnc_numeric new_amount, convrate, amtconv, value;
+ gnc_commodity *curr, *reg_com, *xfer_com;
+ Account *xfer_acc;
- new_amount = gnc_split_register_debcred_cell_value (reg);
- acc = gnc_split_register_get_default_account (reg);
-
- xfer_acc = xaccSplitGetAccount (sd->split);
- xfer_com = xaccAccountGetCommodity (xfer_acc);
- reg_com = xaccAccountGetCommodity (acc);
- curr = xaccTransGetCurrency (sd->trans);
-
- /* First, compute the conversion rate to convert the value to the
- * amount.
- */
- amtconv = convrate = gnc_split_register_get_rate_cell (reg, RATE_CELL);
- if (gnc_split_register_needs_conv_rate (reg, sd->trans, acc)) {
-
- /* If we are in an expanded register and the xfer_acc->comm !=
- * reg_acc->comm then we need to compute the convrate here.
- * Otherwise, we _can_ use the rate_cell!
- */
- if (sd->reg_expanded && ! gnc_commodity_equal (reg_com, xfer_com))
- amtconv = xaccTransGetAccountConvRate(sd->trans, acc);
- }
-
- if (xaccTransUseTradingAccounts (sd->trans)) {
- /* Using currency accounts, the amount is probably really the
- amount and not the value. */
- gboolean is_amount;
- if (reg->type == STOCK_REGISTER ||
- reg->type == CURRENCY_REGISTER ||
- reg->type == PORTFOLIO_LEDGER) {
- if (xaccAccountIsPriced(xfer_acc) ||
- !gnc_commodity_is_iso(xaccAccountGetCommodity(xfer_acc)))
- is_amount = FALSE;
- else
- is_amount = TRUE;
+ new_amount = gnc_split_register_debcred_cell_value (reg);
+ acc = gnc_split_register_get_default_account (reg);
+
+ xfer_acc = xaccSplitGetAccount (sd->split);
+ xfer_com = xaccAccountGetCommodity (xfer_acc);
+ reg_com = xaccAccountGetCommodity (acc);
+ curr = xaccTransGetCurrency (sd->trans);
+
+ /* First, compute the conversion rate to convert the value to the
+ * amount.
+ */
+ amtconv = convrate = gnc_split_register_get_rate_cell (reg, RATE_CELL);
+ if (gnc_split_register_needs_conv_rate (reg, sd->trans, acc))
+ {
+
+ /* If we are in an expanded register and the xfer_acc->comm !=
+ * reg_acc->comm then we need to compute the convrate here.
+ * Otherwise, we _can_ use the rate_cell!
+ */
+ if (sd->reg_expanded && ! gnc_commodity_equal (reg_com, xfer_com))
+ amtconv = xaccTransGetAccountConvRate(sd->trans, acc);
}
- else {
- is_amount = TRUE;
- }
- if (is_amount) {
- xaccSplitSetAmount(sd->split, new_amount);
- if (gnc_split_register_split_needs_amount (reg, sd->split)) {
- value = gnc_numeric_div(new_amount, amtconv,
- gnc_commodity_get_fraction(curr),
- GNC_RND_ROUND);
- xaccSplitSetValue(sd->split, value);
- }
- else
- xaccSplitSetValue(sd->split, new_amount);
+ if (xaccTransUseTradingAccounts (sd->trans))
+ {
+ /* Using currency accounts, the amount is probably really the
+ amount and not the value. */
+ gboolean is_amount;
+ if (reg->type == STOCK_REGISTER ||
+ reg->type == CURRENCY_REGISTER ||
+ reg->type == PORTFOLIO_LEDGER)
+ {
+ if (xaccAccountIsPriced(xfer_acc) ||
+ !gnc_commodity_is_iso(xaccAccountGetCommodity(xfer_acc)))
+ is_amount = FALSE;
+ else
+ is_amount = TRUE;
+ }
+ else
+ {
+ is_amount = TRUE;
+ }
+
+ if (is_amount)
+ {
+ xaccSplitSetAmount(sd->split, new_amount);
+ if (gnc_split_register_split_needs_amount (reg, sd->split))
+ {
+ value = gnc_numeric_div(new_amount, amtconv,
+ gnc_commodity_get_fraction(curr),
+ GNC_RND_ROUND);
+ xaccSplitSetValue(sd->split, value);
+ }
+ else
+ xaccSplitSetValue(sd->split, new_amount);
+ }
+ else
+ {
+ xaccSplitSetValue(sd->split, new_amount);
+ }
+
+ return;
}
- else {
- xaccSplitSetValue(sd->split, new_amount);
- }
-
- return;
- }
-
- /* How to interpret new_amount depends on our view of this
- * transaction. If we're sitting in an account with the same
- * commodity as the transaction, then we can set the Value and then
- * compute the amount. Otherwise we are setting the "converted
- * value". This means we need to convert new_amount to the actual
- * 'value' by dividing by the convrate in order to set the value.
- */
- /* Now compute/set the split value. Amount is in the register
- * currency but we need to convert to the txn currency.
- */
- if (gnc_split_register_needs_conv_rate (reg, sd->trans, acc)) {
+ /* How to interpret new_amount depends on our view of this
+ * transaction. If we're sitting in an account with the same
+ * commodity as the transaction, then we can set the Value and then
+ * compute the amount. Otherwise we are setting the "converted
+ * value". This means we need to convert new_amount to the actual
+ * 'value' by dividing by the convrate in order to set the value.
+ */
- /* convert the amount to the Value ... */
- value = gnc_numeric_div (new_amount, amtconv,
- gnc_commodity_get_fraction (curr),
- GNC_RND_ROUND);
- xaccSplitSetValue (sd->split, value);
- } else
- xaccSplitSetValue (sd->split, new_amount);
+ /* Now compute/set the split value. Amount is in the register
+ * currency but we need to convert to the txn currency.
+ */
+ if (gnc_split_register_needs_conv_rate (reg, sd->trans, acc))
+ {
- /* Now re-compute the Amount from the Value. We may need to convert
- * from the Value back to the amount here using the convrate from
- * earlier.
- */
- value = xaccSplitGetValue (sd->split);
+ /* convert the amount to the Value ... */
+ value = gnc_numeric_div (new_amount, amtconv,
+ gnc_commodity_get_fraction (curr),
+ GNC_RND_ROUND);
+ xaccSplitSetValue (sd->split, value);
+ }
+ else
+ xaccSplitSetValue (sd->split, new_amount);
- if (gnc_split_register_split_needs_amount (reg, sd->split)) {
- acc = xaccSplitGetAccount (sd->split);
- new_amount = gnc_numeric_mul (value, convrate,
- xaccAccountGetCommoditySCU (acc),
- GNC_RND_ROUND);
- xaccSplitSetAmount (sd->split, new_amount);
- }
+ /* Now re-compute the Amount from the Value. We may need to convert
+ * from the Value back to the amount here using the convrate from
+ * earlier.
+ */
+ value = xaccSplitGetValue (sd->split);
+
+ if (gnc_split_register_split_needs_amount (reg, sd->split))
+ {
+ acc = xaccSplitGetAccount (sd->split);
+ new_amount = gnc_numeric_mul (value, convrate,
+ xaccAccountGetCommoditySCU (acc),
+ GNC_RND_ROUND);
+ xaccSplitSetAmount (sd->split, new_amount);
+ }
}
static void
@@ -487,133 +497,133 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- SplitRegister *reg = user_data;
+ SRSaveData *sd = save_data;
+ SplitRegister *reg = user_data;
- g_return_if_fail (gnc_basic_cell_has_name (bcell, DEBT_CELL) ||
- gnc_basic_cell_has_name (bcell, CRED_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (bcell, DEBT_CELL) ||
+ gnc_basic_cell_has_name (bcell, CRED_CELL));
- if (sd->handled_dc)
- return;
+ if (sd->handled_dc)
+ return;
- gnc_split_register_save_amount_values (sd, reg);
+ gnc_split_register_save_amount_values (sd, reg);
- sd->handled_dc = TRUE;
- sd->do_scrub = TRUE;
+ sd->handled_dc = TRUE;
+ sd->do_scrub = TRUE;
}
static void
gnc_split_register_save_rate_cell (BasicCell * bcell,
- gpointer save_data,
- gpointer user_data)
+ gpointer save_data,
+ gpointer user_data)
{
- SRSaveData *sd = save_data;
+ SRSaveData *sd = save_data;
- /* if the exchrate cell changed, then make sure to force a scrub */
- sd->do_scrub = TRUE;
+ /* if the exchrate cell changed, then make sure to force a scrub */
+ sd->do_scrub = TRUE;
}
static void
gnc_split_register_save_cells (gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- SplitRegister *reg = user_data;
- Split *other_split;
- gnc_commodity *txn_cur;
- gnc_numeric rate = gnc_numeric_zero();
+ SRSaveData *sd = save_data;
+ SplitRegister *reg = user_data;
+ Split *other_split;
+ gnc_commodity *txn_cur;
+ gnc_numeric rate = gnc_numeric_zero();
- g_return_if_fail (sd != NULL);
+ g_return_if_fail (sd != NULL);
- if (!sd->do_scrub)
- return;
+ if (!sd->do_scrub)
+ return;
- other_split = xaccSplitGetOtherSplit (sd->split);
- txn_cur = xaccTransGetCurrency (sd->trans);
+ other_split = xaccSplitGetOtherSplit (sd->split);
+ txn_cur = xaccTransGetCurrency (sd->trans);
- xaccSplitScrub (sd->split);
+ xaccSplitScrub (sd->split);
- rate = gnc_split_register_get_rate_cell (reg, RATE_CELL);
+ rate = gnc_split_register_get_rate_cell (reg, RATE_CELL);
- if (other_split && !sd->reg_expanded)
- {
- gnc_numeric amount, value = xaccSplitGetValue (sd->split);
- Account *acc;
- gboolean split_needs_amount;
+ if (other_split && !sd->reg_expanded)
+ {
+ gnc_numeric amount, value = xaccSplitGetValue (sd->split);
+ Account *acc;
+ gboolean split_needs_amount;
- split_needs_amount = gnc_split_register_split_needs_amount(reg, sd->split);
+ split_needs_amount = gnc_split_register_split_needs_amount(reg, sd->split);
- /* We are changing the rate on the current split, but it was not
- * handled in the debcred handler, so we need to do it here.
- */
- if (!sd->handled_dc && split_needs_amount && !gnc_numeric_zero_p (rate))
- {
- gnc_numeric amount = xaccSplitGetAmount (sd->split);
- value = gnc_numeric_div(
- amount, rate, gnc_commodity_get_fraction(txn_cur), GNC_RND_ROUND);
- xaccSplitSetValue (sd->split, value);
+ /* We are changing the rate on the current split, but it was not
+ * handled in the debcred handler, so we need to do it here.
+ */
+ if (!sd->handled_dc && split_needs_amount && !gnc_numeric_zero_p (rate))
+ {
+ gnc_numeric amount = xaccSplitGetAmount (sd->split);
+ value = gnc_numeric_div(
+ amount, rate, gnc_commodity_get_fraction(txn_cur), GNC_RND_ROUND);
+ xaccSplitSetValue (sd->split, value);
- /* XXX: do we need to set the amount on the other split? */
- }
+ /* XXX: do we need to set the amount on the other split? */
+ }
- /* Now reverse the value for the other split */
- value = gnc_numeric_neg (value);
+ /* Now reverse the value for the other split */
+ value = gnc_numeric_neg (value);
- if (gnc_split_register_split_needs_amount (reg, other_split))
- {
- acc = xaccSplitGetAccount (other_split);
+ if (gnc_split_register_split_needs_amount (reg, other_split))
+ {
+ acc = xaccSplitGetAccount (other_split);
- /* If we don't have an exchange rate then figure it out. Or, if
- * BOTH splits require an amount, then most likely we're in the
- * strange case of having a transaction currency different than
- * _both_ accounts -- so grab the other exchange rate.
- */
- if (gnc_numeric_zero_p (rate) || split_needs_amount)
- rate = xaccTransGetAccountConvRate(xaccSplitGetParent (other_split),
- acc);
+ /* If we don't have an exchange rate then figure it out. Or, if
+ * BOTH splits require an amount, then most likely we're in the
+ * strange case of having a transaction currency different than
+ * _both_ accounts -- so grab the other exchange rate.
+ */
+ if (gnc_numeric_zero_p (rate) || split_needs_amount)
+ rate = xaccTransGetAccountConvRate(xaccSplitGetParent (other_split),
+ acc);
- amount = gnc_numeric_mul (value, rate, xaccAccountGetCommoditySCU (acc),
- GNC_RND_ROUND);
- xaccSplitSetAmount (other_split, amount);
+ amount = gnc_numeric_mul (value, rate, xaccAccountGetCommoditySCU (acc),
+ GNC_RND_ROUND);
+ xaccSplitSetAmount (other_split, amount);
- }
+ }
- xaccSplitSetValue (other_split, value);
+ xaccSplitSetValue (other_split, value);
- xaccSplitScrub (other_split);
- }
- else if (gnc_split_register_split_needs_amount (reg, sd->split) &&
- ! gnc_numeric_zero_p (rate))
- {
- /* this is either a multi-split or expanded transaction, so only
- * deal with this split... In particular we need to reset the
- * Value if the conv-rate changed.
- *
- * If we handled the debcred then no need to do anything there --
- * the debcred handler did all the computation. If NOT, then the
- * convrate changed -- reset the value from the amount.
- */
- if (!sd->handled_dc)
+ xaccSplitScrub (other_split);
+ }
+ else if (gnc_split_register_split_needs_amount (reg, sd->split) &&
+ ! gnc_numeric_zero_p (rate))
{
- gnc_split_register_save_amount_values (sd, reg);
+ /* this is either a multi-split or expanded transaction, so only
+ * deal with this split... In particular we need to reset the
+ * Value if the conv-rate changed.
+ *
+ * If we handled the debcred then no need to do anything there --
+ * the debcred handler did all the computation. If NOT, then the
+ * convrate changed -- reset the value from the amount.
+ */
+ if (!sd->handled_dc)
+ {
+ gnc_split_register_save_amount_values (sd, reg);
#if 0
- gnc_numeric value, amount;
+ gnc_numeric value, amount;
- amount = xaccSplitGetAmount (sd->split);
- value = gnc_numeric_div (amount, rate, gnc_commodity_get_fraction (txn_cur),
- GNC_RND_ROUND);
- xaccSplitSetValue (sd->split, value);
+ amount = xaccSplitGetAmount (sd->split);
+ value = gnc_numeric_div (amount, rate, gnc_commodity_get_fraction (txn_cur),
+ GNC_RND_ROUND);
+ xaccSplitSetValue (sd->split, value);
#endif
+ }
}
- }
}
static void
gnc_template_register_save_unexpected_cell (BasicCell * cell,
- gpointer save_data,
- gpointer user_data)
+ gpointer save_data,
+ gpointer user_data)
{
- PERR ("unexpected changed fields in a template register");
+ PERR ("unexpected changed fields in a template register");
}
static void
@@ -621,34 +631,34 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- SplitRegister *reg = user_data;
- SRInfo *info = gnc_split_register_get_info (reg);
- Account *template_acc;
- const GUID *acctGUID;
- kvp_frame *kvpf;
- Account *acct;
+ SRSaveData *sd = save_data;
+ SplitRegister *reg = user_data;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Account *template_acc;
+ const GUID *acctGUID;
+ kvp_frame *kvpf;
+ Account *acct;
- g_return_if_fail (gnc_basic_cell_has_name (cell, XFRM_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, XFRM_CELL));
- /* save the account GUID into the kvp_data. */
- acct = gnc_split_register_get_account (reg, XFRM_CELL);
- if (!acct)
- {
- PERR ("unknown account");
- return;
- }
+ /* save the account GUID into the kvp_data. */
+ acct = gnc_split_register_get_account (reg, XFRM_CELL);
+ if (!acct)
+ {
+ PERR ("unknown account");
+ return;
+ }
- acctGUID = xaccAccountGetGUID (acct);
- kvpf = xaccSplitGetSlots (sd->split);
- kvp_frame_set_slot_path (kvpf, kvp_value_new_guid(acctGUID),
- GNC_SX_ID, GNC_SX_ACCOUNT, NULL);
+ acctGUID = xaccAccountGetGUID (acct);
+ kvpf = xaccSplitGetSlots (sd->split);
+ kvp_frame_set_slot_path (kvpf, kvp_value_new_guid(acctGUID),
+ GNC_SX_ID, GNC_SX_ACCOUNT, NULL);
- template_acc = xaccAccountLookup (&info->template_account,
- gnc_get_current_book ());
+ template_acc = xaccAccountLookup (&info->template_account,
+ gnc_get_current_book ());
- /* set the actual account to the fake account for these templates */
- xaccAccountInsertSplit (template_acc, sd->split);
+ /* set the actual account to the fake account for these templates */
+ xaccAccountInsertSplit (template_acc, sd->split);
}
static void
@@ -660,46 +670,46 @@
static void
gnc_template_register_save_debcred_cell (BasicCell * cell,
- gpointer save_data,
- gpointer user_data)
+ gpointer save_data,
+ gpointer user_data)
{
- SRSaveData *sd = save_data;
- SplitRegister *reg = user_data;
- kvp_frame *kvpf;
- const char *value;
+ SRSaveData *sd = save_data;
+ SplitRegister *reg = user_data;
+ kvp_frame *kvpf;
+ const char *value;
- g_return_if_fail (gnc_basic_cell_has_name (cell, FDEBT_CELL) ||
- gnc_basic_cell_has_name (cell, FCRED_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, FDEBT_CELL) ||
+ gnc_basic_cell_has_name (cell, FCRED_CELL));
- if (sd->handled_dc)
- return;
+ if (sd->handled_dc)
+ return;
- kvpf = xaccSplitGetSlots (sd->split);
+ kvpf = xaccSplitGetSlots (sd->split);
- DEBUG ("kvp_frame before: %s\n", kvp_frame_to_string (kvpf));
+ DEBUG ("kvp_frame before: %s\n", kvp_frame_to_string (kvpf));
- /* amountStr = gnc_numeric_to_string (new_amount); */
+ /* amountStr = gnc_numeric_to_string (new_amount); */
- value = gnc_table_layout_get_cell_value (reg->table->layout, FCRED_CELL);
- kvp_frame_set_slot_path (kvpf, kvp_value_new_string (value),
- GNC_SX_ID,
- GNC_SX_CREDIT_FORMULA,
- NULL);
+ value = gnc_table_layout_get_cell_value (reg->table->layout, FCRED_CELL);
+ kvp_frame_set_slot_path (kvpf, kvp_value_new_string (value),
+ GNC_SX_ID,
+ GNC_SX_CREDIT_FORMULA,
+ NULL);
- value = gnc_table_layout_get_cell_value (reg->table->layout, FDEBT_CELL);
+ value = gnc_table_layout_get_cell_value (reg->table->layout, FDEBT_CELL);
- kvp_frame_set_slot_path (kvpf,
- kvp_value_new_string (value),
- GNC_SX_ID,
- GNC_SX_DEBIT_FORMULA,
- NULL);
+ kvp_frame_set_slot_path (kvpf,
+ kvp_value_new_string (value),
+ GNC_SX_ID,
+ GNC_SX_DEBIT_FORMULA,
+ NULL);
- DEBUG ("kvp_frame after: %s\n", kvp_frame_to_string (kvpf));
+ DEBUG ("kvp_frame after: %s\n", kvp_frame_to_string (kvpf));
- /* set the amount to an innocuous value */
- xaccSplitSetValue (sd->split, gnc_numeric_create (0, 1));
+ /* set the amount to an innocuous value */
+ xaccSplitSetValue (sd->split, gnc_numeric_create (0, 1));
- sd->handled_dc = TRUE;
+ sd->handled_dc = TRUE;
}
static void
@@ -707,162 +717,162 @@
gpointer save_data,
gpointer user_data)
{
- SRSaveData *sd = save_data;
- kvp_frame *kvpf;
- char *sharesStr = "(x + y)/42";
+ SRSaveData *sd = save_data;
+ kvp_frame *kvpf;
+ char *sharesStr = "(x + y)/42";
- g_return_if_fail (gnc_basic_cell_has_name (cell, SHRS_CELL));
+ g_return_if_fail (gnc_basic_cell_has_name (cell, SHRS_CELL));
- kvpf = xaccSplitGetSlots (sd->split);
+ kvpf = xaccSplitGetSlots (sd->split);
- /* FIXME: shares cells are numeric by definition. */
- DEBUG ("kvp_frame before: %s\n", kvp_frame_to_string (kvpf));
+ /* FIXME: shares cells are numeric by definition. */
+ DEBUG ("kvp_frame before: %s\n", kvp_frame_to_string (kvpf));
- /* sharesStr = gnc_numeric_to_string( sharesStr ); */
- kvp_frame_set_slot_path (kvpf,
- kvp_value_new_string (sharesStr),
- GNC_SX_ID,
- GNC_SX_SHARES,
- NULL);
+ /* sharesStr = gnc_numeric_to_string( sharesStr ); */
+ kvp_frame_set_slot_path (kvpf,
+ kvp_value_new_string (sharesStr),
+ GNC_SX_ID,
+ GNC_SX_SHARES,
+ NULL);
- DEBUG ("kvp_frame after: %s\n", kvp_frame_to_string (kvpf));
+ DEBUG ("kvp_frame after: %s\n", kvp_frame_to_string (kvpf));
- /* set the shares to an innocuous value */
- xaccSplitSetSharePriceAndAmount (sd->split,
- gnc_numeric_create (0, 1),
- gnc_numeric_create (0, 1));
+ /* set the shares to an innocuous value */
+ xaccSplitSetSharePriceAndAmount (sd->split,
+ gnc_numeric_create (0, 1),
+ gnc_numeric_create (0, 1));
}
void
gnc_split_register_model_add_save_handlers (TableModel *model)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_date_cell,
- DATE_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_date_cell,
+ DATE_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_due_date_cell,
- DDUE_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_due_date_cell,
+ DDUE_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_type_cell,
- TYPE_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_type_cell,
+ TYPE_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_num_cell,
- NUM_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_num_cell,
+ NUM_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_desc_cell,
- DESC_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_desc_cell,
+ DESC_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_notes_cell,
- NOTES_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_notes_cell,
+ NOTES_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_recn_cell,
- RECN_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_recn_cell,
+ RECN_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_actn_cell,
- ACTN_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_actn_cell,
+ ACTN_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_memo_cell,
- MEMO_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_memo_cell,
+ MEMO_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_xfrm_cell,
- XFRM_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_xfrm_cell,
+ XFRM_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_mxfrm_cell,
- MXFRM_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_mxfrm_cell,
+ MXFRM_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_shares_cell,
- SHRS_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_shares_cell,
+ SHRS_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_price_cell,
- PRIC_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_price_cell,
+ PRIC_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_debcred_cell,
- DEBT_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_debcred_cell,
+ DEBT_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_debcred_cell,
- CRED_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_debcred_cell,
+ CRED_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_split_register_save_rate_cell,
- RATE_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_split_register_save_rate_cell,
+ RATE_CELL);
- gnc_table_model_set_post_save_handler (model, gnc_split_register_save_cells);
+ gnc_table_model_set_post_save_handler (model, gnc_split_register_save_cells);
}
void
gnc_template_register_model_add_save_handlers (TableModel *model)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_split_register_model_add_save_handlers (model);
+ gnc_split_register_model_add_save_handlers (model);
- gnc_table_model_set_save_handler (model,
- gnc_template_register_save_unexpected_cell,
- DATE_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_template_register_save_unexpected_cell,
+ DATE_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_template_register_save_unexpected_cell,
- DDUE_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_template_register_save_unexpected_cell,
+ DDUE_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_template_register_save_xfrm_cell,
- XFRM_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_template_register_save_xfrm_cell,
+ XFRM_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_template_register_save_mxfrm_cell,
- MXFRM_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_template_register_save_mxfrm_cell,
+ MXFRM_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_template_register_save_debcred_cell,
- FDEBT_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_template_register_save_debcred_cell,
+ FDEBT_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_template_register_save_debcred_cell,
- FCRED_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_template_register_save_debcred_cell,
+ FCRED_CELL);
- gnc_table_model_set_save_handler (model,
- gnc_template_register_save_shares_cell,
- SHRS_CELL);
+ gnc_table_model_set_save_handler (model,
+ gnc_template_register_save_shares_cell,
+ SHRS_CELL);
}
SRSaveData *
gnc_split_register_save_data_new (Transaction *trans, Split *split,
- gboolean expanded)
+ gboolean expanded)
{
- SRSaveData *sd;
+ SRSaveData *sd;
- g_return_val_if_fail (trans != NULL, NULL);
- g_return_val_if_fail (split != NULL, NULL);
+ g_return_val_if_fail (trans != NULL, NULL);
+ g_return_val_if_fail (split != NULL, NULL);
- sd = g_new0 (SRSaveData, 1);
+ sd = g_new0 (SRSaveData, 1);
- sd->trans = trans;
- sd->split = split;
- sd->handled_dc = FALSE;
- sd->do_scrub = FALSE;
- sd->reg_expanded = expanded;
+ sd->trans = trans;
+ sd->split = split;
+ sd->handled_dc = FALSE;
+ sd->do_scrub = FALSE;
+ sd->reg_expanded = expanded;
- return sd;
+ return sd;
}
void
gnc_split_register_save_data_destroy (SRSaveData *sd)
{
- g_free (sd);
+ g_free (sd);
}
Modified: gnucash/trunk/src/register/ledger-core/split-register-model-save.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model-save.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-model-save.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -33,8 +33,8 @@
typedef struct sr_save_data SRSaveData;
SRSaveData * gnc_split_register_save_data_new (Transaction *trans,
- Split *split,
- gboolean expanded);
+ Split *split,
+ gboolean expanded);
void gnc_split_register_save_data_destroy (SRSaveData *sd);
Modified: gnucash/trunk/src/register/ledger-core/split-register-model.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-model.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -40,13 +40,13 @@
static SplitRegisterColors reg_colors =
{
- 0x96B183,
- 0xBFDEB9,
- 0xF6FFDA,
- 0xFFEF98,
- 0xFFEF98,
- 0xEDE7D3,
- 0xFFEF98,
+ 0x96B183,
+ 0xBFDEB9,
+ 0xF6FFDA,
+ 0xFFEF98,
+ 0xFFEF98,
+ 0xEDE7D3,
+ 0xFFEF98,
};
/* This static indicates the debugging module that this .o belongs to. */
@@ -56,215 +56,227 @@
static gboolean use_red_for_negative = TRUE;
/* This returns the balance at runtime of a register at the split defined by virt_loc regardless of
- * sort order. It always assumes that the first txn in the register is starting from a 0 balance.
+ * sort order. It always assumes that the first txn in the register is starting from a 0 balance.
* If gboolean subaccounts is TRUE, then it will return the total balance of the parent account
* and all its subaccounts. FALSE will return the balance of just the parent account of the register. */
static gnc_numeric
gnc_split_register_get_rbaln (VirtualLocation virt_loc, gpointer user_data, gboolean subaccounts)
{
- SplitRegister *reg = user_data;
- Split *split;
- SRInfo *info = gnc_split_register_get_info (reg);
- gnc_numeric balance = gnc_numeric_zero();
- Account *account = NULL;
- Transaction *trans;
- GList *node, *child;
- GList *children = NULL;
- int i, row;
+ SplitRegister *reg = user_data;
+ Split *split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ gnc_numeric balance = gnc_numeric_zero();
+ Account *account = NULL;
+ Transaction *trans;
+ GList *node, *child;
+ GList *children = NULL;
+ int i, row;
- balance = gnc_numeric_zero();
+ balance = gnc_numeric_zero();
/* Return NULL if this is a blank transaction. */
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
if (split == xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_book ()))
- return gnc_numeric_zero();
+ return gnc_numeric_zero();
trans = xaccSplitGetParent (split);
if (!trans)
- return gnc_numeric_zero();
+ return gnc_numeric_zero();
/* Get a list of accounts for matching */
account = gnc_split_register_get_default_account(reg);
if (!account)
- /* Register has no account (perhaps general ledger) so it has no
- well defined balance, return zero. */
- return balance;
-
- if (subaccounts) {
- children = gnc_account_get_descendants(account);
- children = g_list_append(children, account);
- }
+ /* Register has no account (perhaps general ledger) so it has no
+ well defined balance, return zero. */
+ return balance;
+ if (subaccounts)
+ {
+ children = gnc_account_get_descendants(account);
+ children = g_list_append(children, account);
+ }
+
/* Get the row number we're on, then start with the first row. */
row = virt_loc.vcell_loc.virt_row;
- virt_loc.vcell_loc.virt_row=0;
+ virt_loc.vcell_loc.virt_row = 0;
- while (virt_loc.vcell_loc.virt_row <= row ) {
- /* Get new temporary split and its parent transaction */
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = xaccSplitGetParent (split);
+ while (virt_loc.vcell_loc.virt_row <= row )
+ {
+ /* Get new temporary split and its parent transaction */
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = xaccSplitGetParent (split);
- i = 1;
- for (node = xaccTransGetSplitList (trans); node; node = node->next) {
- Split *secondary = node->data;
- i++;
+ i = 1;
+ for (node = xaccTransGetSplitList (trans); node; node = node->next)
+ {
+ Split *secondary = node->data;
+ i++;
- if (subaccounts) {
- /* Add up the splits that belong to the transaction if they are
- * from the lead account or one of the subaccounts. */
- account = xaccSplitGetAccount (secondary);
+ if (subaccounts)
+ {
+ /* Add up the splits that belong to the transaction if they are
+ * from the lead account or one of the subaccounts. */
+ account = xaccSplitGetAccount (secondary);
- for (child = children; child; child = child->next) {
- if (account == child->data) {
- balance = gnc_numeric_add_fixed(balance, xaccSplitGetAmount(secondary));
- break;
+ for (child = children; child; child = child->next)
+ {
+ if (account == child->data)
+ {
+ balance = gnc_numeric_add_fixed(balance, xaccSplitGetAmount(secondary));
+ break;
+ }
+ }
}
- }
- } else {
- if ( account == xaccSplitGetAccount(secondary) )
- balance = gnc_numeric_add_fixed( balance, xaccSplitGetAmount(secondary) );
+ else
+ {
+ if ( account == xaccSplitGetAccount(secondary) )
+ balance = gnc_numeric_add_fixed( balance, xaccSplitGetAmount(secondary) );
+ }
}
- }
- virt_loc.vcell_loc.virt_row+=i;
+ virt_loc.vcell_loc.virt_row += i;
}
- if (subaccounts)
- g_list_free(children);
-
- return balance;
+ if (subaccounts)
+ g_list_free(children);
+
+ return balance;
}
static gboolean
gnc_split_register_use_security_cells (SplitRegister *reg,
VirtualLocation virt_loc)
{
- CursorClass cursor_class;
- Account *account;
- Split *split;
+ CursorClass cursor_class;
+ Account *account;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return TRUE;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return TRUE;
- cursor_class = gnc_split_register_get_cursor_class (reg,
- virt_loc.vcell_loc);
- if (cursor_class != CURSOR_CLASS_SPLIT)
- return TRUE;
+ cursor_class = gnc_split_register_get_cursor_class (reg,
+ virt_loc.vcell_loc);
+ if (cursor_class != CURSOR_CLASS_SPLIT)
+ return TRUE;
- account = NULL;
+ account = NULL;
- if (virt_cell_loc_equal (virt_loc.vcell_loc,
- reg->table->current_cursor_loc.vcell_loc) &&
- gnc_table_layout_get_cell_changed (reg->table->layout, XFRM_CELL, FALSE))
- {
- const char *name;
+ if (virt_cell_loc_equal (virt_loc.vcell_loc,
+ reg->table->current_cursor_loc.vcell_loc) &&
+ gnc_table_layout_get_cell_changed (reg->table->layout, XFRM_CELL, FALSE))
+ {
+ const char *name;
- name = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL);
- account = gnc_account_lookup_for_register (gnc_get_current_root_account (), name);
- }
+ name = gnc_table_layout_get_cell_value (reg->table->layout, XFRM_CELL);
+ account = gnc_account_lookup_for_register (gnc_get_current_root_account (), name);
+ }
- if (!account)
- account = xaccSplitGetAccount (split);
+ if (!account)
+ account = xaccSplitGetAccount (split);
- if (!account)
- return TRUE;
+ if (!account)
+ return TRUE;
- if (xaccTransUseTradingAccounts (xaccSplitGetParent (split))) {
- if (!gnc_commodity_is_iso(xaccAccountGetCommodity(account)))
- return TRUE;
- }
-
- return xaccAccountIsPriced(account);
+ if (xaccTransUseTradingAccounts (xaccSplitGetParent (split)))
+ {
+ if (!gnc_commodity_is_iso(xaccAccountGetCommodity(account)))
+ return TRUE;
+ }
+
+ return xaccAccountIsPriced(account);
}
static const char *
gnc_split_register_get_date_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Date");
+ return _("Date");
}
static const char *
gnc_split_register_get_due_date_label (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- return _("Due Date");
+ return _("Due Date");
}
static const char *
gnc_split_register_get_num_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- switch (reg->type) {
- case RECEIVABLE_REGISTER:
- case PAYABLE_REGISTER:
- return _("Ref");
- default:
- return _("Num");
- }
+ switch (reg->type)
+ {
+ case RECEIVABLE_REGISTER:
+ case PAYABLE_REGISTER:
+ return _("Ref");
+ default:
+ return _("Num");
+ }
}
static const char *
gnc_split_register_get_desc_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- switch (reg->type) {
- case RECEIVABLE_REGISTER:
- return _("Customer");
- case PAYABLE_REGISTER:
- return _("Vendor");
- default:
- return _("Description");
- }
+ switch (reg->type)
+ {
+ case RECEIVABLE_REGISTER:
+ return _("Customer");
+ case PAYABLE_REGISTER:
+ return _("Vendor");
+ default:
+ return _("Description");
+ }
}
static const char *
gnc_split_register_get_recn_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- switch (reg->type) {
- case RECEIVABLE_REGISTER:
- case PAYABLE_REGISTER:
- return _("Paid");
+ switch (reg->type)
+ {
+ case RECEIVABLE_REGISTER:
+ case PAYABLE_REGISTER:
+ return _("Paid");
- default:
- return _("Reconciled:R") + 11;
- }
+ default:
+ return _("Reconciled:R") + 11;
+ }
}
static const char *
gnc_split_register_get_baln_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Balance");
+ return _("Balance");
}
static const char *
gnc_split_register_get_action_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Action");
+ return _("Action");
}
static const char *
gnc_split_register_get_xfrm_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Account");
+ return _("Account");
}
static const char *
gnc_split_register_get_mxfrm_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Transfer");
+ return _("Transfer");
}
static const char *
@@ -278,232 +290,232 @@
gnc_split_register_get_type_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Type");
+ return _("Type");
}
static const char *
gnc_split_register_get_debit_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- return gnc_split_register_get_debit_string (reg);
+ return gnc_split_register_get_debit_string (reg);
}
static const char *
gnc_split_register_get_credit_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- return gnc_split_register_get_credit_string (reg);
+ return gnc_split_register_get_credit_string (reg);
}
static const char *
gnc_split_register_get_price_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- if (!gnc_split_register_use_security_cells (reg, virt_loc))
- return NULL;
+ if (!gnc_split_register_use_security_cells (reg, virt_loc))
+ return NULL;
- return _("Price");
+ return _("Price");
}
static const char *
gnc_split_register_get_shares_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- if (!gnc_split_register_use_security_cells (reg, virt_loc))
- return NULL;
+ if (!gnc_split_register_use_security_cells (reg, virt_loc))
+ return NULL;
- return _("Shares");
+ return _("Shares");
}
static const char *
gnc_split_register_get_tcredit_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- SRInfo *info = gnc_split_register_get_info (reg);
+ SplitRegister *reg = user_data;
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (info->tcredit_str)
- return info->tcredit_str;
+ if (info->tcredit_str)
+ return info->tcredit_str;
- {
- const char *string = gnc_split_register_get_credit_string (reg);
+ {
+ const char *string = gnc_split_register_get_credit_string (reg);
- if (string)
- info->tcredit_str = g_strdup_printf (_("Tot %s"), string);
- }
+ if (string)
+ info->tcredit_str = g_strdup_printf (_("Tot %s"), string);
+ }
- if (info->tcredit_str)
- return info->tcredit_str;
+ if (info->tcredit_str)
+ return info->tcredit_str;
- info->tcredit_str = g_strdup (_("Tot Credit"));
+ info->tcredit_str = g_strdup (_("Tot Credit"));
- return info->tcredit_str;
+ return info->tcredit_str;
}
static const char *
gnc_split_register_get_tdebit_label (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- SRInfo *info = gnc_split_register_get_info (reg);
+ SplitRegister *reg = user_data;
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (info->tdebit_str)
- return info->tdebit_str;
+ if (info->tdebit_str)
+ return info->tdebit_str;
- {
- const char *string = gnc_split_register_get_debit_string (reg);
- if (string)
- info->tdebit_str = g_strdup_printf (_("Tot %s"), string);
- }
+ {
+ const char *string = gnc_split_register_get_debit_string (reg);
+ if (string)
+ info->tdebit_str = g_strdup_printf (_("Tot %s"), string);
+ }
- if (info->tdebit_str)
- return info->tdebit_str;
+ if (info->tdebit_str)
+ return info->tdebit_str;
- info->tdebit_str = g_strdup (_("Tot Debit"));
+ info->tdebit_str = g_strdup (_("Tot Debit"));
- return info->tdebit_str;
+ return info->tdebit_str;
}
static const char *
gnc_split_register_get_tshares_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Tot Shares");
+ return _("Tot Shares");
}
static const char *
gnc_split_register_get_tbalance_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Balance");
+ return _("Balance");
}
static const char *
gnc_split_register_get_notes_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Notes");
+ return _("Notes");
}
static const char *
gnc_split_register_get_fdebit_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Debit Formula");
+ return _("Debit Formula");
}
static const char *
gnc_split_register_get_fcredit_label (VirtualLocation virt_loc,
gpointer user_data)
{
- return _("Credit Formula");
+ return _("Credit Formula");
}
static gnc_numeric
get_trans_total_amount (SplitRegister *reg, Transaction *trans)
{
- Account *account = gnc_split_register_get_default_account (reg);
- return xaccTransGetAccountAmount(trans, account);
+ Account *account = gnc_split_register_get_default_account (reg);
+ return xaccTransGetAccountAmount(trans, account);
}
static gnc_numeric
get_trans_total_balance (SplitRegister *reg, Transaction *trans)
{
- Account *account;
+ Account *account;
- account = gnc_split_register_get_default_account (reg);
- if (!trans || !account) return gnc_numeric_zero();
+ account = gnc_split_register_get_default_account (reg);
+ if (!trans || !account) return gnc_numeric_zero();
- return xaccTransGetAccountBalance(trans, account);
+ return xaccTransGetAccountBalance(trans, account);
}
static guint32
gnc_split_register_get_shares_fg_color (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const guint32 black = 0x000000;
- const guint32 red = 0xff0000;
- const char * cell_name;
- gboolean is_current;
- gnc_numeric shares;
- Split *split;
+ SplitRegister *reg = user_data;
+ const guint32 black = 0x000000;
+ const guint32 red = 0xff0000;
+ const char * cell_name;
+ gboolean is_current;
+ gnc_numeric shares;
+ Split *split;
- if (!use_red_for_negative)
- return black;
+ if (!use_red_for_negative)
+ return black;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return black;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return black;
- cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
+ cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
- is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
- virt_loc.vcell_loc);
+ is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
+ virt_loc.vcell_loc);
- if (gnc_cell_name_equal (cell_name, TSHRS_CELL))
- shares = get_trans_total_amount (reg, xaccSplitGetParent (split));
- else if (is_current)
- shares = gnc_price_cell_get_value
- ((PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- SHRS_CELL));
- else
- shares = xaccSplitGetAmount (split);
+ if (gnc_cell_name_equal (cell_name, TSHRS_CELL))
+ shares = get_trans_total_amount (reg, xaccSplitGetParent (split));
+ else if (is_current)
+ shares = gnc_price_cell_get_value
+ ((PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ SHRS_CELL));
+ else
+ shares = xaccSplitGetAmount (split);
- if (gnc_numeric_negative_p (shares))
- return red;
+ if (gnc_numeric_negative_p (shares))
+ return red;
- return black;
+ return black;
}
static guint32
gnc_split_register_get_balance_fg_color (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- const guint32 black = 0x000000;
- const guint32 red = 0xff0000;
- const char * cell_name;
- gnc_numeric balance;
- Split *split;
+ SplitRegister *reg = user_data;
+ const guint32 black = 0x000000;
+ const guint32 red = 0xff0000;
+ const char * cell_name;
+ gnc_numeric balance;
+ Split *split;
- if (!use_red_for_negative)
- return black;
+ if (!use_red_for_negative)
+ return black;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return black;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return black;
- cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
+ cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
- if (gnc_cell_name_equal (cell_name, BALN_CELL))
- balance = xaccSplitGetBalance (split);
- else if (gnc_cell_name_equal (cell_name, RBALN_CELL))
- balance = gnc_split_register_get_rbaln (virt_loc,user_data, TRUE);
- else
- balance = get_trans_total_balance (reg, xaccSplitGetParent (split));
+ if (gnc_cell_name_equal (cell_name, BALN_CELL))
+ balance = xaccSplitGetBalance (split);
+ else if (gnc_cell_name_equal (cell_name, RBALN_CELL))
+ balance = gnc_split_register_get_rbaln (virt_loc, user_data, TRUE);
+ else
+ balance = get_trans_total_balance (reg, xaccSplitGetParent (split));
- {
- Account *account;
+ {
+ Account *account;
- account = xaccSplitGetAccount (split);
+ account = xaccSplitGetAccount (split);
- if (gnc_reverse_balance (account))
- balance = gnc_numeric_neg (balance);
- }
+ if (gnc_reverse_balance (account))
+ balance = gnc_numeric_neg (balance);
+ }
- if (gnc_numeric_negative_p (balance))
- return red;
+ if (gnc_numeric_negative_p (balance))
+ return red;
- return black;
+ return black;
}
static guint32
@@ -511,193 +523,193 @@
gboolean *hatching,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *cursor_name;
- VirtualCell *vcell;
- guint32 bg_color;
- gboolean is_current;
- gboolean double_alternate_virt;
+ SplitRegister *reg = user_data;
+ const char *cursor_name;
+ VirtualCell *vcell;
+ guint32 bg_color;
+ gboolean is_current;
+ gboolean double_alternate_virt;
- if (hatching)
- *hatching = FALSE;
+ if (hatching)
+ *hatching = FALSE;
- bg_color = 0xffffff; /* white */
+ bg_color = 0xffffff; /* white */
- if (!reg)
- return bg_color;
+ if (!reg)
+ return bg_color;
- if (gnc_table_virtual_location_in_header (reg->table, virt_loc))
- return reg_colors.header_bg_color;
+ if (gnc_table_virtual_location_in_header (reg->table, virt_loc))
+ return reg_colors.header_bg_color;
- vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
- if (!vcell || !vcell->cellblock)
- return bg_color;
+ vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
+ if (!vcell || !vcell->cellblock)
+ return bg_color;
- if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
- (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
- return bg_color;
+ if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
+ (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
+ return bg_color;
- is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
- virt_loc.vcell_loc);
+ is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
+ virt_loc.vcell_loc);
- cursor_name = vcell->cellblock->cursor_name;
+ cursor_name = vcell->cellblock->cursor_name;
- if (safe_strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
- safe_strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0)
- {
- if (is_current)
- return vcell->start_primary_color ?
- reg_colors.primary_active_bg_color :
- reg_colors.secondary_active_bg_color;
+ if (safe_strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
+ safe_strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0)
+ {
+ if (is_current)
+ return vcell->start_primary_color ?
+ reg_colors.primary_active_bg_color :
+ reg_colors.secondary_active_bg_color;
- return vcell->start_primary_color ?
- reg_colors.primary_bg_color : reg_colors.secondary_bg_color;
- }
+ return vcell->start_primary_color ?
+ reg_colors.primary_bg_color : reg_colors.secondary_bg_color;
+ }
- if (safe_strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
- safe_strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0)
- {
- double_alternate_virt = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
- "alternate_color_by_transaction",
- NULL);
- if (is_current)
+ if (safe_strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
+ safe_strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0)
{
- if (double_alternate_virt)
- return vcell->start_primary_color ?
- reg_colors.primary_active_bg_color :
- reg_colors.secondary_active_bg_color;
+ double_alternate_virt = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+ "alternate_color_by_transaction",
+ NULL);
+ if (is_current)
+ {
+ if (double_alternate_virt)
+ return vcell->start_primary_color ?
+ reg_colors.primary_active_bg_color :
+ reg_colors.secondary_active_bg_color;
- return (virt_loc.phys_row_offset % 2 == 0) ?
- reg_colors.primary_active_bg_color :
- reg_colors.secondary_active_bg_color;
- }
+ return (virt_loc.phys_row_offset % 2 == 0) ?
+ reg_colors.primary_active_bg_color :
+ reg_colors.secondary_active_bg_color;
+ }
- if (double_alternate_virt)
- return vcell->start_primary_color ?
- reg_colors.primary_bg_color :
- reg_colors.secondary_bg_color;
+ if (double_alternate_virt)
+ return vcell->start_primary_color ?
+ reg_colors.primary_bg_color :
+ reg_colors.secondary_bg_color;
- return (virt_loc.phys_row_offset % 2 == 0) ?
- reg_colors.primary_bg_color :
- reg_colors.secondary_bg_color;
- }
+ return (virt_loc.phys_row_offset % 2 == 0) ?
+ reg_colors.primary_bg_color :
+ reg_colors.secondary_bg_color;
+ }
- if (safe_strcmp (cursor_name, CURSOR_SPLIT) == 0)
- {
- if (is_current)
- return reg_colors.split_active_bg_color;
+ if (safe_strcmp (cursor_name, CURSOR_SPLIT) == 0)
+ {
+ if (is_current)
+ return reg_colors.split_active_bg_color;
- return reg_colors.split_bg_color;
- }
+ return reg_colors.split_bg_color;
+ }
- PWARN ("Unexpected cursor: %s\n", cursor_name);
+ PWARN ("Unexpected cursor: %s\n", cursor_name);
- return bg_color;
+ return bg_color;
}
static RegisterColor
gnc_split_register_get_gtkrc_bg_color (VirtualLocation virt_loc,
- gboolean *hatching,
- gpointer user_data)
+ gboolean *hatching,
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *cursor_name;
- VirtualCell *vcell;
- gboolean is_current;
- gboolean double_alternate_virt;
+ SplitRegister *reg = user_data;
+ const char *cursor_name;
+ VirtualCell *vcell;
+ gboolean is_current;
+ gboolean double_alternate_virt;
- if (!reg)
- return COLOR_UNKNOWN;
+ if (!reg)
+ return COLOR_UNKNOWN;
- if (gnc_table_virtual_location_in_header (reg->table, virt_loc))
- return COLOR_HEADER;
+ if (gnc_table_virtual_location_in_header (reg->table, virt_loc))
+ return COLOR_HEADER;
- vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
- if (!vcell || !vcell->cellblock)
- return COLOR_UNKNOWN;
+ vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
+ if (!vcell || !vcell->cellblock)
+ return COLOR_UNKNOWN;
- if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
- (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
- return COLOR_UNKNOWN;
+ if ((virt_loc.phys_col_offset < vcell->cellblock->start_col) ||
+ (virt_loc.phys_col_offset > vcell->cellblock->stop_col))
+ return COLOR_UNKNOWN;
- is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
- virt_loc.vcell_loc);
+ is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
+ virt_loc.vcell_loc);
- cursor_name = vcell->cellblock->cursor_name;
+ cursor_name = vcell->cellblock->cursor_name;
- if (safe_strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
- safe_strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0)
- {
- if (is_current)
- return vcell->start_primary_color ?
- COLOR_PRIMARY_ACTIVE :
- COLOR_SECONDARY_ACTIVE;
+ if (safe_strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
+ safe_strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0)
+ {
+ if (is_current)
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY_ACTIVE :
+ COLOR_SECONDARY_ACTIVE;
- return vcell->start_primary_color ?
- COLOR_PRIMARY : COLOR_SECONDARY;
- }
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY : COLOR_SECONDARY;
+ }
- if (safe_strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
- safe_strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0)
- {
- double_alternate_virt = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
- "alternate_color_by_transaction",
- NULL);
- if (is_current)
+ if (safe_strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0 ||
+ safe_strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0)
{
- if (double_alternate_virt)
- return vcell->start_primary_color ?
- COLOR_PRIMARY_ACTIVE :
- COLOR_SECONDARY_ACTIVE;
+ double_alternate_virt = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
+ "alternate_color_by_transaction",
+ NULL);
+ if (is_current)
+ {
+ if (double_alternate_virt)
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY_ACTIVE :
+ COLOR_SECONDARY_ACTIVE;
- return (virt_loc.phys_row_offset % 2 == 0) ?
- COLOR_PRIMARY_ACTIVE :
- COLOR_SECONDARY_ACTIVE;
- }
+ return (virt_loc.phys_row_offset % 2 == 0) ?
+ COLOR_PRIMARY_ACTIVE :
+ COLOR_SECONDARY_ACTIVE;
+ }
- if (double_alternate_virt)
- return vcell->start_primary_color ?
- COLOR_PRIMARY :
- COLOR_SECONDARY;
+ if (double_alternate_virt)
+ return vcell->start_primary_color ?
+ COLOR_PRIMARY :
+ COLOR_SECONDARY;
- return (virt_loc.phys_row_offset % 2 == 0) ?
- COLOR_PRIMARY :
- COLOR_SECONDARY;
- }
+ return (virt_loc.phys_row_offset % 2 == 0) ?
+ COLOR_PRIMARY :
+ COLOR_SECONDARY;
+ }
- if (safe_strcmp (cursor_name, CURSOR_SPLIT) == 0)
- {
- if (is_current)
- return COLOR_SPLIT_ACTIVE;
+ if (safe_strcmp (cursor_name, CURSOR_SPLIT) == 0)
+ {
+ if (is_current)
+ return COLOR_SPLIT_ACTIVE;
- return COLOR_SPLIT;
- }
+ return COLOR_SPLIT;
+ }
- PWARN ("Unexpected cursor: %s\n", cursor_name);
+ PWARN ("Unexpected cursor: %s\n", cursor_name);
- return COLOR_UNKNOWN;
+ return COLOR_UNKNOWN;
}
static guint32
gnc_split_register_get_debcred_bg_color (VirtualLocation virt_loc,
- gboolean *hatching,
- gpointer user_data)
+ gboolean *hatching,
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- if (hatching)
- {
- Transaction *trans;
+ if (hatching)
+ {
+ Transaction *trans;
- trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
+ trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
- if (trans)
- *hatching = !xaccTransIsBalanced (trans);
- else
- *hatching = FALSE;
- }
+ if (trans)
+ *hatching = !xaccTransIsBalanced (trans);
+ else
+ *hatching = FALSE;
+ }
- return gnc_split_register_get_bg_color (virt_loc, NULL, user_data);
+ return gnc_split_register_get_bg_color (virt_loc, NULL, user_data);
}
static void
@@ -705,47 +717,47 @@
PhysicalCellBorders *borders,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- CursorClass cursor_class;
- VirtualCell *vcell;
+ SplitRegister *reg = user_data;
+ CursorClass cursor_class;
+ VirtualCell *vcell;
- vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
- if (!vcell || !vcell->cellblock)
- return;
+ vcell = gnc_table_get_virtual_cell (reg->table, virt_loc.vcell_loc);
+ if (!vcell || !vcell->cellblock)
+ return;
- if (virt_loc.phys_col_offset < vcell->cellblock->start_col ||
- virt_loc.phys_col_offset > vcell->cellblock->stop_col)
- {
- borders->top = CELL_BORDER_LINE_NONE;
- borders->bottom = CELL_BORDER_LINE_NONE;
- borders->left = CELL_BORDER_LINE_NONE;
- borders->right = CELL_BORDER_LINE_NONE;
- return;
- }
+ if (virt_loc.phys_col_offset < vcell->cellblock->start_col ||
+ virt_loc.phys_col_offset > vcell->cellblock->stop_col)
+ {
+ borders->top = CELL_BORDER_LINE_NONE;
+ borders->bottom = CELL_BORDER_LINE_NONE;
+ borders->left = CELL_BORDER_LINE_NONE;
+ borders->right = CELL_BORDER_LINE_NONE;
+ return;
+ }
- cursor_class =
- gnc_split_register_cursor_name_to_class (vcell->cellblock->cursor_name);
+ cursor_class =
+ gnc_split_register_cursor_name_to_class (vcell->cellblock->cursor_name);
- if (cursor_class == CURSOR_CLASS_TRANS &&
- virt_loc.phys_col_offset == vcell->cellblock->start_col)
- borders->left = CELL_BORDER_LINE_NONE;
+ if (cursor_class == CURSOR_CLASS_TRANS &&
+ virt_loc.phys_col_offset == vcell->cellblock->start_col)
+ borders->left = CELL_BORDER_LINE_NONE;
- if (cursor_class == CURSOR_CLASS_TRANS &&
- virt_loc.phys_col_offset == vcell->cellblock->stop_col)
- borders->right = CELL_BORDER_LINE_NONE;
+ if (cursor_class == CURSOR_CLASS_TRANS &&
+ virt_loc.phys_col_offset == vcell->cellblock->stop_col)
+ borders->right = CELL_BORDER_LINE_NONE;
- if (cursor_class == CURSOR_CLASS_SPLIT)
- {
- borders->top = CELL_BORDER_LINE_LIGHT;
- borders->bottom = CELL_BORDER_LINE_LIGHT;
- borders->left = MIN (borders->left, CELL_BORDER_LINE_LIGHT);
- borders->right = MIN (borders->right, CELL_BORDER_LINE_LIGHT);
+ if (cursor_class == CURSOR_CLASS_SPLIT)
+ {
+ borders->top = CELL_BORDER_LINE_LIGHT;
+ borders->bottom = CELL_BORDER_LINE_LIGHT;
+ borders->left = MIN (borders->left, CELL_BORDER_LINE_LIGHT);
+ borders->right = MIN (borders->right, CELL_BORDER_LINE_LIGHT);
- if (virt_loc.phys_col_offset == vcell->cellblock->start_col)
- borders->left = CELL_BORDER_LINE_LIGHT;
- if (virt_loc.phys_col_offset == vcell->cellblock->stop_col)
- borders->right = CELL_BORDER_LINE_LIGHT;
- }
+ if (virt_loc.phys_col_offset == vcell->cellblock->start_col)
+ borders->left = CELL_BORDER_LINE_LIGHT;
+ if (virt_loc.phys_col_offset == vcell->cellblock->stop_col)
+ borders->right = CELL_BORDER_LINE_LIGHT;
+ }
}
static const char *
@@ -754,84 +766,89 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *trans;
- char type;
- static char s[2];
+ SplitRegister *reg = user_data;
+ Transaction *trans;
+ char type;
+ static char s[2];
- trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
- if (!trans)
- return NULL;
+ trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
+ if (!trans)
+ return NULL;
- type = xaccTransGetTxnType (trans);
+ type = xaccTransGetTxnType (trans);
- if (type == TXN_TYPE_NONE)
- type = '?';
+ if (type == TXN_TYPE_NONE)
+ type = '?';
- s[0] = type;
- s[1] = '\0';
+ s[0] = type;
+ s[1] = '\0';
- return s;
+ return s;
}
static char
gnc_split_register_get_type_value (SplitRegister *reg,
- VirtualLocation virt_loc)
+ VirtualLocation virt_loc)
{
- RecnCell *cell;
+ RecnCell *cell;
- cell = (RecnCell *)gnc_table_layout_get_cell (reg->table->layout, TYPE_CELL);
- if (!cell)
- return '\0';
+ cell = (RecnCell *)gnc_table_layout_get_cell (reg->table->layout, TYPE_CELL);
+ if (!cell)
+ return '\0';
- return gnc_recn_cell_get_flag (cell);
+ return gnc_recn_cell_get_flag (cell);
}
static const char *
gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
- gboolean translate,
- gboolean *conditionally_changed,
- gpointer user_data)
+ gboolean translate,
+ gboolean *conditionally_changed,
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *trans;
- Split *split;
- Timespec ts;
- gboolean is_current;
- char type;
+ SplitRegister *reg = user_data;
+ Transaction *trans;
+ Split *split;
+ Timespec ts;
+ gboolean is_current;
+ char type;
- is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
- virt_loc.vcell_loc);
+ is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
+ virt_loc.vcell_loc);
- if (is_current) {
- type = gnc_split_register_get_type_value (reg, virt_loc);
- } else {
- const char *typestr =
- gnc_split_register_get_type_entry (virt_loc, translate,
- conditionally_changed, user_data);
- if (typestr != NULL)
- type = *typestr;
+ if (is_current)
+ {
+ type = gnc_split_register_get_type_value (reg, virt_loc);
+ }
else
- type = '\0';
- }
+ {
+ const char *typestr =
+ gnc_split_register_get_type_entry (virt_loc, translate,
+ conditionally_changed, user_data);
+ if (typestr != NULL)
+ type = *typestr;
+ else
+ type = '\0';
+ }
- /* Only print the due date for invoice transactions */
- if (type != TXN_TYPE_INVOICE) {
- //PWARN ("returning NULL due_date entry");
- return NULL;
- }
+ /* Only print the due date for invoice transactions */
+ if (type != TXN_TYPE_INVOICE)
+ {
+ //PWARN ("returning NULL due_date entry");
+ return NULL;
+ }
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = xaccSplitGetParent (split);
- if (!trans) {
- //PWARN ("No transaction in due_date entry");
- return NULL;
- }
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = xaccSplitGetParent (split);
+ if (!trans)
+ {
+ //PWARN ("No transaction in due_date entry");
+ return NULL;
+ }
- xaccTransGetDateDueTS (trans, &ts);
- //PWARN ("returning valid due_date entry");
-
- return gnc_print_date (ts);
+ xaccTransGetDateDueTS (trans, &ts);
+ //PWARN ("returning valid due_date entry");
+
+ return gnc_print_date (ts);
}
static const char *
@@ -840,55 +857,55 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *trans;
- Split *split;
- Timespec ts;
+ SplitRegister *reg = user_data;
+ Transaction *trans;
+ Split *split;
+ Timespec ts;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = xaccSplitGetParent (split);
- if (!trans)
- return NULL;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = xaccSplitGetParent (split);
+ if (!trans)
+ return NULL;
- xaccTransGetDatePostedTS (trans, &ts);
+ xaccTransGetDatePostedTS (trans, &ts);
- return gnc_print_date (ts);
+ return gnc_print_date (ts);
}
static char *
gnc_split_register_get_date_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- BasicCell *cell;
- char string[1024];
- struct tm *tm;
- Timespec ts;
- time_t tt;
+ SplitRegister *reg = user_data;
+ BasicCell *cell;
+ char string[1024];
+ struct tm *tm;
+ Timespec ts;
+ time_t tt;
- cell = gnc_table_get_cell (reg->table, virt_loc);
- if (!cell || !cell->value || *cell->value == '\0')
- return NULL;
+ cell = gnc_table_get_cell (reg->table, virt_loc);
+ if (!cell || !cell->value || *cell->value == '\0')
+ return NULL;
- gnc_date_cell_get_date ((DateCell *) cell, &ts);
- tt = ts.tv_sec;
+ gnc_date_cell_get_date ((DateCell *) cell, &ts);
+ tt = ts.tv_sec;
- tm = localtime (&tt);
+ tm = localtime (&tt);
- qof_strftime (string, sizeof (string), "%A %d %B %Y", tm);
+ qof_strftime (string, sizeof (string), "%A %d %B %Y", tm);
- return g_strdup (string);
+ return g_strdup (string);
}
static const char *
gnc_split_register_get_inactive_date_entry (VirtualLocation virt_loc,
- gboolean translate,
- gboolean *conditionally_changed,
- gpointer user_data)
+ gboolean translate,
+ gboolean *conditionally_changed,
+ gpointer user_data)
{
- /* This seems to be the one that initially gets used, the InactiveDateCell
- is set to, and subsequently displayed. */
- return _("Scheduled");
+ /* This seems to be the one that initially gets used, the InactiveDateCell
+ is set to, and subsequently displayed. */
+ return _("Scheduled");
}
static const char *
@@ -897,37 +914,38 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *trans;
- Split *split;
+ SplitRegister *reg = user_data;
+ Transaction *trans;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = xaccSplitGetParent (split);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = xaccSplitGetParent (split);
- return xaccTransGetNum (trans);
+ return xaccTransGetNum (trans);
}
static char *
gnc_split_register_get_num_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- switch (reg->type) {
- case RECEIVABLE_REGISTER:
- case PAYABLE_REGISTER:
- help = _("Enter the transaction reference, "
- "such as the invoice or check number");
- break;
- default:
- help = _("Enter the transaction number, such as the check number");
- break;
- }
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ switch (reg->type)
+ {
+ case RECEIVABLE_REGISTER:
+ case PAYABLE_REGISTER:
+ help = _("Enter the transaction reference, "
+ "such as the invoice or check number");
+ break;
+ default:
+ help = _("Enter the transaction number, such as the check number");
+ break;
+ }
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
@@ -936,36 +954,37 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *trans;
- Split *split;
+ SplitRegister *reg = user_data;
+ Transaction *trans;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = xaccSplitGetParent (split);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = xaccSplitGetParent (split);
- return xaccTransGetDescription (trans);
+ return xaccTransGetDescription (trans);
}
static char *
gnc_split_register_get_desc_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- switch (reg->type) {
- case RECEIVABLE_REGISTER:
- help = _("Enter the name of the Customer");
- break;
- case PAYABLE_REGISTER:
- help = _("Enter the name of the Vendor");
- break;
- default:
- help = _("Enter a description of the transaction");
- }
- return g_strdup (help);
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ switch (reg->type)
+ {
+ case RECEIVABLE_REGISTER:
+ help = _("Enter the name of the Customer");
+ break;
+ case PAYABLE_REGISTER:
+ help = _("Enter the name of the Vendor");
+ break;
+ default:
+ help = _("Enter a description of the transaction");
+ }
+ return g_strdup (help);
}
static const char *
@@ -974,58 +993,58 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *trans;
- Split *split;
+ SplitRegister *reg = user_data;
+ Transaction *trans;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = xaccSplitGetParent (split);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = xaccSplitGetParent (split);
- return xaccTransGetNotes (trans);
+ return xaccTransGetNotes (trans);
}
static char *
gnc_split_register_get_notes_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter notes for the transaction");
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Enter notes for the transaction");
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
gnc_split_register_get_vnotes_entry (VirtualLocation virt_loc,
- gboolean translate,
- gboolean *conditionally_changed,
- gpointer user_data)
+ gboolean translate,
+ gboolean *conditionally_changed,
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- Transaction *trans;
- Split *split;
+ SplitRegister *reg = user_data;
+ Transaction *trans;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = xaccSplitGetParent (split);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = xaccSplitGetParent (split);
- return xaccTransGetVoidReason(trans);
+ return xaccTransGetVoidReason(trans);
}
static char *
gnc_split_register_get_vnotes_help (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Reason the transaction was voided");
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Reason the transaction was voided");
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
@@ -1034,38 +1053,38 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Split *split, *osplit;
- Transaction *txn;
- gnc_numeric amount, value, convrate;
+ SplitRegister *reg = user_data;
+ Split *split, *osplit;
+ Transaction *txn;
+ gnc_numeric amount, value, convrate;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return NULL;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return NULL;
- /* If this is a basic, non-expanded ledger with exactly two splits,
- * and split->txn->curr == split->acc->comm, then use the OTHER
- * split for the rate.
- */
- osplit = xaccSplitGetOtherSplit (split);
- txn = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
+ /* If this is a basic, non-expanded ledger with exactly two splits,
+ * and split->txn->curr == split->acc->comm, then use the OTHER
+ * split for the rate.
+ */
+ osplit = xaccSplitGetOtherSplit (split);
+ txn = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
- if (!gnc_split_register_current_trans_expanded (reg) && osplit &&
- !gnc_split_register_needs_conv_rate(reg, txn,
- xaccSplitGetAccount(split)))
- {
- split = osplit;
- }
+ if (!gnc_split_register_current_trans_expanded (reg) && osplit &&
+ !gnc_split_register_needs_conv_rate(reg, txn,
+ xaccSplitGetAccount(split)))
+ {
+ split = osplit;
+ }
- amount = xaccSplitGetAmount (split);
- value = xaccSplitGetValue (split);
+ amount = xaccSplitGetAmount (split);
+ value = xaccSplitGetValue (split);
- if (gnc_numeric_zero_p (value))
- return "0";
+ if (gnc_numeric_zero_p (value))
+ return "0";
- convrate = gnc_numeric_div (amount, value, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
+ convrate = gnc_numeric_div (amount, value, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
- return xaccPrintAmount (convrate, gnc_default_price_print_info ());
+ return xaccPrintAmount (convrate, gnc_default_price_print_info ());
}
static const char *
@@ -1074,24 +1093,24 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Split *split;
+ SplitRegister *reg = user_data;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return NULL;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return NULL;
- if (translate)
- return gnc_get_reconcile_str (xaccSplitGetReconcile (split));
- else
- {
- static char s[2];
+ if (translate)
+ return gnc_get_reconcile_str (xaccSplitGetReconcile (split));
+ else
+ {
+ static char s[2];
- s[0] = xaccSplitGetReconcile (split);
- s[1] = '\0';
+ s[0] = xaccSplitGetReconcile (split);
+ s[1] = '\0';
- return s;
- }
+ return s;
+ }
}
static const char *
@@ -1100,24 +1119,24 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
+ SplitRegister *reg = user_data;
+ Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
- return xaccSplitGetAction (split);
+ return xaccSplitGetAction (split);
}
static char *
gnc_split_register_get_action_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter the type of transaction, or choose one from the list");
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Enter the type of transaction, or choose one from the list");
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
@@ -1126,25 +1145,25 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Split *split;
+ SplitRegister *reg = user_data;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- return xaccSplitGetMemo (split);
+ return xaccSplitGetMemo (split);
}
static char *
gnc_split_register_get_memo_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter a description of the split");
- return g_strdup (help);
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Enter a description of the split");
+ return g_strdup (help);
}
static const char *
@@ -1153,35 +1172,35 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- SRInfo *info = gnc_split_register_get_info (reg);
- gnc_numeric balance;
- gboolean is_trans;
- Split *split;
- Account *account;
+ SplitRegister *reg = user_data;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ gnc_numeric balance;
+ gboolean is_trans;
+ Split *split;
+ Account *account;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (split == xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ()))
- return NULL;
+ if (split == xaccSplitLookup (&info->blank_split_guid,
+ gnc_get_current_book ()))
+ return NULL;
- is_trans = gnc_cell_name_equal
- (gnc_table_get_cell_name (reg->table, virt_loc), TBALN_CELL);
+ is_trans = gnc_cell_name_equal
+ (gnc_table_get_cell_name (reg->table, virt_loc), TBALN_CELL);
- if (is_trans)
- balance = get_trans_total_balance (reg, xaccSplitGetParent (split));
- else
- balance = xaccSplitGetBalance (split);
+ if (is_trans)
+ balance = get_trans_total_balance (reg, xaccSplitGetParent (split));
+ else
+ balance = xaccSplitGetBalance (split);
- account = xaccSplitGetAccount (split);
- if (!account)
- account = gnc_split_register_get_default_account (reg);
+ account = xaccSplitGetAccount (split);
+ if (!account)
+ account = gnc_split_register_get_default_account (reg);
- if (gnc_reverse_balance (account))
- balance = gnc_numeric_neg (balance);
+ if (gnc_reverse_balance (account))
+ balance = gnc_numeric_neg (balance);
- return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
+ return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
}
static const char *
@@ -1190,34 +1209,34 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- gnc_numeric price;
- Split *split;
+ SplitRegister *reg = user_data;
+ gnc_numeric price;
+ Split *split;
- if (!gnc_split_register_use_security_cells (reg, virt_loc))
- return NULL;
+ if (!gnc_split_register_use_security_cells (reg, virt_loc))
+ return NULL;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- price = xaccSplitGetSharePrice (split);
- if (gnc_numeric_zero_p (price))
- return NULL;
+ price = xaccSplitGetSharePrice (split);
+ if (gnc_numeric_zero_p (price))
+ return NULL;
- return xaccPrintAmount (price, gnc_default_price_print_info ());
+ return xaccPrintAmount (price, gnc_default_price_print_info ());
}
static char *
gnc_split_register_get_price_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter the effective share price");
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Enter the effective share price");
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
@@ -1226,34 +1245,34 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- gnc_numeric shares;
- Split *split;
+ SplitRegister *reg = user_data;
+ gnc_numeric shares;
+ Split *split;
- if (!gnc_split_register_use_security_cells (reg, virt_loc))
- return NULL;
+ if (!gnc_split_register_use_security_cells (reg, virt_loc))
+ return NULL;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- shares = xaccSplitGetAmount (split);
- if (gnc_numeric_zero_p (shares))
- return NULL;
+ shares = xaccSplitGetAmount (split);
+ if (gnc_numeric_zero_p (shares))
+ return NULL;
- return xaccPrintAmount (shares, gnc_split_amount_print_info (split, FALSE));
+ return xaccPrintAmount (shares, gnc_split_amount_print_info (split, FALSE));
}
static char *
gnc_split_register_get_shares_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter the number of shares bought or sold");
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Enter the number of shares bought or sold");
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
@@ -1262,15 +1281,15 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- gnc_numeric total;
- Split *split;
+ SplitRegister *reg = user_data;
+ gnc_numeric total;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- total = get_trans_total_amount (reg, xaccSplitGetParent (split));
+ total = get_trans_total_amount (reg, xaccSplitGetParent (split));
- return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
+ return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
}
static const char *
@@ -1279,33 +1298,33 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- static char *name = NULL;
+ static char *name = NULL;
- SplitRegister *reg = user_data;
- Split *split;
+ SplitRegister *reg = user_data;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- g_free (name);
+ g_free (name);
- name = gnc_get_account_name_for_register (xaccSplitGetAccount (split));
+ name = gnc_get_account_name_for_register (xaccSplitGetAccount (split));
- return name;
+ return name;
}
static char *
gnc_split_register_get_xfrm_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter the account to transfer from, "
- "or choose one from the list");
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Enter the account to transfer from, "
+ "or choose one from the list");
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
@@ -1314,80 +1333,80 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- static char *name = NULL;
+ static char *name = NULL;
- SplitRegister *reg = user_data;
- Split *split;
- Split *s;
+ SplitRegister *reg = user_data;
+ Split *split;
+ Split *s;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return NULL;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return NULL;
- s = xaccSplitGetOtherSplit (split);
+ s = xaccSplitGetOtherSplit (split);
- g_free (name);
+ g_free (name);
- if (s)
- name = gnc_get_account_name_for_register (xaccSplitGetAccount (s));
- else
- {
- /* For multi-split transactions and stock splits,
- * use a special value. */
- s = xaccTransGetSplit (xaccSplitGetParent(split), 1);
-
if (s)
- name = g_strdup (SPLIT_TRANS_STR);
- else if (safe_strcmp ("stock-split", xaccSplitGetType (split)) == 0)
- name = g_strdup (STOCK_SPLIT_STR);
+ name = gnc_get_account_name_for_register (xaccSplitGetAccount (s));
else
- name = g_strdup ("");
- }
+ {
+ /* For multi-split transactions and stock splits,
+ * use a special value. */
+ s = xaccTransGetSplit (xaccSplitGetParent(split), 1);
- return name;
+ if (s)
+ name = g_strdup (SPLIT_TRANS_STR);
+ else if (safe_strcmp ("stock-split", xaccSplitGetType (split)) == 0)
+ name = g_strdup (STOCK_SPLIT_STR);
+ else
+ name = g_strdup ("");
+ }
+
+ return name;
}
static char *
gnc_split_register_get_mxfrm_help (VirtualLocation virt_loc,
gpointer user_data)
{
- const char *help;
+ const char *help;
- SplitRegister *reg = user_data;
- Split *split;
- Split *s;
+ SplitRegister *reg = user_data;
+ Split *split;
+ Split *s;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return NULL;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return NULL;
- s = xaccSplitGetOtherSplit (split);
+ s = xaccSplitGetOtherSplit (split);
- if (s)
- {
- help = gnc_split_register_get_mxfrm_entry (virt_loc, FALSE,
- NULL, user_data);
- if (!help || *help == '\0')
- help = _("Enter the account to transfer from, "
- "or choose one from the list");
- }
- else
- {
- /* For multi-split transactions and stock splits,
- * use a special value. */
- s = xaccTransGetSplit (xaccSplitGetParent(split), 1);
-
if (s)
- help = _("This transaction has multiple splits; "
- "press the Split button to see them all");
- else if (safe_strcmp ("stock-split", xaccSplitGetType (split)) == 0)
- help = _("This transaction is a stock split; "
- "press the Split button to see details");
+ {
+ help = gnc_split_register_get_mxfrm_entry (virt_loc, FALSE,
+ NULL, user_data);
+ if (!help || *help == '\0')
+ help = _("Enter the account to transfer from, "
+ "or choose one from the list");
+ }
else
- help = "";
- }
+ {
+ /* For multi-split transactions and stock splits,
+ * use a special value. */
+ s = xaccTransGetSplit (xaccSplitGetParent(split), 1);
- return g_strdup (help);
+ if (s)
+ help = _("This transaction has multiple splits; "
+ "press the Split button to see them all");
+ else if (safe_strcmp ("stock-split", xaccSplitGetType (split)) == 0)
+ help = _("This transaction is a stock split; "
+ "press the Split button to see details");
+ else
+ help = "";
+ }
+
+ return g_strdup (help);
}
/* Return the total amount of the transaction for splits of default account
@@ -1395,27 +1414,28 @@
static gnc_numeric
get_trans_total_amount_subaccounts (SplitRegister *reg, Transaction *trans)
{
- GList *children, *child;
- Account *parent;
- gnc_numeric total = gnc_numeric_zero();
+ GList *children, *child;
+ Account *parent;
+ gnc_numeric total = gnc_numeric_zero();
- /* Get a list of all subaccounts for matching */
- parent = gnc_split_register_get_default_account(reg);
- if (!parent)
- /* Register has no account, perhaps it's the general ledger. If it
- has no account then we have no way of picking out the desired splits,
- return zero. */
- return total;
- children = gnc_account_get_descendants(parent);
- children = g_list_append(children, parent);
+ /* Get a list of all subaccounts for matching */
+ parent = gnc_split_register_get_default_account(reg);
+ if (!parent)
+ /* Register has no account, perhaps it's the general ledger. If it
+ has no account then we have no way of picking out the desired splits,
+ return zero. */
+ return total;
+ children = gnc_account_get_descendants(parent);
+ children = g_list_append(children, parent);
- for (child = children; child; child = child->next) {
- total = gnc_numeric_add_fixed(total, xaccTransGetAccountAmount(trans, child->data));
- }
+ for (child = children; child; child = child->next)
+ {
+ total = gnc_numeric_add_fixed(total, xaccTransGetAccountAmount(trans, child->data));
+ }
- g_list_free(children);
-
- return total;
+ g_list_free(children);
+
+ return total;
}
static const char *
@@ -1424,41 +1444,41 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char * cell_name;
- gnc_numeric total;
- Split *split;
+ SplitRegister *reg = user_data;
+ const char * cell_name;
+ gnc_numeric total;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return NULL;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return NULL;
- cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
+ cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
- switch (reg->type)
- {
+ switch (reg->type)
+ {
case GENERAL_LEDGER:
case INCOME_LEDGER:
- total = get_trans_total_amount_subaccounts (reg, xaccSplitGetParent (split));
- break;
+ total = get_trans_total_amount_subaccounts (reg, xaccSplitGetParent (split));
+ break;
default:
- total = get_trans_total_amount (reg, xaccSplitGetParent (split));
- }
+ total = get_trans_total_amount (reg, xaccSplitGetParent (split));
+ }
- if (gnc_numeric_zero_p (total))
- return NULL;
+ if (gnc_numeric_zero_p (total))
+ return NULL;
- if (gnc_numeric_negative_p (total) &&
- gnc_cell_name_equal (cell_name, TDEBT_CELL))
- return NULL;
+ if (gnc_numeric_negative_p (total) &&
+ gnc_cell_name_equal (cell_name, TDEBT_CELL))
+ return NULL;
- if (gnc_numeric_positive_p (total) &&
- gnc_cell_name_equal (cell_name, TCRED_CELL))
- return NULL;
+ if (gnc_numeric_positive_p (total) &&
+ gnc_cell_name_equal (cell_name, TCRED_CELL))
+ return NULL;
- total = gnc_numeric_abs (total);
+ total = gnc_numeric_abs (total);
- return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
+ return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
}
/* return TRUE if we have a RATE_CELL; return FALSE if we do not.
@@ -1467,30 +1487,30 @@
gboolean
gnc_split_reg_has_rate_cell (SplitRegisterType type)
{
- switch (type)
- {
- case BANK_REGISTER:
- case CASH_REGISTER:
- case ASSET_REGISTER:
- case CREDIT_REGISTER:
- case LIABILITY_REGISTER:
- case INCOME_REGISTER:
- case EXPENSE_REGISTER:
- case EQUITY_REGISTER:
- case TRADING_REGISTER:
- case GENERAL_LEDGER:
- case INCOME_LEDGER:
- case PORTFOLIO_LEDGER:
- case SEARCH_LEDGER:
- return TRUE;
+ switch (type)
+ {
+ case BANK_REGISTER:
+ case CASH_REGISTER:
+ case ASSET_REGISTER:
+ case CREDIT_REGISTER:
+ case LIABILITY_REGISTER:
+ case INCOME_REGISTER:
+ case EXPENSE_REGISTER:
+ case EQUITY_REGISTER:
+ case TRADING_REGISTER:
+ case GENERAL_LEDGER:
+ case INCOME_LEDGER:
+ case PORTFOLIO_LEDGER:
+ case SEARCH_LEDGER:
+ return TRUE;
- case STOCK_REGISTER:
- case CURRENCY_REGISTER:
- case RECEIVABLE_REGISTER:
- case PAYABLE_REGISTER:
- default:
- return FALSE;
- }
+ case STOCK_REGISTER:
+ case CURRENCY_REGISTER:
+ case RECEIVABLE_REGISTER:
+ case PAYABLE_REGISTER:
+ default:
+ return FALSE;
+ }
}
/* returns TRUE if you need to convert the split's value to the local
@@ -1499,21 +1519,21 @@
*/
gboolean
gnc_split_register_needs_conv_rate (SplitRegister *reg,
- Transaction *txn, Account *acc)
+ Transaction *txn, Account *acc)
{
- gnc_commodity *txn_cur, *acc_com;
+ gnc_commodity *txn_cur, *acc_com;
- /* If there is not a RATE_CELL, then don't do anything */
- if (!gnc_split_reg_has_rate_cell (reg->type))
- return FALSE;
+ /* If there is not a RATE_CELL, then don't do anything */
+ if (!gnc_split_reg_has_rate_cell (reg->type))
+ return FALSE;
- /* if txn->currency == acc->commodity, then return FALSE */
- acc_com = xaccAccountGetCommodity (acc);
- txn_cur = xaccTransGetCurrency (txn);
- if (txn_cur && acc_com && gnc_commodity_equal (txn_cur, acc_com))
- return FALSE;
+ /* if txn->currency == acc->commodity, then return FALSE */
+ acc_com = xaccAccountGetCommodity (acc);
+ txn_cur = xaccTransGetCurrency (txn);
+ if (txn_cur && acc_com && gnc_commodity_equal (txn_cur, acc_com))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
static const char *
@@ -1522,424 +1542,441 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- gboolean is_debit;
- Split *split;
- Transaction *trans;
- gnc_commodity *currency;
+ SplitRegister *reg = user_data;
+ gboolean is_debit;
+ Split *split;
+ Transaction *trans;
+ gnc_commodity *currency;
- is_debit = gnc_cell_name_equal
- (gnc_table_get_cell_name (reg->table, virt_loc), DEBT_CELL);
+ is_debit = gnc_cell_name_equal
+ (gnc_table_get_cell_name (reg->table, virt_loc), DEBT_CELL);
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ trans = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
- currency = xaccTransGetCurrency (trans);
- if (!currency)
- currency = gnc_default_currency ();
+ currency = xaccTransGetCurrency (trans);
+ if (!currency)
+ currency = gnc_default_currency ();
- if (!split)
- {
- gnc_numeric imbalance;
- Account *acc;
+ if (!split)
+ {
+ gnc_numeric imbalance;
+ Account *acc;
- imbalance = xaccTransGetImbalanceValue (trans);
-
- if (gnc_numeric_zero_p (imbalance))
- return NULL;
-
- if (xaccTransUseTradingAccounts (trans)) {
- MonetaryList *imbal_list;
- gnc_monetary *imbal_mon;
- imbal_list = xaccTransGetImbalance (trans);
-
- if (!imbal_list) {
- /* No commodity imbalance, there shouldn't be a value imablance. */
- return NULL;
- }
-
- if (imbal_list->next) {
- /* Multiple currency imbalance. */
- gnc_monetary_list_free(imbal_list);
- return NULL;
- }
-
- imbal_mon = imbal_list->data;
- if (!gnc_commodity_equal(gnc_monetary_commodity(*imbal_mon), currency)) {
- /* Imbalance is in wrong currency */
- gnc_monetary_list_free(imbal_list);
- return NULL;
- }
-
- if (!gnc_numeric_equal (gnc_monetary_value(*imbal_mon), imbalance)) {
- /* Value and commodity imbalances differ */
- gnc_monetary_list_free(imbal_list);
- return NULL;
- }
-
- /* Done with the imbalance list */
- gnc_monetary_list_free(imbal_list);
- }
+ imbalance = xaccTransGetImbalanceValue (trans);
- imbalance = gnc_numeric_neg (imbalance);
+ if (gnc_numeric_zero_p (imbalance))
+ return NULL;
- if (gnc_numeric_negative_p (imbalance) && is_debit)
- return NULL;
+ if (xaccTransUseTradingAccounts (trans))
+ {
+ MonetaryList *imbal_list;
+ gnc_monetary *imbal_mon;
+ imbal_list = xaccTransGetImbalance (trans);
- if (gnc_numeric_positive_p (imbalance) && !is_debit)
- return NULL;
+ if (!imbal_list)
+ {
+ /* No commodity imbalance, there shouldn't be a value imablance. */
+ return NULL;
+ }
- if (conditionally_changed)
- *conditionally_changed = TRUE;
+ if (imbal_list->next)
+ {
+ /* Multiple currency imbalance. */
+ gnc_monetary_list_free(imbal_list);
+ return NULL;
+ }
- imbalance = gnc_numeric_abs (imbalance);
+ imbal_mon = imbal_list->data;
+ if (!gnc_commodity_equal(gnc_monetary_commodity(*imbal_mon), currency))
+ {
+ /* Imbalance is in wrong currency */
+ gnc_monetary_list_free(imbal_list);
+ return NULL;
+ }
- acc = gnc_split_register_get_default_account (reg);
- if (gnc_split_register_needs_conv_rate (reg, trans, acc)) {
- imbalance = gnc_numeric_mul (imbalance,
- xaccTransGetAccountConvRate(trans, acc),
- gnc_commodity_get_fraction (currency),
- GNC_RND_ROUND);
- } else {
- imbalance = gnc_numeric_convert (imbalance,
- gnc_commodity_get_fraction (currency),
- GNC_RND_ROUND);
- }
+ if (!gnc_numeric_equal (gnc_monetary_value(*imbal_mon), imbalance))
+ {
+ /* Value and commodity imbalances differ */
+ gnc_monetary_list_free(imbal_list);
+ return NULL;
+ }
- return xaccPrintAmount (imbalance, gnc_account_print_info (acc, FALSE));
- }
+ /* Done with the imbalance list */
+ gnc_monetary_list_free(imbal_list);
+ }
- {
- gnc_numeric amount;
- gnc_commodity *split_commodity;
- GNCPrintAmountInfo print_info;
- Account *account;
- gnc_commodity * commodity;
-
- account = gnc_split_register_get_default_account (reg);
- commodity = xaccAccountGetCommodity (account);
- split_commodity = xaccAccountGetCommodity(xaccSplitGetAccount(split));
+ imbalance = gnc_numeric_neg (imbalance);
- if (xaccTransUseTradingAccounts (trans)) {
- gboolean use_symbol, is_current;
- is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
- virt_loc.vcell_loc);
-
- if (reg->type == STOCK_REGISTER ||
- reg->type == CURRENCY_REGISTER ||
- reg->type == PORTFOLIO_LEDGER) {
- gnc_commodity *amount_commodity;
- /* security register. If this split has price and shares columns,
- use the value, otherwise use the amount. */
- if (gnc_split_register_use_security_cells(reg, virt_loc)) {
- amount = xaccSplitGetValue(split);
- amount_commodity = currency;
+ if (gnc_numeric_negative_p (imbalance) && is_debit)
+ return NULL;
+
+ if (gnc_numeric_positive_p (imbalance) && !is_debit)
+ return NULL;
+
+ if (conditionally_changed)
+ *conditionally_changed = TRUE;
+
+ imbalance = gnc_numeric_abs (imbalance);
+
+ acc = gnc_split_register_get_default_account (reg);
+ if (gnc_split_register_needs_conv_rate (reg, trans, acc))
+ {
+ imbalance = gnc_numeric_mul (imbalance,
+ xaccTransGetAccountConvRate(trans, acc),
+ gnc_commodity_get_fraction (currency),
+ GNC_RND_ROUND);
}
- else {
- amount = xaccSplitGetAmount(split);
- amount_commodity = split_commodity;
- }
- /* Show the currency if it is not the default currency */
- if (is_current ||
- gnc_commodity_equiv(amount_commodity, gnc_default_currency()))
- use_symbol = FALSE;
else
- use_symbol = TRUE;
- print_info = gnc_commodity_print_info(amount_commodity, use_symbol);
- }
- else {
- /* non-security register, always use the split amount. */
- amount = xaccSplitGetAmount(split);
- if (is_current ||
- gnc_commodity_equiv(split_commodity, commodity))
- use_symbol = FALSE;
- else
- use_symbol = TRUE;
- print_info = gnc_commodity_print_info(split_commodity, use_symbol);
- }
- }
- else {
- /* If this account is not a stock/mutual/currency account, and
- * currency != the account commodity, then use the SplitAmount
- * instead of the SplitValue.
- */
- switch (reg->type) {
- case STOCK_REGISTER:
- case CURRENCY_REGISTER:
- case PORTFOLIO_LEDGER:
- amount = xaccSplitGetValue (split);
- print_info = gnc_commodity_print_info (currency, FALSE);
- break;
-
- default:
{
- if (commodity && !gnc_commodity_equal (commodity, currency))
- /* Convert this to the "local" value */
- amount = xaccSplitConvertAmount(split, account);
- else
- amount = xaccSplitGetValue (split);
- print_info = gnc_account_print_info (account, FALSE);
+ imbalance = gnc_numeric_convert (imbalance,
+ gnc_commodity_get_fraction (currency),
+ GNC_RND_ROUND);
}
- }
+
+ return xaccPrintAmount (imbalance, gnc_account_print_info (acc, FALSE));
}
- if (gnc_numeric_zero_p (amount))
- return NULL;
+ {
+ gnc_numeric amount;
+ gnc_commodity *split_commodity;
+ GNCPrintAmountInfo print_info;
+ Account *account;
+ gnc_commodity * commodity;
- if (gnc_numeric_negative_p (amount) && is_debit)
- return NULL;
+ account = gnc_split_register_get_default_account (reg);
+ commodity = xaccAccountGetCommodity (account);
+ split_commodity = xaccAccountGetCommodity(xaccSplitGetAccount(split));
- if (gnc_numeric_positive_p (amount) && !is_debit)
- return NULL;
+ if (xaccTransUseTradingAccounts (trans))
+ {
+ gboolean use_symbol, is_current;
+ is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
+ virt_loc.vcell_loc);
- amount = gnc_numeric_abs (amount);
+ if (reg->type == STOCK_REGISTER ||
+ reg->type == CURRENCY_REGISTER ||
+ reg->type == PORTFOLIO_LEDGER)
+ {
+ gnc_commodity *amount_commodity;
+ /* security register. If this split has price and shares columns,
+ use the value, otherwise use the amount. */
+ if (gnc_split_register_use_security_cells(reg, virt_loc))
+ {
+ amount = xaccSplitGetValue(split);
+ amount_commodity = currency;
+ }
+ else
+ {
+ amount = xaccSplitGetAmount(split);
+ amount_commodity = split_commodity;
+ }
+ /* Show the currency if it is not the default currency */
+ if (is_current ||
+ gnc_commodity_equiv(amount_commodity, gnc_default_currency()))
+ use_symbol = FALSE;
+ else
+ use_symbol = TRUE;
+ print_info = gnc_commodity_print_info(amount_commodity, use_symbol);
+ }
+ else
+ {
+ /* non-security register, always use the split amount. */
+ amount = xaccSplitGetAmount(split);
+ if (is_current ||
+ gnc_commodity_equiv(split_commodity, commodity))
+ use_symbol = FALSE;
+ else
+ use_symbol = TRUE;
+ print_info = gnc_commodity_print_info(split_commodity, use_symbol);
+ }
+ }
+ else
+ {
+ /* If this account is not a stock/mutual/currency account, and
+ * currency != the account commodity, then use the SplitAmount
+ * instead of the SplitValue.
+ */
+ switch (reg->type)
+ {
+ case STOCK_REGISTER:
+ case CURRENCY_REGISTER:
+ case PORTFOLIO_LEDGER:
+ amount = xaccSplitGetValue (split);
+ print_info = gnc_commodity_print_info (currency, FALSE);
+ break;
- return xaccPrintAmount (amount, print_info);
- }
+ default:
+ {
+ if (commodity && !gnc_commodity_equal (commodity, currency))
+ /* Convert this to the "local" value */
+ amount = xaccSplitConvertAmount(split, account);
+ else
+ amount = xaccSplitGetValue (split);
+ print_info = gnc_account_print_info (account, FALSE);
+ }
+ }
+ }
+
+ if (gnc_numeric_zero_p (amount))
+ return NULL;
+
+ if (gnc_numeric_negative_p (amount) && is_debit)
+ return NULL;
+
+ if (gnc_numeric_positive_p (amount) && !is_debit)
+ return NULL;
+
+ amount = gnc_numeric_abs (amount);
+
+ return xaccPrintAmount (amount, print_info);
+ }
}
/* Calculates the register balance for each split at runtime.
* This works regardless of the sort order. */
static const char *
gnc_split_register_get_rbaln_entry (VirtualLocation virt_loc,
- gboolean translate,
- gboolean *conditionally_changed,
- gpointer user_data)
+ gboolean translate,
+ gboolean *conditionally_changed,
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- SRInfo *info = gnc_split_register_get_info (reg);
- Split *split;
- Transaction *trans;
- gnc_numeric balance;
- Account *account;
+ SplitRegister *reg = user_data;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Split *split;
+ Transaction *trans;
+ gnc_numeric balance;
+ Account *account;
- /* Return NULL if this is a blank transaction. */
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (split == xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ()))
- return NULL;
+ /* Return NULL if this is a blank transaction. */
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (split == xaccSplitLookup (&info->blank_split_guid,
+ gnc_get_current_book ()))
+ return NULL;
- trans = xaccSplitGetParent (split);
- if (!trans)
- return NULL;
+ trans = xaccSplitGetParent (split);
+ if (!trans)
+ return NULL;
- balance = gnc_split_register_get_rbaln (virt_loc,user_data, TRUE);
+ balance = gnc_split_register_get_rbaln (virt_loc, user_data, TRUE);
- account = xaccSplitGetAccount (split);
- if (!account)
- account = gnc_split_register_get_default_account (reg);
+ account = xaccSplitGetAccount (split);
+ if (!account)
+ account = gnc_split_register_get_default_account (reg);
- if (gnc_reverse_balance (account))
- balance = gnc_numeric_neg (balance);
+ if (gnc_reverse_balance (account))
+ balance = gnc_numeric_neg (balance);
- return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
+ return xaccPrintAmount (balance, gnc_account_print_info (account, FALSE));
}
static gboolean
gnc_split_register_cursor_is_readonly (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- Split *split;
- Transaction *txn;
- char type;
+ SplitRegister *reg = user_data;
+ Split *split;
+ Transaction *txn;
+ char type;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split) return FALSE;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split) return FALSE;
- txn = xaccSplitGetParent (split);
- if (!txn) return FALSE;
+ txn = xaccSplitGetParent (split);
+ if (!txn) return FALSE;
- if (xaccTransGetReadOnly(txn))
- return(TRUE);
+ if (xaccTransGetReadOnly(txn))
+ return(TRUE);
- type = xaccTransGetTxnType (txn);
- return (type == TXN_TYPE_INVOICE);
+ type = xaccTransGetTxnType (txn);
+ return (type == TXN_TYPE_INVOICE);
}
static CellIOFlags
gnc_split_register_get_inactive_io_flags (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
- return XACC_CELL_ALLOW_READ_ONLY;
+ if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
+ return XACC_CELL_ALLOW_READ_ONLY;
- return XACC_CELL_ALLOW_NONE;
+ return XACC_CELL_ALLOW_NONE;
}
static CellIOFlags
gnc_split_register_get_standard_io_flags (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
- return XACC_CELL_ALLOW_READ_ONLY;
+ if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
+ return XACC_CELL_ALLOW_READ_ONLY;
- return XACC_CELL_ALLOW_ALL;
+ return XACC_CELL_ALLOW_ALL;
}
static CellIOFlags
gnc_split_register_get_recn_io_flags (VirtualLocation virt_loc,
gpointer user_data)
{
- if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
- return XACC_CELL_ALLOW_READ_ONLY;
+ if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
+ return XACC_CELL_ALLOW_READ_ONLY;
- return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
+ return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
}
static CellIOFlags
gnc_split_register_get_ddue_io_flags (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- char type;
+ SplitRegister *reg = user_data;
+ char type;
- type = gnc_split_register_get_type_value (reg, virt_loc);
+ type = gnc_split_register_get_type_value (reg, virt_loc);
- /* Only print the due date for invoice transactions */
- if (type != TXN_TYPE_INVOICE) {
- return XACC_CELL_ALLOW_NONE;
- }
+ /* Only print the due date for invoice transactions */
+ if (type != TXN_TYPE_INVOICE)
+ {
+ return XACC_CELL_ALLOW_NONE;
+ }
- return XACC_CELL_ALLOW_READ_ONLY;
+ return XACC_CELL_ALLOW_READ_ONLY;
}
static CellIOFlags
gnc_split_register_get_rate_io_flags (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- return XACC_CELL_ALLOW_SHADOW;
+ return XACC_CELL_ALLOW_SHADOW;
}
static CellIOFlags
gnc_split_register_get_debcred_io_flags (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- Split *split;
+ SplitRegister *reg = user_data;
+ Split *split;
- if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
- return XACC_CELL_ALLOW_READ_ONLY;
+ if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
+ return XACC_CELL_ALLOW_READ_ONLY;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (safe_strcmp ("stock-split", xaccSplitGetType (split)) == 0)
- return XACC_CELL_ALLOW_NONE;
+ if (safe_strcmp ("stock-split", xaccSplitGetType (split)) == 0)
+ return XACC_CELL_ALLOW_NONE;
- return XACC_CELL_ALLOW_ALL;
+ return XACC_CELL_ALLOW_ALL;
}
static CellIOFlags
gnc_split_register_get_security_io_flags (VirtualLocation virt_loc,
- gpointer user_data)
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
+ SplitRegister *reg = user_data;
- if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
- return XACC_CELL_ALLOW_READ_ONLY;
+ if (gnc_split_register_cursor_is_readonly (virt_loc, user_data))
+ return XACC_CELL_ALLOW_READ_ONLY;
- if (gnc_split_register_use_security_cells (reg, virt_loc))
- return XACC_CELL_ALLOW_ALL;
+ if (gnc_split_register_use_security_cells (reg, virt_loc))
+ return XACC_CELL_ALLOW_ALL;
- return XACC_CELL_ALLOW_SHADOW;
+ return XACC_CELL_ALLOW_SHADOW;
}
static gboolean
xaccTransWarnReadOnly (const Transaction *trans)
{
- GtkWidget *dialog;
- const gchar *reason;
- const gchar *format =
- _("Cannot modify or delete this transaction. This transaction is "
- "marked read-only because:\n\n'%s'");
-
- if (!trans) return FALSE;
-
- reason = xaccTransGetReadOnly (trans);
- if (reason) {
- dialog = gtk_message_dialog_new(NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- format,
- reason);
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- return TRUE;
- }
- return FALSE;
+ GtkWidget *dialog;
+ const gchar *reason;
+ const gchar *format =
+ _("Cannot modify or delete this transaction. This transaction is "
+ "marked read-only because:\n\n'%s'");
+
+ if (!trans) return FALSE;
+
+ reason = xaccTransGetReadOnly (trans);
+ if (reason)
+ {
+ dialog = gtk_message_dialog_new(NULL,
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ format,
+ reason);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ return TRUE;
+ }
+ return FALSE;
}
static gboolean
gnc_split_register_confirm (VirtualLocation virt_loc, gpointer user_data)
{
- SplitRegister *reg = user_data;
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *trans;
- Split *split;
- char recn;
+ SplitRegister *reg = user_data;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *trans;
+ Split *split;
+ char recn;
- /* This assumes we reset the flag whenever we change splits.
- * This happens in gnc_split_register_move_cursor(). */
- if (info->change_confirmed)
- return TRUE;
+ /* This assumes we reset the flag whenever we change splits.
+ * This happens in gnc_split_register_move_cursor(). */
+ if (info->change_confirmed)
+ return TRUE;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return TRUE;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return TRUE;
- trans = xaccSplitGetParent (split);
- if (xaccTransWarnReadOnly(trans))
- return FALSE;
- if (gnc_table_layout_get_cell_changed (reg->table->layout, RECN_CELL, FALSE))
- recn = gnc_recn_cell_get_flag
- ((RecnCell *) gnc_table_layout_get_cell (reg->table->layout, RECN_CELL));
- else
- recn = xaccSplitGetReconcile (split);
+ trans = xaccSplitGetParent (split);
+ if (xaccTransWarnReadOnly(trans))
+ return FALSE;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, RECN_CELL, FALSE))
+ recn = gnc_recn_cell_get_flag
+ ((RecnCell *) gnc_table_layout_get_cell (reg->table->layout, RECN_CELL));
+ else
+ recn = xaccSplitGetReconcile (split);
- if (recn == YREC)
- {
- GtkWidget *dialog, *window;
- gint response;
- const gchar *title = _("Change reconciled split?");
- const gchar *message =
- _("You are about to change a reconciled split. Doing so might make "
- "future reconciliation difficult! Continue with this change?");
-
- /* Does the user want to be warned? */
- window = gnc_split_register_get_parent(reg);
- dialog =
- gtk_message_dialog_new(GTK_WINDOW(window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_CANCEL,
- "%s", title);
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- "%s", message);
- gtk_dialog_add_button(GTK_DIALOG(dialog), _("Chan_ge Split"),
- GTK_RESPONSE_YES);
- response = gnc_dialog_run(GTK_DIALOG(dialog), "change_reconciled_split");
- gtk_widget_destroy(dialog);
- if (response != GTK_RESPONSE_YES)
- return FALSE;
+ if (recn == YREC)
+ {
+ GtkWidget *dialog, *window;
+ gint response;
+ const gchar *title = _("Change reconciled split?");
+ const gchar *message =
+ _("You are about to change a reconciled split. Doing so might make "
+ "future reconciliation difficult! Continue with this change?");
- info->change_confirmed = TRUE;
- }
+ /* Does the user want to be warned? */
+ window = gnc_split_register_get_parent(reg);
+ dialog =
+ gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_CANCEL,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+ "%s", message);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), _("Chan_ge Split"),
+ GTK_RESPONSE_YES);
+ response = gnc_dialog_run(GTK_DIALOG(dialog), "change_reconciled_split");
+ gtk_widget_destroy(dialog);
+ if (response != GTK_RESPONSE_YES)
+ return FALSE;
- return TRUE;
+ info->change_confirmed = TRUE;
+ }
+
+ return TRUE;
}
static gpointer
gnc_split_register_guid_malloc (void)
{
- GUID *guid;
+ GUID *guid;
- guid = guid_malloc ();
+ guid = guid_malloc ();
- *guid = *guid_null ();
+ *guid = *guid_null ();
- return guid;
+ return guid;
}
static const char *
@@ -1948,36 +1985,36 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- static char *name = NULL;
+ static char *name = NULL;
- SplitRegister *reg = user_data;
- kvp_frame *kvpf;
- Split *split;
+ SplitRegister *reg = user_data;
+ kvp_frame *kvpf;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return NULL;
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return NULL;
- kvpf = xaccSplitGetSlots (split);
+ kvpf = xaccSplitGetSlots (split);
- g_free (name);
+ g_free (name);
- if (kvpf)
- {
- Account *account;
- GUID *guid;
+ if (kvpf)
+ {
+ Account *account;
+ GUID *guid;
- guid = kvp_value_get_guid(
- kvp_frame_get_slot_path(kvpf, "sched-xaction", "account", NULL));
+ guid = kvp_value_get_guid(
+ kvp_frame_get_slot_path(kvpf, "sched-xaction", "account", NULL));
- account = xaccAccountLookup (guid, gnc_get_current_book ());
+ account = xaccAccountLookup (guid, gnc_get_current_book ());
- name = account ? gnc_get_account_name_for_register (account) : NULL;
- }
- else
- name = NULL;
+ name = account ? gnc_get_account_name_for_register (account) : NULL;
+ }
+ else
+ name = NULL;
- return name;
+ return name;
}
static const char *
@@ -1986,26 +2023,26 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
- kvp_frame *kvpf = xaccSplitGetSlots(split);
+ SplitRegister *reg = user_data;
+ Split *split = gnc_split_register_get_split(reg, virt_loc.vcell_loc);
+ kvp_frame *kvpf = xaccSplitGetSlots(split);
- return kvp_value_get_string(
- kvp_frame_get_slot_path (kvpf, "sched-xaction", "debit-formula", NULL));
+ return kvp_value_get_string(
+ kvp_frame_get_slot_path (kvpf, "sched-xaction", "debit-formula", NULL));
}
static char *
gnc_split_register_get_fdebt_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help;
+ SplitRegister *reg = user_data;
+ const char *help;
- help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter debit formula for real transaction");
+ help = gnc_table_get_entry (reg->table, virt_loc);
+ if (!help || *help == '\0')
+ help = _("Enter debit formula for real transaction");
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
@@ -2014,547 +2051,547 @@
gboolean *conditionally_changed,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- kvp_frame *kvpf;
- Split *split;
+ SplitRegister *reg = user_data;
+ kvp_frame *kvpf;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- kvpf = xaccSplitGetSlots (split);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ kvpf = xaccSplitGetSlots (split);
- return kvp_value_get_string(
- kvp_frame_get_slot_path (kvpf, "sched-xaction", "credit-formula", NULL));
+ return kvp_value_get_string(
+ kvp_frame_get_slot_path (kvpf, "sched-xaction", "credit-formula", NULL));
}
static char *
gnc_split_register_get_fcred_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help = gnc_table_get_entry (reg->table, virt_loc);
+ SplitRegister *reg = user_data;
+ const char *help = gnc_table_get_entry (reg->table, virt_loc);
- if (!help || *help == '\0')
- help = _("Enter credit formula for real transaction");
+ if (!help || *help == '\0')
+ help = _("Enter credit formula for real transaction");
- return g_strdup (help);
+ return g_strdup (help);
}
static char *
gnc_split_register_get_default_help (VirtualLocation virt_loc,
gpointer user_data)
{
- SplitRegister *reg = user_data;
- const char *help = gnc_table_get_entry(reg->table, virt_loc);
+ SplitRegister *reg = user_data;
+ const char *help = gnc_table_get_entry(reg->table, virt_loc);
- return g_strdup (help);
+ return g_strdup (help);
}
static const char *
gnc_template_register_get_debcred_entry (VirtualLocation virt_loc,
- gboolean translate,
- gboolean *conditionally_changed,
- gpointer user_data)
+ gboolean translate,
+ gboolean *conditionally_changed,
+ gpointer user_data)
{
- SplitRegister *reg = user_data;
- kvp_frame *kvpf;
- Split *split;
+ SplitRegister *reg = user_data;
+ kvp_frame *kvpf;
+ Split *split;
- split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- if (!split)
- return gnc_split_register_get_debcred_entry (virt_loc,
- translate,
- conditionally_changed,
- user_data);
+ split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
+ if (!split)
+ return gnc_split_register_get_debcred_entry (virt_loc,
+ translate,
+ conditionally_changed,
+ user_data);
- kvpf = xaccSplitGetSlots (split);
- PWARN( "We're very close to \"wrong\". \"Fix it immediately!!!\"" );
+ kvpf = xaccSplitGetSlots (split);
+ PWARN( "We're very close to \"wrong\". \"Fix it immediately!!!\"" );
- if (kvpf)
- {
- gnc_numeric amount;
- const char * cell_name;
- char *str;
+ if (kvpf)
+ {
+ gnc_numeric amount;
+ const char * cell_name;
+ char *str;
- PWARN("This code is wrong. Fix it immediately!!!!");
- str = kvp_value_get_string(
- kvp_frame_get_slot_path(kvpf, "sched-xaction", "amnt", NULL));
+ PWARN("This code is wrong. Fix it immediately!!!!");
+ str = kvp_value_get_string(
+ kvp_frame_get_slot_path(kvpf, "sched-xaction", "amnt", NULL));
- amount = gnc_numeric_zero ();
- string_to_gnc_numeric (str, &amount);
+ amount = gnc_numeric_zero ();
+ string_to_gnc_numeric (str, &amount);
- if (gnc_numeric_zero_p (amount))
- return "";
+ if (gnc_numeric_zero_p (amount))
+ return "";
- cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
+ cell_name = gnc_table_get_cell_name (reg->table, virt_loc);
- if (gnc_numeric_negative_p (amount) &&
- gnc_cell_name_equal (cell_name, DEBT_CELL))
- return "";
+ if (gnc_numeric_negative_p (amount) &&
+ gnc_cell_name_equal (cell_name, DEBT_CELL))
+ return "";
- if (gnc_numeric_positive_p (amount) &&
- gnc_cell_name_equal (cell_name, CRED_CELL))
- return "";
+ if (gnc_numeric_positive_p (amount) &&
+ gnc_cell_name_equal (cell_name, CRED_CELL))
+ return "";
- amount = gnc_numeric_abs (amount);
+ amount = gnc_numeric_abs (amount);
- /* FIXME: This should be fixed to be correct for the "fake" account. */
- return xaccPrintAmount (amount, gnc_default_print_info (FALSE));
- }
+ /* FIXME: This should be fixed to be correct for the "fake" account. */
+ return xaccPrintAmount (amount, gnc_default_print_info (FALSE));
+ }
- return NULL;
+ return NULL;
}
static void
gnc_split_register_guid_free (gpointer guid)
{
- guid_free (guid);
+ guid_free (guid);
}
static void
gnc_split_register_guid_copy (gpointer p_to, gconstpointer p_from)
{
- GUID *to = p_to;
- const GUID *from = p_from;
+ GUID *to = p_to;
+ const GUID *from = p_from;
- g_return_if_fail (to != NULL);
- *to = from ? *from : *guid_null();
+ g_return_if_fail (to != NULL);
+ *to = from ? *from : *guid_null();
}
static void
gnc_split_register_colorize_negative (GConfEntry *entry, gpointer unused)
{
- GConfValue *value;
+ GConfValue *value;
- value = gconf_entry_get_value(entry);
- use_red_for_negative = gconf_value_get_bool(value);
+ value = gconf_entry_get_value(entry);
+ use_red_for_negative = gconf_value_get_bool(value);
}
static gpointer
gnc_split_register_model_add_hooks (gpointer unused)
{
- gnc_gconf_general_register_cb(KEY_NEGATIVE_IN_RED,
- gnc_split_register_colorize_negative,
- NULL);
- /* Get the initial value */
- use_red_for_negative = gnc_gconf_get_bool(GCONF_GENERAL,
- KEY_NEGATIVE_IN_RED,
- NULL);
- return NULL;
+ gnc_gconf_general_register_cb(KEY_NEGATIVE_IN_RED,
+ gnc_split_register_colorize_negative,
+ NULL);
+ /* Get the initial value */
+ use_red_for_negative = gnc_gconf_get_bool(GCONF_GENERAL,
+ KEY_NEGATIVE_IN_RED,
+ NULL);
+ return NULL;
}
TableModel *
gnc_split_register_model_new (void)
{
- TableModel *model;
- static GOnce once = G_ONCE_INIT;
+ TableModel *model;
+ static GOnce once = G_ONCE_INIT;
- g_once(&once, gnc_split_register_model_add_hooks, NULL);
+ g_once(&once, gnc_split_register_model_add_hooks, NULL);
- model = gnc_table_model_new ();
+ model = gnc_table_model_new ();
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_date_entry,
- DATE_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_date_entry,
+ DATE_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_due_date_entry,
- DDUE_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_due_date_entry,
+ DDUE_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_num_entry,
- NUM_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_num_entry,
+ NUM_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_desc_entry,
- DESC_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_desc_entry,
+ DESC_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_notes_entry,
- NOTES_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_notes_entry,
+ NOTES_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_vnotes_entry,
- VNOTES_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_vnotes_entry,
+ VNOTES_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_rate_entry,
- RATE_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_rate_entry,
+ RATE_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_recn_entry,
- RECN_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_recn_entry,
+ RECN_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_action_entry,
- ACTN_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_action_entry,
+ ACTN_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_memo_entry,
- MEMO_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_memo_entry,
+ MEMO_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_balance_entry,
- BALN_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_balance_entry,
+ BALN_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_balance_entry,
- TBALN_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_balance_entry,
+ TBALN_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_price_entry,
- PRIC_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_price_entry,
+ PRIC_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_shares_entry,
- SHRS_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_shares_entry,
+ SHRS_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_tshares_entry,
- TSHRS_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_tshares_entry,
+ TSHRS_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_xfrm_entry,
- XFRM_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_xfrm_entry,
+ XFRM_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_mxfrm_entry,
- MXFRM_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_mxfrm_entry,
+ MXFRM_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_tdebcred_entry,
- TDEBT_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_tdebcred_entry,
+ TDEBT_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_tdebcred_entry,
- TCRED_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_tdebcred_entry,
+ TCRED_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_type_entry,
- TYPE_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_type_entry,
+ TYPE_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_debcred_entry,
- DEBT_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_debcred_entry,
+ DEBT_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_debcred_entry,
- CRED_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_debcred_entry,
+ CRED_CELL);
- gnc_table_model_set_entry_handler (model,
- gnc_split_register_get_rbaln_entry,
- RBALN_CELL);
+ gnc_table_model_set_entry_handler (model,
+ gnc_split_register_get_rbaln_entry,
+ RBALN_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_date_label,
- DATE_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_date_label,
+ DATE_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_due_date_label,
- DDUE_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_due_date_label,
+ DDUE_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_num_label,
- NUM_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_num_label,
+ NUM_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_desc_label,
- DESC_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_desc_label,
+ DESC_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_recn_label,
- RECN_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_recn_label,
+ RECN_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_baln_label,
- BALN_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_baln_label,
+ BALN_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_action_label,
- ACTN_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_action_label,
+ ACTN_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_xfrm_label,
- XFRM_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_xfrm_label,
+ XFRM_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_memo_label,
- MEMO_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_memo_label,
+ MEMO_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_debit_label,
- DEBT_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_debit_label,
+ DEBT_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_credit_label,
- CRED_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_credit_label,
+ CRED_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_price_label,
- PRIC_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_price_label,
+ PRIC_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_shares_label,
- SHRS_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_shares_label,
+ SHRS_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_mxfrm_label,
- MXFRM_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_mxfrm_label,
+ MXFRM_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_tcredit_label,
- TCRED_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_tcredit_label,
+ TCRED_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_tdebit_label,
- TDEBT_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_tdebit_label,
+ TDEBT_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_tshares_label,
- TSHRS_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_tshares_label,
+ TSHRS_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_tbalance_label,
- TBALN_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_tbalance_label,
+ TBALN_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_type_label,
- TYPE_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_type_label,
+ TYPE_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_notes_label,
- NOTES_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_notes_label,
+ NOTES_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_fdebit_label,
- FDEBT_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_fdebit_label,
+ FDEBT_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_fcredit_label,
- FCRED_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_fcredit_label,
+ FCRED_CELL);
- gnc_table_model_set_label_handler (model,
- gnc_split_register_get_tbalance_label,
- RBALN_CELL);
+ gnc_table_model_set_label_handler (model,
+ gnc_split_register_get_tbalance_label,
+ RBALN_CELL);
- gnc_table_model_set_default_help_handler(
- model, gnc_split_register_get_default_help);
+ gnc_table_model_set_default_help_handler(
+ model, gnc_split_register_get_default_help);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_date_help,
- DATE_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_date_help,
+ DATE_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_date_help,
- DDUE_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_date_help,
+ DDUE_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_num_help,
- NUM_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_num_help,
+ NUM_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_desc_help,
- DESC_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_desc_help,
+ DESC_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_price_help,
- PRIC_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_price_help,
+ PRIC_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_shares_help,
- SHRS_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_shares_help,
+ SHRS_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_action_help,
- ACTN_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_action_help,
+ ACTN_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_memo_help,
- MEMO_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_memo_help,
+ MEMO_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_notes_help,
- NOTES_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_notes_help,
+ NOTES_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_vnotes_help,
- VNOTES_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_vnotes_help,
+ VNOTES_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_xfrm_help,
- XFRM_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_xfrm_help,
+ XFRM_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_mxfrm_help,
- MXFRM_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_mxfrm_help,
+ MXFRM_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_fcred_help,
- FCRED_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_fcred_help,
+ FCRED_CELL);
- gnc_table_model_set_help_handler (model,
- gnc_split_register_get_fdebt_help,
- FDEBT_CELL);
+ gnc_table_model_set_help_handler (model,
+ gnc_split_register_get_fdebt_help,
+ FDEBT_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, DATE_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, DATE_CELL);
- /* FIXME: We really only need a due date for 'invoices', not for
- * 'payments' or 'receipts'. This implies we really only need the
- * due-date for transactions that credit the ACCT_TYPE_RECEIVABLE or
- * debit the ACCT_TYPE_PAYABLE account type.
- */
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_rate_io_flags, RATE_CELL);
+ /* FIXME: We really only need a due date for 'invoices', not for
+ * 'payments' or 'receipts'. This implies we really only need the
+ * due-date for transactions that credit the ACCT_TYPE_RECEIVABLE or
+ * debit the ACCT_TYPE_PAYABLE account type.
+ */
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_rate_io_flags, RATE_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_ddue_io_flags, DDUE_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_ddue_io_flags, DDUE_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, NUM_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, NUM_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, DESC_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, DESC_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, ACTN_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, ACTN_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, XFRM_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, XFRM_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, MEMO_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, MEMO_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, MXFRM_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, MXFRM_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, NOTES_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, NOTES_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_inactive_io_flags, VNOTES_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_inactive_io_flags, VNOTES_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_debcred_io_flags, CRED_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_debcred_io_flags, CRED_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_debcred_io_flags, DEBT_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_debcred_io_flags, DEBT_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_recn_io_flags, RECN_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_recn_io_flags, RECN_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_recn_io_flags, TYPE_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_recn_io_flags, TYPE_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_security_io_flags, PRIC_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_security_io_flags, PRIC_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_security_io_flags, SHRS_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_security_io_flags, SHRS_CELL);
- gnc_table_model_set_fg_color_handler(
- model, gnc_split_register_get_shares_fg_color, SHRS_CELL);
+ gnc_table_model_set_fg_color_handler(
+ model, gnc_split_register_get_shares_fg_color, SHRS_CELL);
- gnc_table_model_set_fg_color_handler(
- model, gnc_split_register_get_shares_fg_color, TSHRS_CELL);
+ gnc_table_model_set_fg_color_handler(
+ model, gnc_split_register_get_shares_fg_color, TSHRS_CELL);
- gnc_table_model_set_fg_color_handler(
- model, gnc_split_register_get_balance_fg_color, BALN_CELL);
+ gnc_table_model_set_fg_color_handler(
+ model, gnc_split_register_get_balance_fg_color, BALN_CELL);
- gnc_table_model_set_fg_color_handler(
- model, gnc_split_register_get_balance_fg_color, TBALN_CELL);
+ gnc_table_model_set_fg_color_handler(
+ model, gnc_split_register_get_balance_fg_color, TBALN_CELL);
- gnc_table_model_set_fg_color_handler(
- model, gnc_split_register_get_balance_fg_color, RBALN_CELL);
+ gnc_table_model_set_fg_color_handler(
+ model, gnc_split_register_get_balance_fg_color, RBALN_CELL);
- gnc_table_model_set_default_bg_color_handler(
- model, gnc_split_register_get_bg_color);
+ gnc_table_model_set_default_bg_color_handler(
+ model, gnc_split_register_get_bg_color);
- gnc_table_model_set_bg_color_handler(
- model, gnc_split_register_get_gtkrc_bg_color, "gtkrc");
+ gnc_table_model_set_bg_color_handler(
+ model, gnc_split_register_get_gtkrc_bg_color, "gtkrc");
- gnc_table_model_set_bg_color_handler(
- model, gnc_split_register_get_debcred_bg_color, DEBT_CELL);
+ gnc_table_model_set_bg_color_handler(
+ model, gnc_split_register_get_debcred_bg_color, DEBT_CELL);
- gnc_table_model_set_bg_color_handler(
- model, gnc_split_register_get_debcred_bg_color, CRED_CELL);
+ gnc_table_model_set_bg_color_handler(
+ model, gnc_split_register_get_debcred_bg_color, CRED_CELL);
- gnc_table_model_set_bg_color_handler(
- model, gnc_split_register_get_debcred_bg_color, TDEBT_CELL);
+ gnc_table_model_set_bg_color_handler(
+ model, gnc_split_register_get_debcred_bg_color, TDEBT_CELL);
- gnc_table_model_set_bg_color_handler(
- model, gnc_split_register_get_debcred_bg_color, TCRED_CELL);
+ gnc_table_model_set_bg_color_handler(
+ model, gnc_split_register_get_debcred_bg_color, TCRED_CELL);
- gnc_table_model_set_bg_color_handler(
- model, gnc_split_register_get_debcred_bg_color, FCRED_CELL);
+ gnc_table_model_set_bg_color_handler(
+ model, gnc_split_register_get_debcred_bg_color, FCRED_CELL);
- gnc_table_model_set_bg_color_handler(
- model, gnc_split_register_get_debcred_bg_color, FDEBT_CELL);
+ gnc_table_model_set_bg_color_handler(
+ model, gnc_split_register_get_debcred_bg_color, FDEBT_CELL);
- gnc_table_model_set_default_cell_border_handler(
- model, gnc_split_register_get_border);
+ gnc_table_model_set_default_cell_border_handler(
+ model, gnc_split_register_get_border);
- gnc_table_model_set_default_confirm_handler(
- model, gnc_split_register_confirm);
+ gnc_table_model_set_default_confirm_handler(
+ model, gnc_split_register_confirm);
- model->cell_data_allocator = gnc_split_register_guid_malloc;
- model->cell_data_deallocator = gnc_split_register_guid_free;
- model->cell_data_copy = gnc_split_register_guid_copy;
+ model->cell_data_allocator = gnc_split_register_guid_malloc;
+ model->cell_data_deallocator = gnc_split_register_guid_free;
+ model->cell_data_copy = gnc_split_register_guid_copy;
- gnc_split_register_model_add_save_handlers (model);
+ gnc_split_register_model_add_save_handlers (model);
- return model;
+ return model;
}
TableModel *
gnc_template_register_model_new (void)
{
- TableModel *model;
+ TableModel *model;
- model = gnc_split_register_model_new ();
+ model = gnc_split_register_model_new ();
- gnc_table_model_set_entry_handler(
- model, gnc_split_register_get_inactive_date_entry, DATE_CELL );
+ gnc_table_model_set_entry_handler(
+ model, gnc_split_register_get_inactive_date_entry, DATE_CELL );
- gnc_table_model_set_entry_handler(
- model, gnc_split_register_get_inactive_date_entry, DDUE_CELL );
+ gnc_table_model_set_entry_handler(
+ model, gnc_split_register_get_inactive_date_entry, DDUE_CELL );
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_inactive_io_flags, DATE_CELL );
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_inactive_io_flags, DATE_CELL );
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_inactive_io_flags, DDUE_CELL );
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_inactive_io_flags, DDUE_CELL );
- gnc_table_model_set_entry_handler(
- model, gnc_template_register_get_xfrm_entry, XFRM_CELL);
+ gnc_table_model_set_entry_handler(
+ model, gnc_template_register_get_xfrm_entry, XFRM_CELL);
- gnc_table_model_set_entry_handler(
- model, gnc_template_register_get_fdebt_entry, FDEBT_CELL);
+ gnc_table_model_set_entry_handler(
+ model, gnc_template_register_get_fdebt_entry, FDEBT_CELL);
- gnc_table_model_set_entry_handler(
- model, gnc_template_register_get_fcred_entry, FCRED_CELL);
+ gnc_table_model_set_entry_handler(
+ model, gnc_template_register_get_fcred_entry, FCRED_CELL);
- gnc_table_model_set_entry_handler(
- model, gnc_template_register_get_debcred_entry, DEBT_CELL);
+ gnc_table_model_set_entry_handler(
+ model, gnc_template_register_get_debcred_entry, DEBT_CELL);
- gnc_table_model_set_entry_handler(
- model, gnc_template_register_get_debcred_entry, CRED_CELL);
+ gnc_table_model_set_entry_handler(
+ model, gnc_template_register_get_debcred_entry, CRED_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, FCRED_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, FCRED_CELL);
- gnc_table_model_set_io_flags_handler(
- model, gnc_split_register_get_standard_io_flags, FDEBT_CELL);
+ gnc_table_model_set_io_flags_handler(
+ model, gnc_split_register_get_standard_io_flags, FDEBT_CELL);
- gnc_template_register_model_add_save_handlers (model);
+ gnc_template_register_model_add_save_handlers (model);
- return model;
+ return model;
}
Modified: gnucash/trunk/src/register/ledger-core/split-register-model.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-model.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -28,15 +28,16 @@
TableModel * gnc_split_register_model_new (void);
TableModel * gnc_template_register_model_new (void);
-typedef enum {
- COLOR_UNKNOWN,
- COLOR_HEADER,
- COLOR_PRIMARY,
- COLOR_PRIMARY_ACTIVE,
- COLOR_SECONDARY,
- COLOR_SECONDARY_ACTIVE,
- COLOR_SPLIT,
- COLOR_SPLIT_ACTIVE,
+typedef enum
+{
+ COLOR_UNKNOWN,
+ COLOR_HEADER,
+ COLOR_PRIMARY,
+ COLOR_PRIMARY_ACTIVE,
+ COLOR_SECONDARY,
+ COLOR_SECONDARY_ACTIVE,
+ COLOR_SPLIT,
+ COLOR_SPLIT_ACTIVE,
} RegisterColor;
#endif
Modified: gnucash/trunk/src/register/ledger-core/split-register-p.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-p.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-p.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -33,90 +33,90 @@
#define ACTION_SELL_STR _("Sell")
struct sr_info
{
- /* The blank split at the bottom of the register */
- GUID blank_split_guid;
+ /* The blank split at the bottom of the register */
+ GUID blank_split_guid;
- /* The currently open transaction, if any */
- GUID pending_trans_guid;
+ /* The currently open transaction, if any */
+ GUID pending_trans_guid;
- /* A transaction used to remember where to put the cursor */
- Transaction *cursor_hint_trans;
+ /* A transaction used to remember where to put the cursor */
+ Transaction *cursor_hint_trans;
- /* A split used to remember where to put the cursor */
- Split *cursor_hint_split;
+ /* A split used to remember where to put the cursor */
+ Split *cursor_hint_split;
- /* A split used to remember where to put the cursor */
- Split *cursor_hint_trans_split;
+ /* A split used to remember where to put the cursor */
+ Split *cursor_hint_trans_split;
- /* Used to remember where to put the cursor */
- CursorClass cursor_hint_cursor_class;
+ /* Used to remember where to put the cursor */
+ CursorClass cursor_hint_cursor_class;
- /* If the hints were set by the traverse callback */
- gboolean hint_set_by_traverse;
+ /* If the hints were set by the traverse callback */
+ gboolean hint_set_by_traverse;
- /* If traverse is to the newly created split */
- gboolean traverse_to_new;
+ /* If traverse is to the newly created split */
+ gboolean traverse_to_new;
- /* A flag indicating if the last traversal was 'exact'.
- * See table-allgui.[ch] for details. */
- gboolean exact_traversal;
+ /* A flag indicating if the last traversal was 'exact'.
+ * See table-allgui.[ch] for details. */
+ gboolean exact_traversal;
- /* Indicates that the current transaction is expanded
- * in ledger mode. Meaningless in other modes. */
- gboolean trans_expanded;
+ /* Indicates that the current transaction is expanded
+ * in ledger mode. Meaningless in other modes. */
+ gboolean trans_expanded;
- /* set to TRUE after register is loaded */
- gboolean reg_loaded;
+ /* set to TRUE after register is loaded */
+ gboolean reg_loaded;
- /* flag indicating whether full refresh is ok */
- gboolean full_refresh;
+ /* flag indicating whether full refresh is ok */
+ gboolean full_refresh;
- /* The default account where new splits are added */
- GUID default_account;
+ /* The default account where new splits are added */
+ GUID default_account;
- /* The last date recorded in the blank split */
- time_t last_date_entered;
+ /* The last date recorded in the blank split */
+ time_t last_date_entered;
- /* true if the current blank split has been edited and commited */
- gboolean blank_split_edited;
+ /* true if the current blank split has been edited and commited */
+ gboolean blank_split_edited;
- /* true if the demarcation between 'past' and 'future' transactions
- * should be visible */
- gboolean show_present_divider;
+ /* true if the demarcation between 'past' and 'future' transactions
+ * should be visible */
+ gboolean show_present_divider;
- /* true if we are loading the register for the first time */
- gboolean first_pass;
+ /* true if we are loading the register for the first time */
+ gboolean first_pass;
- /* true if the user has already confirmed changes of a reconciled
- * split */
- gboolean change_confirmed;
+ /* true if the user has already confirmed changes of a reconciled
+ * split */
+ gboolean change_confirmed;
- /* true if the exchange rate has been reset on the current split */
- gboolean rate_reset;
+ /* true if the exchange rate has been reset on the current split */
+ gboolean rate_reset;
- /* account on the current split when the exchange rate was last set */
- Account *rate_account;
+ /* account on the current split when the exchange rate was last set */
+ Account *rate_account;
- /* User data for users of SplitRegisters */
- gpointer user_data;
+ /* User data for users of SplitRegisters */
+ gpointer user_data;
- /* hook to get parent widget */
- SRGetParentCallback get_parent;
+ /* hook to get parent widget */
+ SRGetParentCallback get_parent;
- /* flag indicating a template register */
- gboolean template;
+ /* flag indicating a template register */
+ gboolean template;
- /* The template account which template transaction should belong to */
- GUID template_account;
+ /* The template account which template transaction should belong to */
+ GUID template_account;
- /* configured strings for debit/credit headers */
- char *debit_str;
- char *credit_str;
- char *tdebit_str;
- char *tcredit_str;
+ /* configured strings for debit/credit headers */
+ char *debit_str;
+ char *credit_str;
+ char *tdebit_str;
+ char *tcredit_str;
- /* true if the account separator has changed */
- gboolean separator_changed;
+ /* true if the account separator has changed */
+ gboolean separator_changed;
};
@@ -130,7 +130,7 @@
Account * gnc_split_register_get_default_account (SplitRegister *reg);
Transaction * gnc_split_register_get_trans (SplitRegister *reg,
- VirtualCellLocation vcell_loc);
+ VirtualCellLocation vcell_loc);
Split *
gnc_split_register_get_trans_split (SplitRegister *reg,
@@ -155,9 +155,9 @@
// all, such as those created for entering new splits on old transactions or
// the 2nd through nth split on brand-new transactions.
void gnc_split_register_set_trans_visible (SplitRegister *reg,
- VirtualCellLocation vcell_loc,
- gboolean visible,
- gboolean only_blank_split);
+ VirtualCellLocation vcell_loc,
+ gboolean visible,
+ gboolean only_blank_split);
void gnc_split_register_set_cell_fractions (SplitRegister *reg, Split *split);
@@ -169,7 +169,7 @@
Account * gnc_split_register_get_account_by_name(
SplitRegister *reg, BasicCell * cell, const char *name, gboolean *new);
Account * gnc_split_register_get_account (SplitRegister *reg,
- const char *cell_name);
+ const char *cell_name);
gboolean gnc_split_register_recn_cell_confirm (char old_flag, gpointer data);
Modified: gnucash/trunk/src/register/ledger-core/split-register-util.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-util.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register-util.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -39,114 +39,114 @@
static void
gnc_split_register_init_info (SplitRegister *reg)
{
- SRInfo *info;
+ SRInfo *info;
- if (reg == NULL)
- return;
+ if (reg == NULL)
+ return;
- info = g_new0 (SRInfo, 1);
+ info = g_new0 (SRInfo, 1);
- info->blank_split_guid = *guid_null ();
- info->pending_trans_guid = *guid_null ();
- info->default_account = *guid_null ();
- info->template_account = *guid_null ();
+ info->blank_split_guid = *guid_null ();
+ info->pending_trans_guid = *guid_null ();
+ info->default_account = *guid_null ();
+ info->template_account = *guid_null ();
- info->last_date_entered = gnc_timet_get_today_start ();
+ info->last_date_entered = gnc_timet_get_today_start ();
- info->first_pass = TRUE;
- info->full_refresh = TRUE;
- info->separator_changed = TRUE;
+ info->first_pass = TRUE;
+ info->full_refresh = TRUE;
+ info->separator_changed = TRUE;
- reg->sr_info = info;
+ reg->sr_info = info;
}
SRInfo *
gnc_split_register_get_info (SplitRegister *reg)
{
- if (!reg)
- return NULL;
+ if (!reg)
+ return NULL;
- if (reg->sr_info == NULL)
- gnc_split_register_init_info (reg);
+ if (reg->sr_info == NULL)
+ gnc_split_register_init_info (reg);
- return reg->sr_info;
+ return reg->sr_info;
}
gncUIWidget
gnc_split_register_get_parent (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (reg == NULL)
- return NULL;
+ if (reg == NULL)
+ return NULL;
- if (info->get_parent == NULL)
- return NULL;
+ if (info->get_parent == NULL)
+ return NULL;
- return info->get_parent (info->user_data);
+ return info->get_parent (info->user_data);
}
Split *
gnc_split_register_get_split (SplitRegister *reg,
VirtualCellLocation vcell_loc)
{
- GUID *guid;
+ GUID *guid;
- if (reg == NULL)
- return NULL;
+ if (reg == NULL)
+ return NULL;
- guid = gnc_table_get_vcell_data (reg->table, vcell_loc);
- if (guid == NULL)
- return NULL;
+ guid = gnc_table_get_vcell_data (reg->table, vcell_loc);
+ if (guid == NULL)
+ return NULL;
- return xaccSplitLookup (guid, gnc_get_current_book ());
+ return xaccSplitLookup (guid, gnc_get_current_book ());
}
Account *
gnc_split_register_get_default_account (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- return xaccAccountLookup (&info->default_account,
- gnc_get_current_book ());
+ return xaccAccountLookup (&info->default_account,
+ gnc_get_current_book ());
}
void
gnc_split_register_set_template_account (SplitRegister *reg,
- Account *template_account)
+ Account *template_account)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- g_return_if_fail (reg != NULL);
+ g_return_if_fail (reg != NULL);
- info->template_account = *xaccAccountGetGUID (template_account);
+ info->template_account = *xaccAccountGetGUID (template_account);
}
Transaction *
gnc_split_register_get_trans (SplitRegister *reg,
VirtualCellLocation vcell_loc)
{
- Split *split;
+ Split *split;
- if (!reg || !reg->table)
- return NULL;
+ if (!reg || !reg->table)
+ return NULL;
- split = gnc_split_register_get_split (reg, vcell_loc);
+ split = gnc_split_register_get_split (reg, vcell_loc);
- if (split != NULL)
- return xaccSplitGetParent(split);
+ if (split != NULL)
+ return xaccSplitGetParent(split);
- /* Split is blank. Assume it is the blank split of a multi-line
- * transaction. Go back one row to find a split in the transaction. */
- vcell_loc.virt_row--;
+ /* Split is blank. Assume it is the blank split of a multi-line
+ * transaction. Go back one row to find a split in the transaction. */
+ vcell_loc.virt_row--;
- split = gnc_split_register_get_split (reg, vcell_loc);
+ split = gnc_split_register_get_split (reg, vcell_loc);
- /* This split could be NULL during register initialization. */
- if (split == NULL)
- return NULL;
+ /* This split could be NULL during register initialization. */
+ if (split == NULL)
+ return NULL;
- return xaccSplitGetParent(split);
+ return xaccSplitGetParent(split);
}
Split *
@@ -154,45 +154,45 @@
VirtualCellLocation vcell_loc,
VirtualCellLocation *trans_split_loc)
{
- CursorClass cursor_class;
+ CursorClass cursor_class;
- if (reg == NULL)
- return NULL;
+ if (reg == NULL)
+ return NULL;
- while (TRUE)
- {
- if ((0 > vcell_loc.virt_row) || (0 > vcell_loc.virt_col))
+ while (TRUE)
{
- PERR ("bad row \n");
- return NULL;
- }
+ if ((0 > vcell_loc.virt_row) || (0 > vcell_loc.virt_col))
+ {
+ PERR ("bad row \n");
+ return NULL;
+ }
- cursor_class = gnc_split_register_get_cursor_class (reg, vcell_loc);
+ cursor_class = gnc_split_register_get_cursor_class (reg, vcell_loc);
- if (cursor_class == CURSOR_CLASS_TRANS)
- {
- if (trans_split_loc)
- *trans_split_loc = vcell_loc;
+ if (cursor_class == CURSOR_CLASS_TRANS)
+ {
+ if (trans_split_loc)
+ *trans_split_loc = vcell_loc;
- return gnc_split_register_get_split (reg, vcell_loc);
+ return gnc_split_register_get_split (reg, vcell_loc);
+ }
+
+ vcell_loc.virt_row--;
}
-
- vcell_loc.virt_row--;
- }
}
Split *
gnc_split_register_get_current_trans_split(
SplitRegister *reg, VirtualCellLocation *trans_split_loc)
{
- VirtualCellLocation vcell_loc;
+ VirtualCellLocation vcell_loc;
- if (reg == NULL)
- return NULL;
+ if (reg == NULL)
+ return NULL;
- vcell_loc = reg->table->current_cursor_loc.vcell_loc;
+ vcell_loc = reg->table->current_cursor_loc.vcell_loc;
- return gnc_split_register_get_trans_split (reg, vcell_loc, trans_split_loc);
+ return gnc_split_register_get_trans_split (reg, vcell_loc, trans_split_loc);
}
gboolean
@@ -201,114 +201,114 @@
Split *split, CursorClass find_class,
VirtualCellLocation *vcell_loc)
{
- Table *table = reg->table;
- gboolean found_trans = FALSE;
- gboolean found_trans_split = FALSE;
- gboolean found_something = FALSE;
- CursorClass cursor_class;
- int v_row, v_col;
- Transaction *t;
- Split *s;
+ Table *table = reg->table;
+ gboolean found_trans = FALSE;
+ gboolean found_trans_split = FALSE;
+ gboolean found_something = FALSE;
+ CursorClass cursor_class;
+ int v_row, v_col;
+ Transaction *t;
+ Split *s;
- for (v_row = 1; v_row < table->num_virt_rows; v_row++)
- for (v_col = 0; v_col < table->num_virt_cols; v_col++)
- {
- VirtualCellLocation vc_loc = { v_row, v_col };
+ for (v_row = 1; v_row < table->num_virt_rows; v_row++)
+ for (v_col = 0; v_col < table->num_virt_cols; v_col++)
+ {
+ VirtualCellLocation vc_loc = { v_row, v_col };
- s = gnc_split_register_get_split (reg, vc_loc);
- t = xaccSplitGetParent(s);
+ s = gnc_split_register_get_split (reg, vc_loc);
+ t = xaccSplitGetParent(s);
- cursor_class = gnc_split_register_get_cursor_class (reg, vc_loc);
+ cursor_class = gnc_split_register_get_cursor_class (reg, vc_loc);
- if (t == trans)
- {
- /* A register entry for the correct transaction. */
- found_trans = TRUE;
+ if (t == trans)
+ {
+ /* A register entry for the correct transaction. */
+ found_trans = TRUE;
- if (cursor_class == CURSOR_CLASS_TRANS)
- {
- /* This row is the transaction split for this transaction. */
- if (s == trans_split)
- /* It's the copy of the transaction that we want. */
- found_trans_split = TRUE;
- else
- found_trans_split = FALSE;
+ if (cursor_class == CURSOR_CLASS_TRANS)
+ {
+ /* This row is the transaction split for this transaction. */
+ if (s == trans_split)
+ /* It's the copy of the transaction that we want. */
+ found_trans_split = TRUE;
+ else
+ found_trans_split = FALSE;
- if (find_class == CURSOR_CLASS_TRANS &&
- (s == split || reg->style == REG_STYLE_JOURNAL))
- {
- /* We're looking for a transaction split and this is the split we're looking for
- or there is only one entry for this transaction in this register (since it's
- a journal style register) so we must return the only transaction split there is. */
- if (vcell_loc != NULL)
- *vcell_loc = vc_loc;
- return TRUE;
- }
- }
- }
- else
- {
- /* Not the correct transaction. We shouldn't get here if these are true, but just
- to be safe reset them. */
- found_trans = FALSE;
- found_trans_split = FALSE;
- }
+ if (find_class == CURSOR_CLASS_TRANS &&
+ (s == split || reg->style == REG_STYLE_JOURNAL))
+ {
+ /* We're looking for a transaction split and this is the split we're looking for
+ or there is only one entry for this transaction in this register (since it's
+ a journal style register) so we must return the only transaction split there is. */
+ if (vcell_loc != NULL)
+ *vcell_loc = vc_loc;
+ return TRUE;
+ }
+ }
+ }
+ else
+ {
+ /* Not the correct transaction. We shouldn't get here if these are true, but just
+ to be safe reset them. */
+ found_trans = FALSE;
+ found_trans_split = FALSE;
+ }
- if (found_trans && (s == split) && s)
- {
- /* We're on the right transaction, but perhaps not the copy of it we want, and
- this is the correct split, return it if we don't find anything better. */
- if (vcell_loc != NULL)
- *vcell_loc = vc_loc;
+ if (found_trans && (s == split) && s)
+ {
+ /* We're on the right transaction, but perhaps not the copy of it we want, and
+ this is the correct split, return it if we don't find anything better. */
+ if (vcell_loc != NULL)
+ *vcell_loc = vc_loc;
- found_something = TRUE;
- }
+ found_something = TRUE;
+ }
- if (found_trans_split && (s == split))
- {
- /* We're on the right copy of the right transaction, and this is the split we
- want, return it (it should be the right class since if we wanted a transaction
- split we would have returned it above. */
- if (vcell_loc != NULL)
- *vcell_loc = vc_loc;
+ if (found_trans_split && (s == split))
+ {
+ /* We're on the right copy of the right transaction, and this is the split we
+ want, return it (it should be the right class since if we wanted a transaction
+ split we would have returned it above. */
+ if (vcell_loc != NULL)
+ *vcell_loc = vc_loc;
- if (cursor_class == find_class)
- return TRUE;
- }
- }
+ if (cursor_class == find_class)
+ return TRUE;
+ }
+ }
- return found_something;
+ return found_something;
}
void
gnc_split_register_show_trans (SplitRegister *reg,
VirtualCellLocation start_loc)
{
- VirtualCellLocation end_loc;
- int v_row;
+ VirtualCellLocation end_loc;
+ int v_row;
- end_loc = start_loc;
+ end_loc = start_loc;
- for (v_row = end_loc.virt_row + 1;
- v_row < reg->table->num_virt_rows; v_row++)
- {
- VirtualCellLocation vc_loc = { v_row, 0 };
- CursorClass cursor_class;
+ for (v_row = end_loc.virt_row + 1;
+ v_row < reg->table->num_virt_rows; v_row++)
+ {
+ VirtualCellLocation vc_loc = { v_row, 0 };
+ CursorClass cursor_class;
- cursor_class = gnc_split_register_get_cursor_class (reg, vc_loc);
- if (cursor_class == CURSOR_CLASS_TRANS)
- break;
+ cursor_class = gnc_split_register_get_cursor_class (reg, vc_loc);
+ if (cursor_class == CURSOR_CLASS_TRANS)
+ break;
- if (cursor_class != CURSOR_CLASS_SPLIT)
- {
- v_row--;
- break;
+ if (cursor_class != CURSOR_CLASS_SPLIT)
+ {
+ v_row--;
+ break;
+ }
}
- }
- end_loc.virt_row = MIN (v_row, reg->table->num_virt_rows - 1);
+ end_loc.virt_row = MIN (v_row, reg->table->num_virt_rows - 1);
- gnc_table_show_range (reg->table, start_loc, end_loc);
+ gnc_table_show_range (reg->table, start_loc, end_loc);
}
void
@@ -317,194 +317,194 @@
gboolean visible,
gboolean only_blank_split)
{
- CursorClass cursor_class;
+ CursorClass cursor_class;
- while (TRUE)
- {
- vcell_loc.virt_row++;
+ while (TRUE)
+ {
+ vcell_loc.virt_row++;
- cursor_class = gnc_split_register_get_cursor_class (reg, vcell_loc);
- if (cursor_class != CURSOR_CLASS_SPLIT)
- return;
+ cursor_class = gnc_split_register_get_cursor_class (reg, vcell_loc);
+ if (cursor_class != CURSOR_CLASS_SPLIT)
+ return;
- if (only_blank_split && gnc_split_register_get_split (reg, vcell_loc))
- continue;
+ if (only_blank_split && gnc_split_register_get_split (reg, vcell_loc))
+ continue;
- gnc_table_set_virt_cell_visible (reg->table, vcell_loc, visible);
- }
+ gnc_table_set_virt_cell_visible (reg->table, vcell_loc, visible);
+ }
}
void
gnc_split_register_set_cell_fractions (SplitRegister *reg, Split *split)
{
- Account *account;
- Transaction *trans;
- gnc_commodity *currency;
- PriceCell *cell;
- int fraction;
+ Account *account;
+ Transaction *trans;
+ gnc_commodity *currency;
+ PriceCell *cell;
+ int fraction;
- trans = xaccSplitGetParent (split);
- currency = xaccTransGetCurrency (trans);
- if (!currency)
- currency = gnc_default_currency ();
+ trans = xaccSplitGetParent (split);
+ currency = xaccTransGetCurrency (trans);
+ if (!currency)
+ currency = gnc_default_currency ();
- fraction = gnc_commodity_get_fraction (currency);
+ fraction = gnc_commodity_get_fraction (currency);
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- DEBT_CELL);
- gnc_price_cell_set_fraction (cell, fraction);
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ DEBT_CELL);
+ gnc_price_cell_set_fraction (cell, fraction);
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- CRED_CELL);
- gnc_price_cell_set_fraction (cell, fraction);
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ CRED_CELL);
+ gnc_price_cell_set_fraction (cell, fraction);
- account = xaccSplitGetAccount (split);
+ account = xaccSplitGetAccount (split);
- if (account == NULL)
- account = gnc_split_register_get_default_account (reg);
+ if (account == NULL)
+ account = gnc_split_register_get_default_account (reg);
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- SHRS_CELL);
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ SHRS_CELL);
- if (account)
- gnc_price_cell_set_fraction (cell, xaccAccountGetCommoditySCU (account));
- else
- gnc_price_cell_set_fraction (cell, 100000);
+ if (account)
+ gnc_price_cell_set_fraction (cell, xaccAccountGetCommoditySCU (account));
+ else
+ gnc_price_cell_set_fraction (cell, 100000);
}
CellBlock *
gnc_split_register_get_passive_cursor (SplitRegister *reg)
{
- const char *cursor_name = NULL;
+ const char *cursor_name = NULL;
- switch (reg->style)
- {
+ switch (reg->style)
+ {
case REG_STYLE_LEDGER:
case REG_STYLE_AUTO_LEDGER:
- cursor_name = reg->use_double_line ?
- CURSOR_DOUBLE_LEDGER : CURSOR_SINGLE_LEDGER;
- break;
+ cursor_name = reg->use_double_line ?
+ CURSOR_DOUBLE_LEDGER : CURSOR_SINGLE_LEDGER;
+ break;
case REG_STYLE_JOURNAL:
- cursor_name = reg->use_double_line ?
- CURSOR_DOUBLE_JOURNAL : CURSOR_SINGLE_JOURNAL;
- break;
- }
+ cursor_name = reg->use_double_line ?
+ CURSOR_DOUBLE_JOURNAL : CURSOR_SINGLE_JOURNAL;
+ break;
+ }
- if (!cursor_name)
- {
- PWARN ("bad register style");
- return NULL;
- }
+ if (!cursor_name)
+ {
+ PWARN ("bad register style");
+ return NULL;
+ }
- return gnc_table_layout_get_cursor (reg->table->layout, cursor_name);
+ return gnc_table_layout_get_cursor (reg->table->layout, cursor_name);
}
CellBlock *
gnc_split_register_get_active_cursor (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- const char *cursor_name = NULL;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ const char *cursor_name = NULL;
- switch (reg->style)
- {
+ switch (reg->style)
+ {
case REG_STYLE_LEDGER:
- if (!info->trans_expanded)
- {
- cursor_name = reg->use_double_line ?
- CURSOR_DOUBLE_LEDGER : CURSOR_SINGLE_LEDGER;
- break;
- }
+ if (!info->trans_expanded)
+ {
+ cursor_name = reg->use_double_line ?
+ CURSOR_DOUBLE_LEDGER : CURSOR_SINGLE_LEDGER;
+ break;
+ }
- /* fall through */
+ /* fall through */
case REG_STYLE_AUTO_LEDGER:
case REG_STYLE_JOURNAL:
- cursor_name = reg->use_double_line ?
- CURSOR_DOUBLE_JOURNAL : CURSOR_SINGLE_JOURNAL;
- break;
- }
+ cursor_name = reg->use_double_line ?
+ CURSOR_DOUBLE_JOURNAL : CURSOR_SINGLE_JOURNAL;
+ break;
+ }
- if (!cursor_name)
- {
- PWARN ("bad register style");
- return NULL;
- }
+ if (!cursor_name)
+ {
+ PWARN ("bad register style");
+ return NULL;
+ }
- return gnc_table_layout_get_cursor (reg->table->layout, cursor_name);
+ return gnc_table_layout_get_cursor (reg->table->layout, cursor_name);
}
void
gnc_split_register_set_last_num (SplitRegister *reg, const char *num)
{
- Account *account;
+ Account *account;
- account = gnc_split_register_get_default_account (reg);
- if (!account)
- return;
+ account = gnc_split_register_get_default_account (reg);
+ if (!account)
+ return;
- xaccAccountSetLastNum (account, num);
+ xaccAccountSetLastNum (account, num);
}
static CursorClass
gnc_split_register_cursor_class (SplitRegister *reg,
CellBlock *cursor)
{
- if (cursor == NULL)
- return CURSOR_CLASS_NONE;
+ if (cursor == NULL)
+ return CURSOR_CLASS_NONE;
- return gnc_split_register_cursor_name_to_class (cursor->cursor_name);
+ return gnc_split_register_cursor_name_to_class (cursor->cursor_name);
}
CursorClass
gnc_split_register_get_cursor_class (SplitRegister *reg,
VirtualCellLocation vcell_loc)
{
- VirtualCell *vcell;
- Table *table;
+ VirtualCell *vcell;
+ Table *table;
- if (reg == NULL)
- return CURSOR_CLASS_NONE;
+ if (reg == NULL)
+ return CURSOR_CLASS_NONE;
- table = reg->table;
- if (table == NULL)
- return CURSOR_CLASS_NONE;
+ table = reg->table;
+ if (table == NULL)
+ return CURSOR_CLASS_NONE;
- vcell = gnc_table_get_virtual_cell (table, vcell_loc);
- if (vcell == NULL)
- return CURSOR_CLASS_NONE;
+ vcell = gnc_table_get_virtual_cell (table, vcell_loc);
+ if (vcell == NULL)
+ return CURSOR_CLASS_NONE;
- return gnc_split_register_cursor_class (reg, vcell->cellblock);
+ return gnc_split_register_cursor_class (reg, vcell->cellblock);
}
CursorClass
gnc_split_register_get_current_cursor_class (SplitRegister *reg)
{
- Table *table;
+ Table *table;
- if (reg == NULL)
- return CURSOR_CLASS_NONE;
+ if (reg == NULL)
+ return CURSOR_CLASS_NONE;
- table = reg->table;
- if (table == NULL)
- return CURSOR_CLASS_NONE;
+ table = reg->table;
+ if (table == NULL)
+ return CURSOR_CLASS_NONE;
- return gnc_split_register_cursor_class (reg, table->current_cursor);
+ return gnc_split_register_cursor_class (reg, table->current_cursor);
}
CursorClass
gnc_split_register_cursor_name_to_class (const char *cursor_name)
{
- if (cursor_name == NULL)
- return CURSOR_CLASS_NONE;
+ if (cursor_name == NULL)
+ return CURSOR_CLASS_NONE;
- if (strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0 ||
- strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0 ||
- strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
- strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0)
- return CURSOR_CLASS_TRANS;
+ if (strcmp (cursor_name, CURSOR_SINGLE_LEDGER) == 0 ||
+ strcmp (cursor_name, CURSOR_DOUBLE_LEDGER) == 0 ||
+ strcmp (cursor_name, CURSOR_SINGLE_JOURNAL) == 0 ||
+ strcmp (cursor_name, CURSOR_DOUBLE_JOURNAL) == 0)
+ return CURSOR_CLASS_TRANS;
- if (strcmp (cursor_name, CURSOR_SPLIT) == 0)
- return CURSOR_CLASS_SPLIT;
+ if (strcmp (cursor_name, CURSOR_SPLIT) == 0)
+ return CURSOR_CLASS_SPLIT;
- return CURSOR_CLASS_NONE;
+ return CURSOR_CLASS_NONE;
}
Modified: gnucash/trunk/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -64,10 +64,10 @@
/** static prototypes *****************************************************/
static gboolean gnc_split_register_save_to_scm (SplitRegister *reg,
- SCM trans_scm, SCM split_scm,
- gboolean use_cut_semantics);
+ SCM trans_scm, SCM split_scm,
+ gboolean use_cut_semantics);
static gboolean gnc_split_register_auto_calc (SplitRegister *reg,
- Split *split);
+ Split *split);
/** implementations *******************************************************/
@@ -76,16 +76,16 @@
static void
gnc_copy_split_onto_split(Split *from, Split *to, gboolean use_cut_semantics)
{
- SCM split_scm;
+ SCM split_scm;
- if ((from == NULL) || (to == NULL))
- return;
+ if ((from == NULL) || (to == NULL))
+ return;
- split_scm = gnc_copy_split(from, use_cut_semantics);
- if (split_scm == SCM_UNDEFINED)
- return;
+ split_scm = gnc_copy_split(from, use_cut_semantics);
+ if (split_scm == SCM_UNDEFINED)
+ return;
- gnc_copy_split_scm_onto_split(split_scm, to, gnc_get_current_book ());
+ gnc_copy_split_scm_onto_split(split_scm, to, gnc_get_current_book ());
}
/* Uses the scheme transaction copying routines */
@@ -94,1135 +94,1157 @@
gboolean use_cut_semantics,
gboolean do_commit)
{
- SCM trans_scm;
+ SCM trans_scm;
- if ((from == NULL) || (to == NULL))
- return;
+ if ((from == NULL) || (to == NULL))
+ return;
- trans_scm = gnc_copy_trans(from, use_cut_semantics);
- if (trans_scm == SCM_UNDEFINED)
- return;
+ trans_scm = gnc_copy_trans(from, use_cut_semantics);
+ if (trans_scm == SCM_UNDEFINED)
+ return;
- gnc_copy_trans_scm_onto_trans(trans_scm, to, do_commit,
- gnc_get_current_book ());
+ gnc_copy_trans_scm_onto_trans(trans_scm, to, do_commit,
+ gnc_get_current_book ());
}
static int
gnc_split_get_value_denom (Split *split)
{
- gnc_commodity *currency;
- int denom;
+ gnc_commodity *currency;
+ int denom;
- currency = xaccTransGetCurrency (xaccSplitGetParent (split));
- denom = gnc_commodity_get_fraction (currency);
- if (denom == 0)
- {
- gnc_commodity *commodity = gnc_default_currency ();
- denom = gnc_commodity_get_fraction (commodity);
+ currency = xaccTransGetCurrency (xaccSplitGetParent (split));
+ denom = gnc_commodity_get_fraction (currency);
if (denom == 0)
- denom = 100;
- }
+ {
+ gnc_commodity *commodity = gnc_default_currency ();
+ denom = gnc_commodity_get_fraction (commodity);
+ if (denom == 0)
+ denom = 100;
+ }
- return denom;
+ return denom;
}
static int
gnc_split_get_amount_denom (Split *split)
{
- int denom;
+ int denom;
- denom = xaccAccountGetCommoditySCU (xaccSplitGetAccount (split));
- if (denom == 0)
- {
- gnc_commodity *commodity = gnc_default_currency ();
- denom = gnc_commodity_get_fraction (commodity);
+ denom = xaccAccountGetCommoditySCU (xaccSplitGetAccount (split));
if (denom == 0)
- denom = 100;
- }
+ {
+ gnc_commodity *commodity = gnc_default_currency ();
+ denom = gnc_commodity_get_fraction (commodity);
+ if (denom == 0)
+ denom = 100;
+ }
- return denom;
+ return denom;
}
/* returns TRUE if begin_edit was aborted */
gboolean
gnc_split_register_begin_edit_or_warn(SRInfo *info, Transaction *trans)
{
- ENTER("info=%p, trans=%p", info, trans);
+ ENTER("info=%p, trans=%p", info, trans);
- if (!xaccTransIsOpen(trans)) {
- xaccTransBeginEdit(trans);
- /* This is now the pending transaction */
- info->pending_trans_guid = *xaccTransGetGUID(trans);
- LEAVE("opened and marked pending");
- return FALSE;
- } else {
+ if (!xaccTransIsOpen(trans))
+ {
+ xaccTransBeginEdit(trans);
+ /* This is now the pending transaction */
+ info->pending_trans_guid = *xaccTransGetGUID(trans);
+ LEAVE("opened and marked pending");
+ return FALSE;
+ }
+ else
+ {
Split *blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
+ gnc_get_current_book ());
Transaction *blank_trans = xaccSplitGetParent (blank_split);
- if (trans == blank_trans) {
- /* This is a brand-new transaction. It is already
- * open, so just mark it as pending. */
- info->pending_trans_guid = *xaccTransGetGUID(trans);
- LEAVE("already open, now pending.");
- return FALSE;
- } else {
- GtkWidget *parent = NULL;
- if (info->get_parent)
- parent = info->get_parent(info->user_data);
- gnc_error_dialog(parent, "%s", _("This transaction is already being edited in another register. Please finish editing it there first."));
- LEAVE("already editing");
- return TRUE;
+ if (trans == blank_trans)
+ {
+ /* This is a brand-new transaction. It is already
+ * open, so just mark it as pending. */
+ info->pending_trans_guid = *xaccTransGetGUID(trans);
+ LEAVE("already open, now pending.");
+ return FALSE;
}
- }
- LEAVE(" ");
+ else
+ {
+ GtkWidget *parent = NULL;
+ if (info->get_parent)
+ parent = info->get_parent(info->user_data);
+ gnc_error_dialog(parent, "%s", _("This transaction is already being edited in another register. Please finish editing it there first."));
+ LEAVE("already editing");
+ return TRUE;
+ }
+ }
+ LEAVE(" ");
}
void
gnc_split_register_expand_current_trans (SplitRegister *reg, gboolean expand)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- VirtualLocation virt_loc;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ VirtualLocation virt_loc;
- if (!reg)
- return;
+ if (!reg)
+ return;
- if (reg->style == REG_STYLE_AUTO_LEDGER ||
- reg->style == REG_STYLE_JOURNAL)
- return;
+ if (reg->style == REG_STYLE_AUTO_LEDGER ||
+ reg->style == REG_STYLE_JOURNAL)
+ return;
- /* ok, so I just wanted an excuse to use exclusive-or */
- if (!(expand ^ info->trans_expanded))
- return;
+ /* ok, so I just wanted an excuse to use exclusive-or */
+ if (!(expand ^ info->trans_expanded))
+ return;
- if (!expand)
- {
- virt_loc = reg->table->current_cursor_loc;
- gnc_split_register_get_trans_split (reg, virt_loc.vcell_loc,
- &virt_loc.vcell_loc);
+ if (!expand)
+ {
+ virt_loc = reg->table->current_cursor_loc;
+ gnc_split_register_get_trans_split (reg, virt_loc.vcell_loc,
+ &virt_loc.vcell_loc);
- if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE))
- gnc_table_move_cursor_gui (reg->table, virt_loc);
- else
- {
- PERR ("Can't find place to go!");
- return;
+ if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE))
+ gnc_table_move_cursor_gui (reg->table, virt_loc);
+ else
+ {
+ PERR ("Can't find place to go!");
+ return;
+ }
}
- }
- info->trans_expanded = expand;
+ info->trans_expanded = expand;
- gnc_table_set_virt_cell_cursor (reg->table,
- reg->table->current_cursor_loc.vcell_loc,
- gnc_split_register_get_active_cursor (reg));
+ gnc_table_set_virt_cell_cursor (reg->table,
+ reg->table->current_cursor_loc.vcell_loc,
+ gnc_split_register_get_active_cursor (reg));
- gnc_split_register_set_trans_visible(
- reg, reg->table->current_cursor_loc.vcell_loc, expand, FALSE);
+ gnc_split_register_set_trans_visible(
+ reg, reg->table->current_cursor_loc.vcell_loc, expand, FALSE);
- virt_loc = reg->table->current_cursor_loc;
- if (!expand || !gnc_table_virtual_loc_valid (reg->table, virt_loc, FALSE))
- {
- if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE))
- gnc_table_move_cursor_gui (reg->table, virt_loc);
- else
- {
- PERR ("Can't find place to go!");
- return;
- }
- }
+ virt_loc = reg->table->current_cursor_loc;
+ if (!expand || !gnc_table_virtual_loc_valid (reg->table, virt_loc, FALSE))
+ {
+ if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE))
+ gnc_table_move_cursor_gui (reg->table, virt_loc);
+ else
+ {
+ PERR ("Can't find place to go!");
+ return;
+ }
+ }
- gnc_table_refresh_gui (reg->table, TRUE);
+ gnc_table_refresh_gui (reg->table, TRUE);
- if (expand)
- gnc_split_register_show_trans (reg,
- reg->table->current_cursor_loc.vcell_loc);
+ if (expand)
+ gnc_split_register_show_trans (reg,
+ reg->table->current_cursor_loc.vcell_loc);
}
gboolean
gnc_split_register_current_trans_expanded (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (!reg)
- return FALSE;
+ if (!reg)
+ return FALSE;
- if (reg->style == REG_STYLE_AUTO_LEDGER ||
- reg->style == REG_STYLE_JOURNAL)
- return TRUE;
+ if (reg->style == REG_STYLE_AUTO_LEDGER ||
+ reg->style == REG_STYLE_JOURNAL)
+ return TRUE;
- return info->trans_expanded;
+ return info->trans_expanded;
}
Transaction *
gnc_split_register_get_current_trans (SplitRegister *reg)
{
- Split *split;
- VirtualCellLocation vcell_loc;
+ Split *split;
+ VirtualCellLocation vcell_loc;
- if (reg == NULL)
- return NULL;
+ if (reg == NULL)
+ return NULL;
- split = gnc_split_register_get_current_split (reg);
- if (split != NULL)
- return xaccSplitGetParent(split);
+ split = gnc_split_register_get_current_split (reg);
+ if (split != NULL)
+ return xaccSplitGetParent(split);
- /* Split is blank. Assume it is the blank split of a multi-line
- * transaction. Go back one row to find a split in the transaction. */
- vcell_loc = reg->table->current_cursor_loc.vcell_loc;
+ /* Split is blank. Assume it is the blank split of a multi-line
+ * transaction. Go back one row to find a split in the transaction. */
+ vcell_loc = reg->table->current_cursor_loc.vcell_loc;
- vcell_loc.virt_row--;
+ vcell_loc.virt_row--;
- split = gnc_split_register_get_split (reg, vcell_loc);
+ split = gnc_split_register_get_split (reg, vcell_loc);
- return xaccSplitGetParent (split);
+ return xaccSplitGetParent (split);
}
Split *
gnc_split_register_get_current_split (SplitRegister *reg)
{
- if (reg == NULL)
- return NULL;
+ if (reg == NULL)
+ return NULL;
- return gnc_split_register_get_split(
- reg, reg->table->current_cursor_loc.vcell_loc);
+ return gnc_split_register_get_split(
+ reg, reg->table->current_cursor_loc.vcell_loc);
}
Split *
gnc_split_register_get_blank_split (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (!reg) return NULL;
+ if (!reg) return NULL;
- return xaccSplitLookup (&info->blank_split_guid, gnc_get_current_book ());
+ return xaccSplitLookup (&info->blank_split_guid, gnc_get_current_book ());
}
gboolean
gnc_split_register_get_split_virt_loc (SplitRegister *reg, Split *split,
VirtualCellLocation *vcell_loc)
{
- Table *table;
- int v_row;
- int v_col;
+ Table *table;
+ int v_row;
+ int v_col;
- if (!reg || !split) return FALSE;
+ if (!reg || !split) return FALSE;
- table = reg->table;
+ table = reg->table;
- /* go backwards because typically you search for splits at the end
- * and because we find split rows before transaction rows. */
+ /* go backwards because typically you search for splits at the end
+ * and because we find split rows before transaction rows. */
- for (v_row = table->num_virt_rows - 1; v_row > 0; v_row--)
- for (v_col = 0; v_col < table->num_virt_cols; v_col++)
- {
- VirtualCellLocation vc_loc = { v_row, v_col };
- VirtualCell *vcell;
- Split *s;
+ for (v_row = table->num_virt_rows - 1; v_row > 0; v_row--)
+ for (v_col = 0; v_col < table->num_virt_cols; v_col++)
+ {
+ VirtualCellLocation vc_loc = { v_row, v_col };
+ VirtualCell *vcell;
+ Split *s;
- vcell = gnc_table_get_virtual_cell (table, vc_loc);
- if (!vcell || !vcell->visible)
- continue;
+ vcell = gnc_table_get_virtual_cell (table, vc_loc);
+ if (!vcell || !vcell->visible)
+ continue;
- s = xaccSplitLookup (vcell->vcell_data, gnc_get_current_book ());
+ s = xaccSplitLookup (vcell->vcell_data, gnc_get_current_book ());
- if (s == split)
- {
- if (vcell_loc)
- *vcell_loc = vc_loc;
+ if (s == split)
+ {
+ if (vcell_loc)
+ *vcell_loc = vc_loc;
- return TRUE;
- }
- }
+ return TRUE;
+ }
+ }
- return FALSE;
+ return FALSE;
}
gboolean
gnc_split_register_get_split_amount_virt_loc (SplitRegister *reg, Split *split,
- VirtualLocation *virt_loc)
+ VirtualLocation *virt_loc)
{
- VirtualLocation v_loc;
- CursorClass cursor_class;
- const char *cell_name;
- gnc_numeric value;
+ VirtualLocation v_loc;
+ CursorClass cursor_class;
+ const char *cell_name;
+ gnc_numeric value;
- if (!gnc_split_register_get_split_virt_loc (reg, split, &v_loc.vcell_loc))
- return FALSE;
+ if (!gnc_split_register_get_split_virt_loc (reg, split, &v_loc.vcell_loc))
+ return FALSE;
- cursor_class = gnc_split_register_get_cursor_class (reg, v_loc.vcell_loc);
+ cursor_class = gnc_split_register_get_cursor_class (reg, v_loc.vcell_loc);
- value = xaccSplitGetValue (split);
+ value = xaccSplitGetValue (split);
- switch (cursor_class)
- {
+ switch (cursor_class)
+ {
case CURSOR_CLASS_SPLIT:
case CURSOR_CLASS_TRANS:
- cell_name = (gnc_numeric_negative_p (value)) ? CRED_CELL : DEBT_CELL;
- break;
+ cell_name = (gnc_numeric_negative_p (value)) ? CRED_CELL : DEBT_CELL;
+ break;
default:
- return FALSE;
- }
+ return FALSE;
+ }
- if (!gnc_table_get_cell_location (reg->table, cell_name,
- v_loc.vcell_loc, &v_loc))
- return FALSE;
+ if (!gnc_table_get_cell_location (reg->table, cell_name,
+ v_loc.vcell_loc, &v_loc))
+ return FALSE;
- if (virt_loc == NULL)
- return TRUE;
+ if (virt_loc == NULL)
+ return TRUE;
- *virt_loc = v_loc;
+ *virt_loc = v_loc;
- return TRUE;
+ return TRUE;
}
Split *
gnc_split_register_duplicate_current (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info(reg);
- CursorClass cursor_class;
- Transaction *trans;
- Split *return_split;
- Split *trans_split;
- Split *blank_split;
- gboolean changed;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info(reg);
+ CursorClass cursor_class;
+ Transaction *trans;
+ Split *return_split;
+ Split *trans_split;
+ Split *blank_split;
+ gboolean changed;
+ Split *split;
- ENTER("reg=%p", reg);
+ ENTER("reg=%p", reg);
- blank_split = xaccSplitLookup(&info->blank_split_guid,
- gnc_get_current_book ());
- split = gnc_split_register_get_current_split (reg);
- trans = gnc_split_register_get_current_trans (reg);
- trans_split = gnc_split_register_get_current_trans_split (reg, NULL);
+ blank_split = xaccSplitLookup(&info->blank_split_guid,
+ gnc_get_current_book ());
+ split = gnc_split_register_get_current_split (reg);
+ trans = gnc_split_register_get_current_trans (reg);
+ trans_split = gnc_split_register_get_current_trans_split (reg, NULL);
- /* This shouldn't happen, but be paranoid. */
- if (trans == NULL)
- {
- LEAVE("no transaction");
- return NULL;
- }
+ /* This shouldn't happen, but be paranoid. */
+ if (trans == NULL)
+ {
+ LEAVE("no transaction");
+ return NULL;
+ }
- cursor_class = gnc_split_register_get_current_cursor_class (reg);
+ cursor_class = gnc_split_register_get_current_cursor_class (reg);
- /* Can't do anything with this. */
- if (cursor_class == CURSOR_CLASS_NONE)
- {
- LEAVE("no cursor class");
- return NULL;
- }
+ /* Can't do anything with this. */
+ if (cursor_class == CURSOR_CLASS_NONE)
+ {
+ LEAVE("no cursor class");
+ return NULL;
+ }
- /* This shouldn't happen, but be paranoid. */
- if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
- {
- LEAVE("no split with transaction class");
- return NULL;
- }
+ /* This shouldn't happen, but be paranoid. */
+ if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
+ {
+ LEAVE("no split with transaction class");
+ return NULL;
+ }
- changed = gnc_table_current_cursor_changed (reg->table, FALSE);
+ changed = gnc_table_current_cursor_changed (reg->table, FALSE);
- /* See if we were asked to duplicate an unchanged blank split.
- * There's no point in doing that! */
- if (!changed && ((split == NULL) || (split == blank_split)))
- {
- LEAVE("skip unchanged blank split");
- return NULL;
- }
+ /* See if we were asked to duplicate an unchanged blank split.
+ * There's no point in doing that! */
+ if (!changed && ((split == NULL) || (split == blank_split)))
+ {
+ LEAVE("skip unchanged blank split");
+ return NULL;
+ }
- gnc_suspend_gui_refresh ();
+ 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)
- {
- GtkWidget *dialog, *window;
- gint response;
- const char *title = _("Save transaction before duplicating?");
- const char *message =
- _("The current transaction has been changed. Would you like to "
- "record the changes before duplicating the transaction, or "
- "cancel the duplication?");
-
- window = gnc_split_register_get_parent(reg);
- dialog = gtk_message_dialog_new(GTK_WINDOW(window),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_CANCEL,
- "%s", title);
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- "%s", message);
- gtk_dialog_add_button(GTK_DIALOG(dialog),
- _("_Record"), GTK_RESPONSE_ACCEPT);
- response = gnc_dialog_run(GTK_DIALOG(dialog), "transaction_duplicated");
- gtk_widget_destroy(dialog);
-
- if (response != GTK_RESPONSE_ACCEPT)
+ /* 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)
{
- gnc_resume_gui_refresh ();
- LEAVE("save cancelled");
- return NULL;
- }
+ GtkWidget *dialog, *window;
+ gint response;
+ const char *title = _("Save transaction before duplicating?");
+ const char *message =
+ _("The current transaction has been changed. Would you like to "
+ "record the changes before duplicating the transaction, or "
+ "cancel the duplication?");
- gnc_split_register_save (reg, TRUE);
+ window = gnc_split_register_get_parent(reg);
+ dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_CANCEL,
+ "%s", title);
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+ "%s", message);
+ gtk_dialog_add_button(GTK_DIALOG(dialog),
+ _("_Record"), GTK_RESPONSE_ACCEPT);
+ response = gnc_dialog_run(GTK_DIALOG(dialog), "transaction_duplicated");
+ gtk_widget_destroy(dialog);
- /* If the split is NULL, then we were on a blank split row
- * in an expanded transaction. The new split (created by
- * gnc_split_register_save above) will be the last split in the
- * current transaction, as it was just added. */
- if (split == NULL)
- split = xaccTransGetSplit (trans, xaccTransCountSplits (trans) - 1);
- }
+ if (response != GTK_RESPONSE_ACCEPT)
+ {
+ gnc_resume_gui_refresh ();
+ LEAVE("save cancelled");
+ return NULL;
+ }
- /* Ok, we are now ready to make the copy. */
+ gnc_split_register_save (reg, TRUE);
- if (cursor_class == CURSOR_CLASS_SPLIT)
- {
- Split *new_split;
+ /* If the split is NULL, then we were on a blank split row
+ * in an expanded transaction. The new split (created by
+ * gnc_split_register_save above) will be the last split in the
+ * current transaction, as it was just added. */
+ if (split == NULL)
+ split = xaccTransGetSplit (trans, xaccTransCountSplits (trans) - 1);
+ }
- /* We are on a split in an expanded transaction.
- * Just copy the split and add it to the transaction. */
+ /* Ok, we are now ready to make the copy. */
- new_split = xaccMallocSplit (gnc_get_current_book ());
+ if (cursor_class == CURSOR_CLASS_SPLIT)
+ {
+ Split *new_split;
- xaccTransBeginEdit (trans);
- xaccSplitSetParent (new_split, trans);
- gnc_copy_split_onto_split (split, new_split, FALSE);
- xaccTransCommitEdit (trans);
+ /* We are on a split in an expanded transaction.
+ * Just copy the split and add it to the transaction. */
- return_split = new_split;
+ new_split = xaccMallocSplit (gnc_get_current_book ());
- info->cursor_hint_split = new_split;
- info->cursor_hint_cursor_class = CURSOR_CLASS_SPLIT;
- }
- else
- {
- NumCell *num_cell;
- Transaction *new_trans;
- int trans_split_index;
- int split_index;
- const char *in_num = NULL;
- char *out_num;
- time_t date;
+ xaccTransBeginEdit (trans);
+ xaccSplitSetParent (new_split, trans);
+ gnc_copy_split_onto_split (split, new_split, FALSE);
+ xaccTransCommitEdit (trans);
- /* We are on a transaction row. Copy the whole transaction. */
+ return_split = new_split;
- date = info->last_date_entered;
- if (gnc_strisnum (xaccTransGetNum (trans)))
+ info->cursor_hint_split = new_split;
+ info->cursor_hint_cursor_class = CURSOR_CLASS_SPLIT;
+ }
+ else
{
- Account *account = gnc_split_register_get_default_account (reg);
+ NumCell *num_cell;
+ Transaction *new_trans;
+ int trans_split_index;
+ int split_index;
+ const char *in_num = NULL;
+ char *out_num;
+ time_t date;
- if (account)
- in_num = xaccAccountGetLastNum (account);
- else
- in_num = xaccTransGetNum (trans);
- }
+ /* We are on a transaction row. Copy the whole transaction. */
- if (!gnc_dup_trans_dialog (gnc_split_register_get_parent (reg),
- &date, in_num, &out_num))
- {
- gnc_resume_gui_refresh ();
- LEAVE("dup cancelled");
- return NULL;
- }
+ date = info->last_date_entered;
+ if (gnc_strisnum (xaccTransGetNum (trans)))
+ {
+ Account *account = gnc_split_register_get_default_account (reg);
- split_index = xaccTransGetSplitIndex(trans, split);
- trans_split_index = xaccTransGetSplitIndex(trans, trans_split);
+ if (account)
+ in_num = xaccAccountGetLastNum (account);
+ else
+ in_num = xaccTransGetNum (trans);
+ }
- /* we should *always* find the split, but be paranoid */
- if (split_index < 0)
- {
- gnc_resume_gui_refresh ();
- LEAVE("no split");
- return NULL;
- }
+ if (!gnc_dup_trans_dialog (gnc_split_register_get_parent (reg),
+ &date, in_num, &out_num))
+ {
+ gnc_resume_gui_refresh ();
+ LEAVE("dup cancelled");
+ return NULL;
+ }
- new_trans = xaccMallocTransaction (gnc_get_current_book ());
+ split_index = xaccTransGetSplitIndex(trans, split);
+ trans_split_index = xaccTransGetSplitIndex(trans, trans_split);
- xaccTransBeginEdit (new_trans);
- gnc_copy_trans_onto_trans (trans, new_trans, FALSE, FALSE);
- xaccTransSetDateSecs (new_trans, date);
- xaccTransSetNum (new_trans, out_num);
- xaccTransCommitEdit (new_trans);
+ /* we should *always* find the split, but be paranoid */
+ if (split_index < 0)
+ {
+ gnc_resume_gui_refresh ();
+ LEAVE("no split");
+ return NULL;
+ }
- num_cell = (NumCell *) gnc_table_layout_get_cell (reg->table->layout,
- NUM_CELL);
- if (gnc_num_cell_set_last_num (num_cell, out_num))
- gnc_split_register_set_last_num (reg, out_num);
+ new_trans = xaccMallocTransaction (gnc_get_current_book ());
- g_free (out_num);
+ xaccTransBeginEdit (new_trans);
+ gnc_copy_trans_onto_trans (trans, new_trans, FALSE, FALSE);
+ xaccTransSetDateSecs (new_trans, date);
+ xaccTransSetNum (new_trans, out_num);
+ xaccTransCommitEdit (new_trans);
- /* This shouldn't happen, but be paranoid. */
- if (split_index >= xaccTransCountSplits (new_trans))
- split_index = 0;
+ num_cell = (NumCell *) gnc_table_layout_get_cell (reg->table->layout,
+ NUM_CELL);
+ if (gnc_num_cell_set_last_num (num_cell, out_num))
+ gnc_split_register_set_last_num (reg, out_num);
- return_split = xaccTransGetSplit (new_trans, split_index);
- trans_split = xaccTransGetSplit (new_trans, trans_split_index);
+ g_free (out_num);
- info->cursor_hint_trans = new_trans;
- info->cursor_hint_split = return_split;
- info->cursor_hint_trans_split = trans_split;
- info->cursor_hint_cursor_class = CURSOR_CLASS_TRANS;
+ /* This shouldn't happen, but be paranoid. */
+ if (split_index >= xaccTransCountSplits (new_trans))
+ split_index = 0;
- info->trans_expanded = FALSE;
- }
+ return_split = xaccTransGetSplit (new_trans, split_index);
+ trans_split = xaccTransGetSplit (new_trans, trans_split_index);
- /* Refresh the GUI. */
- gnc_resume_gui_refresh ();
+ info->cursor_hint_trans = new_trans;
+ info->cursor_hint_split = return_split;
+ info->cursor_hint_trans_split = trans_split;
+ info->cursor_hint_cursor_class = CURSOR_CLASS_TRANS;
- LEAVE(" ");
- return return_split;
+ info->trans_expanded = FALSE;
+ }
+
+ /* Refresh the GUI. */
+ gnc_resume_gui_refresh ();
+
+ LEAVE(" ");
+ return return_split;
}
static void
gnc_split_register_copy_current_internal (SplitRegister *reg,
- gboolean use_cut_semantics)
+ gboolean use_cut_semantics)
{
- SRInfo *info = gnc_split_register_get_info(reg);
- CursorClass cursor_class;
- Transaction *trans;
- Split *blank_split;
- gboolean changed;
- Split *split;
- SCM new_item;
+ SRInfo *info = gnc_split_register_get_info(reg);
+ CursorClass cursor_class;
+ Transaction *trans;
+ Split *blank_split;
+ gboolean changed;
+ Split *split;
+ SCM new_item;
- g_return_if_fail(reg);
- ENTER("reg=%p, use_cut_semantics=%s", reg,
- use_cut_semantics? "TRUE" : "FALSE");
+ g_return_if_fail(reg);
+ ENTER("reg=%p, use_cut_semantics=%s", reg,
+ use_cut_semantics ? "TRUE" : "FALSE");
- blank_split = xaccSplitLookup(&info->blank_split_guid,
- gnc_get_current_book ());
- split = gnc_split_register_get_current_split (reg);
- trans = gnc_split_register_get_current_trans (reg);
+ blank_split = xaccSplitLookup(&info->blank_split_guid,
+ gnc_get_current_book ());
+ split = gnc_split_register_get_current_split (reg);
+ trans = gnc_split_register_get_current_trans (reg);
- /* This shouldn't happen, but be paranoid. */
- if (trans == NULL)
- {
- LEAVE("no trans");
- return;
- }
+ /* This shouldn't happen, but be paranoid. */
+ if (trans == NULL)
+ {
+ LEAVE("no trans");
+ return;
+ }
- cursor_class = gnc_split_register_get_current_cursor_class (reg);
+ cursor_class = gnc_split_register_get_current_cursor_class (reg);
- /* Can't do anything with this. */
- if (cursor_class == CURSOR_CLASS_NONE)
- {
- LEAVE("no cursor class");
- return;
- }
+ /* Can't do anything with this. */
+ if (cursor_class == CURSOR_CLASS_NONE)
+ {
+ LEAVE("no cursor class");
+ return;
+ }
- /* This shouldn't happen, but be paranoid. */
- if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
- {
- g_warning("BUG DETECTED: transaction cursor with no anchoring split!");
- LEAVE("transaction cursor with no anchoring split");
- return;
- }
+ /* This shouldn't happen, but be paranoid. */
+ if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
+ {
+ g_warning("BUG DETECTED: transaction cursor with no anchoring split!");
+ LEAVE("transaction cursor with no anchoring split");
+ return;
+ }
- changed = gnc_table_current_cursor_changed (reg->table, FALSE);
+ changed = gnc_table_current_cursor_changed (reg->table, FALSE);
- /* See if we were asked to copy an unchanged blank split. Don't. */
- if (!changed && ((split == NULL) || (split == blank_split)))
- {
- /* We're either on an unedited, brand-new split or an unedited, brand-new
- * transaction (the transaction anchored by the blank split.) */
- /* FIXME: This doesn't work exactly right. When entering a new transaction,
- * you can edit the description, move to a split row, then move
- * back to the description, then ask for a copy, and this code will
- * be reached. It forgets that you changed the row the first time
- * you were there. -Charles */
- LEAVE("nothing to copy/cut");
- return;
- }
+ /* See if we were asked to copy an unchanged blank split. Don't. */
+ if (!changed && ((split == NULL) || (split == blank_split)))
+ {
+ /* We're either on an unedited, brand-new split or an unedited, brand-new
+ * transaction (the transaction anchored by the blank split.) */
+ /* FIXME: This doesn't work exactly right. When entering a new transaction,
+ * you can edit the description, move to a split row, then move
+ * back to the description, then ask for a copy, and this code will
+ * be reached. It forgets that you changed the row the first time
+ * you were there. -Charles */
+ LEAVE("nothing to copy/cut");
+ return;
+ }
- /* Ok, we are now ready to make the copy. */
+ /* Ok, we are now ready to make the copy. */
- if (cursor_class == CURSOR_CLASS_SPLIT)
- {
- /* We are on a split in an expanded transaction. Just copy the split. */
- new_item = gnc_copy_split(split, use_cut_semantics);
-
- if (new_item != SCM_UNDEFINED)
+ if (cursor_class == CURSOR_CLASS_SPLIT)
{
- if (changed)
- gnc_split_register_save_to_scm (reg, SCM_UNDEFINED, new_item,
- use_cut_semantics);
+ /* We are on a split in an expanded transaction. Just copy the split. */
+ new_item = gnc_copy_split(split, use_cut_semantics);
- copied_leader_guid = *guid_null();
+ if (new_item != SCM_UNDEFINED)
+ {
+ if (changed)
+ gnc_split_register_save_to_scm (reg, SCM_UNDEFINED, new_item,
+ use_cut_semantics);
+
+ copied_leader_guid = *guid_null();
+ }
}
- }
- else
- {
- /* We are on a transaction row. Copy the whole transaction. */
- new_item = gnc_copy_trans(trans, use_cut_semantics);
-
- if (new_item != SCM_UNDEFINED)
+ else
{
- if (changed)
- {
- int split_index;
- SCM split_scm;
+ /* We are on a transaction row. Copy the whole transaction. */
+ new_item = gnc_copy_trans(trans, use_cut_semantics);
- split_index = xaccTransGetSplitIndex(trans, split);
- if (split_index >= 0)
- split_scm = gnc_trans_scm_get_split_scm(new_item, split_index);
- else
- split_scm = SCM_UNDEFINED;
+ if (new_item != SCM_UNDEFINED)
+ {
+ if (changed)
+ {
+ int split_index;
+ SCM split_scm;
- gnc_split_register_save_to_scm (reg, new_item, split_scm,
- use_cut_semantics);
- }
+ split_index = xaccTransGetSplitIndex(trans, split);
+ if (split_index >= 0)
+ split_scm = gnc_trans_scm_get_split_scm(new_item, split_index);
+ else
+ split_scm = SCM_UNDEFINED;
- copied_leader_guid = info->default_account;
+ gnc_split_register_save_to_scm (reg, new_item, split_scm,
+ use_cut_semantics);
+ }
+
+ copied_leader_guid = info->default_account;
+ }
}
- }
- if (new_item == SCM_UNDEFINED)
- {
- g_warning("BUG DETECTED: copy failed");
- LEAVE("copy failed");
- return;
- }
+ if (new_item == SCM_UNDEFINED)
+ {
+ g_warning("BUG DETECTED: copy failed");
+ LEAVE("copy failed");
+ return;
+ }
- /* unprotect the old object, if any */
- if (copied_item != SCM_UNDEFINED)
- scm_gc_unprotect_object(copied_item);
+ /* unprotect the old object, if any */
+ if (copied_item != SCM_UNDEFINED)
+ scm_gc_unprotect_object(copied_item);
- copied_item = new_item;
- scm_gc_protect_object(copied_item);
+ copied_item = new_item;
+ scm_gc_protect_object(copied_item);
- copied_class = cursor_class;
- LEAVE("%s %s", use_cut_semantics? "cut" : "copied",
- cursor_class == CURSOR_CLASS_SPLIT? "split" : "transaction");
+ copied_class = cursor_class;
+ LEAVE("%s %s", use_cut_semantics ? "cut" : "copied",
+ cursor_class == CURSOR_CLASS_SPLIT ? "split" : "transaction");
}
void
gnc_split_register_copy_current (SplitRegister *reg)
{
- gnc_split_register_copy_current_internal (reg, FALSE);
+ gnc_split_register_copy_current_internal (reg, FALSE);
}
void
gnc_split_register_cut_current (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- CursorClass cursor_class;
- Transaction *trans;
- Split *blank_split;
- gboolean changed;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ CursorClass cursor_class;
+ Transaction *trans;
+ Split *blank_split;
+ gboolean changed;
+ Split *split;
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
- split = gnc_split_register_get_current_split (reg);
- trans = gnc_split_register_get_current_trans (reg);
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
+ gnc_get_current_book ());
+ split = gnc_split_register_get_current_split (reg);
+ trans = gnc_split_register_get_current_trans (reg);
- /* This shouldn't happen, but be paranoid. */
- if (trans == NULL)
- return;
+ /* This shouldn't happen, but be paranoid. */
+ if (trans == NULL)
+ return;
- cursor_class = gnc_split_register_get_current_cursor_class (reg);
+ cursor_class = gnc_split_register_get_current_cursor_class (reg);
- /* Can't do anything with this. */
- if (cursor_class == CURSOR_CLASS_NONE)
- return;
+ /* Can't do anything with this. */
+ if (cursor_class == CURSOR_CLASS_NONE)
+ return;
- /* This shouldn't happen, but be paranoid. */
- if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
- return;
+ /* This shouldn't happen, but be paranoid. */
+ if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
+ return;
- changed = gnc_table_current_cursor_changed (reg->table, FALSE);
+ changed = gnc_table_current_cursor_changed (reg->table, FALSE);
- /* See if we were asked to cut an unchanged blank split. Don't. */
- if (!changed && ((split == NULL) || (split == blank_split)))
- return;
+ /* See if we were asked to cut an unchanged blank split. Don't. */
+ if (!changed && ((split == NULL) || (split == blank_split)))
+ return;
- gnc_split_register_copy_current_internal (reg, TRUE);
+ gnc_split_register_copy_current_internal (reg, TRUE);
- if (cursor_class == CURSOR_CLASS_SPLIT)
- gnc_split_register_delete_current_split (reg);
- else
- gnc_split_register_delete_current_trans (reg);
+ if (cursor_class == CURSOR_CLASS_SPLIT)
+ gnc_split_register_delete_current_split (reg);
+ else
+ gnc_split_register_delete_current_trans (reg);
}
void
gnc_split_register_paste_current (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info(reg);
- CursorClass cursor_class;
- Transaction *trans;
- Transaction *blank_trans;
- Split *blank_split;
- Split *trans_split;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info(reg);
+ CursorClass cursor_class;
+ Transaction *trans;
+ Transaction *blank_trans;
+ Split *blank_split;
+ Split *trans_split;
+ Split *split;
- ENTER("reg=%p", reg);
+ ENTER("reg=%p", reg);
- if (copied_class == CURSOR_CLASS_NONE)
- {
- LEAVE("no copied cursor class");
- return;
- }
-
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
- blank_trans = xaccSplitGetParent (blank_split);
- split = gnc_split_register_get_current_split (reg);
- trans = gnc_split_register_get_current_trans (reg);
-
- trans_split = gnc_split_register_get_current_trans_split (reg, NULL);
-
- /* This shouldn't happen, but be paranoid. */
- if (trans == NULL)
- {
- LEAVE("no transaction");
- return;
- }
-
- cursor_class = gnc_split_register_get_current_cursor_class (reg);
-
- /* Can't do anything with this. */
- if (cursor_class == CURSOR_CLASS_NONE)
- {
- LEAVE("no current cursor class");
- return;
- }
-
- /* This shouldn't happen, but be paranoid. */
- if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
- {
- g_warning("BUG DETECTED: transaction cursor with no anchoring split!");
- LEAVE("transaction cursor with no anchoring split");
- return;
- }
-
- if (cursor_class == CURSOR_CLASS_SPLIT)
- {
- const char *message = _("You are about to overwrite an existing split. "
- "Are you sure you want to do that?");
-
- if (copied_class == CURSOR_CLASS_TRANS)
+ if (copied_class == CURSOR_CLASS_NONE)
{
- /* An entire transaction was copied, but we're just on a split. */
- LEAVE("can't copy trans to split");
- return;
+ LEAVE("no copied cursor class");
+ return;
}
- /* Ask before overwriting an existing split. */
- if (split != NULL &&
- !gnc_verify_dialog (gnc_split_register_get_parent (reg),
- FALSE, "%s", message))
- {
- LEAVE("user cancelled");
- return;
- }
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
+ gnc_get_current_book ());
+ blank_trans = xaccSplitGetParent (blank_split);
+ split = gnc_split_register_get_current_split (reg);
+ trans = gnc_split_register_get_current_trans (reg);
- gnc_suspend_gui_refresh ();
+ trans_split = gnc_split_register_get_current_trans_split (reg, NULL);
- if (split == NULL)
- { /* We are on a null split in an expanded transaction. */
- split = xaccMallocSplit(gnc_get_current_book ());
- xaccSplitSetParent(split, trans);
+ /* This shouldn't happen, but be paranoid. */
+ if (trans == NULL)
+ {
+ LEAVE("no transaction");
+ return;
}
- gnc_copy_split_scm_onto_split(copied_item, split,
- gnc_get_current_book ());
- }
- else
- {
- const char *message = _("You are about to overwrite an existing "
- "transaction. "
- "Are you sure you want to do that?");
- Account * copied_leader;
- const GUID *new_guid;
- int trans_split_index;
- int split_index;
- int num_splits;
+ cursor_class = gnc_split_register_get_current_cursor_class (reg);
- if (copied_class == CURSOR_CLASS_SPLIT)
+ /* Can't do anything with this. */
+ if (cursor_class == CURSOR_CLASS_NONE)
{
- LEAVE("can't copy split to transaction");
- return;
+ LEAVE("no current cursor class");
+ return;
}
- /* Ask before overwriting an existing transaction. */
- if (split != blank_split &&
- !gnc_verify_dialog(gnc_split_register_get_parent(reg),
- FALSE, "%s", message))
+ /* This shouldn't happen, but be paranoid. */
+ if ((split == NULL) && (cursor_class == CURSOR_CLASS_TRANS))
{
- LEAVE("user cancelled");
- return;
+ g_warning("BUG DETECTED: transaction cursor with no anchoring split!");
+ LEAVE("transaction cursor with no anchoring split");
+ return;
}
- /* Open the transaction for editing. */
- if (gnc_split_register_begin_edit_or_warn(info, trans))
+ if (cursor_class == CURSOR_CLASS_SPLIT)
{
- LEAVE("can't begin editing");
- return;
- }
+ const char *message = _("You are about to overwrite an existing split. "
+ "Are you sure you want to do that?");
- gnc_suspend_gui_refresh ();
+ if (copied_class == CURSOR_CLASS_TRANS)
+ {
+ /* An entire transaction was copied, but we're just on a split. */
+ LEAVE("can't copy trans to split");
+ return;
+ }
- DEBUG("Pasting txn, trans=%p, split=%p, blank_trans=%p, blank_split=%p",
- trans, split, blank_trans, blank_split);
+ /* Ask before overwriting an existing split. */
+ if (split != NULL &&
+ !gnc_verify_dialog (gnc_split_register_get_parent (reg),
+ FALSE, "%s", message))
+ {
+ LEAVE("user cancelled");
+ return;
+ }
- split_index = xaccTransGetSplitIndex(trans, split);
- trans_split_index = xaccTransGetSplitIndex(trans, trans_split);
+ gnc_suspend_gui_refresh ();
- copied_leader = xaccAccountLookup(&copied_leader_guid,
- gnc_get_current_book());
- if (copied_leader && (gnc_split_register_get_default_account(reg) != NULL))
- {
- new_guid = &info->default_account;
- gnc_copy_trans_scm_onto_trans_swap_accounts(copied_item, trans,
- &copied_leader_guid,
- new_guid, FALSE,
- gnc_get_current_book ());
+ if (split == NULL)
+ {
+ /* We are on a null split in an expanded transaction. */
+ split = xaccMallocSplit(gnc_get_current_book ());
+ xaccSplitSetParent(split, trans);
+ }
+
+ gnc_copy_split_scm_onto_split(copied_item, split,
+ gnc_get_current_book ());
}
else
- gnc_copy_trans_scm_onto_trans(copied_item, trans, FALSE,
- gnc_get_current_book ());
+ {
+ const char *message = _("You are about to overwrite an existing "
+ "transaction. "
+ "Are you sure you want to do that?");
+ Account * copied_leader;
+ const GUID *new_guid;
+ int trans_split_index;
+ int split_index;
+ int num_splits;
- num_splits = xaccTransCountSplits(trans);
- if (split_index >= num_splits)
- split_index = 0;
+ if (copied_class == CURSOR_CLASS_SPLIT)
+ {
+ LEAVE("can't copy split to transaction");
+ return;
+ }
- if (trans == blank_trans)
- {
- /* In pasting, the blank split is deleted. Pick a new one. */
- blank_split = xaccTransGetSplit(trans, 0);
- info->blank_split_guid = *xaccSplitGetGUID (blank_split);
- info->blank_split_edited = TRUE;
- DEBUG("replacement blank_split=%p", blank_split);
+ /* Ask before overwriting an existing transaction. */
+ if (split != blank_split &&
+ !gnc_verify_dialog(gnc_split_register_get_parent(reg),
+ FALSE, "%s", message))
+ {
+ LEAVE("user cancelled");
+ return;
+ }
- /* NOTE: At this point, the blank transaction virtual cell is still
- * anchored by the old, deleted blank split. The register will
- * have to be reloaded (redrawn) to correct this. */
+ /* Open the transaction for editing. */
+ if (gnc_split_register_begin_edit_or_warn(info, trans))
+ {
+ LEAVE("can't begin editing");
+ return;
+ }
+
+ gnc_suspend_gui_refresh ();
+
+ DEBUG("Pasting txn, trans=%p, split=%p, blank_trans=%p, blank_split=%p",
+ trans, split, blank_trans, blank_split);
+
+ split_index = xaccTransGetSplitIndex(trans, split);
+ trans_split_index = xaccTransGetSplitIndex(trans, trans_split);
+
+ copied_leader = xaccAccountLookup(&copied_leader_guid,
+ gnc_get_current_book());
+ if (copied_leader && (gnc_split_register_get_default_account(reg) != NULL))
+ {
+ new_guid = &info->default_account;
+ gnc_copy_trans_scm_onto_trans_swap_accounts(copied_item, trans,
+ &copied_leader_guid,
+ new_guid, FALSE,
+ gnc_get_current_book ());
+ }
+ else
+ gnc_copy_trans_scm_onto_trans(copied_item, trans, FALSE,
+ gnc_get_current_book ());
+
+ num_splits = xaccTransCountSplits(trans);
+ if (split_index >= num_splits)
+ split_index = 0;
+
+ if (trans == blank_trans)
+ {
+ /* In pasting, the blank split is deleted. Pick a new one. */
+ blank_split = xaccTransGetSplit(trans, 0);
+ info->blank_split_guid = *xaccSplitGetGUID (blank_split);
+ info->blank_split_edited = TRUE;
+ DEBUG("replacement blank_split=%p", blank_split);
+
+ /* NOTE: At this point, the blank transaction virtual cell is still
+ * anchored by the old, deleted blank split. The register will
+ * have to be reloaded (redrawn) to correct this. */
+ }
+
+ info->cursor_hint_trans = trans;
+ info->cursor_hint_split = xaccTransGetSplit(trans, split_index);
+ info->cursor_hint_trans_split = xaccTransGetSplit(trans,
+ trans_split_index);
+ info->cursor_hint_cursor_class = CURSOR_CLASS_TRANS;
}
- info->cursor_hint_trans = trans;
- info->cursor_hint_split = xaccTransGetSplit(trans, split_index);
- info->cursor_hint_trans_split = xaccTransGetSplit(trans,
- trans_split_index);
- info->cursor_hint_cursor_class = CURSOR_CLASS_TRANS;
- }
-
- /* Refresh the GUI. */
- gnc_resume_gui_refresh ();
- LEAVE(" ");
+ /* Refresh the GUI. */
+ gnc_resume_gui_refresh ();
+ LEAVE(" ");
}
void
gnc_split_register_delete_current_split (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
- Transaction *trans;
- Split *blank_split;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
+ Transaction *trans;
+ Split *blank_split;
+ Split *split;
- if (!reg) return;
+ if (!reg) return;
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
-
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_book ());
- /* get the current split based on cursor position */
- split = gnc_split_register_get_current_split (reg);
- if (split == NULL)
- return;
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- /* If we are deleting the blank split, just cancel. The user is
- * allowed to delete the blank split as a method for discarding
- * any edits they may have made to it. */
- if (split == blank_split)
- {
- gnc_split_register_cancel_cursor_split_changes (reg);
- return;
- }
+ /* get the current split based on cursor position */
+ split = gnc_split_register_get_current_split (reg);
+ if (split == NULL)
+ return;
- gnc_suspend_gui_refresh ();
+ /* If we are deleting the blank split, just cancel. The user is
+ * allowed to delete the blank split as a method for discarding
+ * any edits they may have made to it. */
+ if (split == blank_split)
+ {
+ gnc_split_register_cancel_cursor_split_changes (reg);
+ return;
+ }
- trans = xaccSplitGetParent(split);
+ gnc_suspend_gui_refresh ();
- /* Check pending transaction */
- if (trans == pending_trans) {
- g_assert(xaccTransIsOpen(trans));
- } else {
- g_assert(!pending_trans);
- if (gnc_split_register_begin_edit_or_warn(info, trans)) {
- gnc_resume_gui_refresh ();
- return;
- }
- }
- xaccSplitDestroy (split);
+ trans = xaccSplitGetParent(split);
- gnc_resume_gui_refresh ();
- gnc_split_register_redraw(reg);
+ /* Check pending transaction */
+ if (trans == pending_trans)
+ {
+ g_assert(xaccTransIsOpen(trans));
+ }
+ else
+ {
+ g_assert(!pending_trans);
+ if (gnc_split_register_begin_edit_or_warn(info, trans))
+ {
+ gnc_resume_gui_refresh ();
+ return;
+ }
+ }
+ xaccSplitDestroy (split);
+
+ gnc_resume_gui_refresh ();
+ gnc_split_register_redraw(reg);
}
void
gnc_split_register_delete_current_trans (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
- Transaction *trans;
- Split *blank_split;
- Split *split;
- gboolean was_open;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
+ Transaction *trans;
+ Split *blank_split;
+ Split *split;
+ gboolean was_open;
- ENTER("reg=%p", reg);
- if (!reg)
- {
- LEAVE("no register");
- return;
- }
+ ENTER("reg=%p", reg);
+ if (!reg)
+ {
+ LEAVE("no register");
+ return;
+ }
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_book ());
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- /* get the current split based on cursor position */
- split = gnc_split_register_get_current_split (reg);
- if (split == NULL)
- {
- LEAVE("no split");
- return;
- }
+ /* get the current split based on cursor position */
+ split = gnc_split_register_get_current_split (reg);
+ if (split == NULL)
+ {
+ LEAVE("no split");
+ return;
+ }
- gnc_suspend_gui_refresh ();
- trans = xaccSplitGetParent(split);
+ gnc_suspend_gui_refresh ();
+ trans = xaccSplitGetParent(split);
- /* If we just deleted the blank split, clean up. The user is
- * allowed to delete the blank split as a method for discarding
- * any edits they may have made to it. */
- if (split == blank_split) {
- DEBUG("deleting blank split");
- info->blank_split_guid = *guid_null();
- } else {
- info->trans_expanded = FALSE;
- }
-
- /* Check pending transaction */
- if (trans == pending_trans) {
- DEBUG("clearing pending trans");
- info->pending_trans_guid = *guid_null();
- pending_trans = NULL;
- }
+ /* If we just deleted the blank split, clean up. The user is
+ * allowed to delete the blank split as a method for discarding
+ * any edits they may have made to it. */
+ if (split == blank_split)
+ {
+ DEBUG("deleting blank split");
+ info->blank_split_guid = *guid_null();
+ }
+ else
+ {
+ info->trans_expanded = FALSE;
+ }
- was_open = xaccTransIsOpen(trans);
- xaccTransDestroy(trans);
- if (was_open)
- {
- DEBUG("committing");
- xaccTransCommitEdit(trans);
- }
- gnc_resume_gui_refresh ();
- LEAVE(" ");
+ /* Check pending transaction */
+ if (trans == pending_trans)
+ {
+ DEBUG("clearing pending trans");
+ info->pending_trans_guid = *guid_null();
+ pending_trans = NULL;
+ }
+
+ was_open = xaccTransIsOpen(trans);
+ xaccTransDestroy(trans);
+ if (was_open)
+ {
+ DEBUG("committing");
+ xaccTransCommitEdit(trans);
+ }
+ gnc_resume_gui_refresh ();
+ LEAVE(" ");
}
void
gnc_split_register_void_current_trans (SplitRegister *reg, const char *reason)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
- Transaction *trans;
- Split *blank_split;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
+ Transaction *trans;
+ Split *blank_split;
+ Split *split;
- if (!reg) return;
+ if (!reg) return;
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_book ());
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- /* get the current split based on cursor position */
- split = gnc_split_register_get_current_split (reg);
- if (split == NULL)
- return;
+ /* get the current split based on cursor position */
+ split = gnc_split_register_get_current_split (reg);
+ if (split == NULL)
+ return;
- /* Bail if trying to void the blank split. */
- if (split == blank_split)
- return;
+ /* Bail if trying to void the blank split. */
+ if (split == blank_split)
+ return;
- /* already voided. */
- if (xaccSplitGetReconcile (split) == VREC)
- return;
+ /* already voided. */
+ if (xaccSplitGetReconcile (split) == VREC)
+ return;
- info->trans_expanded = FALSE;
+ info->trans_expanded = FALSE;
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- trans = xaccSplitGetParent(split);
- xaccTransVoid(trans, reason);
+ trans = xaccSplitGetParent(split);
+ xaccTransVoid(trans, reason);
- /* Check pending transaction */
- if (trans == pending_trans)
- {
- info->pending_trans_guid = *guid_null();
- pending_trans = NULL;
- }
- if (xaccTransIsOpen(trans)) {
- PERR("We should not be voiding an open transaction.");
- xaccTransCommitEdit(trans);
- }
- gnc_resume_gui_refresh ();
+ /* Check pending transaction */
+ if (trans == pending_trans)
+ {
+ info->pending_trans_guid = *guid_null();
+ pending_trans = NULL;
+ }
+ if (xaccTransIsOpen(trans))
+ {
+ PERR("We should not be voiding an open transaction.");
+ xaccTransCommitEdit(trans);
+ }
+ gnc_resume_gui_refresh ();
}
void
gnc_split_register_unvoid_current_trans (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
- Transaction *trans;
- Split *blank_split;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
+ Transaction *trans;
+ Split *blank_split;
+ Split *split;
- if (!reg) return;
+ if (!reg) return;
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_book ());
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- /* get the current split based on cursor position */
- split = gnc_split_register_get_current_split (reg);
- if (split == NULL)
- return;
+ /* get the current split based on cursor position */
+ split = gnc_split_register_get_current_split (reg);
+ if (split == NULL)
+ return;
- /* Bail if trying to unvoid the blank split. */
- if (split == blank_split)
- return;
+ /* Bail if trying to unvoid the blank split. */
+ if (split == blank_split)
+ return;
- /* not voided. */
- if (xaccSplitGetReconcile (split) != VREC)
- return;
+ /* not voided. */
+ if (xaccSplitGetReconcile (split) != VREC)
+ return;
- info->trans_expanded = FALSE;
+ info->trans_expanded = FALSE;
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- trans = xaccSplitGetParent(split);
+ trans = xaccSplitGetParent(split);
- xaccTransUnvoid(trans);
+ xaccTransUnvoid(trans);
- /* Check pending transaction */
- if (trans == pending_trans)
- {
- info->pending_trans_guid = *guid_null();
- pending_trans = NULL;
- }
+ /* Check pending transaction */
+ if (trans == pending_trans)
+ {
+ info->pending_trans_guid = *guid_null();
+ pending_trans = NULL;
+ }
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh ();
}
void
-gnc_split_register_empty_current_trans_except_split (SplitRegister *reg,
- Split *split)
+gnc_split_register_empty_current_trans_except_split (SplitRegister *reg,
+ Split *split)
{
- SRInfo *info;
- Transaction *trans;
- Transaction *pending;
- int i = 0;
- Split *s;
+ SRInfo *info;
+ Transaction *trans;
+ Transaction *pending;
+ int i = 0;
+ Split *s;
- if ((reg == NULL) || (split == NULL))
- return;
+ if ((reg == NULL) || (split == NULL))
+ return;
- gnc_suspend_gui_refresh ();
- info = gnc_split_register_get_info(reg);
- pending = xaccTransLookup(&info->pending_trans_guid, gnc_get_current_book());
+ gnc_suspend_gui_refresh ();
+ info = gnc_split_register_get_info(reg);
+ pending = xaccTransLookup(&info->pending_trans_guid, gnc_get_current_book());
- trans = xaccSplitGetParent(split);
- if (!pending) {
- if (gnc_split_register_begin_edit_or_warn(info, trans)) {
- gnc_resume_gui_refresh ();
- return;
- }
- } else if (pending == trans) {
- g_assert(xaccTransIsOpen(trans));
- } else g_assert_not_reached();
+ trans = xaccSplitGetParent(split);
+ if (!pending)
+ {
+ if (gnc_split_register_begin_edit_or_warn(info, trans))
+ {
+ gnc_resume_gui_refresh ();
+ return;
+ }
+ }
+ else if (pending == trans)
+ {
+ g_assert(xaccTransIsOpen(trans));
+ }
+ else g_assert_not_reached();
- while ((s = xaccTransGetSplit(trans, i)) != NULL) {
- if (s != split)
- xaccSplitDestroy(s);
- else i++;
- }
+ while ((s = xaccTransGetSplit(trans, i)) != NULL)
+ {
+ if (s != split)
+ xaccSplitDestroy(s);
+ else i++;
+ }
- gnc_resume_gui_refresh ();
- gnc_split_register_redraw(reg);
+ gnc_resume_gui_refresh ();
+ gnc_split_register_redraw(reg);
}
void
gnc_split_register_empty_current_trans (SplitRegister *reg)
{
- Split *split;
+ Split *split;
- /* get the current split based on cursor position */
- split = gnc_split_register_get_current_split (reg);
- gnc_split_register_empty_current_trans_except_split (reg, split);
+ /* get the current split based on cursor position */
+ split = gnc_split_register_get_current_split (reg);
+ gnc_split_register_empty_current_trans_except_split (reg, split);
}
void
gnc_split_register_cancel_cursor_split_changes (SplitRegister *reg)
{
- VirtualLocation virt_loc;
+ VirtualLocation virt_loc;
- if (reg == NULL)
- return;
+ if (reg == NULL)
+ return;
- virt_loc = reg->table->current_cursor_loc;
+ virt_loc = reg->table->current_cursor_loc;
- if (!gnc_table_current_cursor_changed (reg->table, FALSE))
- return;
+ if (!gnc_table_current_cursor_changed (reg->table, FALSE))
+ return;
- /* We're just cancelling the current split here, not the transaction.
- * When cancelling edits, reload the cursor from the transaction. */
- gnc_table_clear_current_cursor_changes (reg->table);
+ /* We're just cancelling the current split here, not the transaction.
+ * When cancelling edits, reload the cursor from the transaction. */
+ gnc_table_clear_current_cursor_changes (reg->table);
- if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE))
- gnc_table_move_cursor_gui (reg->table, virt_loc);
+ if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE))
+ gnc_table_move_cursor_gui (reg->table, virt_loc);
- gnc_table_refresh_gui (reg->table, TRUE);
+ gnc_table_refresh_gui (reg->table, TRUE);
}
void
gnc_split_register_cancel_cursor_trans_changes (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
- gnc_get_current_book ());
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- /* Get the currently open transaction, rollback the edits on it, and
- * then repaint everything. To repaint everything, make a note of
- * all of the accounts that will be affected by this rollback. */
- if (!xaccTransIsOpen (pending_trans))
- {
- gnc_split_register_cancel_cursor_split_changes (reg);
- return;
- }
+ /* Get the currently open transaction, rollback the edits on it, and
+ * then repaint everything. To repaint everything, make a note of
+ * all of the accounts that will be affected by this rollback. */
+ if (!xaccTransIsOpen (pending_trans))
+ {
+ gnc_split_register_cancel_cursor_split_changes (reg);
+ return;
+ }
- if (!pending_trans)
- return;
+ if (!pending_trans)
+ return;
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- xaccTransRollbackEdit (pending_trans);
+ xaccTransRollbackEdit (pending_trans);
- info->pending_trans_guid = *guid_null ();
+ info->pending_trans_guid = *guid_null ();
- gnc_resume_gui_refresh ();
- gnc_split_register_redraw(reg);
+ gnc_resume_gui_refresh ();
+ gnc_split_register_redraw(reg);
}
void
-gnc_split_register_redraw (SplitRegister *reg)
+gnc_split_register_redraw (SplitRegister *reg)
{
- gnc_ledger_display_refresh_by_split_register (reg);
+ gnc_ledger_display_refresh_by_split_register (reg);
}
/* Copy from the register object to scheme. This needs to be
@@ -1232,949 +1254,960 @@
SCM trans_scm, SCM split_scm,
gboolean use_cut_semantics)
{
- SCM other_split_scm = SCM_UNDEFINED;
- Transaction *trans;
+ SCM other_split_scm = SCM_UNDEFINED;
+ Transaction *trans;
- /* use the changed flag to avoid heavy-weight updates
- * of the split & transaction fields. This will help
- * cut down on uneccessary register redraws. */
- if (!gnc_table_current_cursor_changed (reg->table, FALSE))
- return FALSE;
+ /* use the changed flag to avoid heavy-weight updates
+ * of the split & transaction fields. This will help
+ * cut down on uneccessary register redraws. */
+ if (!gnc_table_current_cursor_changed (reg->table, FALSE))
+ return FALSE;
- /* get the handle to the current split and transaction */
- trans = gnc_split_register_get_current_trans (reg);
- if (trans == NULL)
- return FALSE;
+ /* get the handle to the current split and transaction */
+ trans = gnc_split_register_get_current_trans (reg);
+ if (trans == NULL)
+ return FALSE;
- /* copy the contents from the cursor to the split */
- if (gnc_table_layout_get_cell_changed (reg->table->layout, DATE_CELL, TRUE))
- {
- BasicCell *cell;
- Timespec ts;
+ /* copy the contents from the cursor to the split */
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, DATE_CELL, TRUE))
+ {
+ BasicCell *cell;
+ Timespec ts;
- cell = gnc_table_layout_get_cell (reg->table->layout, DATE_CELL);
- gnc_date_cell_get_date ((DateCell *) cell, &ts);
+ cell = gnc_table_layout_get_cell (reg->table->layout, DATE_CELL);
+ gnc_date_cell_get_date ((DateCell *) cell, &ts);
- gnc_trans_scm_set_date(trans_scm, &ts);
- }
+ gnc_trans_scm_set_date(trans_scm, &ts);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, NUM_CELL, TRUE))
- {
- const char *value;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, NUM_CELL, TRUE))
+ {
+ const char *value;
- value = gnc_table_layout_get_cell_value (reg->table->layout, NUM_CELL);
- gnc_trans_scm_set_num (trans_scm, value);
- }
+ value = gnc_table_layout_get_cell_value (reg->table->layout, NUM_CELL);
+ gnc_trans_scm_set_num (trans_scm, value);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, DESC_CELL, TRUE))
- {
- const char *value;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, DESC_CELL, TRUE))
+ {
+ const char *value;
- value = gnc_table_layout_get_cell_value (reg->table->layout, DESC_CELL);
- gnc_trans_scm_set_description (trans_scm, value);
- }
+ value = gnc_table_layout_get_cell_value (reg->table->layout, DESC_CELL);
+ gnc_trans_scm_set_description (trans_scm, value);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, NOTES_CELL, TRUE))
- {
- const char *value;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, NOTES_CELL, TRUE))
+ {
+ const char *value;
- value = gnc_table_layout_get_cell_value (reg->table->layout, NOTES_CELL);
- gnc_trans_scm_set_notes (trans_scm, value);
- }
+ value = gnc_table_layout_get_cell_value (reg->table->layout, NOTES_CELL);
+ gnc_trans_scm_set_notes (trans_scm, value);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, RECN_CELL, TRUE))
- {
- BasicCell *cell;
- char flag;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, RECN_CELL, TRUE))
+ {
+ BasicCell *cell;
+ char flag;
- cell = gnc_table_layout_get_cell (reg->table->layout, RECN_CELL);
- flag = gnc_recn_cell_get_flag ((RecnCell *) cell);
+ cell = gnc_table_layout_get_cell (reg->table->layout, RECN_CELL);
+ flag = gnc_recn_cell_get_flag ((RecnCell *) cell);
- gnc_split_scm_set_reconcile_state(split_scm, flag);
- }
+ gnc_split_scm_set_reconcile_state(split_scm, flag);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, ACTN_CELL, TRUE))
- {
- const char *value;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, ACTN_CELL, TRUE))
+ {
+ const char *value;
- value = gnc_table_layout_get_cell_value (reg->table->layout, ACTN_CELL);
- gnc_split_scm_set_action (split_scm, value);
- }
+ value = gnc_table_layout_get_cell_value (reg->table->layout, ACTN_CELL);
+ gnc_split_scm_set_action (split_scm, value);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, MEMO_CELL, TRUE))
- {
- const char *value;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, MEMO_CELL, TRUE))
+ {
+ const char *value;
- value = gnc_table_layout_get_cell_value (reg->table->layout, MEMO_CELL);
- gnc_split_scm_set_memo (split_scm, value);
- }
+ value = gnc_table_layout_get_cell_value (reg->table->layout, MEMO_CELL);
+ gnc_split_scm_set_memo (split_scm, value);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, XFRM_CELL, TRUE))
- {
- Account *new_account;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, XFRM_CELL, TRUE))
+ {
+ Account *new_account;
- new_account = gnc_split_register_get_account (reg, XFRM_CELL);
+ new_account = gnc_split_register_get_account (reg, XFRM_CELL);
- if (new_account != NULL)
- gnc_split_scm_set_account (split_scm, new_account);
- }
+ if (new_account != NULL)
+ gnc_split_scm_set_account (split_scm, new_account);
+ }
- if (reg->style == REG_STYLE_LEDGER)
- other_split_scm = gnc_trans_scm_get_other_split_scm (trans_scm, split_scm);
+ if (reg->style == REG_STYLE_LEDGER)
+ other_split_scm = gnc_trans_scm_get_other_split_scm (trans_scm, split_scm);
- if (gnc_table_layout_get_cell_changed (reg->table->layout, MXFRM_CELL, TRUE))
- {
- other_split_scm = gnc_trans_scm_get_other_split_scm (trans_scm, split_scm);
-
- if (other_split_scm == SCM_UNDEFINED)
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, MXFRM_CELL, TRUE))
{
- if (gnc_trans_scm_get_num_splits(trans_scm) == 1)
- {
- Split *temp_split;
+ other_split_scm = gnc_trans_scm_get_other_split_scm (trans_scm, split_scm);
- temp_split = xaccMallocSplit (gnc_get_current_book ());
- other_split_scm = gnc_copy_split (temp_split, use_cut_semantics);
- xaccSplitDestroy (temp_split);
+ if (other_split_scm == SCM_UNDEFINED)
+ {
+ if (gnc_trans_scm_get_num_splits(trans_scm) == 1)
+ {
+ Split *temp_split;
- gnc_trans_scm_append_split_scm (trans_scm, other_split_scm);
- }
- }
+ temp_split = xaccMallocSplit (gnc_get_current_book ());
+ other_split_scm = gnc_copy_split (temp_split, use_cut_semantics);
+ xaccSplitDestroy (temp_split);
- if (other_split_scm != SCM_UNDEFINED)
- {
- Account *new_account;
+ gnc_trans_scm_append_split_scm (trans_scm, other_split_scm);
+ }
+ }
- new_account = gnc_split_register_get_account (reg, MXFRM_CELL);
+ if (other_split_scm != SCM_UNDEFINED)
+ {
+ Account *new_account;
- if (new_account != NULL)
- gnc_split_scm_set_account (other_split_scm, new_account);
+ new_account = gnc_split_register_get_account (reg, MXFRM_CELL);
+
+ if (new_account != NULL)
+ gnc_split_scm_set_account (other_split_scm, new_account);
+ }
}
- }
- if (gnc_table_layout_get_cell_changed (reg->table->layout,
- DEBT_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- CRED_CELL, TRUE))
- {
- BasicCell *cell;
- gnc_numeric new_value;
- gnc_numeric credit;
- gnc_numeric debit;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout,
+ DEBT_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ CRED_CELL, TRUE))
+ {
+ BasicCell *cell;
+ gnc_numeric new_value;
+ gnc_numeric credit;
+ gnc_numeric debit;
- cell = gnc_table_layout_get_cell (reg->table->layout, CRED_CELL);
- credit = gnc_price_cell_get_value ((PriceCell *) cell);
+ cell = gnc_table_layout_get_cell (reg->table->layout, CRED_CELL);
+ credit = gnc_price_cell_get_value ((PriceCell *) cell);
- cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL);
- debit = gnc_price_cell_get_value ((PriceCell *) cell);
+ cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL);
+ debit = gnc_price_cell_get_value ((PriceCell *) cell);
- new_value = gnc_numeric_sub_fixed (debit, credit);
+ new_value = gnc_numeric_sub_fixed (debit, credit);
- gnc_split_scm_set_value (split_scm, new_value);
- }
+ gnc_split_scm_set_value (split_scm, new_value);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, PRIC_CELL, TRUE))
- {
- /* do nothing for now */
- }
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, PRIC_CELL, TRUE))
+ {
+ /* do nothing for now */
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout, SHRS_CELL, TRUE))
- {
- BasicCell *cell;
- gnc_numeric shares;
+ if (gnc_table_layout_get_cell_changed (reg->table->layout, SHRS_CELL, TRUE))
+ {
+ BasicCell *cell;
+ gnc_numeric shares;
- cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
+ cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
- shares = gnc_price_cell_get_value ((PriceCell *) cell);
+ shares = gnc_price_cell_get_value ((PriceCell *) cell);
- gnc_split_scm_set_amount (split_scm, shares);
- }
+ gnc_split_scm_set_amount (split_scm, shares);
+ }
- if (gnc_table_layout_get_cell_changed (reg->table->layout,
- DEBT_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- CRED_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- PRIC_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- SHRS_CELL, TRUE))
- {
- if (other_split_scm != SCM_UNDEFINED)
+ if (gnc_table_layout_get_cell_changed (reg->table->layout,
+ DEBT_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ CRED_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ PRIC_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ SHRS_CELL, TRUE))
{
- gnc_numeric num;
+ if (other_split_scm != SCM_UNDEFINED)
+ {
+ gnc_numeric num;
- num = gnc_split_scm_get_amount (split_scm);
- gnc_split_scm_set_amount (other_split_scm, gnc_numeric_neg (num));
+ num = gnc_split_scm_get_amount (split_scm);
+ gnc_split_scm_set_amount (other_split_scm, gnc_numeric_neg (num));
- num = gnc_split_scm_get_value (split_scm);
- gnc_split_scm_set_value (other_split_scm, gnc_numeric_neg (num));
+ num = gnc_split_scm_get_value (split_scm);
+ gnc_split_scm_set_value (other_split_scm, gnc_numeric_neg (num));
+ }
}
- }
- return TRUE;
+ return TRUE;
}
gboolean
gnc_split_register_save (SplitRegister *reg, gboolean do_commit)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
- Transaction *blank_trans;
- Transaction *trans;
- Account *account;
- Split *blank_split;
- const char *memo;
- const char *desc;
- Split *split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
+ Transaction *blank_trans;
+ Transaction *trans;
+ Account *account;
+ Split *blank_split;
+ const char *memo;
+ const char *desc;
+ Split *split;
- ENTER("reg=%p, do_commit=%s", reg, do_commit ? "TRUE" : "FALSE");
+ ENTER("reg=%p, do_commit=%s", reg, do_commit ? "TRUE" : "FALSE");
- if (!reg)
- {
- LEAVE("no register");
- return FALSE;
- }
+ if (!reg)
+ {
+ LEAVE("no register");
+ return FALSE;
+ }
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
+ gnc_get_current_book ());
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
- gnc_get_current_book ());
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- blank_trans = xaccSplitGetParent (blank_split);
+ blank_trans = xaccSplitGetParent (blank_split);
- /* get the handle to the current split and transaction */
- split = gnc_split_register_get_current_split (reg);
- trans = gnc_split_register_get_current_trans (reg);
- if (trans == NULL)
- {
- LEAVE("no transaction");
- return FALSE;
- }
+ /* get the handle to the current split and transaction */
+ split = gnc_split_register_get_current_split (reg);
+ trans = gnc_split_register_get_current_trans (reg);
+ if (trans == NULL)
+ {
+ LEAVE("no transaction");
+ return FALSE;
+ }
- /* use the changed flag to avoid heavy-weight updates
- * of the split & transaction fields. This will help
- * cut down on unnecessary register redraws. */
- if (!gnc_table_current_cursor_changed (reg->table, FALSE))
- {
- if (!do_commit)
- {
- LEAVE("commit unnecessary");
- return FALSE;
- }
+ /* use the changed flag to avoid heavy-weight updates
+ * of the split & transaction fields. This will help
+ * cut down on unnecessary register redraws. */
+ if (!gnc_table_current_cursor_changed (reg->table, FALSE))
+ {
+ if (!do_commit)
+ {
+ LEAVE("commit unnecessary");
+ return FALSE;
+ }
- if (!xaccTransIsOpen(trans))
- {
- LEAVE("transaction not open");
- return FALSE;
- }
+ if (!xaccTransIsOpen(trans))
+ {
+ LEAVE("transaction not open");
+ return FALSE;
+ }
- if (trans == pending_trans ||
- (trans == blank_trans && info->blank_split_edited)) {
- /* We are going to commit. */
+ if (trans == pending_trans ||
+ (trans == blank_trans && info->blank_split_edited))
+ {
+ /* We are going to commit. */
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- if (trans == blank_trans) {
- /* We have to clear the blank split before the
- * refresh or a new one won't be created. */
- info->last_date_entered = xaccTransGetDate (trans);
- info->blank_split_guid = *guid_null ();
- info->blank_split_edited = FALSE;
- }
+ if (trans == blank_trans)
+ {
+ /* We have to clear the blank split before the
+ * refresh or a new one won't be created. */
+ info->last_date_entered = xaccTransGetDate (trans);
+ info->blank_split_guid = *guid_null ();
+ info->blank_split_edited = FALSE;
+ }
- /* We have to clear the pending guid *before* committing the
- * trans, because the event handler will find it otherwise. */
- if (trans == pending_trans)
- info->pending_trans_guid = *guid_null ();
+ /* We have to clear the pending guid *before* committing the
+ * trans, because the event handler will find it otherwise. */
+ if (trans == pending_trans)
+ info->pending_trans_guid = *guid_null ();
- PINFO("committing trans (%p)", trans);
- xaccTransCommitEdit(trans);
+ PINFO("committing trans (%p)", trans);
+ xaccTransCommitEdit(trans);
- gnc_resume_gui_refresh ();
- }
- else
- DEBUG("leaving trans (%p) open", trans);
+ gnc_resume_gui_refresh ();
+ }
+ else
+ DEBUG("leaving trans (%p) open", trans);
- LEAVE("unchanged cursor");
- return TRUE;
- }
+ LEAVE("unchanged cursor");
+ return TRUE;
+ }
- DEBUG("save split=%p", split);
- DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p, trans=%p",
- blank_split, blank_trans, pending_trans, trans);
+ DEBUG("save split=%p", split);
+ DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p, trans=%p",
+ blank_split, blank_trans, pending_trans, trans);
- /* Act on any changes to the current cell before the save. */
- (void) gnc_split_register_check_cell (reg,
- gnc_table_get_current_cell_name (reg->table));
+ /* Act on any changes to the current cell before the save. */
+ (void) gnc_split_register_check_cell (reg,
+ gnc_table_get_current_cell_name (reg->table));
- if (!gnc_split_register_auto_calc (reg, split))
- {
- LEAVE("auto calc failed");
- return FALSE;
- }
+ if (!gnc_split_register_auto_calc (reg, split))
+ {
+ LEAVE("auto calc failed");
+ return FALSE;
+ }
- /* Validate the transfer account names */
- (void)gnc_split_register_get_account (reg, MXFRM_CELL);
- (void)gnc_split_register_get_account (reg, XFRM_CELL);
+ /* Validate the transfer account names */
+ (void)gnc_split_register_get_account (reg, MXFRM_CELL);
+ (void)gnc_split_register_get_account (reg, XFRM_CELL);
- /* Maybe deal with exchange-rate transfers */
- if (gnc_split_register_handle_exchange (reg, FALSE))
- {
- LEAVE("no exchange rate");
- return TRUE;
- }
+ /* Maybe deal with exchange-rate transfers */
+ if (gnc_split_register_handle_exchange (reg, FALSE))
+ {
+ LEAVE("no exchange rate");
+ return TRUE;
+ }
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- /* determine whether we should commit the pending transaction */
- if (pending_trans != trans)
- {
- // FIXME: How could the pending transaction not be open?
- // FIXME: For that matter, how could an open pending
- // transaction ever not be the current trans?
- if (xaccTransIsOpen (pending_trans)) {
- g_warning("Impossible? commiting pending %p", pending_trans);
- xaccTransCommitEdit (pending_trans);
- } else if (pending_trans) {
- g_critical("BUG DETECTED! pending transaction (%p) not open",
- pending_trans);
- g_assert_not_reached();
- }
+ /* determine whether we should commit the pending transaction */
+ if (pending_trans != trans)
+ {
+ // FIXME: How could the pending transaction not be open?
+ // FIXME: For that matter, how could an open pending
+ // transaction ever not be the current trans?
+ if (xaccTransIsOpen (pending_trans))
+ {
+ g_warning("Impossible? commiting pending %p", pending_trans);
+ xaccTransCommitEdit (pending_trans);
+ }
+ else if (pending_trans)
+ {
+ g_critical("BUG DETECTED! pending transaction (%p) not open",
+ pending_trans);
+ g_assert_not_reached();
+ }
- if (trans == blank_trans) {
- /* Don't begin editing the blank trans, because it's
- already open, but mark it pending now. */
- g_assert(xaccTransIsOpen(blank_trans));
- /* This is now the pending transaction */
- info->pending_trans_guid = *xaccTransGetGUID(blank_trans);
- } else {
- PINFO("beginning edit of trans %p", trans);
- if (gnc_split_register_begin_edit_or_warn(info, trans))
- {
- gnc_resume_gui_refresh ();
- LEAVE("transaction opened elsewhere");
- return FALSE;
- }
- }
- pending_trans = trans;
- }
- g_assert(xaccTransIsOpen(trans));
+ if (trans == blank_trans)
+ {
+ /* Don't begin editing the blank trans, because it's
+ already open, but mark it pending now. */
+ g_assert(xaccTransIsOpen(blank_trans));
+ /* This is now the pending transaction */
+ info->pending_trans_guid = *xaccTransGetGUID(blank_trans);
+ }
+ else
+ {
+ PINFO("beginning edit of trans %p", trans);
+ if (gnc_split_register_begin_edit_or_warn(info, trans))
+ {
+ gnc_resume_gui_refresh ();
+ LEAVE("transaction opened elsewhere");
+ return FALSE;
+ }
+ }
+ pending_trans = trans;
+ }
+ g_assert(xaccTransIsOpen(trans));
- /* If we are saving a brand new transaction and the blank split hasn't
- * been edited, then we need to give it a default account. */
- /* Q: Why check 'split == blank_split'? Isn't 'trans == blank_trans'
- * even better? What if there were some way that we could be on
- * a row other than the transaction row or blank split row, but
- * the blank split still hasn't been edited? It seems to be assumed
- * that it isn't possible, but... -Charles, Jan 2009 */
- if (split == blank_split && !info->blank_split_edited)
- {
- /* If we've reached this point, it means that the blank split is
- * anchoring the transaction - see gnc_split_register_add_transaction()
- * for an explanation - and the transaction has been edited (as evidenced
- * by the earlier check for a changed cursor.) Since the blank split
- * itself has not been edited, we'll have to assign a default account. */
- account = gnc_split_register_get_default_account(reg);
- if (account)
- xaccSplitSetAccount(blank_split, account);
- xaccTransSetDateEnteredSecs(trans, time(NULL));
- }
+ /* If we are saving a brand new transaction and the blank split hasn't
+ * been edited, then we need to give it a default account. */
+ /* Q: Why check 'split == blank_split'? Isn't 'trans == blank_trans'
+ * even better? What if there were some way that we could be on
+ * a row other than the transaction row or blank split row, but
+ * the blank split still hasn't been edited? It seems to be assumed
+ * that it isn't possible, but... -Charles, Jan 2009 */
+ if (split == blank_split && !info->blank_split_edited)
+ {
+ /* If we've reached this point, it means that the blank split is
+ * anchoring the transaction - see gnc_split_register_add_transaction()
+ * for an explanation - and the transaction has been edited (as evidenced
+ * by the earlier check for a changed cursor.) Since the blank split
+ * itself has not been edited, we'll have to assign a default account. */
+ account = gnc_split_register_get_default_account(reg);
+ if (account)
+ xaccSplitSetAccount(blank_split, account);
+ xaccTransSetDateEnteredSecs(trans, time(NULL));
+ }
- if (split == NULL)
- {
- /* If we were asked to save data for a row for which there is no
- * associated split, then assume that this was an "empty" row - see
- * gnc_split_register_add_transaction() for an explanation. This row
- * is used to add splits to an existing transaction, or to add the
- * 2nd through nth split rows to a brand new transaction.
- * xaccSRGetCurrent will handle this case, too. We will create
- * a new split, copy the row contents to that split, and append
- * the split to the pre-existing transaction. */
- Split *trans_split;
+ if (split == NULL)
+ {
+ /* If we were asked to save data for a row for which there is no
+ * associated split, then assume that this was an "empty" row - see
+ * gnc_split_register_add_transaction() for an explanation. This row
+ * is used to add splits to an existing transaction, or to add the
+ * 2nd through nth split rows to a brand new transaction.
+ * xaccSRGetCurrent will handle this case, too. We will create
+ * a new split, copy the row contents to that split, and append
+ * the split to the pre-existing transaction. */
+ Split *trans_split;
- split = xaccMallocSplit (gnc_get_current_book ());
- xaccTransAppendSplit (trans, split);
+ split = xaccMallocSplit (gnc_get_current_book ());
+ xaccTransAppendSplit (trans, split);
- gnc_table_set_virt_cell_data (reg->table,
- reg->table->current_cursor_loc.vcell_loc,
- xaccSplitGetGUID (split));
- DEBUG("assigned cell to new split=%p", split);
+ gnc_table_set_virt_cell_data (reg->table,
+ reg->table->current_cursor_loc.vcell_loc,
+ xaccSplitGetGUID (split));
+ DEBUG("assigned cell to new split=%p", split);
- trans_split = gnc_split_register_get_current_trans_split (reg, NULL);
- if ((info->cursor_hint_trans == trans) &&
- (info->cursor_hint_trans_split == trans_split) &&
- (info->cursor_hint_split == NULL))
- {
- info->cursor_hint_split = split;
- info->cursor_hint_cursor_class = CURSOR_CLASS_SPLIT;
- }
- }
+ trans_split = gnc_split_register_get_current_trans_split (reg, NULL);
+ if ((info->cursor_hint_trans == trans) &&
+ (info->cursor_hint_trans_split == trans_split) &&
+ (info->cursor_hint_split == NULL))
+ {
+ info->cursor_hint_split = split;
+ info->cursor_hint_cursor_class = CURSOR_CLASS_SPLIT;
+ }
+ }
- DEBUG("updating trans=%p", trans);
+ DEBUG("updating trans=%p", trans);
- {
- SRSaveData *sd;
+ {
+ SRSaveData *sd;
- sd = gnc_split_register_save_data_new (
- trans, split, (info->trans_expanded ||
- reg->style == REG_STYLE_AUTO_LEDGER ||
- reg->style == REG_STYLE_JOURNAL));
- gnc_table_save_cells (reg->table, sd);
- gnc_split_register_save_data_destroy (sd);
- }
+ sd = gnc_split_register_save_data_new (
+ trans, split, (info->trans_expanded ||
+ reg->style == REG_STYLE_AUTO_LEDGER ||
+ reg->style == REG_STYLE_JOURNAL));
+ gnc_table_save_cells (reg->table, sd);
+ gnc_split_register_save_data_destroy (sd);
+ }
- memo = xaccSplitGetMemo (split);
- memo = memo ? memo : "(null)";
- desc = xaccTransGetDescription (trans);
- desc = desc ? desc : "(null)";
- PINFO ("finished saving split \"%s\" of trans \"%s\"", memo, desc);
+ memo = xaccSplitGetMemo (split);
+ memo = memo ? memo : "(null)";
+ desc = xaccTransGetDescription (trans);
+ desc = desc ? desc : "(null)";
+ PINFO ("finished saving split \"%s\" of trans \"%s\"", memo, desc);
- /* If the modified split is the "blank split", then it is now an
- * official part of the account. Set the blank split to NULL, so we
- * can be sure of getting a new blank split. Also, save the date
- * for the new blank split. */
- if (trans == blank_trans)
- {
- if (do_commit)
- {
- info->blank_split_guid = *guid_null ();
- blank_split = NULL;
- info->last_date_entered = xaccTransGetDate (trans);
- }
- else
- info->blank_split_edited = TRUE;
- }
+ /* If the modified split is the "blank split", then it is now an
+ * official part of the account. Set the blank split to NULL, so we
+ * can be sure of getting a new blank split. Also, save the date
+ * for the new blank split. */
+ if (trans == blank_trans)
+ {
+ if (do_commit)
+ {
+ info->blank_split_guid = *guid_null ();
+ blank_split = NULL;
+ info->last_date_entered = xaccTransGetDate (trans);
+ }
+ else
+ info->blank_split_edited = TRUE;
+ }
- /* If requested, commit the current transaction and set the pending
- * transaction to NULL. */
- if (do_commit)
- {
- g_assert(trans == blank_trans || trans == pending_trans);
- if (pending_trans == trans)
- {
- pending_trans = NULL;
- info->pending_trans_guid = *guid_null ();
- }
- xaccTransCommitEdit (trans);
- }
+ /* If requested, commit the current transaction and set the pending
+ * transaction to NULL. */
+ if (do_commit)
+ {
+ g_assert(trans == blank_trans || trans == pending_trans);
+ if (pending_trans == trans)
+ {
+ pending_trans = NULL;
+ info->pending_trans_guid = *guid_null ();
+ }
+ xaccTransCommitEdit (trans);
+ }
- gnc_table_clear_current_cursor_changes (reg->table);
+ gnc_table_clear_current_cursor_changes (reg->table);
- gnc_resume_gui_refresh ();
+ gnc_resume_gui_refresh ();
- LEAVE(" ");
- return TRUE;
+ LEAVE(" ");
+ return TRUE;
}
Account *
gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * bcell,
- const char *name, gboolean *refresh)
+ const char *name, gboolean *refresh)
{
- const char *placeholder = _("The account %s does not allow transactions.");
- const char *missing = _("The account %s does not exist. "
- "Would you like to create it?");
- char *account_name;
- ComboCell *cell = (ComboCell *) bcell;
- Account *account;
+ const char *placeholder = _("The account %s does not allow transactions.");
+ const char *missing = _("The account %s does not exist. "
+ "Would you like to create it?");
+ char *account_name;
+ ComboCell *cell = (ComboCell *) bcell;
+ Account *account;
- if (!name || (strlen(name) == 0))
- return NULL;
+ if (!name || (strlen(name) == 0))
+ return NULL;
- /* Find the account */
- account = gnc_account_lookup_for_register (gnc_get_current_root_account (), name);
- if (!account)
- account = gnc_account_lookup_by_code(gnc_get_current_root_account(), name);
+ /* Find the account */
+ account = gnc_account_lookup_for_register (gnc_get_current_root_account (), name);
+ if (!account)
+ account = gnc_account_lookup_by_code(gnc_get_current_root_account(), name);
- if (!account) {
- /* Ask if they want to create a new one. */
- if (!gnc_verify_dialog (gnc_split_register_get_parent (reg),
- TRUE, missing, name))
- return NULL;
-
- /* User said yes, they want to create a new account. */
- *refresh = FALSE;
- account = gnc_ui_new_accounts_from_name_window (name);
if (!account)
- return NULL;
- }
+ {
+ /* Ask if they want to create a new one. */
+ if (!gnc_verify_dialog (gnc_split_register_get_parent (reg),
+ TRUE, missing, name))
+ return NULL;
- /* Now have the account. */
- account_name = gnc_get_account_name_for_register (account);
- if (safe_strcmp(account_name, gnc_basic_cell_get_value(bcell)))
- {
- /* The name has changed. Update the cell. */
- gnc_combo_cell_set_value (cell, account_name);
- gnc_basic_cell_set_changed (&cell->cell, TRUE);
- *refresh = TRUE;
- }
- g_free (account_name);
+ /* User said yes, they want to create a new account. */
+ *refresh = FALSE;
+ account = gnc_ui_new_accounts_from_name_window (name);
+ if (!account)
+ return NULL;
+ }
- /* See if the account (either old or new) is a placeholder. */
- if (xaccAccountGetPlaceholder (account)) {
- gnc_error_dialog (gnc_split_register_get_parent (reg),
- placeholder, name);
- }
+ /* Now have the account. */
+ account_name = gnc_get_account_name_for_register (account);
+ if (safe_strcmp(account_name, gnc_basic_cell_get_value(bcell)))
+ {
+ /* The name has changed. Update the cell. */
+ gnc_combo_cell_set_value (cell, account_name);
+ gnc_basic_cell_set_changed (&cell->cell, TRUE);
+ *refresh = TRUE;
+ }
+ g_free (account_name);
- /* Be seeing you. */
- return account;
+ /* See if the account (either old or new) is a placeholder. */
+ if (xaccAccountGetPlaceholder (account))
+ {
+ gnc_error_dialog (gnc_split_register_get_parent (reg),
+ placeholder, name);
+ }
+
+ /* Be seeing you. */
+ return account;
}
Account *
gnc_split_register_get_account (SplitRegister *reg, const char * cell_name)
{
- BasicCell *cell;
- const char *name;
- gboolean dummy;
+ BasicCell *cell;
+ const char *name;
+ gboolean dummy;
- if (!gnc_table_layout_get_cell_changed (reg->table->layout, cell_name, TRUE))
- return NULL;
+ if (!gnc_table_layout_get_cell_changed (reg->table->layout, cell_name, TRUE))
+ return NULL;
- cell = gnc_table_layout_get_cell (reg->table->layout, cell_name);
- if (!cell)
- return NULL;
- name = gnc_basic_cell_get_value (cell);
- return gnc_split_register_get_account_by_name (reg, cell, name, &dummy);
+ cell = gnc_table_layout_get_cell (reg->table->layout, cell_name);
+ if (!cell)
+ return NULL;
+ name = gnc_basic_cell_get_value (cell);
+ return gnc_split_register_get_account_by_name (reg, cell, name, &dummy);
}
static gboolean
gnc_split_register_auto_calc (SplitRegister *reg, Split *split)
{
- PriceCell *cell;
- gboolean recalc_shares = FALSE;
- gboolean recalc_price = FALSE;
- gboolean recalc_value = FALSE;
- gboolean price_changed;
- gboolean amount_changed; /* please s/amount_changed/value_changed/ */
- gboolean shares_changed;
- gnc_numeric calc_value;
- gnc_numeric value;
- gnc_numeric price;
- gnc_numeric amount;
- Account *account;
- int denom;
+ PriceCell *cell;
+ gboolean recalc_shares = FALSE;
+ gboolean recalc_price = FALSE;
+ gboolean recalc_value = FALSE;
+ gboolean price_changed;
+ gboolean amount_changed; /* please s/amount_changed/value_changed/ */
+ gboolean shares_changed;
+ gnc_numeric calc_value;
+ gnc_numeric value;
+ gnc_numeric price;
+ gnc_numeric amount;
+ Account *account;
+ int denom;
- if (STOCK_REGISTER != reg->type &&
- CURRENCY_REGISTER != reg->type &&
- PORTFOLIO_LEDGER != reg->type)
- return TRUE;
+ if (STOCK_REGISTER != reg->type &&
+ CURRENCY_REGISTER != reg->type &&
+ PORTFOLIO_LEDGER != reg->type)
+ return TRUE;
- account = gnc_split_register_get_account (reg, XFRM_CELL);
+ account = gnc_split_register_get_account (reg, XFRM_CELL);
- if (!account)
- account = xaccSplitGetAccount (split);
+ if (!account)
+ account = xaccSplitGetAccount (split);
- if (!account)
- account = gnc_split_register_get_default_account (reg);
+ if (!account)
+ account = gnc_split_register_get_default_account (reg);
- if (!xaccAccountIsPriced(account))
- return TRUE;
+ if (!xaccAccountIsPriced(account))
+ return TRUE;
- price_changed = gnc_table_layout_get_cell_changed (reg->table->layout,
- PRIC_CELL, TRUE);
- amount_changed = (gnc_table_layout_get_cell_changed (reg->table->layout,
- DEBT_CELL, TRUE) ||
- gnc_table_layout_get_cell_changed (reg->table->layout,
- CRED_CELL, TRUE));
- shares_changed = gnc_table_layout_get_cell_changed (reg->table->layout,
- SHRS_CELL, TRUE);
+ price_changed = gnc_table_layout_get_cell_changed (reg->table->layout,
+ PRIC_CELL, TRUE);
+ amount_changed = (gnc_table_layout_get_cell_changed (reg->table->layout,
+ DEBT_CELL, TRUE) ||
+ gnc_table_layout_get_cell_changed (reg->table->layout,
+ CRED_CELL, TRUE));
+ shares_changed = gnc_table_layout_get_cell_changed (reg->table->layout,
+ SHRS_CELL, TRUE);
- if (!price_changed && !amount_changed && !shares_changed)
- return TRUE;
+ if (!price_changed && !amount_changed && !shares_changed)
+ return TRUE;
- /* If we are using commodity trading accounts then the value may
- not really be the value. Punt if so. */
- if (xaccTransUseTradingAccounts (xaccSplitGetParent (split))) {
- gnc_commodity *acc_commodity;
- acc_commodity = xaccAccountGetCommodity (account);
- if (! (xaccAccountIsPriced (account) ||
- !gnc_commodity_is_iso (acc_commodity)))
- return TRUE;
- }
-
- if (shares_changed)
- {
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- SHRS_CELL);
- amount = gnc_price_cell_get_value (cell);
- }
- else
- amount = xaccSplitGetAmount (split);
+ /* If we are using commodity trading accounts then the value may
+ not really be the value. Punt if so. */
+ if (xaccTransUseTradingAccounts (xaccSplitGetParent (split)))
+ {
+ gnc_commodity *acc_commodity;
+ acc_commodity = xaccAccountGetCommodity (account);
+ if (! (xaccAccountIsPriced (account) ||
+ !gnc_commodity_is_iso (acc_commodity)))
+ return TRUE;
+ }
- if (price_changed)
- {
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- PRIC_CELL);
- price = gnc_price_cell_get_value (cell);
- }
- else
- price = xaccSplitGetSharePrice (split);
+ if (shares_changed)
+ {
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ SHRS_CELL);
+ amount = gnc_price_cell_get_value (cell);
+ }
+ else
+ amount = xaccSplitGetAmount (split);
- if (amount_changed)
- {
- gnc_numeric credit;
- gnc_numeric debit;
+ if (price_changed)
+ {
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ PRIC_CELL);
+ price = gnc_price_cell_get_value (cell);
+ }
+ else
+ price = xaccSplitGetSharePrice (split);
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- CRED_CELL);
- credit = gnc_price_cell_get_value (cell);
+ if (amount_changed)
+ {
+ gnc_numeric credit;
+ gnc_numeric debit;
- cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
- DEBT_CELL);
- debit = gnc_price_cell_get_value (cell);
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ CRED_CELL);
+ credit = gnc_price_cell_get_value (cell);
- value = gnc_numeric_sub_fixed (debit, credit);
- }
- else
- value = xaccSplitGetValue (split);
+ cell = (PriceCell *) gnc_table_layout_get_cell (reg->table->layout,
+ DEBT_CELL);
+ debit = gnc_price_cell_get_value (cell);
+ value = gnc_numeric_sub_fixed (debit, credit);
+ }
+ else
+ value = xaccSplitGetValue (split);
- /* Check if shares and price are BOTH zero (and value is non-zero).
- * If so, we can assume that this is an income-correcting split
- */
- if (gnc_numeric_zero_p(amount) && gnc_numeric_zero_p(price) &&
- !gnc_numeric_zero_p(value))
- {
- /* XXX: should we ask the user? */
- return TRUE;
- }
- /* Check if precisely one value is zero. If so, we can assume that the
- * zero value needs to be recalculated. */
+ /* Check if shares and price are BOTH zero (and value is non-zero).
+ * If so, we can assume that this is an income-correcting split
+ */
+ if (gnc_numeric_zero_p(amount) && gnc_numeric_zero_p(price) &&
+ !gnc_numeric_zero_p(value))
+ {
+ /* XXX: should we ask the user? */
+ return TRUE;
+ }
- if (!gnc_numeric_zero_p (amount))
- {
- if (gnc_numeric_zero_p (price))
+ /* Check if precisely one value is zero. If so, we can assume that the
+ * zero value needs to be recalculated. */
+
+ if (!gnc_numeric_zero_p (amount))
{
- if (!gnc_numeric_zero_p (value))
- recalc_price = TRUE;
+ if (gnc_numeric_zero_p (price))
+ {
+ if (!gnc_numeric_zero_p (value))
+ recalc_price = TRUE;
+ }
+ else if (gnc_numeric_zero_p (value))
+ recalc_value = TRUE;
}
- else if (gnc_numeric_zero_p (value))
- recalc_value = TRUE;
- }
- else if (!gnc_numeric_zero_p (price))
- if (!gnc_numeric_zero_p (value))
- recalc_shares = TRUE;
+ else if (!gnc_numeric_zero_p (price))
+ if (!gnc_numeric_zero_p (value))
+ recalc_shares = TRUE;
- /* If we have not already flagged a recalc, check if this is a split
- * which has 2 of the 3 values changed. */
+ /* If we have not already flagged a recalc, check if this is a split
+ * which has 2 of the 3 values changed. */
- if((!recalc_shares) &&
- (!recalc_price) &&
- (!recalc_value))
- {
- if (price_changed && amount_changed)
+ if ((!recalc_shares) &&
+ (!recalc_price) &&
+ (!recalc_value))
{
- if (!shares_changed)
- recalc_shares = TRUE;
+ if (price_changed && amount_changed)
+ {
+ if (!shares_changed)
+ recalc_shares = TRUE;
+ }
+ else if (amount_changed && shares_changed)
+ recalc_price = TRUE;
+ else if (price_changed && shares_changed)
+ recalc_value = TRUE;
}
- else if (amount_changed && shares_changed)
- recalc_price = TRUE;
- else if (price_changed && shares_changed)
- recalc_value = TRUE;
- }
- calc_value = gnc_numeric_mul (price, amount, GNC_DENOM_AUTO, GNC_DENOM_LCD);
+ calc_value = gnc_numeric_mul (price, amount, GNC_DENOM_AUTO, GNC_DENOM_LCD);
- denom = gnc_split_get_value_denom (split);
+ denom = gnc_split_get_value_denom (split);
- /* Now, if we have not flagged one of the recalcs, and value and
- * calc_value are not the same number, then we need to ask for
- * help from the user. */
+ /* Now, if we have not flagged one of the recalcs, and value and
+ * calc_value are not the same number, then we need to ask for
+ * help from the user. */
- if (!recalc_shares &&
- !recalc_price &&
- !recalc_value &&
- !gnc_numeric_same (value, calc_value, denom, GNC_RND_ROUND))
- {
- int choice;
- int default_value;
- GList *node;
- GList *radio_list = NULL;
- const char *title = _("Recalculate Transaction");
- const char *message = _("The values entered for this transaction "
- "are inconsistent. Which value would you "
- "like to have recalculated?");
+ if (!recalc_shares &&
+ !recalc_price &&
+ !recalc_value &&
+ !gnc_numeric_same (value, calc_value, denom, GNC_RND_ROUND))
+ {
+ int choice;
+ int default_value;
+ GList *node;
+ GList *radio_list = NULL;
+ const char *title = _("Recalculate Transaction");
+ const char *message = _("The values entered for this transaction "
+ "are inconsistent. Which value would you "
+ "like to have recalculated?");
- if (shares_changed)
- radio_list = g_list_append (radio_list,
- g_strdup_printf ("%s (%s)",
- _("_Shares"), _("Changed")));
- else
- radio_list = g_list_append (radio_list, g_strdup (_("_Shares")));
+ if (shares_changed)
+ radio_list = g_list_append (radio_list,
+ g_strdup_printf ("%s (%s)",
+ _("_Shares"), _("Changed")));
+ else
+ radio_list = g_list_append (radio_list, g_strdup (_("_Shares")));
- if (price_changed)
- radio_list = g_list_append (radio_list,
- g_strdup_printf ("%s (%s)",
- _("_Price"), _("Changed")));
- else
- radio_list = g_list_append (radio_list, g_strdup (_("_Price")));
+ if (price_changed)
+ radio_list = g_list_append (radio_list,
+ g_strdup_printf ("%s (%s)",
+ _("_Price"), _("Changed")));
+ else
+ radio_list = g_list_append (radio_list, g_strdup (_("_Price")));
- if (amount_changed)
- radio_list = g_list_append (radio_list,
- g_strdup_printf ("%s (%s)",
- _("_Value"), _("Changed")));
- else
- radio_list = g_list_append (radio_list, g_strdup (_("_Value")));
+ if (amount_changed)
+ radio_list = g_list_append (radio_list,
+ g_strdup_printf ("%s (%s)",
+ _("_Value"), _("Changed")));
+ else
+ radio_list = g_list_append (radio_list, g_strdup (_("_Value")));
- if (price_changed) default_value = 2; /* change the value */
- else default_value = 1; /* change the value */
+ if (price_changed) default_value = 2; /* change the value */
+ else default_value = 1; /* change the value */
- choice = gnc_choose_radio_option_dialog
- (gnc_split_register_get_parent (reg),
- title,
- message,
- _("_Recalculate"),
- default_value,
- radio_list);
+ choice = gnc_choose_radio_option_dialog
+ (gnc_split_register_get_parent (reg),
+ title,
+ message,
+ _("_Recalculate"),
+ default_value,
+ radio_list);
- for (node = radio_list; node; node = node->next)
- g_free (node->data);
+ for (node = radio_list; node; node = node->next)
+ g_free (node->data);
- g_list_free (radio_list);
+ g_list_free (radio_list);
- switch (choice)
- {
- case 0: /* Modify number of shares */
- recalc_shares = TRUE;
- break;
- case 1: /* Modify the share price */
- recalc_price = TRUE;
- break;
- case 2: /* Modify total value */
- recalc_value = TRUE;
- break;
- default: /* Cancel */
- return FALSE;
+ switch (choice)
+ {
+ case 0: /* Modify number of shares */
+ recalc_shares = TRUE;
+ break;
+ case 1: /* Modify the share price */
+ recalc_price = TRUE;
+ break;
+ case 2: /* Modify total value */
+ recalc_value = TRUE;
+ break;
+ default: /* Cancel */
+ return FALSE;
+ }
}
- }
- if (recalc_shares)
- if (!gnc_numeric_zero_p (price))
- {
- BasicCell *cell;
+ if (recalc_shares)
+ if (!gnc_numeric_zero_p (price))
+ {
+ BasicCell *cell;
- denom = gnc_split_get_amount_denom (split);
+ denom = gnc_split_get_amount_denom (split);
- amount = gnc_numeric_div (value, price, denom, GNC_RND_ROUND);
+ amount = gnc_numeric_div (value, price, denom, GNC_RND_ROUND);
- cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
- gnc_price_cell_set_value ((PriceCell *) cell, amount);
- gnc_basic_cell_set_changed (cell, TRUE);
+ cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
+ gnc_price_cell_set_value ((PriceCell *) cell, amount);
+ gnc_basic_cell_set_changed (cell, TRUE);
- if (amount_changed)
- {
- cell = gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL);
- gnc_basic_cell_set_changed (cell, FALSE);
- }
- }
+ if (amount_changed)
+ {
+ cell = gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL);
+ gnc_basic_cell_set_changed (cell, FALSE);
+ }
+ }
- if (recalc_price)
- if (!gnc_numeric_zero_p (amount))
- {
- BasicCell *price_cell;
+ if (recalc_price)
+ if (!gnc_numeric_zero_p (amount))
+ {
+ BasicCell *price_cell;
- price = gnc_numeric_div (value, amount,
- GNC_DENOM_AUTO,
- GNC_DENOM_EXACT);
+ price = gnc_numeric_div (value, amount,
+ GNC_DENOM_AUTO,
+ GNC_DENOM_EXACT);
- if (gnc_numeric_negative_p (price))
- {
- BasicCell *debit_cell;
- BasicCell *credit_cell;
+ if (gnc_numeric_negative_p (price))
+ {
+ BasicCell *debit_cell;
+ BasicCell *credit_cell;
- debit_cell = gnc_table_layout_get_cell (reg->table->layout,
- DEBT_CELL);
+ debit_cell = gnc_table_layout_get_cell (reg->table->layout,
+ DEBT_CELL);
- credit_cell = gnc_table_layout_get_cell (reg->table->layout,
- CRED_CELL);
+ credit_cell = gnc_table_layout_get_cell (reg->table->layout,
+ CRED_CELL);
- price = gnc_numeric_neg (price);
+ price = gnc_numeric_neg (price);
- gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell,
- (PriceCell *) credit_cell,
- gnc_numeric_neg (value));
+ gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell,
+ (PriceCell *) credit_cell,
+ gnc_numeric_neg (value));
- gnc_basic_cell_set_changed (debit_cell, TRUE);
- gnc_basic_cell_set_changed (credit_cell, TRUE);
- }
+ gnc_basic_cell_set_changed (debit_cell, TRUE);
+ gnc_basic_cell_set_changed (credit_cell, TRUE);
+ }
- price_cell = gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL);
- gnc_price_cell_set_value ((PriceCell *) price_cell, price);
- gnc_basic_cell_set_changed (price_cell, TRUE);
- }
+ price_cell = gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL);
+ gnc_price_cell_set_value ((PriceCell *) price_cell, price);
+ gnc_basic_cell_set_changed (price_cell, TRUE);
+ }
- if (recalc_value)
- {
- BasicCell *debit_cell;
- BasicCell *credit_cell;
+ if (recalc_value)
+ {
+ BasicCell *debit_cell;
+ BasicCell *credit_cell;
- debit_cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL);
- credit_cell = gnc_table_layout_get_cell (reg->table->layout, CRED_CELL);
+ debit_cell = gnc_table_layout_get_cell (reg->table->layout, DEBT_CELL);
+ credit_cell = gnc_table_layout_get_cell (reg->table->layout, CRED_CELL);
- denom = gnc_split_get_value_denom (split);
+ denom = gnc_split_get_value_denom (split);
- value = gnc_numeric_mul (price, amount, denom, GNC_RND_ROUND);
+ value = gnc_numeric_mul (price, amount, denom, GNC_RND_ROUND);
- gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell,
- (PriceCell *) credit_cell, value);
+ gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell,
+ (PriceCell *) credit_cell, value);
- gnc_basic_cell_set_changed (debit_cell, TRUE);
- gnc_basic_cell_set_changed (credit_cell, TRUE);
+ gnc_basic_cell_set_changed (debit_cell, TRUE);
+ gnc_basic_cell_set_changed (credit_cell, TRUE);
- if (shares_changed)
- {
- BasicCell *cell;
+ if (shares_changed)
+ {
+ BasicCell *cell;
- cell = gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL);
- gnc_basic_cell_set_changed (cell, FALSE);
+ cell = gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL);
+ gnc_basic_cell_set_changed (cell, FALSE);
+ }
}
- }
- return TRUE;
+ return TRUE;
}
static GNCAccountType
gnc_split_register_type_to_account_type (SplitRegisterType sr_type)
{
- switch (sr_type)
- {
+ switch (sr_type)
+ {
case BANK_REGISTER:
- return ACCT_TYPE_BANK;
+ return ACCT_TYPE_BANK;
case CASH_REGISTER:
- return ACCT_TYPE_CASH;
+ return ACCT_TYPE_CASH;
case ASSET_REGISTER:
- return ACCT_TYPE_ASSET;
+ return ACCT_TYPE_ASSET;
case CREDIT_REGISTER:
- return ACCT_TYPE_CREDIT;
+ return ACCT_TYPE_CREDIT;
case LIABILITY_REGISTER:
- return ACCT_TYPE_LIABILITY;
+ return ACCT_TYPE_LIABILITY;
case PAYABLE_REGISTER:
- return ACCT_TYPE_PAYABLE;
+ return ACCT_TYPE_PAYABLE;
case RECEIVABLE_REGISTER:
- return ACCT_TYPE_RECEIVABLE;
- case INCOME_LEDGER:
+ return ACCT_TYPE_RECEIVABLE;
+ case INCOME_LEDGER:
case INCOME_REGISTER:
- return ACCT_TYPE_INCOME;
+ return ACCT_TYPE_INCOME;
case EXPENSE_REGISTER:
- return ACCT_TYPE_EXPENSE;
+ return ACCT_TYPE_EXPENSE;
case STOCK_REGISTER:
case PORTFOLIO_LEDGER:
- return ACCT_TYPE_STOCK;
+ return ACCT_TYPE_STOCK;
case CURRENCY_REGISTER:
- return ACCT_TYPE_CURRENCY;
+ return ACCT_TYPE_CURRENCY;
case TRADING_REGISTER:
- return ACCT_TYPE_TRADING;
- case GENERAL_LEDGER:
- return ACCT_TYPE_NONE;
+ return ACCT_TYPE_TRADING;
+ case GENERAL_LEDGER:
+ return ACCT_TYPE_NONE;
case EQUITY_REGISTER:
- return ACCT_TYPE_EQUITY;
+ return ACCT_TYPE_EQUITY;
case SEARCH_LEDGER:
- return ACCT_TYPE_NONE;
+ return ACCT_TYPE_NONE;
default:
- return ACCT_TYPE_NONE;
- }
+ return ACCT_TYPE_NONE;
+ }
}
const char *
gnc_split_register_get_debit_string (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (!reg)
- return NULL;
+ if (!reg)
+ return NULL;
- if (info->debit_str)
- return info->debit_str;
+ if (info->debit_str)
+ return info->debit_str;
- info->debit_str =
- gnc_get_debit_string
- (gnc_split_register_type_to_account_type (reg->type));
+ info->debit_str =
+ gnc_get_debit_string
+ (gnc_split_register_type_to_account_type (reg->type));
- if (info->debit_str)
- return info->debit_str;
+ if (info->debit_str)
+ return info->debit_str;
- info->debit_str = g_strdup (_("Debit"));
+ info->debit_str = g_strdup (_("Debit"));
- return info->debit_str;
+ return info->debit_str;
}
const char *
gnc_split_register_get_credit_string (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (!reg)
- return NULL;
+ if (!reg)
+ return NULL;
- if (info->credit_str)
- return info->credit_str;
+ if (info->credit_str)
+ return info->credit_str;
- info->credit_str =
- gnc_get_credit_string
- (gnc_split_register_type_to_account_type (reg->type));
+ info->credit_str =
+ gnc_get_credit_string
+ (gnc_split_register_type_to_account_type (reg->type));
- if (info->credit_str)
- return info->credit_str;
+ if (info->credit_str)
+ return info->credit_str;
- info->credit_str = g_strdup (_("Credit"));
+ info->credit_str = g_strdup (_("Credit"));
- return info->credit_str;
+ return info->credit_str;
}
gboolean
gnc_split_register_changed (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
- ENTER("reg=%p", reg);
+ ENTER("reg=%p", reg);
- if (reg == NULL)
- {
- LEAVE("no register");
- return FALSE;
- }
+ if (reg == NULL)
+ {
+ LEAVE("no register");
+ return FALSE;
+ }
- if (gnc_table_current_cursor_changed (reg->table, FALSE))
- {
- LEAVE("cursor changed");
- return TRUE;
- }
+ if (gnc_table_current_cursor_changed (reg->table, FALSE))
+ {
+ LEAVE("cursor changed");
+ return TRUE;
+ }
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
- gnc_get_current_book ());
- if (xaccTransIsOpen (pending_trans))
- {
- LEAVE("open and pending txn");
- return TRUE;
- }
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
+ if (xaccTransIsOpen (pending_trans))
+ {
+ LEAVE("open and pending txn");
+ return TRUE;
+ }
- LEAVE("register unchanged");
- return FALSE;
+ LEAVE("register unchanged");
+ return FALSE;
}
void
gnc_split_register_show_present_divider (SplitRegister *reg,
- gboolean show_present)
+ gboolean show_present)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (reg == NULL)
- return;
+ if (reg == NULL)
+ return;
- info->show_present_divider = show_present;
+ info->show_present_divider = show_present;
}
gboolean
gnc_split_register_full_refresh_ok (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- if (!info)
- return FALSE;
+ if (!info)
+ return FALSE;
- return info->full_refresh;
+ return info->full_refresh;
}
/* configAction strings into the action cell */
@@ -2182,229 +2215,234 @@
static void
gnc_split_register_config_action (SplitRegister *reg)
{
- ComboCell *cell;
+ ComboCell *cell;
- cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout,
- ACTN_CELL);
+ cell = (ComboCell *) gnc_table_layout_get_cell (reg->table->layout,
+ ACTN_CELL);
- /* setup strings in the action pull-down */
- switch (reg->type)
- {
+ /* setup strings in the action pull-down */
+ switch (reg->type)
+ {
case BANK_REGISTER:
- /* broken ! FIXME bg */
+ /* broken ! FIXME bg */
case SEARCH_LEDGER:
- /* Translators: This string has a context prefix; the translation
- must only contain the part after the | character. */
- gnc_combo_cell_add_menu_item (cell, Q_("Action Column|Deposit"));
- gnc_combo_cell_add_menu_item (cell, _("Withdraw"));
- gnc_combo_cell_add_menu_item (cell, _("Check"));
- gnc_combo_cell_add_menu_item (cell, _("Interest"));
- gnc_combo_cell_add_menu_item (cell, _("ATM Deposit"));
- gnc_combo_cell_add_menu_item (cell, _("ATM Draw"));
- gnc_combo_cell_add_menu_item (cell, _("Teller"));
- gnc_combo_cell_add_menu_item (cell, _("Charge"));
- gnc_combo_cell_add_menu_item (cell, _("Payment"));
- gnc_combo_cell_add_menu_item (cell, _("Receipt"));
- gnc_combo_cell_add_menu_item (cell, _("Increase"));
- gnc_combo_cell_add_menu_item (cell, _("Decrease"));
- /* Action: Point Of Sale */
- gnc_combo_cell_add_menu_item (cell, _("POS"));
- gnc_combo_cell_add_menu_item (cell, _("Phone"));
- gnc_combo_cell_add_menu_item (cell, _("Online"));
- /* Action: Automatic Deposit ?!? */
- gnc_combo_cell_add_menu_item (cell, _("AutoDep"));
- gnc_combo_cell_add_menu_item (cell, _("Wire"));
- gnc_combo_cell_add_menu_item (cell, _("Credit"));
- gnc_combo_cell_add_menu_item (cell, _("Direct Debit"));
- gnc_combo_cell_add_menu_item (cell, _("Transfer"));
- break;
+ /* Translators: This string has a context prefix; the translation
+ must only contain the part after the | character. */
+ gnc_combo_cell_add_menu_item (cell, Q_("Action Column|Deposit"));
+ gnc_combo_cell_add_menu_item (cell, _("Withdraw"));
+ gnc_combo_cell_add_menu_item (cell, _("Check"));
+ gnc_combo_cell_add_menu_item (cell, _("Interest"));
+ gnc_combo_cell_add_menu_item (cell, _("ATM Deposit"));
+ gnc_combo_cell_add_menu_item (cell, _("ATM Draw"));
+ gnc_combo_cell_add_menu_item (cell, _("Teller"));
+ gnc_combo_cell_add_menu_item (cell, _("Charge"));
+ gnc_combo_cell_add_menu_item (cell, _("Payment"));
+ gnc_combo_cell_add_menu_item (cell, _("Receipt"));
+ gnc_combo_cell_add_menu_item (cell, _("Increase"));
+ gnc_combo_cell_add_menu_item (cell, _("Decrease"));
+ /* Action: Point Of Sale */
+ gnc_combo_cell_add_menu_item (cell, _("POS"));
+ gnc_combo_cell_add_menu_item (cell, _("Phone"));
+ gnc_combo_cell_add_menu_item (cell, _("Online"));
+ /* Action: Automatic Deposit ?!? */
+ gnc_combo_cell_add_menu_item (cell, _("AutoDep"));
+ gnc_combo_cell_add_menu_item (cell, _("Wire"));
+ gnc_combo_cell_add_menu_item (cell, _("Credit"));
+ gnc_combo_cell_add_menu_item (cell, _("Direct Debit"));
+ gnc_combo_cell_add_menu_item (cell, _("Transfer"));
+ break;
case CASH_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("Increase"));
- gnc_combo_cell_add_menu_item (cell, _("Decrease"));
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("Increase"));
+ gnc_combo_cell_add_menu_item (cell, _("Decrease"));
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ break;
case ASSET_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- gnc_combo_cell_add_menu_item (cell, _("Fee"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ gnc_combo_cell_add_menu_item (cell, _("Fee"));
+ break;
case CREDIT_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("ATM Deposit"));
- gnc_combo_cell_add_menu_item (cell, _("ATM Draw"));
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Credit"));
- gnc_combo_cell_add_menu_item (cell, _("Fee"));
- gnc_combo_cell_add_menu_item (cell, _("Interest"));
- gnc_combo_cell_add_menu_item (cell, _("Online"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("ATM Deposit"));
+ gnc_combo_cell_add_menu_item (cell, _("ATM Draw"));
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Credit"));
+ gnc_combo_cell_add_menu_item (cell, _("Fee"));
+ gnc_combo_cell_add_menu_item (cell, _("Interest"));
+ gnc_combo_cell_add_menu_item (cell, _("Online"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ break;
case LIABILITY_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- gnc_combo_cell_add_menu_item (cell, _("Loan"));
- gnc_combo_cell_add_menu_item (cell, _("Interest"));
- gnc_combo_cell_add_menu_item (cell, _("Payment"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ gnc_combo_cell_add_menu_item (cell, _("Loan"));
+ gnc_combo_cell_add_menu_item (cell, _("Interest"));
+ gnc_combo_cell_add_menu_item (cell, _("Payment"));
+ break;
case RECEIVABLE_REGISTER:
case PAYABLE_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("Invoice"));
- gnc_combo_cell_add_menu_item (cell, _("Payment"));
- gnc_combo_cell_add_menu_item (cell, _("Interest"));
- gnc_combo_cell_add_menu_item (cell, _("Credit"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("Invoice"));
+ gnc_combo_cell_add_menu_item (cell, _("Payment"));
+ gnc_combo_cell_add_menu_item (cell, _("Interest"));
+ gnc_combo_cell_add_menu_item (cell, _("Credit"));
+ break;
case INCOME_LEDGER:
case INCOME_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("Increase"));
- gnc_combo_cell_add_menu_item (cell, _("Decrease"));
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- gnc_combo_cell_add_menu_item (cell, _("Interest"));
- gnc_combo_cell_add_menu_item (cell, _("Payment"));
- gnc_combo_cell_add_menu_item (cell, _("Rebate"));
- gnc_combo_cell_add_menu_item (cell, _("Paycheck"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("Increase"));
+ gnc_combo_cell_add_menu_item (cell, _("Decrease"));
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ gnc_combo_cell_add_menu_item (cell, _("Interest"));
+ gnc_combo_cell_add_menu_item (cell, _("Payment"));
+ gnc_combo_cell_add_menu_item (cell, _("Rebate"));
+ gnc_combo_cell_add_menu_item (cell, _("Paycheck"));
+ break;
case EXPENSE_REGISTER:
case TRADING_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("Increase"));
- gnc_combo_cell_add_menu_item (cell, _("Decrease"));
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("Increase"));
+ gnc_combo_cell_add_menu_item (cell, _("Decrease"));
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ break;
case GENERAL_LEDGER:
case EQUITY_REGISTER:
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- gnc_combo_cell_add_menu_item (cell, _("Equity"));
- break;
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ gnc_combo_cell_add_menu_item (cell, _("Equity"));
+ break;
case STOCK_REGISTER:
case PORTFOLIO_LEDGER:
case CURRENCY_REGISTER:
- gnc_combo_cell_add_menu_item (cell, ACTION_BUY_STR);
- gnc_combo_cell_add_menu_item (cell, ACTION_SELL_STR);
- gnc_combo_cell_add_menu_item (cell, _("Price"));
- gnc_combo_cell_add_menu_item (cell, _("Fee"));
- /* Action: Dividend */
- gnc_combo_cell_add_menu_item (cell, _("Dividend"));
- gnc_combo_cell_add_menu_item (cell, _("Interest"));
- /* Action: Long Term Capital Gains */
- gnc_combo_cell_add_menu_item (cell, _("LTCG"));
- /* Action: Short Term Capital Gains */
- gnc_combo_cell_add_menu_item (cell, _("STCG"));
- gnc_combo_cell_add_menu_item (cell, _("Income"));
- /* Action: Distribution */
- gnc_combo_cell_add_menu_item (cell, _("Dist"));
- /* Translators: This string has a disambiguation prefix */
- gnc_combo_cell_add_menu_item (cell, Q_("Action Column|Split"));
- break;
+ gnc_combo_cell_add_menu_item (cell, ACTION_BUY_STR);
+ gnc_combo_cell_add_menu_item (cell, ACTION_SELL_STR);
+ gnc_combo_cell_add_menu_item (cell, _("Price"));
+ gnc_combo_cell_add_menu_item (cell, _("Fee"));
+ /* Action: Dividend */
+ gnc_combo_cell_add_menu_item (cell, _("Dividend"));
+ gnc_combo_cell_add_menu_item (cell, _("Interest"));
+ /* Action: Long Term Capital Gains */
+ gnc_combo_cell_add_menu_item (cell, _("LTCG"));
+ /* Action: Short Term Capital Gains */
+ gnc_combo_cell_add_menu_item (cell, _("STCG"));
+ gnc_combo_cell_add_menu_item (cell, _("Income"));
+ /* Action: Distribution */
+ gnc_combo_cell_add_menu_item (cell, _("Dist"));
+ /* Translators: This string has a disambiguation prefix */
+ gnc_combo_cell_add_menu_item (cell, Q_("Action Column|Split"));
+ break;
default:
- gnc_combo_cell_add_menu_item (cell, _("Increase"));
- gnc_combo_cell_add_menu_item (cell, _("Decrease"));
- gnc_combo_cell_add_menu_item (cell, _("Buy"));
- gnc_combo_cell_add_menu_item (cell, _("Sell"));
- break;
- }
+ gnc_combo_cell_add_menu_item (cell, _("Increase"));
+ gnc_combo_cell_add_menu_item (cell, _("Decrease"));
+ gnc_combo_cell_add_menu_item (cell, _("Buy"));
+ gnc_combo_cell_add_menu_item (cell, _("Sell"));
+ break;
+ }
}
static void
gnc_split_register_config_cells (SplitRegister *reg)
{
- gnc_combo_cell_add_ignore_string
+ gnc_combo_cell_add_ignore_string
((ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL),
SPLIT_TRANS_STR);
- gnc_combo_cell_add_ignore_string
+ gnc_combo_cell_add_ignore_string
((ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL),
STOCK_SPLIT_STR);
- /* the action cell */
- gnc_combo_cell_set_autosize
+ /* the action cell */
+ gnc_combo_cell_set_autosize
((ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), TRUE);
- /* Use 6 decimal places for prices and "exchange rates" */
- gnc_price_cell_set_fraction
+ /* Use 6 decimal places for prices and "exchange rates" */
+ gnc_price_cell_set_fraction
((PriceCell *)
gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL), 1000000);
- /* Initialize shares and share balance cells */
- gnc_price_cell_set_print_info
+ /* Initialize shares and share balance cells */
+ gnc_price_cell_set_print_info
((PriceCell *) gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL),
gnc_default_share_print_info ());
- gnc_price_cell_set_print_info
+ gnc_price_cell_set_print_info
((PriceCell *) gnc_table_layout_get_cell (reg->table->layout, TSHRS_CELL),
gnc_default_share_print_info ());
- /* Initialize the rate cell
- * use a share_print_info to make sure we don't have rounding errors
- */
- gnc_price_cell_set_print_info
+ /* Initialize the rate cell
+ * use a share_print_info to make sure we don't have rounding errors
+ */
+ gnc_price_cell_set_print_info
((PriceCell *) gnc_table_layout_get_cell (reg->table->layout, RATE_CELL),
gnc_default_share_print_info());
- /* The action cell should accept strings not in the list */
- gnc_combo_cell_set_strict
+ /* The action cell should accept strings not in the list */
+ gnc_combo_cell_set_strict
((ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), FALSE);
- /* number format for share quantities in stock ledgers */
- switch (reg->type)
- {
+ /* number format for share quantities in stock ledgers */
+ switch (reg->type)
+ {
case CURRENCY_REGISTER:
case STOCK_REGISTER:
case PORTFOLIO_LEDGER:
- gnc_price_cell_set_print_info
+ gnc_price_cell_set_print_info
((PriceCell *)
gnc_table_layout_get_cell (reg->table->layout, PRIC_CELL),
gnc_default_price_print_info ());
- break;
+ break;
default:
- break;
- }
+ break;
+ }
- /* add menu items for the action cell */
- gnc_split_register_config_action (reg);
+ /* add menu items for the action cell */
+ gnc_split_register_config_action (reg);
}
static void
split_register_gconf_changed (GConfEntry *entry, gpointer user_data)
{
- SplitRegister * reg = user_data;
- SRInfo *info;
+ SplitRegister * reg = user_data;
+ SRInfo *info;
- g_return_if_fail(entry && entry->key);
- if (reg == NULL)
- return;
+ g_return_if_fail(entry && entry->key);
+ if (reg == NULL)
+ return;
- info = reg->sr_info;
- if (!info)
- return;
+ info = reg->sr_info;
+ if (!info)
+ return;
- if (g_str_has_suffix(entry->key, KEY_ACCOUNTING_LABELS)) {
- /* Release current strings. Will be reloaded at next reference. */
- g_free (info->debit_str);
- g_free (info->tdebit_str);
- g_free (info->credit_str);
- g_free (info->tcredit_str);
+ if (g_str_has_suffix(entry->key, KEY_ACCOUNTING_LABELS))
+ {
+ /* Release current strings. Will be reloaded at next reference. */
+ g_free (info->debit_str);
+ g_free (info->tdebit_str);
+ g_free (info->credit_str);
+ g_free (info->tcredit_str);
- info->debit_str = NULL;
- info->tdebit_str = NULL;
- info->credit_str = NULL;
- info->tcredit_str = NULL;
+ info->debit_str = NULL;
+ info->tdebit_str = NULL;
+ info->credit_str = NULL;
+ info->tcredit_str = NULL;
- } else if (g_str_has_suffix(entry->key, KEY_ACCOUNT_SEPARATOR)) {
- info->separator_changed = TRUE;
- } else {
- g_warning("split_register_gconf_changed: Unknown gconf key %s", entry->key);
- }
+ }
+ else if (g_str_has_suffix(entry->key, KEY_ACCOUNT_SEPARATOR))
+ {
+ info->separator_changed = TRUE;
+ }
+ else
+ {
+ g_warning("split_register_gconf_changed: Unknown gconf key %s", entry->key);
+ }
}
-static void
+static void
gnc_split_register_init (SplitRegister *reg,
SplitRegisterType type,
SplitRegisterStyle style,
@@ -2412,73 +2450,73 @@
gboolean do_auto_complete,
gboolean is_template)
{
- TableLayout *layout;
- TableModel *model;
- TableControl *control;
+ TableLayout *layout;
+ TableModel *model;
+ TableControl *control;
- /* Register 'destroy' callback */
- gnc_gconf_general_register_cb(KEY_ACCOUNTING_LABELS,
- split_register_gconf_changed,
- reg);
- gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
- split_register_gconf_changed,
- reg);
+ /* Register 'destroy' callback */
+ gnc_gconf_general_register_cb(KEY_ACCOUNTING_LABELS,
+ split_register_gconf_changed,
+ reg);
+ gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
+ split_register_gconf_changed,
+ reg);
- reg->sr_info = NULL;
+ reg->sr_info = NULL;
- reg->type = type;
- reg->style = style;
- reg->use_double_line = use_double_line;
- reg->do_auto_complete = do_auto_complete;
- reg->is_template = is_template;
+ reg->type = type;
+ reg->style = style;
+ reg->use_double_line = use_double_line;
+ reg->do_auto_complete = do_auto_complete;
+ reg->is_template = is_template;
- layout = gnc_split_register_layout_new (reg);
+ layout = gnc_split_register_layout_new (reg);
- if (is_template)
- model = gnc_template_register_model_new ();
- else
- model = gnc_split_register_model_new ();
- model->handler_user_data = reg;
+ if (is_template)
+ model = gnc_template_register_model_new ();
+ else
+ model = gnc_split_register_model_new ();
+ model->handler_user_data = reg;
- control = gnc_split_register_control_new ();
- control->user_data = reg;
+ control = gnc_split_register_control_new ();
+ control->user_data = reg;
- reg->table = gnc_table_new (layout, model, control);
+ reg->table = gnc_table_new (layout, model, control);
- gnc_split_register_config_cells (reg);
+ gnc_split_register_config_cells (reg);
- /* Set up header */
- {
- VirtualCellLocation vcell_loc = { 0, 0 };
- CellBlock *header;
+ /* Set up header */
+ {
+ VirtualCellLocation vcell_loc = { 0, 0 };
+ CellBlock *header;
- header = gnc_table_layout_get_cursor (reg->table->layout, CURSOR_HEADER);
+ header = gnc_table_layout_get_cursor (reg->table->layout, CURSOR_HEADER);
- gnc_table_set_vcell (reg->table, header, NULL, TRUE, TRUE, vcell_loc);
- }
+ gnc_table_set_vcell (reg->table, header, NULL, TRUE, TRUE, vcell_loc);
+ }
- /* Set up first and only initial row */
- {
- VirtualLocation vloc;
- CellBlock *cursor;
+ /* Set up first and only initial row */
+ {
+ VirtualLocation vloc;
+ CellBlock *cursor;
- vloc.vcell_loc.virt_row = 1;
- vloc.vcell_loc.virt_col = 0;
- vloc.phys_row_offset = 0;
- vloc.phys_col_offset = 0;
+ vloc.vcell_loc.virt_row = 1;
+ vloc.vcell_loc.virt_col = 0;
+ vloc.phys_row_offset = 0;
+ vloc.phys_col_offset = 0;
- cursor = gnc_table_layout_get_cursor (reg->table->layout,
- CURSOR_SINGLE_LEDGER);
+ cursor = gnc_table_layout_get_cursor (reg->table->layout,
+ CURSOR_SINGLE_LEDGER);
- gnc_table_set_vcell (reg->table, cursor, NULL, TRUE, TRUE, vloc.vcell_loc);
+ gnc_table_set_vcell (reg->table, cursor, NULL, TRUE, TRUE, vloc.vcell_loc);
- if (gnc_table_find_close_valid_cell (reg->table, &vloc, FALSE))
- gnc_table_move_cursor (reg->table, vloc);
- else
- {
- PERR ("Can't find valid initial location");
+ if (gnc_table_find_close_valid_cell (reg->table, &vloc, FALSE))
+ gnc_table_move_cursor (reg->table, vloc);
+ else
+ {
+ PERR ("Can't find valid initial location");
+ }
}
- }
}
SplitRegister *
@@ -2487,22 +2525,22 @@
gboolean use_double_line,
gboolean is_template)
{
- SplitRegister * reg;
- gboolean default_do_auto_complete = TRUE;
+ SplitRegister * reg;
+ gboolean default_do_auto_complete = TRUE;
- reg = g_new0 (SplitRegister, 1);
+ reg = g_new0 (SplitRegister, 1);
- if (type >= NUM_SINGLE_REGISTER_TYPES)
- style = REG_STYLE_JOURNAL;
+ if (type >= NUM_SINGLE_REGISTER_TYPES)
+ style = REG_STYLE_JOURNAL;
- gnc_split_register_init (reg,
- type,
- style,
- use_double_line,
- default_do_auto_complete,
- is_template);
+ gnc_split_register_init (reg,
+ type,
+ style,
+ use_double_line,
+ default_do_auto_complete,
+ is_template);
- return reg;
+ return reg;
}
void
@@ -2511,179 +2549,184 @@
SplitRegisterStyle newstyle,
gboolean use_double_line)
{
- if (!reg) return;
+ if (!reg) return;
- /* If shrinking the transaction split, put the cursor on the first row of the trans */
- if (reg->use_double_line && !use_double_line) {
- VirtualLocation virt_loc = reg->table->current_cursor_loc;
- if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE)) {
- if (virt_loc.phys_row_offset) {
- gnc_table_move_vertical_position (reg->table, &virt_loc, -virt_loc.phys_row_offset);
- gnc_table_move_cursor_gui (reg->table, virt_loc);
- }
- } else {
- /* WTF? Go to a known safe location. */
- virt_loc.vcell_loc.virt_row = 1;
- virt_loc.vcell_loc.virt_col = 0;
- virt_loc.phys_row_offset = 0;
- virt_loc.phys_col_offset = 0;
- gnc_table_move_cursor_gui (reg->table, virt_loc);
+ /* If shrinking the transaction split, put the cursor on the first row of the trans */
+ if (reg->use_double_line && !use_double_line)
+ {
+ VirtualLocation virt_loc = reg->table->current_cursor_loc;
+ if (gnc_table_find_close_valid_cell (reg->table, &virt_loc, FALSE))
+ {
+ if (virt_loc.phys_row_offset)
+ {
+ gnc_table_move_vertical_position (reg->table, &virt_loc, -virt_loc.phys_row_offset);
+ gnc_table_move_cursor_gui (reg->table, virt_loc);
+ }
+ }
+ else
+ {
+ /* WTF? Go to a known safe location. */
+ virt_loc.vcell_loc.virt_row = 1;
+ virt_loc.vcell_loc.virt_col = 0;
+ virt_loc.phys_row_offset = 0;
+ virt_loc.phys_col_offset = 0;
+ gnc_table_move_cursor_gui (reg->table, virt_loc);
+ }
}
- }
- reg->type = newtype;
+ reg->type = newtype;
- if (reg->type >= NUM_SINGLE_REGISTER_TYPES)
- newstyle = REG_STYLE_JOURNAL;
+ if (reg->type >= NUM_SINGLE_REGISTER_TYPES)
+ newstyle = REG_STYLE_JOURNAL;
- reg->style = newstyle;
- reg->use_double_line = use_double_line;
+ reg->style = newstyle;
+ reg->use_double_line = use_double_line;
- gnc_table_realize_gui (reg->table);
+ gnc_table_realize_gui (reg->table);
}
void
gnc_split_register_set_auto_complete(SplitRegister *reg,
gboolean do_auto_complete)
{
- g_return_if_fail(reg);
- reg->do_auto_complete = do_auto_complete;
+ g_return_if_fail(reg);
+ reg->do_auto_complete = do_auto_complete;
}
static void
gnc_split_register_destroy_info (SplitRegister *reg)
{
- SRInfo *info;
+ SRInfo *info;
- if (reg == NULL)
- return;
+ if (reg == NULL)
+ return;
- info = reg->sr_info;
- if (!info)
- return;
+ info = reg->sr_info;
+ if (!info)
+ return;
- g_free (info->debit_str);
- g_free (info->tdebit_str);
- g_free (info->credit_str);
- g_free (info->tcredit_str);
+ g_free (info->debit_str);
+ g_free (info->tdebit_str);
+ g_free (info->credit_str);
+ g_free (info->tcredit_str);
- info->debit_str = NULL;
- info->tdebit_str = NULL;
- info->credit_str = NULL;
- info->tcredit_str = NULL;
+ info->debit_str = NULL;
+ info->tdebit_str = NULL;
+ info->credit_str = NULL;
+ info->tcredit_str = NULL;
- g_free (reg->sr_info);
+ g_free (reg->sr_info);
- reg->sr_info = NULL;
+ reg->sr_info = NULL;
}
void
gnc_split_register_set_data (SplitRegister *reg, void *user_data,
SRGetParentCallback get_parent)
{
- SRInfo *info = gnc_split_register_get_info (reg);
+ SRInfo *info = gnc_split_register_get_info (reg);
- g_return_if_fail (reg != NULL);
+ g_return_if_fail (reg != NULL);
- info->user_data = user_data;
- info->get_parent = get_parent;
+ info->user_data = user_data;
+ info->get_parent = get_parent;
}
static void
gnc_split_register_cleanup (SplitRegister *reg)
{
- SRInfo *info = gnc_split_register_get_info (reg);
- Transaction *pending_trans;
- Transaction *blank_trans = NULL;
- Split *blank_split;
+ SRInfo *info = gnc_split_register_get_info (reg);
+ Transaction *pending_trans;
+ Transaction *blank_trans = NULL;
+ Split *blank_split;
- ENTER("reg=%p", reg);
+ ENTER("reg=%p", reg);
- blank_split = xaccSplitLookup (&info->blank_split_guid,
- gnc_get_current_book ());
+ blank_split = xaccSplitLookup (&info->blank_split_guid,
+ gnc_get_current_book ());
- pending_trans = xaccTransLookup (&info->pending_trans_guid,
- gnc_get_current_book ());
+ pending_trans = xaccTransLookup (&info->pending_trans_guid,
+ gnc_get_current_book ());
- gnc_suspend_gui_refresh ();
+ gnc_suspend_gui_refresh ();
- /* Destroy the transaction containing the "blank split", which was only
- * created to support the area for entering a new transaction. Since the
- * register is closing, this transaction is no longer needed. */
- if (blank_split != NULL)
- {
- gboolean was_open;
+ /* Destroy the transaction containing the "blank split", which was only
+ * created to support the area for entering a new transaction. Since the
+ * register is closing, this transaction is no longer needed. */
+ if (blank_split != NULL)
+ {
+ gboolean was_open;
- blank_trans = xaccSplitGetParent (blank_split);
+ blank_trans = xaccSplitGetParent (blank_split);
- DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p",
- blank_split, blank_trans, pending_trans);
+ DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p",
+ blank_split, blank_trans, pending_trans);
- /* Destroying the transaction will automatically remove its splits. */
- was_open = xaccTransIsOpen (blank_trans);
- xaccTransDestroy (blank_trans);
- if (was_open)
- xaccTransCommitEdit (blank_trans);
+ /* Destroying the transaction will automatically remove its splits. */
+ was_open = xaccTransIsOpen (blank_trans);
+ xaccTransDestroy (blank_trans);
+ if (was_open)
+ xaccTransCommitEdit (blank_trans);
- /* Update the register info. */
- if (blank_trans == pending_trans)
- {
+ /* Update the register info. */
+ if (blank_trans == pending_trans)
+ {
+ info->pending_trans_guid = *guid_null ();
+ pending_trans = NULL;
+ }
+ info->blank_split_guid = *guid_null ();
+ blank_split = NULL;
+ }
+
+ /* be sure to take care of any open transactions */
+ if (pending_trans != NULL)
+ {
+ g_critical("BUG DETECTED: pending_trans=%p, blank_split=%p, blank_trans=%p",
+ pending_trans, blank_split, blank_trans);
+ g_assert_not_reached();
info->pending_trans_guid = *guid_null ();
+ /* CAS: It's not clear to me that we'd really want to commit
+ here, rather than rollback. But, maybe this is just dead
+ code. */
+ if (xaccTransIsOpen (pending_trans))
+ xaccTransCommitEdit (pending_trans);
+ else g_assert_not_reached();
+
pending_trans = NULL;
- }
- info->blank_split_guid = *guid_null ();
- blank_split = NULL;
- }
+ }
- /* be sure to take care of any open transactions */
- if (pending_trans != NULL)
- {
- g_critical("BUG DETECTED: pending_trans=%p, blank_split=%p, blank_trans=%p",
- pending_trans, blank_split, blank_trans);
- g_assert_not_reached();
- info->pending_trans_guid = *guid_null ();
- /* CAS: It's not clear to me that we'd really want to commit
- here, rather than rollback. But, maybe this is just dead
- code. */
- if (xaccTransIsOpen (pending_trans))
- xaccTransCommitEdit (pending_trans);
- else g_assert_not_reached();
+ gnc_split_register_destroy_info (reg);
- pending_trans = NULL;
- }
+ gnc_resume_gui_refresh ();
- gnc_split_register_destroy_info (reg);
-
- gnc_resume_gui_refresh ();
-
- LEAVE(" ");
+ LEAVE(" ");
}
void
gnc_split_register_destroy (SplitRegister *reg)
{
- g_return_if_fail(reg);
+ g_return_if_fail(reg);
- ENTER("reg=%p", reg);
+ ENTER("reg=%p", reg);
- gnc_gconf_general_remove_cb(KEY_ACCOUNTING_LABELS,
- split_register_gconf_changed,
- reg);
- gnc_gconf_general_remove_cb(KEY_ACCOUNT_SEPARATOR,
- split_register_gconf_changed,
- reg);
- gnc_split_register_cleanup (reg);
+ gnc_gconf_general_remove_cb(KEY_ACCOUNTING_LABELS,
+ split_register_gconf_changed,
+ reg);
+ gnc_gconf_general_remove_cb(KEY_ACCOUNT_SEPARATOR,
+ split_register_gconf_changed,
+ reg);
+ gnc_split_register_cleanup (reg);
- gnc_table_destroy (reg->table);
- reg->table = NULL;
+ gnc_table_destroy (reg->table);
+ reg->table = NULL;
- /* free the memory itself */
- g_free (reg);
- LEAVE(" ");
+ /* free the memory itself */
+ g_free (reg);
+ LEAVE(" ");
}
-void
+void
gnc_split_register_set_read_only (SplitRegister *reg, gboolean read_only)
{
- gnc_table_model_set_read_only (reg->table->model, read_only);
+ gnc_table_model_set_read_only (reg->table->model, read_only);
}
Modified: gnucash/trunk/src/register/ledger-core/split-register.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/ledger-core/split-register.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -151,35 +151,35 @@
* "ledgers" are multiple-account display windows */
typedef enum
{
- BANK_REGISTER,
- CASH_REGISTER,
- ASSET_REGISTER,
- CREDIT_REGISTER,
- LIABILITY_REGISTER,
- INCOME_REGISTER,
- EXPENSE_REGISTER,
- EQUITY_REGISTER,
- STOCK_REGISTER,
- CURRENCY_REGISTER,
- RECEIVABLE_REGISTER,
- PAYABLE_REGISTER,
- TRADING_REGISTER,
- NUM_SINGLE_REGISTER_TYPES,
+ BANK_REGISTER,
+ CASH_REGISTER,
+ ASSET_REGISTER,
+ CREDIT_REGISTER,
+ LIABILITY_REGISTER,
+ INCOME_REGISTER,
+ EXPENSE_REGISTER,
+ EQUITY_REGISTER,
+ STOCK_REGISTER,
+ CURRENCY_REGISTER,
+ RECEIVABLE_REGISTER,
+ PAYABLE_REGISTER,
+ TRADING_REGISTER,
+ NUM_SINGLE_REGISTER_TYPES,
- GENERAL_LEDGER = NUM_SINGLE_REGISTER_TYPES,
- INCOME_LEDGER,
- PORTFOLIO_LEDGER,
- SEARCH_LEDGER,
+ GENERAL_LEDGER = NUM_SINGLE_REGISTER_TYPES,
+ INCOME_LEDGER,
+ PORTFOLIO_LEDGER,
+ SEARCH_LEDGER,
- NUM_REGISTER_TYPES
+ NUM_REGISTER_TYPES
} SplitRegisterType;
/** Register styles */
typedef enum
{
- REG_STYLE_LEDGER,
- REG_STYLE_AUTO_LEDGER,
- REG_STYLE_JOURNAL
+ REG_STYLE_LEDGER,
+ REG_STYLE_AUTO_LEDGER,
+ REG_STYLE_JOURNAL
} SplitRegisterStyle;
/** @name Cell Names
@@ -227,24 +227,24 @@
/** Types of cursors */
typedef enum
{
- CURSOR_CLASS_NONE = -1,
- CURSOR_CLASS_SPLIT,
- CURSOR_CLASS_TRANS,
- NUM_CURSOR_CLASSES
+ CURSOR_CLASS_NONE = -1,
+ CURSOR_CLASS_SPLIT,
+ CURSOR_CLASS_TRANS,
+ NUM_CURSOR_CLASSES
} CursorClass;
typedef struct split_register_colors
{
- guint32 header_bg_color;
+ guint32 header_bg_color;
- guint32 primary_bg_color;
- guint32 secondary_bg_color;
+ guint32 primary_bg_color;
+ guint32 secondary_bg_color;
- guint32 primary_active_bg_color;
- guint32 secondary_active_bg_color;
+ guint32 primary_active_bg_color;
+ guint32 secondary_active_bg_color;
- guint32 split_bg_color;
- guint32 split_active_bg_color;
+ guint32 split_bg_color;
+ guint32 split_active_bg_color;
} SplitRegisterColors;
@@ -255,16 +255,16 @@
/** @brief The type, style and table for the register. */
struct split_register
{
- Table * table; /**< The table itself that implements the underlying GUI. */
+ Table * table; /**< The table itself that implements the underlying GUI. */
- SplitRegisterType type;
- SplitRegisterStyle style;
+ SplitRegisterType type;
+ SplitRegisterStyle style;
- gboolean use_double_line; /**< whether to use two lines per transaction */
- gboolean is_template;
- gboolean do_auto_complete; /**< whether to use auto-competion */
+ gboolean use_double_line; /**< whether to use two lines per transaction */
+ gboolean is_template;
+ gboolean do_auto_complete; /**< whether to use auto-competion */
- SRInfo * sr_info; /**< private data; outsiders should not access this */
+ SRInfo * sr_info; /**< private data; outsiders should not access this */
};
/** Callback function type */
@@ -320,7 +320,7 @@
* @param do_auto_complete @c TRUE to use auto-completion, @c FALSE otherwise
*/
void gnc_split_register_set_auto_complete(SplitRegister *reg,
- gboolean do_auto_complete);
+ gboolean do_auto_complete);
/** Sets whether a register window is "read only".
*
@@ -338,7 +338,7 @@
* @param template_account the account to use for the template
*/
void gnc_split_register_set_template_account (SplitRegister *reg,
- Account *template_account);
+ Account *template_account);
/** Sets the user data and callback hooks for the register. */
void gnc_split_register_set_data (SplitRegister *reg, gpointer user_data,
@@ -361,8 +361,8 @@
* @return the ::CursorClass of the cursor at @a vcell_loc
*/
CursorClass gnc_split_register_get_cursor_class
- (SplitRegister *reg,
- VirtualCellLocation vcell_loc);
+(SplitRegister *reg,
+ VirtualCellLocation vcell_loc);
/** Gets the transaction at the current cursor location, which may be on
* the transaction itself or on any of its splits.
@@ -385,7 +385,7 @@
*/
Split *
gnc_split_register_get_current_trans_split (SplitRegister *reg,
- VirtualCellLocation *vcell_loc);
+ VirtualCellLocation *vcell_loc);
/** Returns the split at which the cursor is currently located.
*
@@ -437,7 +437,7 @@
*/
gboolean
gnc_split_register_get_split_amount_virt_loc (SplitRegister *reg, Split *split,
- VirtualLocation *virt_loc);
+ VirtualLocation *virt_loc);
/** Duplicates either the current transaction or the current split
* depending on the register mode and cursor position. Returns the
@@ -468,7 +468,7 @@
/** Voids the transaction associated with the current cursor, if
* non-NULL. */
void gnc_split_register_void_current_trans (SplitRegister *reg,
- const char *reason);
+ const char *reason);
/** Unvoids the transaction associated with the current cursor, if
* non-NULL. */
@@ -528,11 +528,11 @@
* dates prior to the present, and after. This will only make sense if
* the splits are ordered primarily by post date. */
void gnc_split_register_show_present_divider (SplitRegister *reg,
- gboolean show_present);
+ gboolean show_present);
/** Expand the current transaction if it is collapsed. */
void gnc_split_register_expand_current_trans (SplitRegister *reg,
- gboolean expand);
+ gboolean expand);
/** Mark the current transaction as collapsed, and do callbacks. */
void gnc_split_register_collapse_current_trans (SplitRegister *reg);
Modified: gnucash/trunk/src/register/register-core/basiccell.c
===================================================================
--- gnucash/trunk/src/register/register-core/basiccell.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/basiccell.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -24,7 +24,7 @@
* FILE:
* basiccell.c
*
- * FUNCTION:
+ * FUNCTION:
* Implements the base class for the cell handler object.
* See the header file for additional documentation.
*
@@ -48,207 +48,207 @@
gnc_cell_name_equal (const char * cell_name_1,
const char * cell_name_2)
{
- return (safe_strcmp (cell_name_1, cell_name_2) == 0);
+ return (safe_strcmp (cell_name_1, cell_name_2) == 0);
}
BasicCell *
gnc_basic_cell_new (void)
{
- BasicCell * cell;
+ BasicCell * cell;
- cell = g_new0 (BasicCell, 1);
+ cell = g_new0 (BasicCell, 1);
- gnc_basic_cell_init (cell);
+ gnc_basic_cell_init (cell);
- return cell;
+ return cell;
}
static void
gnc_basic_cell_clear (BasicCell *cell)
{
- g_free (cell->cell_name);
- cell->cell_name = NULL;
+ g_free (cell->cell_name);
+ cell->cell_name = NULL;
- cell->changed = FALSE;
- cell->conditionally_changed = FALSE;
+ cell->changed = FALSE;
+ cell->conditionally_changed = FALSE;
- cell->value = NULL;
- cell->value_chars = 0;
+ cell->value = NULL;
+ cell->value_chars = 0;
- cell->set_value = NULL;
- cell->enter_cell = NULL;
- cell->modify_verify = NULL;
- cell->direct_update = NULL;
- cell->leave_cell = NULL;
- cell->gui_realize = NULL;
- cell->gui_move = NULL;
- cell->gui_destroy = NULL;
+ cell->set_value = NULL;
+ cell->enter_cell = NULL;
+ cell->modify_verify = NULL;
+ cell->direct_update = NULL;
+ cell->leave_cell = NULL;
+ cell->gui_realize = NULL;
+ cell->gui_move = NULL;
+ cell->gui_destroy = NULL;
- cell->is_popup = FALSE;
+ cell->is_popup = FALSE;
- cell->gui_private = NULL;
+ cell->gui_private = NULL;
- g_free (cell->sample_text);
- cell->sample_text = NULL;
+ g_free (cell->sample_text);
+ cell->sample_text = NULL;
}
void
gnc_basic_cell_init (BasicCell *cell)
{
- gnc_basic_cell_clear (cell);
+ gnc_basic_cell_clear (cell);
- cell->value = g_strdup ("");
+ cell->value = g_strdup ("");
}
void
gnc_basic_cell_destroy (BasicCell *cell)
{
- ENTER(" ");
- if (cell->destroy)
- cell->destroy (cell);
+ ENTER(" ");
+ if (cell->destroy)
+ cell->destroy (cell);
- /* give any gui elements a chance to clean up */
- if (cell->gui_destroy)
- (*(cell->gui_destroy)) (cell);
+ /* give any gui elements a chance to clean up */
+ if (cell->gui_destroy)
+ (*(cell->gui_destroy)) (cell);
- /* free up data strings */
- g_free (cell->value);
- cell->value = NULL;
+ /* free up data strings */
+ g_free (cell->value);
+ cell->value = NULL;
- /* help prevent access to freed memory */
- gnc_basic_cell_clear (cell);
+ /* help prevent access to freed memory */
+ gnc_basic_cell_clear (cell);
- /* free the object itself */
- g_free (cell);
- LEAVE(" ");
+ /* free the object itself */
+ g_free (cell);
+ LEAVE(" ");
}
void
gnc_basic_cell_set_name (BasicCell *cell, const char *name)
{
- if (!cell) return;
- if (cell->cell_name == name) return;
+ if (!cell) return;
+ if (cell->cell_name == name) return;
- g_free (cell->cell_name);
- cell->cell_name = g_strdup (name);
+ g_free (cell->cell_name);
+ cell->cell_name = g_strdup (name);
}
gboolean
gnc_basic_cell_has_name (BasicCell *cell, const char *name)
{
- if (!cell) return FALSE;
- if (!name) return FALSE;
- if (!cell->cell_name) return FALSE;
+ if (!cell) return FALSE;
+ if (!name) return FALSE;
+ if (!cell->cell_name) return FALSE;
- return (strcmp (name, cell->cell_name) == 0);
+ return (strcmp (name, cell->cell_name) == 0);
}
void
gnc_basic_cell_set_sample_text (BasicCell *cell,
const char *sample_text)
{
- if (!cell) return;
- if (cell->sample_text == sample_text) return;
+ if (!cell) return;
+ if (cell->sample_text == sample_text) return;
- g_free (cell->sample_text);
- cell->sample_text = g_strdup (sample_text);
+ g_free (cell->sample_text);
+ cell->sample_text = g_strdup (sample_text);
}
void
gnc_basic_cell_set_alignment (BasicCell *cell,
CellAlignment alignment)
{
- if (!cell) return;
- cell->alignment = alignment;
+ if (!cell) return;
+ cell->alignment = alignment;
}
void
gnc_basic_cell_set_expandable (BasicCell *cell, gboolean expandable)
{
- if (!cell) return;
- cell->expandable = expandable;
+ if (!cell) return;
+ cell->expandable = expandable;
}
void
gnc_basic_cell_set_span (BasicCell *cell, gboolean span)
{
- if (!cell) return;
- cell->span = span;
+ if (!cell) return;
+ cell->span = span;
}
const char *
gnc_basic_cell_get_value (BasicCell *cell)
{
- g_return_val_if_fail (cell != NULL, NULL);
+ g_return_val_if_fail (cell != NULL, NULL);
- return cell->value;
+ return cell->value;
}
void
gnc_basic_cell_set_value (BasicCell *cell, const char *val)
{
- CellSetValueFunc cb;
+ CellSetValueFunc cb;
- cb = cell->set_value;
- if (cb)
- {
- /* avoid recursion by disabling the
- * callback while it's being called. */
- cell->set_value = NULL;
- cb (cell, val);
- cell->set_value = cb;
- }
- else
- gnc_basic_cell_set_value_internal (cell, val);
+ cb = cell->set_value;
+ if (cb)
+ {
+ /* avoid recursion by disabling the
+ * callback while it's being called. */
+ cell->set_value = NULL;
+ cb (cell, val);
+ cell->set_value = cb;
+ }
+ else
+ gnc_basic_cell_set_value_internal (cell, val);
}
gboolean
gnc_basic_cell_get_changed (BasicCell *cell)
{
- if (!cell) return FALSE;
+ if (!cell) return FALSE;
- return cell->changed;
+ return cell->changed;
}
gboolean
gnc_basic_cell_get_conditionally_changed (BasicCell *cell)
{
- if (!cell) return FALSE;
+ if (!cell) return FALSE;
- return cell->conditionally_changed;
+ return cell->conditionally_changed;
}
void
gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed)
{
- if (!cell) return;
+ if (!cell) return;
- cell->changed = changed;
+ cell->changed = changed;
}
void
gnc_basic_cell_set_conditionally_changed (BasicCell *cell, gboolean changed)
{
- if (!cell) return;
+ if (!cell) return;
- cell->conditionally_changed = changed;
+ cell->conditionally_changed = changed;
}
void
gnc_basic_cell_set_value_internal (BasicCell *cell, const char *value)
{
- if (value == NULL)
- value = "";
+ if (value == NULL)
+ value = "";
- /* If the caller tries to set the value with our own value then do
- * nothing because we have no work to do (or, at least, all the work
- * will result in the status-quo, so why do anything?) See bug
- * #103174 and the description in the changelog on 2003-09-04.
- */
- if (cell->value == value)
- return;
+ /* If the caller tries to set the value with our own value then do
+ * nothing because we have no work to do (or, at least, all the work
+ * will result in the status-quo, so why do anything?) See bug
+ * #103174 and the description in the changelog on 2003-09-04.
+ */
+ if (cell->value == value)
+ return;
- g_free (cell->value);
- cell->value = g_strdup (value);
- cell->value_chars = g_utf8_strlen(value, -1);
+ g_free (cell->value);
+ cell->value = g_strdup (value);
+ cell->value_chars = g_utf8_strlen(value, -1);
}
Modified: gnucash/trunk/src/register/register-core/basiccell.h
===================================================================
--- gnucash/trunk/src/register/register-core/basiccell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/basiccell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -25,19 +25,19 @@
* basiccell.h
*
* FUNCTION:
- * The BasicCell class provides an abstract base class
+ * The BasicCell class provides an abstract base class
* defining the handling of the editing of a cell of a table.
* Classes that provide the actual handling for different
* cell types should inherit from this class.
*
* The BasicCell class encapsulates a single string value
- * which can be set & read by the programmer, and edited
- * by the "user". In the text below, the "user" is the
- * person controlling the mouse and keyboard. Thus, when
- * the user makes a move, it means that they have somehow
- * interacted with the cell, by clicking with mouse or by
- * typing at the keyboard. This class provides three
- * callbacks which allow the programmer to understand what
+ * which can be set & read by the programmer, and edited
+ * by the "user". In the text below, the "user" is the
+ * person controlling the mouse and keyboard. Thus, when
+ * the user makes a move, it means that they have somehow
+ * interacted with the cell, by clicking with mouse or by
+ * typing at the keyboard. This class provides three
+ * callbacks which allow the programmer to understand what
* the user is doing.
*
* The programmer can create a custom GUI for editing the
@@ -45,23 +45,23 @@
* a custom GUI to be created, destroyed and moved about.
*
* Since this class is implemented in C not C++, there is
- * a "minor" problem with inheritance. To emulate the
- * overloading of a virtual "SetValues" method, there is
+ * a "minor" problem with inheritance. To emulate the
+ * overloading of a virtual "SetValues" method, there is
* a set_value() callback, which will be called whenever
* the xaccSetBasicCellValue() subroutine is called.
*
* VIRTUAL/OVERLOADED METHODS:
* The set_value() callback will be called whenever the
- * xaccSetBasicCellValue() method is called. Derived
+ * xaccSetBasicCellValue() method is called. Derived
* classes should provide a callback here if they need
* to understand special cell formats.
*
* USER CALLBACKS:
* The enter_cell() callback is called when the user first
* makes a move to enter a cell. This might be by clicking
- * on the cell with the mouse, by tabbing to it, using the
+ * on the cell with the mouse, by tabbing to it, using the
* arrow keys, or otherwise "selecting" it as the current
- * cell to edit.
+ * cell to edit.
*
* The callback may change the value of the cell. The callback
* should return true if the cell should allow direct editing
@@ -73,16 +73,16 @@
* update appropriately.
*
* The leave_cell() callback is called when the user exits
- * a cell. This can be by tabbing or arrow-keying away
- * from it, or by using the mouse to specify a different
+ * a cell. This can be by tabbing or arrow-keying away
+ * from it, or by using the mouse to specify a different
* cell, etc. The callback may change the value of the cell.
*
* The modify_verify() callback is called when a user makes a
* change to a cell. It is called after every keystroke,
* (actually, after every X11 "input-method" type input,
- * so that ctrl-alt-etc modifier keys are pre-processed in
+ * so that ctrl-alt-etc modifier keys are pre-processed in
* the usual X11 fashion).
- *
+ *
* The arguments passed in are :
* "add", the string the user is attempting to add
* (will be null if text is being deleted).
@@ -116,7 +116,7 @@
* callbacks that allow the programmer to perform GUI-specific
* initialization & changes.
*
- * The gui_realize() callback will be called when GUI-specific
+ * The gui_realize() callback will be called when GUI-specific
* initialization needs to be done. For Gnome, the second
* argument will be cast to the parent widget.
*
@@ -128,7 +128,7 @@
* The second argument is the virtual location the GUI
* element should be moved to.
*
- * The gui_private member may be used by the derived class to
+ * The gui_private member may be used by the derived class to
* store any additional GUI-specific data.
*
* HISTORY:
@@ -167,10 +167,10 @@
int *end_selection);
typedef gboolean (*CellDirectUpdateFunc) (BasicCell *cell,
- int *cursor_position,
- int *start_selection,
- int *end_selection,
- gpointer gui_data);
+ int *cursor_position,
+ int *start_selection,
+ int *end_selection,
+ gpointer gui_data);
typedef void (*CellLeaveFunc) (BasicCell *cell);
@@ -182,45 +182,45 @@
typedef enum
{
- CELL_ALIGN_RIGHT,
- CELL_ALIGN_CENTER,
- CELL_ALIGN_LEFT
+ CELL_ALIGN_RIGHT,
+ CELL_ALIGN_CENTER,
+ CELL_ALIGN_LEFT
} CellAlignment;
struct basic_cell
{
- char * cell_name;
+ char * cell_name;
- char * value; /* current value */
- guint value_chars; /* number of characters in value */
+ char * value; /* current value */
+ guint value_chars; /* number of characters in value */
- gboolean changed; /* true if value modified */
- gboolean conditionally_changed; /* true if value modified conditionally */
+ gboolean changed; /* true if value modified */
+ gboolean conditionally_changed; /* true if value modified conditionally */
- /* "virtual", overloaded methods */
- CellSetValueFunc set_value;
- CellDestroyFunc destroy;
+ /* "virtual", overloaded methods */
+ CellSetValueFunc set_value;
+ CellDestroyFunc destroy;
- /* cell-editing callbacks */
- CellEnterFunc enter_cell;
- CellModifyVerifyFunc modify_verify;
- CellDirectUpdateFunc direct_update;
- CellLeaveFunc leave_cell;
+ /* cell-editing callbacks */
+ CellEnterFunc enter_cell;
+ CellModifyVerifyFunc modify_verify;
+ CellDirectUpdateFunc direct_update;
+ CellLeaveFunc leave_cell;
- /* private, GUI-specific callbacks */
- CellRealizeFunc gui_realize;
- CellMoveFunc gui_move;
- CellDestroyFunc gui_destroy;
+ /* private, GUI-specific callbacks */
+ CellRealizeFunc gui_realize;
+ CellMoveFunc gui_move;
+ CellDestroyFunc gui_destroy;
- /* GUI information */
- char *sample_text; /* sample text for sizing purposes */
- CellAlignment alignment; /* horizontal alignment in column */
- gboolean expandable; /* can fill with extra space */
- gboolean span; /* can span multiple columns */
- gboolean is_popup; /* is a popup widget */
+ /* GUI information */
+ char *sample_text; /* sample text for sizing purposes */
+ CellAlignment alignment; /* horizontal alignment in column */
+ gboolean expandable; /* can fill with extra space */
+ gboolean span; /* can span multiple columns */
+ gboolean is_popup; /* is a popup widget */
- /* general hook for gui-private data */
- gpointer gui_private;
+ /* general hook for gui-private data */
+ gpointer gui_private;
};
@@ -235,11 +235,11 @@
gboolean gnc_basic_cell_has_name (BasicCell *cell, const char *name);
void gnc_basic_cell_set_sample_text (BasicCell *cell,
- const char *sample_text);
+ const char *sample_text);
void gnc_basic_cell_set_alignment (BasicCell *cell,
- CellAlignment alignment);
+ CellAlignment alignment);
void gnc_basic_cell_set_expandable (BasicCell *cell,
- gboolean expandable);
+ gboolean expandable);
void gnc_basic_cell_set_span (BasicCell *cell,
gboolean span);
@@ -251,10 +251,10 @@
void gnc_basic_cell_set_changed (BasicCell *cell, gboolean changed);
void gnc_basic_cell_set_conditionally_changed (BasicCell *cell,
- gboolean changed);
+ gboolean changed);
/* for sub-class use only */
void gnc_basic_cell_set_value_internal (BasicCell *bcell,
- const char *value);
+ const char *value);
#endif /* BASIC_CELL_H */
Modified: gnucash/trunk/src/register/register-core/cell-factory.c
===================================================================
--- gnucash/trunk/src/register/register-core/cell-factory.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/cell-factory.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -31,46 +31,46 @@
typedef struct cell_record
{
- char *cell_type_name;
+ char *cell_type_name;
- CellCreateFunc creator;
+ CellCreateFunc creator;
} CellRecord;
struct cell_factory
{
- GHashTable *cell_table;
+ GHashTable *cell_table;
};
CellFactory *
gnc_cell_factory_new (void)
{
- CellFactory *cf;
+ CellFactory *cf;
- cf = g_new0 (CellFactory, 1);
+ cf = g_new0 (CellFactory, 1);
- cf->cell_table = g_hash_table_new (g_str_hash, g_str_equal);
+ cf->cell_table = g_hash_table_new (g_str_hash, g_str_equal);
- return cf;
+ return cf;
}
static void
cell_table_destroy_helper (gpointer key, gpointer value, gpointer user_data)
{
- CellRecord *cr = value;
+ CellRecord *cr = value;
- g_free (cr->cell_type_name);
- g_free (cr);
+ g_free (cr->cell_type_name);
+ g_free (cr);
}
void
gnc_cell_factory_destroy (CellFactory *cf)
{
- if (!cf) return;
+ if (!cf) return;
- g_hash_table_foreach (cf->cell_table, cell_table_destroy_helper, NULL);
+ g_hash_table_foreach (cf->cell_table, cell_table_destroy_helper, NULL);
- g_free (cf);
+ g_free (cf);
}
void
@@ -78,37 +78,37 @@
const char *cell_type_name,
CellCreateFunc cell_creator)
{
- CellRecord *cr;
+ CellRecord *cr;
- g_return_if_fail (cell_type_name != NULL);
- g_return_if_fail (cell_creator != NULL);
+ g_return_if_fail (cell_type_name != NULL);
+ g_return_if_fail (cell_creator != NULL);
- cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
+ cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
- if (cr)
- {
- g_hash_table_remove (cf->cell_table, cell_type_name);
- g_free (cr->cell_type_name);
- }
- else
- cr = g_new0 (CellRecord, 1);
+ if (cr)
+ {
+ g_hash_table_remove (cf->cell_table, cell_type_name);
+ g_free (cr->cell_type_name);
+ }
+ else
+ cr = g_new0 (CellRecord, 1);
- cr->cell_type_name = g_strdup (cell_type_name);
- cr->creator = cell_creator;
+ cr->cell_type_name = g_strdup (cell_type_name);
+ cr->creator = cell_creator;
- g_hash_table_insert (cf->cell_table, cr->cell_type_name, cr);
+ g_hash_table_insert (cf->cell_table, cr->cell_type_name, cr);
}
BasicCell *
gnc_cell_factory_make_cell (CellFactory *cf, const char *cell_type_name)
{
- CellRecord *cr;
+ CellRecord *cr;
- g_return_val_if_fail (cf != NULL, NULL);
- g_return_val_if_fail (cell_type_name != NULL, NULL);
+ g_return_val_if_fail (cf != NULL, NULL);
+ g_return_val_if_fail (cell_type_name != NULL, NULL);
- cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
- g_return_val_if_fail (cr != NULL, NULL);
+ cr = g_hash_table_lookup (cf->cell_table, cell_type_name);
+ g_return_val_if_fail (cr != NULL, NULL);
- return cr->creator ();
+ return cr->creator ();
}
Modified: gnucash/trunk/src/register/register-core/cellblock.c
===================================================================
--- gnucash/trunk/src/register/register-core/cellblock.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/cellblock.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -23,7 +23,7 @@
/*
* FILE:
* cellblock.c
- *
+ *
* FUNCTION:
* implements a rectangular array of cells. See the header file for
* additional documentation.
@@ -43,49 +43,49 @@
CellBlock *
gnc_cellblock_new (int rows, int cols, const char *cursor_name)
{
- CellBlock *cellblock;
+ CellBlock *cellblock;
- g_return_val_if_fail (rows > 0, NULL);
- g_return_val_if_fail (cols > 0, NULL);
- g_return_val_if_fail (cursor_name != NULL, NULL);
+ g_return_val_if_fail (rows > 0, NULL);
+ g_return_val_if_fail (cols > 0, NULL);
+ g_return_val_if_fail (cursor_name != NULL, NULL);
- cellblock = g_new0 (CellBlock, 1);
+ cellblock = g_new0 (CellBlock, 1);
- gnc_cellblock_init (cellblock, rows, cols);
+ gnc_cellblock_init (cellblock, rows, cols);
- cellblock->cursor_name = g_strdup (cursor_name);
+ cellblock->cursor_name = g_strdup (cursor_name);
- return cellblock;
+ return cellblock;
}
static void
gnc_cellblock_init (CellBlock *cellblock, int rows, int cols)
{
- /* record new size */
- cellblock->num_rows = rows;
- cellblock->num_cols = cols;
+ /* record new size */
+ cellblock->num_rows = rows;
+ cellblock->num_cols = cols;
- cellblock->start_col = cols;
- cellblock->stop_col = -1;
+ cellblock->start_col = cols;
+ cellblock->stop_col = -1;
- /* malloc new cell table */
- cellblock->cells = g_ptr_array_new ();
+ /* malloc new cell table */
+ cellblock->cells = g_ptr_array_new ();
- g_ptr_array_set_size (cellblock->cells, rows * cols);
+ g_ptr_array_set_size (cellblock->cells, rows * cols);
}
-void
+void
gnc_cellblock_destroy (CellBlock *cellblock)
{
- if (!cellblock) return;
+ if (!cellblock) return;
- g_ptr_array_free (cellblock->cells, FALSE);
- cellblock->cells = NULL;
+ g_ptr_array_free (cellblock->cells, FALSE);
+ cellblock->cells = NULL;
- g_free (cellblock->cursor_name);
- cellblock->cursor_name = NULL;
+ g_free (cellblock->cursor_name);
+ cellblock->cursor_name = NULL;
- g_free (cellblock);
+ g_free (cellblock);
}
void
@@ -93,31 +93,31 @@
int row, int col,
BasicCell *cell)
{
- if (cellblock == NULL)
- return;
+ if (cellblock == NULL)
+ return;
- if (row < 0 || row >= cellblock->num_rows)
- return;
+ if (row < 0 || row >= cellblock->num_rows)
+ return;
- if (col < 0 || col >= cellblock->num_cols)
- return;
+ if (col < 0 || col >= cellblock->num_cols)
+ return;
- cellblock->cells->pdata[(row * cellblock->num_cols) + col] = cell;
+ cellblock->cells->pdata[(row * cellblock->num_cols) + col] = cell;
}
BasicCell *
gnc_cellblock_get_cell (CellBlock *cellblock, int row, int col)
{
- if (cellblock == NULL)
- return NULL;
+ if (cellblock == NULL)
+ return NULL;
- if (row < 0 || row >= cellblock->num_rows)
- return NULL;
+ if (row < 0 || row >= cellblock->num_rows)
+ return NULL;
- if (col < 0 || col >= cellblock->num_cols)
- return NULL;
+ if (col < 0 || col >= cellblock->num_cols)
+ return NULL;
- return cellblock->cells->pdata[(row * cellblock->num_cols) + col];
+ return cellblock->cells->pdata[(row * cellblock->num_cols) + col];
}
BasicCell *
@@ -125,84 +125,84 @@
const char *cell_name,
int *row, int *col)
{
- int r, c, num_rows, num_cols;
+ int r, c, num_rows, num_cols;
- if (cellblock == NULL)
- return NULL;
+ if (cellblock == NULL)
+ return NULL;
- if (cell_name == NULL)
- return NULL;
+ if (cell_name == NULL)
+ return NULL;
- num_rows = cellblock->num_rows;
- num_cols = cellblock->num_cols;
- for (r = 0; r < num_rows; r++)
- for (c = 0; c < num_cols; c++)
- {
- BasicCell *cell = cellblock->cells->pdata[(r * num_cols) + c];
- if (!cell) continue;
- if (gnc_cell_name_equal(cell->cell_name, cell_name))
- {
- if (row)
- *row = r;
- if (col)
- *col = c;
- return cell;
- }
- }
+ num_rows = cellblock->num_rows;
+ num_cols = cellblock->num_cols;
+ for (r = 0; r < num_rows; r++)
+ for (c = 0; c < num_cols; c++)
+ {
+ BasicCell *cell = cellblock->cells->pdata[(r * num_cols) + c];
+ if (!cell) continue;
+ if (gnc_cell_name_equal(cell->cell_name, cell_name))
+ {
+ if (row)
+ *row = r;
+ if (col)
+ *col = c;
+ return cell;
+ }
+ }
- return NULL;
+ return NULL;
}
int
gnc_cellblock_changed (CellBlock *cursor, gboolean include_conditional)
{
- int changed = 0;
- int r, c;
+ int changed = 0;
+ int r, c;
- if (!cursor)
- return FALSE;
+ if (!cursor)
+ return FALSE;
- for (r = 0; r < cursor->num_rows; r++)
- for (c = 0; c < cursor->num_cols; c++)
- {
- BasicCell *cell;
+ for (r = 0; r < cursor->num_rows; r++)
+ for (c = 0; c < cursor->num_cols; c++)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (cursor, r, c);
- if (cell == NULL)
- continue;
+ cell = gnc_cellblock_get_cell (cursor, r, c);
+ if (cell == NULL)
+ continue;
- if (gnc_basic_cell_get_changed (cell))
- {
- changed++;
- continue;
- }
+ if (gnc_basic_cell_get_changed (cell))
+ {
+ changed++;
+ continue;
+ }
- if (include_conditional &&
- gnc_basic_cell_get_conditionally_changed (cell))
- changed++;
- }
+ if (include_conditional &&
+ gnc_basic_cell_get_conditionally_changed (cell))
+ changed++;
+ }
- return changed;
+ return changed;
}
void
gnc_cellblock_clear_changes (CellBlock *cursor)
{
- int r, c;
+ int r, c;
- if (!cursor)
- return;
+ if (!cursor)
+ return;
- for (r = 0; r < cursor->num_rows; r++)
- for (c = 0; c < cursor->num_cols; c++)
- {
- BasicCell *cell;
+ for (r = 0; r < cursor->num_rows; r++)
+ for (c = 0; c < cursor->num_cols; c++)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (cursor, r, c);
- if (cell == NULL)
- continue;
+ cell = gnc_cellblock_get_cell (cursor, r, c);
+ if (cell == NULL)
+ continue;
- gnc_basic_cell_set_changed (cell, FALSE);
- gnc_basic_cell_set_conditionally_changed (cell, FALSE);
- }
+ gnc_basic_cell_set_changed (cell, FALSE);
+ gnc_basic_cell_set_conditionally_changed (cell, FALSE);
+ }
}
Modified: gnucash/trunk/src/register/register-core/cellblock.h
===================================================================
--- gnucash/trunk/src/register/register-core/cellblock.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/cellblock.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -34,7 +34,7 @@
* @author Copyright (c) 2000-2001 Dave Peticolas <dave at krondo.com>
*
* @details
- * The CellBlock struct is a rectangular grid of cells that
+ * The CellBlock struct is a rectangular grid of cells that
* define an arrangement of cells. It is typically used to
* define a virtual cursor within a larger table of cells.
*/
@@ -48,15 +48,15 @@
typedef struct
{
- short num_rows;
- short num_cols;
+ short num_rows;
+ short num_cols;
- short start_col;
- short stop_col;
+ short start_col;
+ short stop_col;
- char *cursor_name;
+ char *cursor_name;
- GPtrArray *cells; /* Holds the CellBlockCell table */
+ GPtrArray *cells; /* Holds the CellBlockCell table */
} CellBlock;
@@ -87,8 +87,8 @@
* @return the matching cell, or @c NULL
*/
BasicCell * gnc_cellblock_get_cell_by_name(CellBlock *cellblock,
- const char *cell_name,
- int *row, int *col);
+ const char *cell_name,
+ int *row, int *col);
/* Return number of changed cells. */
int gnc_cellblock_changed (CellBlock *cursor,
Modified: gnucash/trunk/src/register/register-core/checkboxcell.c
===================================================================
--- gnucash/trunk/src/register/register-core/checkboxcell.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/checkboxcell.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -23,7 +23,7 @@
/*
* FILE:
* checkboxcell.c
- *
+ *
* FUNCTION:
* Implements a mouse-click cell that toggles a yes/no value.
*
@@ -48,71 +48,71 @@
static void
gnc_checkbox_cell_set_value (BasicCell *_cell, const char *value)
{
- CheckboxCell *cell = (CheckboxCell *) _cell;
- gboolean flag = FALSE;
+ CheckboxCell *cell = (CheckboxCell *) _cell;
+ gboolean flag = FALSE;
- if (value && *value == 'X')
- flag = TRUE;
+ if (value && *value == 'X')
+ flag = TRUE;
- gnc_checkbox_cell_set_flag (cell, flag);
+ gnc_checkbox_cell_set_flag (cell, flag);
}
static gboolean
gnc_checkbox_cell_enter (BasicCell *_cell,
- int *cursor_position,
- int *start_selection,
- int *end_selection)
+ int *cursor_position,
+ int *start_selection,
+ int *end_selection)
{
- CheckboxCell *cell = (CheckboxCell *) _cell;
- gnc_checkbox_cell_set_flag (cell, !cell->flag);
- return FALSE;
+ CheckboxCell *cell = (CheckboxCell *) _cell;
+ gnc_checkbox_cell_set_flag (cell, !cell->flag);
+ return FALSE;
}
static void
gnc_checkbox_cell_init (CheckboxCell *cell)
{
- gnc_basic_cell_init (&cell->cell);
+ gnc_basic_cell_init (&cell->cell);
- gnc_checkbox_cell_set_flag (cell, FALSE);
- cell->cell.enter_cell = gnc_checkbox_cell_enter;
- cell->cell.set_value = gnc_checkbox_cell_set_value;
+ gnc_checkbox_cell_set_flag (cell, FALSE);
+ cell->cell.enter_cell = gnc_checkbox_cell_enter;
+ cell->cell.set_value = gnc_checkbox_cell_set_value;
}
BasicCell *
gnc_checkbox_cell_new (void)
{
- CheckboxCell * cell;
+ CheckboxCell * cell;
- cell = g_new0 (CheckboxCell, 1);
+ cell = g_new0 (CheckboxCell, 1);
- gnc_checkbox_cell_init (cell);
+ gnc_checkbox_cell_init (cell);
- return &cell->cell;
+ return &cell->cell;
}
void
gnc_checkbox_cell_set_flag (CheckboxCell *cell, gboolean flag)
{
- const char *string;
+ const char *string;
- g_return_if_fail (cell != NULL);
+ g_return_if_fail (cell != NULL);
- cell->flag = flag;
- string = gnc_checkbox_cell_get_string (flag);
+ cell->flag = flag;
+ string = gnc_checkbox_cell_get_string (flag);
- gnc_basic_cell_set_value_internal (&cell->cell, string);
+ gnc_basic_cell_set_value_internal (&cell->cell, string);
}
gboolean
gnc_checkbox_cell_get_flag (CheckboxCell *cell)
{
- g_return_val_if_fail (cell != NULL, '\0');
+ g_return_val_if_fail (cell != NULL, '\0');
- return cell->flag;
+ return cell->flag;
}
const char *
gnc_checkbox_cell_get_string (gboolean flag)
{
- return (flag ? "X" : " ");
+ return (flag ? "X" : " ");
}
Modified: gnucash/trunk/src/register/register-core/checkboxcell.h
===================================================================
--- gnucash/trunk/src/register/register-core/checkboxcell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/checkboxcell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -41,9 +41,9 @@
typedef struct
{
- BasicCell cell;
+ BasicCell cell;
- gboolean flag;
+ gboolean flag;
} CheckboxCell;
Modified: gnucash/trunk/src/register/register-core/combocell.h
===================================================================
--- gnucash/trunk/src/register/register-core/combocell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/combocell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -22,16 +22,16 @@
/**
* @file combocell.h
- * @brief The ComboCell object implements a cell handler with a
- * "combination-box" pull-down menu in it.
- *
+ * @brief The ComboCell object implements a cell handler with a
+ * "combination-box" pull-down menu in it.
+ *
* On output, the currently selected menu item is displayed.
* On input, the user can select from a list in the pull-down menu,
* or use the keyboard to slect a menu entry by typing the first
* few menu characters.
*
- * @author Created Jan 1998 Linas Vepstas
- * @author Copyright (c) 1998 Linas Vepstas <linas at linas.org>
+ * @author Created Jan 1998 Linas Vepstas
+ * @author Copyright (c) 1998 Linas Vepstas <linas at linas.org>
* @author Copyright (c) 2000 Dave Peticolas
*/
@@ -45,8 +45,8 @@
typedef struct
{
- BasicCell cell;
- gpointer shared_store;
+ BasicCell cell;
+ gpointer shared_store;
} ComboCell;
@@ -75,19 +75,19 @@
/** Sets a character used for special completion processing. */
void gnc_combo_cell_set_complete_char (ComboCell *cell,
- gunichar complete_char);
+ gunichar complete_char);
/** Add a string to a list of strings which, if the cell has that value,
* will cause the cell to be uneditable on 'enter'. */
void gnc_combo_cell_add_ignore_string (ComboCell *cell,
- const char *ignore_string);
+ const char *ignore_string);
/** Determines whether the popup list autosizes itself or uses
* all available space. FALSE by default. */
void gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize);
/** Tell the combocell to use a shared QuickFill object. Using this routine
- * can dramatically improve performance when creating combocells with a
+ * can dramatically improve performance when creating combocells with a
* large number of entries. For example, users with thousands of accounts
* are complaining about 10-second register startup times, of which 98%
* of the cpu is spent building the multi-thousand entry quickfill.
Modified: gnucash/trunk/src/register/register-core/datecell.h
===================================================================
--- gnucash/trunk/src/register/register-core/datecell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/datecell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -26,63 +26,63 @@
*
* FUNCTION:
* The DateCell object implements a date handling cell. It
- * is able to display dates in several formats, it is also
+ * is able to display dates in several formats, it is also
* able to accept date input, and also supports a number of accelerator
* keys.
*
* On output, this cell will display a date as mm/dd/yy
* The actual date formate is compile-time configurable.
*
- * hack alert -- make the display format run-time configurable, and
+ * hack alert -- make the display format run-time configurable, and
* appropriately internationalized.
*
* One input, this cell is able to parse dates that are entered.
* It rejects any input that is not in the form of a date. Input
- * also includes a number of accelerators:
+ * also includes a number of accelerators:
*
* '+':
- * '=': increment day
+ * '=': increment day
*
* '_':
- * '-': decrement day
+ * '-': decrement day
*
* '}':
- * ']': increment month
+ * ']': increment month
*
* '{':
- * '[': decrment month
+ * '[': decrment month
*
* 'M':
- * 'm': begining of month
+ * 'm': begining of month
*
* 'H':
- * 'h': end of month
+ * 'h': end of month
*
* 'Y':
- * 'y': begining of year
+ * 'y': begining of year
*
* 'R':
- * 'r': end of year
+ * 'r': end of year
*
* 'T':
- * 't': today
+ * 't': today
*
- *
+ *
* METHODS:
* The xaccSetDateCellValue() method accepts a numeric date and
* sets the contents of the date cell to that value. The
* value day, month, year should follow the regular written
* conventions, i.e. day==(1..31), mon==(1..12), year==4 digits
*
- * The xaccCommitDateCell() method commits any pending changes to the
- * value of the cell. That is, it will take the cells current string
+ * The xaccCommitDateCell() method commits any pending changes to the
+ * value of the cell. That is, it will take the cells current string
* value, and parse it into a month-day-year value.
*
* Why is this needed? Basically, while the user is typing into the
* cell, we do not even try to parse the date, lest we confuse things
- * royally. Normally, when the user leaves this cell, and moves to
- * another, we parse the date and print it nicely and cleanly into
- * the cell. But it can happen that we want to get the accurate contents
+ * royally. Normally, when the user leaves this cell, and moves to
+ * another, we parse the date and print it nicely and cleanly into
+ * the cell. But it can happen that we want to get the accurate contents
* of the date cell before we've left it, e.g. if the user has clicked
* on the "commit" button. This is the routine to call for that.
*
@@ -90,7 +90,7 @@
* Copyright (c) 1998, 1999, 2000 Linas Vepstas <linas at linas.org>
* Copyright (c) 2000 Dave Peticolas
*/
-
+
#ifndef DATE_CELL_H
#define DATE_CELL_H
@@ -102,7 +102,7 @@
typedef struct date_cell
{
- BasicCell cell;
+ BasicCell cell;
} DateCell;
/* installs a callback to handle date recording */
@@ -110,7 +110,7 @@
/* days are 1-31, mon is 1-12, year 1900 == 1900 */
void gnc_date_cell_set_value (DateCell *cell,
- int day, int mon, int year);
+ int day, int mon, int year);
void gnc_date_cell_set_value_secs (DateCell *cell, time_t secs);
void gnc_date_cell_commit (DateCell *cell);
Modified: gnucash/trunk/src/register/register-core/formulacell.c
===================================================================
--- gnucash/trunk/src/register/register-core/formulacell.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/formulacell.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -43,48 +43,48 @@
static void gnc_formula_cell_leave( BasicCell *_cell );
-static void gnc_formula_cell_modify_verify( BasicCell *_cell,
- const char *change,
- int change_len,
- const char *newval,
- int newval_len,
- int *cursor_position,
- int *start_selection,
- int *end_selection );
+static void gnc_formula_cell_modify_verify( BasicCell *_cell,
+ const char *change,
+ int change_len,
+ const char *newval,
+ int newval_len,
+ int *cursor_position,
+ int *start_selection,
+ int *end_selection );
static void gnc_formula_cell_set_value_internal( BasicCell *_cell,
- const char *str );
+ const char *str );
BasicCell*
gnc_formula_cell_new(void)
{
- FormulaCell *fc = g_new0( FormulaCell, 1 );
- gnc_formula_cell_init( fc );
- return &fc->cell;
+ FormulaCell *fc = g_new0( FormulaCell, 1 );
+ gnc_formula_cell_init( fc );
+ return &fc->cell;
}
static
void
gnc_formula_cell_init( FormulaCell *fc )
{
- gnc_basic_cell_init (&(fc->cell));
+ gnc_basic_cell_init (&(fc->cell));
- fc->print_info = gnc_default_print_info (FALSE);
+ fc->print_info = gnc_default_print_info (FALSE);
- fc->cell.enter_cell = gnc_formula_cell_enter;
- fc->cell.modify_verify = gnc_formula_cell_modify_verify;
- fc->cell.set_value = gnc_formula_cell_set_value_internal;
- fc->cell.leave_cell = gnc_formula_cell_leave;
+ fc->cell.enter_cell = gnc_formula_cell_enter;
+ fc->cell.modify_verify = gnc_formula_cell_modify_verify;
+ fc->cell.set_value = gnc_formula_cell_set_value_internal;
+ fc->cell.leave_cell = gnc_formula_cell_leave;
}
void
gnc_formula_cell_set_value( FormulaCell *fc,
const char *newVal )
{
- g_debug("got value [%s]", newVal);
- gnc_formula_cell_set_value_internal( &fc->cell, newVal );
+ g_debug("got value [%s]", newVal);
+ gnc_formula_cell_set_value_internal( &fc->cell, newVal );
}
static
@@ -94,32 +94,32 @@
int *start_selection,
int *end_selection )
{
- g_debug("%d, %d, %d", *cursor_position, *start_selection, *end_selection);
- *cursor_position = -1;
- *start_selection = 0;
- *end_selection = -1;
- return TRUE;
+ g_debug("%d, %d, %d", *cursor_position, *start_selection, *end_selection);
+ *cursor_position = -1;
+ *start_selection = 0;
+ *end_selection = -1;
+ return TRUE;
}
static void
gnc_formula_cell_leave(BasicCell *_cell)
{
- char *str;
- FormulaCell *fc = (FormulaCell*)_cell;
- str = fc->cell.value;
- {
- char *error_location = NULL;
- gnc_numeric amount;
- if (str != NULL
- && strlen(str) != 0
- && !gnc_exp_parser_parse(str, &amount, &error_location))
+ char *str;
+ FormulaCell *fc = (FormulaCell*)_cell;
+ str = fc->cell.value;
{
- gnc_warning_dialog(NULL, _("An error occurred while processing %s."),
- str);//, (error_location - str));
+ char *error_location = NULL;
+ gnc_numeric amount;
+ if (str != NULL
+ && strlen(str) != 0
+ && !gnc_exp_parser_parse(str, &amount, &error_location))
+ {
+ gnc_warning_dialog(NULL, _("An error occurred while processing %s."),
+ str);//, (error_location - str));
+ }
}
- }
- gnc_basic_cell_set_value_internal( &fc->cell, str );
+ gnc_basic_cell_set_value_internal( &fc->cell, str );
}
static
@@ -133,51 +133,51 @@
int *start_selection,
int *end_selection )
{
- FormulaCell *cell = (FormulaCell *)_cell;
- struct lconv *lc = gnc_localeconv ();
- const char *toks = "+-*/=()_:";
- gunichar decimal_point;
- gunichar thousands_sep;
- const char *c;
- gunichar uc;
+ FormulaCell *cell = (FormulaCell *)_cell;
+ struct lconv *lc = gnc_localeconv ();
+ const char *toks = "+-*/=()_:";
+ gunichar decimal_point;
+ gunichar thousands_sep;
+ const char *c;
+ gunichar uc;
- g_debug("%s, %d, %s, %d, %d, %d, %d",
- change ? (gchar *)change : "(null)", change_len,
- newval ? (gchar *)newval : "(null)", newval_len,
- *cursor_position, *start_selection, *end_selection);
+ g_debug("%s, %d, %s, %d, %d, %d, %d",
+ change ? (gchar *)change : "(null)", change_len,
+ newval ? (gchar *)newval : "(null)", newval_len,
+ *cursor_position, *start_selection, *end_selection);
- /* accept the newval string if user action was delete */
- if (change == NULL)
- {
- gnc_basic_cell_set_value_internal( &cell->cell, newval );
- return;
- }
+ /* accept the newval string if user action was delete */
+ if (change == NULL)
+ {
+ gnc_basic_cell_set_value_internal( &cell->cell, newval );
+ return;
+ }
- if (cell->print_info.monetary)
- decimal_point = g_utf8_get_char(lc->mon_decimal_point);
- else
- decimal_point = g_utf8_get_char(lc->decimal_point);
+ if (cell->print_info.monetary)
+ decimal_point = g_utf8_get_char(lc->mon_decimal_point);
+ else
+ decimal_point = g_utf8_get_char(lc->decimal_point);
- if (cell->print_info.monetary)
- thousands_sep = g_utf8_get_char(lc->mon_thousands_sep);
- else
- thousands_sep = g_utf8_get_char(lc->thousands_sep);
+ if (cell->print_info.monetary)
+ thousands_sep = g_utf8_get_char(lc->mon_thousands_sep);
+ else
+ thousands_sep = g_utf8_get_char(lc->thousands_sep);
- c = change;
- while (*c)
- {
- uc = g_utf8_get_char (c);
- if (!g_unichar_isdigit (uc) &&
- !g_unichar_isspace (uc) &&
- !g_unichar_isalpha (uc) &&
- (decimal_point != uc) &&
- (thousands_sep != uc) &&
- (g_utf8_strchr (toks, -1, uc) == NULL))
- return;
- c = g_utf8_next_char (c);
- }
+ c = change;
+ while (*c)
+ {
+ uc = g_utf8_get_char (c);
+ if (!g_unichar_isdigit (uc) &&
+ !g_unichar_isspace (uc) &&
+ !g_unichar_isalpha (uc) &&
+ (decimal_point != uc) &&
+ (thousands_sep != uc) &&
+ (g_utf8_strchr (toks, -1, uc) == NULL))
+ return;
+ c = g_utf8_next_char (c);
+ }
- gnc_basic_cell_set_value_internal( &cell->cell, newval );
+ gnc_basic_cell_set_value_internal( &cell->cell, newval );
}
static
@@ -185,7 +185,7 @@
gnc_formula_cell_set_value_internal( BasicCell *_cell,
const char *str )
{
- FormulaCell *fc = (FormulaCell*)_cell;
- g_debug("internal string: [%s]", str);
- gnc_basic_cell_set_value_internal( &fc->cell, str );
+ FormulaCell *fc = (FormulaCell*)_cell;
+ g_debug("internal string: [%s]", str);
+ gnc_basic_cell_set_value_internal( &fc->cell, str );
}
Modified: gnucash/trunk/src/register/register-core/formulacell.h
===================================================================
--- gnucash/trunk/src/register/register-core/formulacell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/formulacell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -24,14 +24,14 @@
* formulacell.h
*
* FUNCTION:
- *
+ *
* The FormulaCell is a register-table cell which can contain a formula
* involving numbers, formula markup and strings denoting either functions or
* variables.
*
* Copyright (c) 2002 Joshua Sled <jsled at asynchronous.org>
**/
-
+
#ifndef FORMULA_CELL_H
#define FORMULA_CELL_H
@@ -44,13 +44,13 @@
typedef struct _FormulaCell
{
- BasicCell cell;
+ BasicCell cell;
- /** The print-info for numeric values. **/
- GNCPrintAmountInfo print_info;
+ /** The print-info for numeric values. **/
+ GNCPrintAmountInfo print_info;
- /** The user-entered formula. **/
- char *formula;
+ /** The user-entered formula. **/
+ char *formula;
} FormulaCell;
/* installs a callback to handle date recording */
Modified: gnucash/trunk/src/register/register-core/gtable.c
===================================================================
--- gnucash/trunk/src/register/register-core/gtable.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/gtable.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -27,17 +27,17 @@
struct GTable
{
- GArray *array;
+ GArray *array;
- guint entry_size;
+ guint entry_size;
- int rows;
- int cols;
+ int rows;
+ int cols;
- g_table_entry_constructor constructor;
- g_table_entry_destroyer destroyer;
+ g_table_entry_constructor constructor;
+ g_table_entry_destroyer destroyer;
- gpointer user_data;
+ gpointer user_data;
};
GTable *
@@ -46,125 +46,125 @@
g_table_entry_destroyer destroyer,
gpointer user_data)
{
- GTable *gtable;
+ GTable *gtable;
- gtable = g_new(GTable, 1);
+ gtable = g_new(GTable, 1);
- gtable->array = g_array_new(FALSE, FALSE, entry_size);
+ gtable->array = g_array_new(FALSE, FALSE, entry_size);
- gtable->entry_size = entry_size;
+ gtable->entry_size = entry_size;
- gtable->rows = 0;
- gtable->cols = 0;
+ gtable->rows = 0;
+ gtable->cols = 0;
- gtable->constructor = constructor;
- gtable->destroyer = destroyer;
+ gtable->constructor = constructor;
+ gtable->destroyer = destroyer;
- gtable->user_data = user_data;
+ gtable->user_data = user_data;
- return gtable;
+ return gtable;
}
void
g_table_destroy (GTable *gtable)
{
- if (gtable == NULL)
- return;
+ if (gtable == NULL)
+ return;
- g_table_resize (gtable, 0, 0);
+ g_table_resize (gtable, 0, 0);
- g_array_free (gtable->array, TRUE);
+ g_array_free (gtable->array, TRUE);
- gtable->array = NULL;
+ gtable->array = NULL;
- g_free(gtable);
+ g_free(gtable);
}
gpointer
g_table_index (GTable *gtable, int row, int col)
{
- guint index;
+ guint index;
- if (gtable == NULL)
- return NULL;
- if ((row < 0) || (col < 0))
- return NULL;
- if (row >= gtable->rows)
- return NULL;
- if (col >= gtable->cols)
- return NULL;
+ if (gtable == NULL)
+ return NULL;
+ if ((row < 0) || (col < 0))
+ return NULL;
+ if (row >= gtable->rows)
+ return NULL;
+ if (col >= gtable->cols)
+ return NULL;
- index = ((row * gtable->cols) + col) * gtable->entry_size;
+ index = ((row * gtable->cols) + col) * gtable->entry_size;
- return >able->array->data[index];
+ return >able->array->data[index];
}
void
g_table_resize (GTable *gtable, int rows, int cols)
{
- guint old_len;
- guint new_len;
+ guint old_len;
+ guint new_len;
- if (gtable == NULL)
- return;
- if ((rows < 0) || (cols < 0))
- return;
+ if (gtable == NULL)
+ return;
+ if ((rows < 0) || (cols < 0))
+ return;
- old_len = gtable->array->len;
- new_len = rows * cols;
+ old_len = gtable->array->len;
+ new_len = rows * cols;
- if (new_len == old_len)
- return;
+ if (new_len == old_len)
+ return;
- /* If shrinking, destroy extra cells */
- if ((new_len < old_len) && gtable->destroyer)
- {
- gchar *entry;
- guint i;
+ /* If shrinking, destroy extra cells */
+ if ((new_len < old_len) && gtable->destroyer)
+ {
+ gchar *entry;
+ guint i;
- entry = >able->array->data[new_len * gtable->entry_size];
- for (i = new_len; i < old_len; i++)
- {
- gtable->destroyer(entry, gtable->user_data);
- entry += gtable->entry_size;
+ entry = >able->array->data[new_len * gtable->entry_size];
+ for (i = new_len; i < old_len; i++)
+ {
+ gtable->destroyer(entry, gtable->user_data);
+ entry += gtable->entry_size;
+ }
}
- }
- /* Change the size */
- g_array_set_size(gtable->array, new_len);
+ /* Change the size */
+ g_array_set_size(gtable->array, new_len);
- /* If expanding, construct the new cells */
- if ((new_len > old_len) && gtable->constructor)
- {
- gchar *entry;
- guint i;
+ /* If expanding, construct the new cells */
+ if ((new_len > old_len) && gtable->constructor)
+ {
+ gchar *entry;
+ guint i;
- entry = >able->array->data[old_len * gtable->entry_size];
- for (i = old_len; i < new_len; i++)
- {
- gtable->constructor(entry, gtable->user_data);
- entry += gtable->entry_size;
+ entry = >able->array->data[old_len * gtable->entry_size];
+ for (i = old_len; i < new_len; i++)
+ {
+ gtable->constructor(entry, gtable->user_data);
+ entry += gtable->entry_size;
+ }
}
- }
- gtable->rows = rows;
- gtable->cols = cols;
+ gtable->rows = rows;
+ gtable->cols = cols;
}
int
g_table_rows (GTable *gtable)
{
- if (gtable == NULL)
- return 0;
+ if (gtable == NULL)
+ return 0;
- return gtable->rows;
+ return gtable->rows;
}
int
g_table_cols (GTable *gtable)
{
- if (gtable == NULL)
- return 0;
+ if (gtable == NULL)
+ return 0;
- return gtable->cols;
+ return gtable->cols;
}
Modified: gnucash/trunk/src/register/register-core/gtable.h
===================================================================
--- gnucash/trunk/src/register/register-core/gtable.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/gtable.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -27,7 +27,7 @@
/* This is the API for GTables, a datatype for 2-dimensional tables
- * with automatic resizing and memory management.
+ * with automatic resizing and memory management.
*
* HACK ALERT -- this thing should proably become a part of glib (??)
*/
Modified: gnucash/trunk/src/register/register-core/numcell.c
===================================================================
--- gnucash/trunk/src/register/register-core/numcell.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/numcell.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -52,27 +52,27 @@
static gboolean
gnc_parse_num (const char *string, long int *num)
{
- long int number;
+ long int number;
- if (string == NULL)
- return FALSE;
+ if (string == NULL)
+ return FALSE;
- if (!gnc_strisnum (string))
- return FALSE;
+ if (!gnc_strisnum (string))
+ return FALSE;
- number = strtol (string, NULL, 10);
+ number = strtol (string, NULL, 10);
- if ((number == LONG_MIN) || (number == LONG_MAX))
- return FALSE;
+ if ((number == LONG_MIN) || (number == LONG_MAX))
+ return FALSE;
- if (num != NULL)
- *num = number;
+ if (num != NULL)
+ *num = number;
- return TRUE;
+ return TRUE;
}
static void
-gnc_num_cell_modify_verify (BasicCell *_cell,
+gnc_num_cell_modify_verify (BasicCell *_cell,
const char *change,
int change_len,
const char *newval,
@@ -81,158 +81,158 @@
int *start_selection,
int *end_selection)
{
- NumCell *cell = (NumCell *) _cell;
- gboolean accel = FALSE;
- gboolean is_num;
- long int number = 0;
- gunichar uc;
- glong change_chars;
-
- if (change == NULL) /* if we are deleting */
- /* then just accept the proposed change */
- {
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
- return;
- }
+ NumCell *cell = (NumCell *) _cell;
+ gboolean accel = FALSE;
+ gboolean is_num;
+ long int number = 0;
+ gunichar uc;
+ glong change_chars;
- change_chars = g_utf8_strlen (change, -1);
+ if (change == NULL) /* if we are deleting */
+ /* then just accept the proposed change */
+ {
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
+ return;
+ }
- if ((change_chars == 0) || /* if we are deleting */
- (change_chars > 1)) /* or entering > 1 char */
- /* then just accept the proposed change */
- {
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
- return;
- }
+ change_chars = g_utf8_strlen (change, -1);
- /* otherwise, it may be an accelerator key. */
+ if ((change_chars == 0) || /* if we are deleting */
+ (change_chars > 1)) /* or entering > 1 char */
+ /* then just accept the proposed change */
+ {
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
+ return;
+ }
- is_num = gnc_parse_num (_cell->value, &number);
+ /* otherwise, it may be an accelerator key. */
- if (is_num && (number < 0))
- is_num = FALSE;
+ is_num = gnc_parse_num (_cell->value, &number);
- uc = g_utf8_get_char (change);
- switch (uc)
- {
+ if (is_num && (number < 0))
+ is_num = FALSE;
+
+ uc = g_utf8_get_char (change);
+ switch (uc)
+ {
case '+':
case '=':
- number++;
- accel = TRUE;
- break;
+ number++;
+ accel = TRUE;
+ break;
case '_':
case '-':
- number--;
- accel = TRUE;
- break;
+ number--;
+ accel = TRUE;
+ break;
case '}':
case ']':
- number += 10;
- accel = TRUE;
- break;
+ number += 10;
+ accel = TRUE;
+ break;
case '{':
case '[':
- number -= 10;
- accel = TRUE;
- break;
- }
+ number -= 10;
+ accel = TRUE;
+ break;
+ }
- if (number < 0)
- number = 0;
+ if (number < 0)
+ number = 0;
- /* If there is already a non-number there, don't accelerate. */
- if (accel && !is_num && (safe_strcmp(_cell->value, "") != 0))
- accel = FALSE;
+ /* If there is already a non-number there, don't accelerate. */
+ if (accel && !is_num && (safe_strcmp(_cell->value, "") != 0))
+ accel = FALSE;
- if (accel)
- {
- char buff[128];
+ if (accel)
+ {
+ char buff[128];
- if (!is_num)
- number = cell->next_num;
+ if (!is_num)
+ number = cell->next_num;
- strcpy (buff, "");
- snprintf (buff, sizeof(buff), "%ld", number);
+ strcpy (buff, "");
+ snprintf (buff, sizeof(buff), "%ld", number);
- if (safe_strcmp (buff, "") == 0)
- return;
+ if (safe_strcmp (buff, "") == 0)
+ return;
- gnc_basic_cell_set_value_internal (&cell->cell, buff);
+ gnc_basic_cell_set_value_internal (&cell->cell, buff);
- *cursor_position = -1;
+ *cursor_position = -1;
- return;
- }
+ return;
+ }
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
}
BasicCell *
gnc_num_cell_new (void)
{
- NumCell *cell;
+ NumCell *cell;
- cell = g_new0 (NumCell, 1);
+ cell = g_new0 (NumCell, 1);
- gnc_num_cell_init (cell);
+ gnc_num_cell_init (cell);
- return &cell->cell;
+ return &cell->cell;
}
-static void
+static void
gnc_num_cell_set_value_internal (BasicCell *_cell, const char *str)
{
- NumCell *cell = (NumCell *) _cell;
+ NumCell *cell = (NumCell *) _cell;
- if (!cell->next_num_set)
- {
- long int number;
+ if (!cell->next_num_set)
+ {
+ long int number;
- if (gnc_parse_num (str, &number))
- cell->next_num = number + 1;
- }
+ if (gnc_parse_num (str, &number))
+ cell->next_num = number + 1;
+ }
- gnc_basic_cell_set_value_internal (_cell, str);
+ gnc_basic_cell_set_value_internal (_cell, str);
}
void
gnc_num_cell_set_value (NumCell *cell, const char *str)
{
- if (!cell)
- return;
+ if (!cell)
+ return;
- gnc_num_cell_set_value_internal (&cell->cell, str);
+ gnc_num_cell_set_value_internal (&cell->cell, str);
}
gboolean
gnc_num_cell_set_last_num (NumCell *cell, const char *str)
{
- long int number;
+ long int number;
- if (!cell)
- return FALSE;
+ if (!cell)
+ return FALSE;
- if (gnc_parse_num (str, &number))
- {
- cell->next_num = number + 1;
- cell->next_num_set = TRUE;
- return TRUE;
- }
+ if (gnc_parse_num (str, &number))
+ {
+ cell->next_num = number + 1;
+ cell->next_num_set = TRUE;
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
static void
gnc_num_cell_init (NumCell *cell)
{
- gnc_basic_cell_init (&(cell->cell));
+ gnc_basic_cell_init (&(cell->cell));
- cell->next_num = 0;
- cell->next_num_set = FALSE;
-
- cell->cell.modify_verify = gnc_num_cell_modify_verify;
- cell->cell.set_value = gnc_num_cell_set_value_internal;
+ cell->next_num = 0;
+ cell->next_num_set = FALSE;
+
+ cell->cell.modify_verify = gnc_num_cell_modify_verify;
+ cell->cell.set_value = gnc_num_cell_set_value_internal;
}
Modified: gnucash/trunk/src/register/register-core/numcell.h
===================================================================
--- gnucash/trunk/src/register/register-core/numcell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/numcell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -31,7 +31,7 @@
* HISTORY:
* Copyright (c) 2000 Dave Peticolas <dave at krondo.com>
*/
-
+
#ifndef NUM_CELL_H
#define NUM_CELL_H
@@ -39,9 +39,9 @@
typedef struct
{
- BasicCell cell;
- long int next_num;
- gboolean next_num_set;
+ BasicCell cell;
+ long int next_num;
+ gboolean next_num_set;
} NumCell;
BasicCell * gnc_num_cell_new (void);
Modified: gnucash/trunk/src/register/register-core/pricecell.c
===================================================================
--- gnucash/trunk/src/register/register-core/pricecell.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/pricecell.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -50,7 +50,7 @@
static void gnc_price_cell_init (PriceCell *cell);
static void gnc_price_cell_set_value_internal (BasicCell *bcell,
- const char *value);
+ const char *value);
static const char * gnc_price_cell_print_value (PriceCell *cell);
@@ -60,11 +60,11 @@
int *start_selection,
int *end_selection)
{
- *cursor_position = -1;
- *start_selection = 0;
- *end_selection = -1;
+ *cursor_position = -1;
+ *start_selection = 0;
+ *end_selection = -1;
- return TRUE;
+ return TRUE;
}
static void
@@ -77,223 +77,223 @@
int *start_selection,
int *end_selection)
{
- PriceCell *cell = (PriceCell *) _cell;
- struct lconv *lc = gnc_localeconv ();
- const char *toks = "+-*/=()_";
- gunichar decimal_point;
- gunichar thousands_sep;
- const char *c;
- gunichar uc;
+ PriceCell *cell = (PriceCell *) _cell;
+ struct lconv *lc = gnc_localeconv ();
+ const char *toks = "+-*/=()_";
+ gunichar decimal_point;
+ gunichar thousands_sep;
+ const char *c;
+ gunichar uc;
- /* accept the newval string if user action was delete */
- if (change == NULL)
- {
- gnc_basic_cell_set_value_internal (_cell, newval);
- cell->need_to_parse = TRUE;
- return;
- }
+ /* accept the newval string if user action was delete */
+ if (change == NULL)
+ {
+ gnc_basic_cell_set_value_internal (_cell, newval);
+ cell->need_to_parse = TRUE;
+ return;
+ }
- if (cell->print_info.monetary)
- decimal_point = g_utf8_get_char(lc->mon_decimal_point);
- else
- decimal_point = g_utf8_get_char(lc->decimal_point);
+ if (cell->print_info.monetary)
+ decimal_point = g_utf8_get_char(lc->mon_decimal_point);
+ else
+ decimal_point = g_utf8_get_char(lc->decimal_point);
- if (cell->print_info.monetary)
- thousands_sep = g_utf8_get_char(lc->mon_thousands_sep);
- else
- thousands_sep = g_utf8_get_char(lc->thousands_sep);
+ if (cell->print_info.monetary)
+ thousands_sep = g_utf8_get_char(lc->mon_thousands_sep);
+ else
+ thousands_sep = g_utf8_get_char(lc->thousands_sep);
- c = change;
- while (*c)
- {
- uc = g_utf8_get_char (c);
- if (!g_unichar_isdigit (uc) &&
- !g_unichar_isspace (uc) &&
- !g_unichar_isalpha (uc) &&
- (decimal_point != uc) &&
- (thousands_sep != uc) &&
- (g_utf8_strchr (toks, -1, uc) == NULL))
- return;
- c = g_utf8_next_char (c);
- }
+ c = change;
+ while (*c)
+ {
+ uc = g_utf8_get_char (c);
+ if (!g_unichar_isdigit (uc) &&
+ !g_unichar_isspace (uc) &&
+ !g_unichar_isalpha (uc) &&
+ (decimal_point != uc) &&
+ (thousands_sep != uc) &&
+ (g_utf8_strchr (toks, -1, uc) == NULL))
+ return;
+ c = g_utf8_next_char (c);
+ }
- gnc_basic_cell_set_value_internal (_cell, newval);
- cell->need_to_parse = TRUE;
+ gnc_basic_cell_set_value_internal (_cell, newval);
+ cell->need_to_parse = TRUE;
}
static gint
gnc_price_cell_parse (PriceCell *cell, gboolean update_value)
{
- const char *newval;
- char *oldval;
- gnc_numeric amount;
+ const char *newval;
+ char *oldval;
+ gnc_numeric amount;
- if (!cell->need_to_parse)
- return -1;
+ if (!cell->need_to_parse)
+ return -1;
- oldval = cell->cell.value;
- if (oldval == NULL)
- oldval = "";
+ oldval = cell->cell.value;
+ if (oldval == NULL)
+ oldval = "";
- {
- char *err_location = NULL;
- if (strlen(g_strstrip(cell->cell.value)) == 0)
{
- cell->amount = gnc_numeric_zero ();
- }
- else if (gnc_exp_parser_parse (cell->cell.value, &amount, &err_location))
- {
- if (cell->fraction > 0)
- amount = gnc_numeric_convert (amount, cell->fraction, GNC_RND_ROUND);
+ char *err_location = NULL;
+ if (strlen(g_strstrip(cell->cell.value)) == 0)
+ {
+ cell->amount = gnc_numeric_zero ();
+ }
+ else if (gnc_exp_parser_parse (cell->cell.value, &amount, &err_location))
+ {
+ if (cell->fraction > 0)
+ amount = gnc_numeric_convert (amount, cell->fraction, GNC_RND_ROUND);
- cell->amount = amount;
+ cell->amount = amount;
+ }
+ else
+ {
+ return (err_location - cell->cell.value);
+ }
}
- else
- {
- return (err_location - cell->cell.value);
- }
- }
- if (!update_value)
- return -1;
+ if (!update_value)
+ return -1;
- newval = gnc_price_cell_print_value (cell);
+ newval = gnc_price_cell_print_value (cell);
- /* If they are identical do nothing */
- if (strcmp(newval, oldval) == 0)
+ /* If they are identical do nothing */
+ if (strcmp(newval, oldval) == 0)
+ return -1;
+
+ /* Otherwise, change it */
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
return -1;
-
- /* Otherwise, change it */
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
- return -1;
}
static void
-gnc_price_cell_leave (BasicCell *_cell)
+gnc_price_cell_leave (BasicCell *_cell)
{
- gint error_position = -1;
- PriceCell *cell = (PriceCell *) _cell;
+ gint error_position = -1;
+ PriceCell *cell = (PriceCell *) _cell;
- error_position = gnc_price_cell_parse (cell, TRUE);
- if (error_position != -1)
- {
- gnc_warning_dialog(NULL, _("An error occurred while processing %s."),
- cell->cell.value);
- }
+ error_position = gnc_price_cell_parse (cell, TRUE);
+ if (error_position != -1)
+ {
+ gnc_warning_dialog(NULL, _("An error occurred while processing %s."),
+ cell->cell.value);
+ }
}
BasicCell *
gnc_price_cell_new (void)
{
- PriceCell *cell;
+ PriceCell *cell;
- cell = g_new0 (PriceCell, 1);
+ cell = g_new0 (PriceCell, 1);
- gnc_price_cell_init (cell);
+ gnc_price_cell_init (cell);
- return &cell->cell;
+ return &cell->cell;
}
void
gnc_price_cell_init (PriceCell *cell)
{
- gnc_basic_cell_init (&(cell->cell));
+ gnc_basic_cell_init (&(cell->cell));
- cell->amount = gnc_numeric_zero ();
- cell->fraction = 0;
- cell->blank_zero = TRUE;
+ cell->amount = gnc_numeric_zero ();
+ cell->fraction = 0;
+ cell->blank_zero = TRUE;
- cell->print_info = gnc_default_print_info (FALSE);
+ cell->print_info = gnc_default_print_info (FALSE);
- cell->need_to_parse = FALSE;
+ cell->need_to_parse = FALSE;
- cell->cell.enter_cell = gnc_price_cell_enter;
- cell->cell.modify_verify = gnc_price_cell_modify_verify;
- cell->cell.leave_cell = gnc_price_cell_leave;
- cell->cell.set_value = gnc_price_cell_set_value_internal;
+ cell->cell.enter_cell = gnc_price_cell_enter;
+ cell->cell.modify_verify = gnc_price_cell_modify_verify;
+ cell->cell.leave_cell = gnc_price_cell_leave;
+ cell->cell.set_value = gnc_price_cell_set_value_internal;
}
static const char *
gnc_price_cell_print_value (PriceCell *cell)
{
- if (cell->blank_zero && gnc_numeric_zero_p (cell->amount))
- return "";
+ if (cell->blank_zero && gnc_numeric_zero_p (cell->amount))
+ return "";
- return xaccPrintAmount (cell->amount, cell->print_info);
+ return xaccPrintAmount (cell->amount, cell->print_info);
}
gnc_numeric
gnc_price_cell_get_value (PriceCell *cell)
{
- if (cell == NULL)
- return gnc_numeric_zero ();
+ if (cell == NULL)
+ return gnc_numeric_zero ();
- gnc_price_cell_parse (cell, FALSE);
+ gnc_price_cell_parse (cell, FALSE);
- return cell->amount;
+ return cell->amount;
}
gboolean
gnc_price_cell_set_value (PriceCell * cell, gnc_numeric amount)
{
- const char *buff;
+ const char *buff;
- if (cell == NULL)
- return FALSE;
+ if (cell == NULL)
+ return FALSE;
- if (cell->fraction > 0)
- amount = gnc_numeric_convert (amount, cell->fraction, GNC_RND_ROUND);
+ if (cell->fraction > 0)
+ amount = gnc_numeric_convert (amount, cell->fraction, GNC_RND_ROUND);
- cell->amount = amount;
- buff = gnc_price_cell_print_value (cell);
- cell->need_to_parse = FALSE;
+ cell->amount = amount;
+ buff = gnc_price_cell_print_value (cell);
+ cell->need_to_parse = FALSE;
- if (safe_strcmp (buff, cell->cell.value) == 0)
- return FALSE;
+ if (safe_strcmp (buff, cell->cell.value) == 0)
+ return FALSE;
- gnc_basic_cell_set_value_internal (&cell->cell, buff);
+ gnc_basic_cell_set_value_internal (&cell->cell, buff);
- return TRUE;
+ return TRUE;
}
void
gnc_price_cell_set_fraction (PriceCell *cell, int fraction)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- cell->fraction = ABS (fraction);
+ cell->fraction = ABS (fraction);
}
void
gnc_price_cell_blank (PriceCell *cell)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- cell->amount = gnc_numeric_zero ();
- cell->need_to_parse = FALSE;
+ cell->amount = gnc_numeric_zero ();
+ cell->need_to_parse = FALSE;
- gnc_basic_cell_set_value_internal (&cell->cell, "");
+ gnc_basic_cell_set_value_internal (&cell->cell, "");
}
void
gnc_price_cell_set_blank_zero (PriceCell *cell, gboolean blank_zero)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- cell->blank_zero = blank_zero;
+ cell->blank_zero = blank_zero;
}
void
gnc_price_cell_set_print_info (PriceCell *cell, GNCPrintAmountInfo print_info)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- cell->print_info = print_info;
+ cell->print_info = print_info;
}
void
@@ -301,30 +301,30 @@
PriceCell * credit,
gnc_numeric amount)
{
- /* debits are positive, credits are negative */
- if (gnc_numeric_positive_p (amount))
- {
- gnc_price_cell_set_value (debit, amount);
- gnc_price_cell_set_value (credit, gnc_numeric_zero ());
- }
- else
- {
- gnc_price_cell_set_value (debit, gnc_numeric_zero ());
- gnc_price_cell_set_value (credit, gnc_numeric_neg (amount));
- }
+ /* debits are positive, credits are negative */
+ if (gnc_numeric_positive_p (amount))
+ {
+ gnc_price_cell_set_value (debit, amount);
+ gnc_price_cell_set_value (credit, gnc_numeric_zero ());
+ }
+ else
+ {
+ gnc_price_cell_set_value (debit, gnc_numeric_zero ());
+ gnc_price_cell_set_value (credit, gnc_numeric_neg (amount));
+ }
}
-static void
+static void
gnc_price_cell_set_value_internal (BasicCell *_cell, const char *str)
{
- PriceCell *cell = (PriceCell *) _cell;
- gnc_numeric amount;
+ PriceCell *cell = (PriceCell *) _cell;
+ gnc_numeric amount;
- if (str == NULL)
- str = "";
+ if (str == NULL)
+ str = "";
- if (*str == '\0')
- gnc_price_cell_set_value (cell, gnc_numeric_zero ());
- else if (gnc_exp_parser_parse (str, &amount, NULL))
- gnc_price_cell_set_value (cell, amount);
+ if (*str == '\0')
+ gnc_price_cell_set_value (cell, gnc_numeric_zero ());
+ else if (gnc_exp_parser_parse (str, &amount, NULL))
+ gnc_price_cell_set_value (cell, amount);
}
Modified: gnucash/trunk/src/register/register-core/pricecell.h
===================================================================
--- gnucash/trunk/src/register/register-core/pricecell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/pricecell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -26,8 +26,8 @@
*
* FUNCTION:
* The PriceCell object implements a cell handler that stores
- * a single double-precision value, and has the smarts to
- * display it as a price/amount as well as accepting monetary
+ * a single double-precision value, and has the smarts to
+ * display it as a price/amount as well as accepting monetary
* or general numeric input.
*
* By default, the PriceCell is an input/output cell.
@@ -50,17 +50,17 @@
typedef struct
{
- BasicCell cell;
+ BasicCell cell;
- gnc_numeric amount; /* the amount associated with this cell */
+ gnc_numeric amount; /* the amount associated with this cell */
- int fraction; /* fraction used for rounding, if 0 no rounding */
+ int fraction; /* fraction used for rounding, if 0 no rounding */
- gboolean blank_zero; /* controls printing of zero values */
+ gboolean blank_zero; /* controls printing of zero values */
- GNCPrintAmountInfo print_info; /* amount printing context */
+ GNCPrintAmountInfo print_info; /* amount printing context */
- gboolean need_to_parse; /* internal */
+ gboolean need_to_parse; /* internal */
} PriceCell;
/* installs a callback to handle price recording */
@@ -82,16 +82,16 @@
/* determines whether 0 values are left blank or printed.
* defaults to true. */
void gnc_price_cell_set_blank_zero (PriceCell *cell,
- gboolean blank_zero);
+ gboolean blank_zero);
/* set the printing context of the price cell */
void gnc_price_cell_set_print_info (PriceCell *cell,
- GNCPrintAmountInfo print_info);
+ GNCPrintAmountInfo print_info);
/* updates two cells; the deb cell if amt is negative, the credit cell
* if amount is positive, and makes the other cell blank. */
void gnc_price_cell_set_debt_credit_value (PriceCell *debit,
- PriceCell *credit,
- gnc_numeric amount);
+ PriceCell *credit,
+ gnc_numeric amount);
#endif
Modified: gnucash/trunk/src/register/register-core/quickfillcell.c
===================================================================
--- gnucash/trunk/src/register/register-core/quickfillcell.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/quickfillcell.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -1,6 +1,6 @@
/********************************************************************\
* quickfillcell.c -- autocompletion based on memorized history *
- * *
+ * *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
@@ -46,15 +46,15 @@
static void gnc_quickfill_cell_set_original (QuickFillCell *cell,
- const char *original);
+ const char *original);
static void
gnc_quickfill_cell_set_value_internal (BasicCell *_cell,
const char *val)
{
- QuickFillCell *cell = (QuickFillCell *) _cell;
- gnc_quickfill_cell_set_value (cell, val);
+ QuickFillCell *cell = (QuickFillCell *) _cell;
+ gnc_quickfill_cell_set_value (cell, val);
}
/* when entering new cell, put cursor at end and select everything */
@@ -64,93 +64,93 @@
int *start_selection,
int *end_selection)
{
- QuickFillCell *cell = (QuickFillCell *) _cell;
+ QuickFillCell *cell = (QuickFillCell *) _cell;
- *cursor_position = -1;
- *start_selection = 0;
- *end_selection = -1;
+ *cursor_position = -1;
+ *start_selection = 0;
+ *end_selection = -1;
- gnc_quickfill_cell_set_original (cell, NULL);
+ gnc_quickfill_cell_set_original (cell, NULL);
- return TRUE;
+ return TRUE;
}
static gboolean
utf8_caseequal (const char *s1, const char *s2)
{
- char *s1new;
- char *s2new;
- gboolean equal = FALSE;
-
- if (s1 == s2)
- return TRUE;
-
- if (!s1 || !s2)
- return FALSE;
+ char *s1new;
+ char *s2new;
+ gboolean equal = FALSE;
- s1new = g_utf8_casefold(s1, -1);
- s2new = g_utf8_casefold(s2, -1);
+ if (s1 == s2)
+ return TRUE;
- if (g_utf8_collate(s1new, s2new) == 0)
- equal = TRUE;
+ if (!s1 || !s2)
+ return FALSE;
- g_free (s1new);
- g_free (s2new);
-
- return equal;
+ s1new = g_utf8_casefold(s1, -1);
+ s2new = g_utf8_casefold(s2, -1);
+
+ if (g_utf8_collate(s1new, s2new) == 0)
+ equal = TRUE;
+
+ g_free (s1new);
+ g_free (s2new);
+
+ return equal;
}
static gboolean
utf8_caseequal_len (const char *s1, const char *s2, guint len)
-{
- gchar *s1new;
- gchar *s2new;
- const gchar *s1_offset;
- const gchar *s2_offset;
- glong s1chars;
- glong s2chars;
- glong s1_bytes_len;
- glong s2_bytes_len;
- gboolean equal = FALSE;
-
- if (len == 0)
- return TRUE;
-
- if (s1 == s2)
- return TRUE;
-
- if (!s1 || !s2)
- return FALSE;
+{
+ gchar *s1new;
+ gchar *s2new;
+ const gchar *s1_offset;
+ const gchar *s2_offset;
+ glong s1chars;
+ glong s2chars;
+ glong s1_bytes_len;
+ glong s2_bytes_len;
+ gboolean equal = FALSE;
- /* Obtain the number of bytes for the given number of characters */
- s1_offset = g_utf8_offset_to_pointer (s1, len);
- s2_offset = g_utf8_offset_to_pointer (s2, len);
- s1_bytes_len = s1_offset - s1;
- s2_bytes_len = s2_offset - s2;
+ if (len == 0)
+ return TRUE;
- /* Test whether the number of characters might be too small anyway
- (dont need to examine more than bytes_len bytes to check that) */
- s1chars = g_utf8_strlen (s1, s1_bytes_len);
- s2chars = g_utf8_strlen (s2, s2_bytes_len);
- if ( (s1chars < len) || (s2chars < len) )
- return FALSE;
+ if (s1 == s2)
+ return TRUE;
- /* Allocate new strings that are case-independent. */
- s1new = g_utf8_casefold (s1, s1_bytes_len);
- s2new = g_utf8_casefold (s2, s2_bytes_len);
+ if (!s1 || !s2)
+ return FALSE;
- /* equal = utf8_caseequal (s1new, s2new); */
- /* ^^ don't call this to save one string allocation; we used
- g_utf8_casefold here already. */
+ /* Obtain the number of bytes for the given number of characters */
+ s1_offset = g_utf8_offset_to_pointer (s1, len);
+ s2_offset = g_utf8_offset_to_pointer (s2, len);
+ s1_bytes_len = s1_offset - s1;
+ s2_bytes_len = s2_offset - s2;
- /* Now really compare the two strings */
- if (g_utf8_collate(s1new, s2new) == 0)
- equal = TRUE;
-
- g_free (s1new);
- g_free (s2new);
-
- return equal;
+ /* Test whether the number of characters might be too small anyway
+ (dont need to examine more than bytes_len bytes to check that) */
+ s1chars = g_utf8_strlen (s1, s1_bytes_len);
+ s2chars = g_utf8_strlen (s2, s2_bytes_len);
+ if ( (s1chars < len) || (s2chars < len) )
+ return FALSE;
+
+ /* Allocate new strings that are case-independent. */
+ s1new = g_utf8_casefold (s1, s1_bytes_len);
+ s2new = g_utf8_casefold (s2, s2_bytes_len);
+
+ /* equal = utf8_caseequal (s1new, s2new); */
+ /* ^^ don't call this to save one string allocation; we used
+ g_utf8_casefold here already. */
+
+ /* Now really compare the two strings */
+ if (g_utf8_collate(s1new, s2new) == 0)
+ equal = TRUE;
+
+ g_free (s1new);
+ g_free (s2new);
+
+ return equal;
}
static void
@@ -163,181 +163,181 @@
int *start_selection,
int *end_selection)
{
- QuickFillCell *cell = (QuickFillCell *) _cell;
- const char *match_str;
- QuickFill *match;
+ QuickFillCell *cell = (QuickFillCell *) _cell;
+ const char *match_str;
+ QuickFill *match;
- glong newval_chars;
- glong change_chars;
+ glong newval_chars;
+ glong change_chars;
- newval_chars = g_utf8_strlen(newval, newval_len);
- change_chars = g_utf8_strlen(change, change_len);
-
- /* If deleting, just accept */
- if (change == NULL)
- {
- /* if the new value is a prefix of the original modulo case,
- * just truncate the end of the original. Otherwise, set it
- * to NULL */
- if ((*cursor_position >= newval_chars) &&
- (cell->original != NULL) &&
- (g_utf8_strlen (cell->original, -1) >= newval_chars) &&
- utf8_caseequal_len (cell->original, newval, newval_chars))
- {
- gchar *temp = g_strndup (cell->original, newval_len);
- gnc_quickfill_cell_set_original (cell, temp);
- g_free (temp);
- }
- else
- gnc_quickfill_cell_set_original (cell, NULL);
+ newval_chars = g_utf8_strlen(newval, newval_len);
+ change_chars = g_utf8_strlen(change, change_len);
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
- return;
- }
+ /* If deleting, just accept */
+ if (change == NULL)
+ {
+ /* if the new value is a prefix of the original modulo case,
+ * just truncate the end of the original. Otherwise, set it
+ * to NULL */
+ if ((*cursor_position >= newval_chars) &&
+ (cell->original != NULL) &&
+ (g_utf8_strlen (cell->original, -1) >= newval_chars) &&
+ utf8_caseequal_len (cell->original, newval, newval_chars))
+ {
+ gchar *temp = g_strndup (cell->original, newval_len);
+ gnc_quickfill_cell_set_original (cell, temp);
+ g_free (temp);
+ }
+ else
+ gnc_quickfill_cell_set_original (cell, NULL);
- /* If we are inserting in the middle, just accept */
- if (*cursor_position < _cell->value_chars)
- {
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
- gnc_quickfill_cell_set_original (cell, NULL);
- return;
- }
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
+ return;
+ }
- if (cell->original == NULL)
- cell->original = g_strdup (newval);
- else if (utf8_caseequal (cell->original, _cell->value))
- {
- GString *original;
+ /* If we are inserting in the middle, just accept */
+ if (*cursor_position < _cell->value_chars)
+ {
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
+ gnc_quickfill_cell_set_original (cell, NULL);
+ return;
+ }
- original = g_string_new (cell->original);
- g_string_append (original, change);
+ if (cell->original == NULL)
+ cell->original = g_strdup (newval);
+ else if (utf8_caseequal (cell->original, _cell->value))
+ {
+ GString *original;
- g_free (cell->original);
- cell->original = g_strdup (original->str);
- g_string_free (original, TRUE);
- }
- else
- {
- g_free (cell->original);
- cell->original = NULL;
- }
+ original = g_string_new (cell->original);
+ g_string_append (original, change);
- match = gnc_quickfill_get_string_match (cell->qf, newval);
+ g_free (cell->original);
+ cell->original = g_strdup (original->str);
+ g_string_free (original, TRUE);
+ }
+ else
+ {
+ g_free (cell->original);
+ cell->original = NULL;
+ }
- match_str = gnc_quickfill_string (match);
+ match = gnc_quickfill_get_string_match (cell->qf, newval);
- if (match_str == NULL)
- {
- if (cell->original != NULL)
- newval = cell->original;
+ match_str = gnc_quickfill_string (match);
- *cursor_position = -1;
+ if (match_str == NULL)
+ {
+ if (cell->original != NULL)
+ newval = cell->original;
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
- return;
- }
+ *cursor_position = -1;
- *start_selection = newval_chars;
- *end_selection = -1;
- *cursor_position += change_chars;
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
+ return;
+ }
- gnc_basic_cell_set_value_internal (&cell->cell, match_str);
+ *start_selection = newval_chars;
+ *end_selection = -1;
+ *cursor_position += change_chars;
+
+ gnc_basic_cell_set_value_internal (&cell->cell, match_str);
}
/* when leaving cell, make sure that text was put into the qf */
static void
-gnc_quickfill_cell_leave (BasicCell * _cell)
+gnc_quickfill_cell_leave (BasicCell * _cell)
{
- QuickFillCell *cell = (QuickFillCell *) _cell;
+ QuickFillCell *cell = (QuickFillCell *) _cell;
- gnc_quickfill_insert (cell->qf, _cell->value, cell->sort);
+ gnc_quickfill_insert (cell->qf, _cell->value, cell->sort);
}
static void
gnc_quickfill_cell_destroy (BasicCell *bcell)
{
- QuickFillCell *cell = (QuickFillCell *) bcell;
+ QuickFillCell *cell = (QuickFillCell *) bcell;
- gnc_quickfill_destroy (cell->qf);
- cell->qf = NULL;
+ gnc_quickfill_destroy (cell->qf);
+ cell->qf = NULL;
- g_free (cell->original);
- cell->original = NULL;
+ g_free (cell->original);
+ cell->original = NULL;
- cell->cell.enter_cell = NULL;
- cell->cell.modify_verify = NULL;
- cell->cell.leave_cell = NULL;
- cell->cell.set_value = NULL;
+ cell->cell.enter_cell = NULL;
+ cell->cell.modify_verify = NULL;
+ cell->cell.leave_cell = NULL;
+ cell->cell.set_value = NULL;
}
static void
gnc_quickfill_cell_init (QuickFillCell *cell)
{
- gnc_basic_cell_init (&(cell->cell));
+ gnc_basic_cell_init (&(cell->cell));
- cell->qf = gnc_quickfill_new ();
- cell->sort = QUICKFILL_LIFO;
- cell->original = NULL;
+ cell->qf = gnc_quickfill_new ();
+ cell->sort = QUICKFILL_LIFO;
+ cell->original = NULL;
- cell->cell.destroy = gnc_quickfill_cell_destroy;
+ cell->cell.destroy = gnc_quickfill_cell_destroy;
- cell->cell.enter_cell = gnc_quickfill_cell_enter;
- cell->cell.modify_verify = gnc_quickfill_cell_modify_verify;
- cell->cell.leave_cell = gnc_quickfill_cell_leave;
- cell->cell.set_value = gnc_quickfill_cell_set_value_internal;
+ cell->cell.enter_cell = gnc_quickfill_cell_enter;
+ cell->cell.modify_verify = gnc_quickfill_cell_modify_verify;
+ cell->cell.leave_cell = gnc_quickfill_cell_leave;
+ cell->cell.set_value = gnc_quickfill_cell_set_value_internal;
}
BasicCell *
gnc_quickfill_cell_new (void)
{
- QuickFillCell *cell;
+ QuickFillCell *cell;
- cell = g_new0 (QuickFillCell, 1);
+ cell = g_new0 (QuickFillCell, 1);
- gnc_quickfill_cell_init (cell);
+ gnc_quickfill_cell_init (cell);
- return &cell->cell;
+ return &cell->cell;
}
void
gnc_quickfill_cell_set_value (QuickFillCell *cell, const char * value)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- gnc_basic_cell_set_value_internal (&cell->cell, value);
- gnc_quickfill_insert (cell->qf, value, cell->sort);
+ gnc_basic_cell_set_value_internal (&cell->cell, value);
+ gnc_quickfill_insert (cell->qf, value, cell->sort);
}
void
gnc_quickfill_cell_set_sort (QuickFillCell *cell, QuickFillSort sort)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- cell->sort = sort;
+ cell->sort = sort;
}
static void
gnc_quickfill_cell_set_original (QuickFillCell *cell, const char *original)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- g_free (cell->original);
+ g_free (cell->original);
- if ((original != NULL) && (*original != 0))
- cell->original = strdup (original);
- else
- cell->original = NULL;
+ if ((original != NULL) && (*original != 0))
+ cell->original = strdup (original);
+ else
+ cell->original = NULL;
}
void
gnc_quickfill_cell_add_completion (QuickFillCell *cell, const char *completion)
{
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- gnc_quickfill_insert (cell->qf, completion, cell->sort);
+ gnc_quickfill_insert (cell->qf, completion, cell->sort);
}
Modified: gnucash/trunk/src/register/register-core/quickfillcell.h
===================================================================
--- gnucash/trunk/src/register/register-core/quickfillcell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/quickfillcell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -25,17 +25,17 @@
* quickfillcell.h
*
* FUNCTION:
- * The QuickFillCell implements a text cell with quick-fill
- * capabilities. By "quick fill" we mean a cell that will
- * automatically sentance-complete the entry after the user
- * typed a sufficient number of letters to identify a unique
- * entry.
+ * The QuickFillCell implements a text cell with quick-fill
+ * capabilities. By "quick fill" we mean a cell that will
+ * automatically sentance-complete the entry after the user
+ * typed a sufficient number of letters to identify a unique
+ * entry.
*
* On the output side, this is just a plain text cell.
*
* METHODS:
* The xaccSetQuickFillCellValue() method sets the
- * current cell value to the indicated string,
+ * current cell value to the indicated string,
* simultaneously adding the string to the quick-fill
* tree.
*
@@ -52,24 +52,24 @@
typedef struct
{
- BasicCell cell;
- QuickFill *qf; /* quickfill-tree handled by this cell */
+ BasicCell cell;
+ QuickFill *qf; /* quickfill-tree handled by this cell */
- QuickFillSort sort; /* determines order of strings matched.
+ QuickFillSort sort; /* determines order of strings matched.
* default is QUICKFILL_LIFO. */
- char *original; /* original string entered in original case */
+ char *original; /* original string entered in original case */
} QuickFillCell;
BasicCell * gnc_quickfill_cell_new (void);
void gnc_quickfill_cell_set_value (QuickFillCell *cell,
- const char *value);
+ const char *value);
void gnc_quickfill_cell_set_sort (QuickFillCell *cell,
- QuickFillSort sort);
+ QuickFillSort sort);
void gnc_quickfill_cell_add_completion (QuickFillCell *cell,
- const char *completion);
+ const char *completion);
#endif
Modified: gnucash/trunk/src/register/register-core/recncell.c
===================================================================
--- gnucash/trunk/src/register/register-core/recncell.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/recncell.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -23,7 +23,7 @@
/*
* FILE:
* recncell.c
- *
+ *
* FUNCTION:
* Implements a mouse-click cell that allows a series
* of values to be clicked through.
@@ -51,14 +51,14 @@
static const char *
gnc_recn_cell_get_string (RecnCell *cell, char flag)
{
- static char str[2] = { 0, 0 };
+ static char str[2] = { 0, 0 };
- if (cell->get_string != NULL)
- return (cell->get_string)(flag);
+ if (cell->get_string != NULL)
+ return (cell->get_string)(flag);
- str[0] = flag;
+ str[0] = flag;
- return str;
+ return str;
}
static gboolean
@@ -67,140 +67,143 @@
int *start_selection,
int *end_selection)
{
- RecnCell *cell = (RecnCell *) _cell;
- char * this_flag;
+ RecnCell *cell = (RecnCell *) _cell;
+ char * this_flag;
- if (cell->confirm_cb &&
- ! (cell->confirm_cb (cell->flag, cell->confirm_data)))
- return FALSE;
+ if (cell->confirm_cb &&
+ ! (cell->confirm_cb (cell->flag, cell->confirm_data)))
+ return FALSE;
- /* Find the current flag in the list of flags */
- this_flag = strchr (cell->flag_order, cell->flag);
+ /* Find the current flag in the list of flags */
+ this_flag = strchr (cell->flag_order, cell->flag);
- if (this_flag == NULL || *this_flag == '\0') {
- /* If it's not there (or the list is empty) use default_flag */
- cell->flag = cell->default_flag;
+ if (this_flag == NULL || *this_flag == '\0')
+ {
+ /* If it's not there (or the list is empty) use default_flag */
+ cell->flag = cell->default_flag;
- } else {
- /* It is in the list -- choose the -next- item in the list (wrapping
- * around as necessary).
- */
- this_flag++;
- if (*this_flag != '\0')
- cell->flag = *this_flag;
+ }
else
- cell->flag = *(cell->flag_order);
- }
+ {
+ /* It is in the list -- choose the -next- item in the list (wrapping
+ * around as necessary).
+ */
+ this_flag++;
+ if (*this_flag != '\0')
+ cell->flag = *this_flag;
+ else
+ cell->flag = *(cell->flag_order);
+ }
- /* And set the display */
- gnc_recn_cell_set_flag (cell, cell->flag);
+ /* And set the display */
+ gnc_recn_cell_set_flag (cell, cell->flag);
- return FALSE;
+ return FALSE;
}
static void
gnc_recn_cell_init (RecnCell *cell)
{
- gnc_basic_cell_init (&cell->cell);
+ gnc_basic_cell_init (&cell->cell);
- gnc_recn_cell_set_flag (cell, '\0');
- cell->confirm_cb = NULL;
- cell->get_string = NULL;
- cell->valid_flags = "";
- cell->flag_order = "";
+ gnc_recn_cell_set_flag (cell, '\0');
+ cell->confirm_cb = NULL;
+ cell->get_string = NULL;
+ cell->valid_flags = "";
+ cell->flag_order = "";
- cell->cell.enter_cell = gnc_recn_cell_enter;
- cell->cell.set_value = gnc_recn_cell_set_value;
+ cell->cell.enter_cell = gnc_recn_cell_enter;
+ cell->cell.set_value = gnc_recn_cell_set_value;
}
BasicCell *
gnc_recn_cell_new (void)
{
- RecnCell * cell;
+ RecnCell * cell;
- cell = g_new0 (RecnCell, 1);
+ cell = g_new0 (RecnCell, 1);
- gnc_recn_cell_init (cell);
+ gnc_recn_cell_init (cell);
- return &cell->cell;
+ return &cell->cell;
}
/* assumes we are given the untranslated form */
static void
gnc_recn_cell_set_value (BasicCell *_cell, const char *value)
{
- RecnCell *cell = (RecnCell *) _cell;
- char flag;
+ RecnCell *cell = (RecnCell *) _cell;
+ char flag;
- if (!value || *value == '\0')
- {
- cell->flag = cell->default_flag;
- gnc_basic_cell_set_value_internal (_cell, "");
- return;
- }
+ if (!value || *value == '\0')
+ {
+ cell->flag = cell->default_flag;
+ gnc_basic_cell_set_value_internal (_cell, "");
+ return;
+ }
- flag = cell->default_flag;
- if (strchr (cell->valid_flags, *value) != NULL)
- flag = *value;
+ flag = cell->default_flag;
+ if (strchr (cell->valid_flags, *value) != NULL)
+ flag = *value;
- gnc_recn_cell_set_flag (cell, flag);
+ gnc_recn_cell_set_flag (cell, flag);
}
void
gnc_recn_cell_set_flag (RecnCell *cell, char flag)
{
- const char *string;
+ const char *string;
- g_return_if_fail (cell != NULL);
+ g_return_if_fail (cell != NULL);
- cell->flag = flag;
- string = gnc_recn_cell_get_string (cell, flag);
+ cell->flag = flag;
+ string = gnc_recn_cell_get_string (cell, flag);
- gnc_basic_cell_set_value_internal (&cell->cell, string);
+ gnc_basic_cell_set_value_internal (&cell->cell, string);
}
char
gnc_recn_cell_get_flag (RecnCell *cell)
{
- g_return_val_if_fail (cell != NULL, '\0');
+ g_return_val_if_fail (cell != NULL, '\0');
- return cell->flag;
+ return cell->flag;
}
void
gnc_recn_cell_set_string_getter (RecnCell *cell,
- RecnCellStringGetter get_string)
+ RecnCellStringGetter get_string)
{
- g_return_if_fail (cell != NULL);
- cell->get_string = get_string;
+ g_return_if_fail (cell != NULL);
+ cell->get_string = get_string;
}
void
gnc_recn_cell_set_confirm_cb (RecnCell *cell, RecnCellConfirm confirm_cb,
gpointer data)
{
- g_return_if_fail (cell != NULL);
+ g_return_if_fail (cell != NULL);
- cell->confirm_cb = confirm_cb;
- cell->confirm_data = data;
+ cell->confirm_cb = confirm_cb;
+ cell->confirm_data = data;
}
void
gnc_recn_cell_set_valid_flags (RecnCell *cell, const char *flags,
- char default_flag)
+ char default_flag)
{
- g_return_if_fail (cell != NULL);
- g_return_if_fail (flags != NULL);
+ g_return_if_fail (cell != NULL);
+ g_return_if_fail (flags != NULL);
- cell->valid_flags = (char *)flags;
- cell->default_flag = default_flag;
+ cell->valid_flags = (char *)flags;
+ cell->default_flag = default_flag;
}
void
gnc_recn_cell_set_flag_order (RecnCell *cell, const char *flags)
{
- g_return_if_fail (cell != NULL);
- g_return_if_fail (flags != NULL);
+ g_return_if_fail (cell != NULL);
+ g_return_if_fail (flags != NULL);
- cell->flag_order = (char *)flags;
+ cell->flag_order = (char *)flags;
}
Modified: gnucash/trunk/src/register/register-core/recncell.h
===================================================================
--- gnucash/trunk/src/register/register-core/recncell.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/recncell.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -47,17 +47,17 @@
typedef struct
{
- BasicCell cell;
+ BasicCell cell;
- char flag; /* The actual flag value */
+ char flag; /* The actual flag value */
- char * valid_flags; /* The list of valid flags */
- char * flag_order; /* Automatic flag selection order */
- char default_flag; /* Default flag for unknown user input */
+ char * valid_flags; /* The list of valid flags */
+ char * flag_order; /* Automatic flag selection order */
+ char default_flag; /* Default flag for unknown user input */
- RecnCellStringGetter get_string;
- RecnCellConfirm confirm_cb;
- gpointer confirm_data;
+ RecnCellStringGetter get_string;
+ RecnCellConfirm confirm_cb;
+ gpointer confirm_data;
} RecnCell;
BasicCell * gnc_recn_cell_new (void);
@@ -66,11 +66,11 @@
char gnc_recn_cell_get_flag (RecnCell *cell);
void gnc_recn_cell_set_confirm_cb (RecnCell *cell,
- RecnCellConfirm confirm_cb,
- gpointer data);
-
+ RecnCellConfirm confirm_cb,
+ gpointer data);
+
void gnc_recn_cell_set_string_getter (RecnCell *cell,
- RecnCellStringGetter getter);
+ RecnCellStringGetter getter);
/*
* note that chars is copied into the RecnCell directly, but remains
@@ -81,7 +81,7 @@
* each cell. - warlord 2001-11-28
*/
void gnc_recn_cell_set_valid_flags (RecnCell *cell, const char *flags,
- char default_flag);
+ char default_flag);
void gnc_recn_cell_set_flag_order (RecnCell *cell, const char *flags);
#endif
Modified: gnucash/trunk/src/register/register-core/register-common.c
===================================================================
--- gnucash/trunk/src/register/register-core/register-common.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/register-common.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -42,69 +42,69 @@
void
gnc_register_init (void)
{
- if (register_inited)
- return;
+ if (register_inited)
+ return;
- register_inited = TRUE;
+ register_inited = TRUE;
- global_factory = gnc_cell_factory_new ();
+ global_factory = gnc_cell_factory_new ();
- gnc_register_add_cell_type (BASIC_CELL_TYPE_NAME, gnc_basic_cell_new);
+ gnc_register_add_cell_type (BASIC_CELL_TYPE_NAME, gnc_basic_cell_new);
- gnc_register_add_cell_type (NUM_CELL_TYPE_NAME, gnc_num_cell_new);
+ gnc_register_add_cell_type (NUM_CELL_TYPE_NAME, gnc_num_cell_new);
- gnc_register_add_cell_type (PRICE_CELL_TYPE_NAME, gnc_price_cell_new);
+ gnc_register_add_cell_type (PRICE_CELL_TYPE_NAME, gnc_price_cell_new);
- gnc_register_add_cell_type (RECN_CELL_TYPE_NAME, gnc_recn_cell_new);
+ gnc_register_add_cell_type (RECN_CELL_TYPE_NAME, gnc_recn_cell_new);
- gnc_register_add_cell_type (QUICKFILL_CELL_TYPE_NAME,
- gnc_quickfill_cell_new);
+ gnc_register_add_cell_type (QUICKFILL_CELL_TYPE_NAME,
+ gnc_quickfill_cell_new);
- gnc_register_add_cell_type (FORMULA_CELL_TYPE_NAME,
- gnc_formula_cell_new);
+ gnc_register_add_cell_type (FORMULA_CELL_TYPE_NAME,
+ gnc_formula_cell_new);
- gnc_register_add_cell_type (CHECKBOX_CELL_TYPE_NAME, gnc_checkbox_cell_new);
+ gnc_register_add_cell_type (CHECKBOX_CELL_TYPE_NAME, gnc_checkbox_cell_new);
}
void
gnc_register_shutdown (void)
{
- if (!register_inited)
- return;
+ if (!register_inited)
+ return;
- gnc_cell_factory_destroy (global_factory);
- global_factory = NULL;
+ gnc_cell_factory_destroy (global_factory);
+ global_factory = NULL;
}
void
gnc_register_add_cell_type (const char *cell_type_name,
CellCreateFunc cell_creator)
{
- gnc_register_init ();
+ gnc_register_init ();
- gnc_cell_factory_add_cell_type (global_factory,
- cell_type_name, cell_creator);
+ gnc_cell_factory_add_cell_type (global_factory,
+ cell_type_name, cell_creator);
}
BasicCell *
gnc_register_make_cell (const char *cell_type_name)
{
- gnc_register_init ();
+ gnc_register_init ();
- return gnc_cell_factory_make_cell (global_factory, cell_type_name);
+ return gnc_cell_factory_make_cell (global_factory, cell_type_name);
}
gboolean
virt_cell_loc_equal (VirtualCellLocation vcl1, VirtualCellLocation vcl2)
{
- return ((vcl1.virt_row == vcl2.virt_row) &&
- (vcl1.virt_col == vcl2.virt_col));
+ return ((vcl1.virt_row == vcl2.virt_row) &&
+ (vcl1.virt_col == vcl2.virt_col));
}
gboolean
virt_loc_equal (VirtualLocation vl1, VirtualLocation vl2)
{
- return (virt_cell_loc_equal (vl1.vcell_loc, vl2.vcell_loc) &&
- (vl1.phys_row_offset == vl2.phys_row_offset) &&
- (vl1.phys_col_offset == vl2.phys_col_offset));
+ return (virt_cell_loc_equal (vl1.vcell_loc, vl2.vcell_loc) &&
+ (vl1.phys_row_offset == vl2.phys_row_offset) &&
+ (vl1.phys_col_offset == vl2.phys_col_offset));
}
Modified: gnucash/trunk/src/register/register-core/register-common.h
===================================================================
--- gnucash/trunk/src/register/register-core/register-common.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/register-common.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -29,7 +29,7 @@
/** @addtogroup RegisterCore Register Core
* @brief An infrastructure for building a modular matrix of cells like a
* spreadsheet or checkbook register.
- *
+ *
* @details Each cell may be specialized to perform a particular function,
* e.g. to read dates, numerical amounts, or text. The register core has been
* designed to be easy to extend, modular, easy to maintain, and memory
@@ -83,9 +83,10 @@
* location of a virtual cell.
*/
typedef struct _VirtualCellLocation VirtualCellLocation;
-struct _VirtualCellLocation {
- int virt_row;
- int virt_col;
+struct _VirtualCellLocation
+{
+ int virt_row;
+ int virt_col;
};
@@ -105,10 +106,11 @@
* the cell block.
*/
typedef struct _VirtualLocation VirtualLocation;
-struct _VirtualLocation {
- VirtualCellLocation vcell_loc;
- int phys_row_offset;
- int phys_col_offset;
+struct _VirtualLocation
+{
+ VirtualCellLocation vcell_loc;
+ int phys_row_offset;
+ int phys_col_offset;
};
Modified: gnucash/trunk/src/register/register-core/table-allgui.c
===================================================================
--- gnucash/trunk/src/register/register-core/table-allgui.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-allgui.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -1,6 +1,6 @@
/********************************************************************\
* table-allgui.c -- 2D grid table object, embeds cells for i/o *
- * *
+ * *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
@@ -66,128 +66,128 @@
void
gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers)
{
- if (!gui_handlers)
- memset (&default_gui_handlers, 0, sizeof (default_gui_handlers));
- else
- default_gui_handlers = *gui_handlers;
+ if (!gui_handlers)
+ memset (&default_gui_handlers, 0, sizeof (default_gui_handlers));
+ else
+ default_gui_handlers = *gui_handlers;
}
-Table *
+Table *
gnc_table_new (TableLayout *layout, TableModel *model, TableControl *control)
{
- Table *table;
+ Table *table;
- g_return_val_if_fail (layout != NULL, NULL);
- g_return_val_if_fail (model != NULL, NULL);
- g_return_val_if_fail (control != NULL, NULL);
+ g_return_val_if_fail (layout != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (control != NULL, NULL);
- table = g_new0 (Table, 1);
+ table = g_new0 (Table, 1);
- table->layout = layout;
- table->model = model;
- table->control = control;
+ table->layout = layout;
+ table->model = model;
+ table->control = control;
- table->gui_handlers = default_gui_handlers;
+ table->gui_handlers = default_gui_handlers;
- gnc_table_init (table);
+ gnc_table_init (table);
- table->virt_cells = g_table_new (sizeof (VirtualCell),
- gnc_virtual_cell_construct,
- gnc_virtual_cell_destroy, table);
+ table->virt_cells = g_table_new (sizeof (VirtualCell),
+ gnc_virtual_cell_construct,
+ gnc_virtual_cell_destroy, table);
- return table;
+ return table;
}
static void
gnc_table_init (Table * table)
{
- table->num_virt_rows = -1;
- table->num_virt_cols = -1;
+ table->num_virt_rows = -1;
+ table->num_virt_cols = -1;
- table->current_cursor = NULL;
+ table->current_cursor = NULL;
- gnc_virtual_location_init (&table->current_cursor_loc);
+ gnc_virtual_location_init (&table->current_cursor_loc);
- /* initialize private data */
+ /* initialize private data */
- table->virt_cells = NULL;
- table->ui_data = NULL;
+ table->virt_cells = NULL;
+ table->ui_data = NULL;
}
-void
+void
gnc_table_destroy (Table * table)
{
- /* invoke destroy callback */
- if (table->gui_handlers.destroy)
- table->gui_handlers.destroy (table);
+ /* invoke destroy callback */
+ if (table->gui_handlers.destroy)
+ table->gui_handlers.destroy (table);
- /* free the dynamic structures */
- gnc_table_free_data (table);
+ /* free the dynamic structures */
+ gnc_table_free_data (table);
- /* free the cell tables */
- g_table_destroy (table->virt_cells);
+ /* free the cell tables */
+ g_table_destroy (table->virt_cells);
- gnc_table_layout_destroy (table->layout);
- table->layout = NULL;
+ gnc_table_layout_destroy (table->layout);
+ table->layout = NULL;
- gnc_table_control_destroy (table->control);
- table->control = NULL;
+ gnc_table_control_destroy (table->control);
+ table->control = NULL;
- gnc_table_model_destroy (table->model);
- table->model = NULL;
+ gnc_table_model_destroy (table->model);
+ table->model = NULL;
- /* intialize vars to null value so that any access is voided. */
- gnc_table_init (table);
+ /* intialize vars to null value so that any access is voided. */
+ gnc_table_init (table);
- g_free (table);
+ g_free (table);
}
int
gnc_table_current_cursor_changed (Table *table,
gboolean include_conditional)
{
- if (!table)
- return FALSE;
+ if (!table)
+ return FALSE;
- return gnc_cellblock_changed (table->current_cursor, include_conditional);
+ return gnc_cellblock_changed (table->current_cursor, include_conditional);
}
void
gnc_table_clear_current_cursor_changes (Table *table)
{
- if (!table)
- return;
+ if (!table)
+ return;
- gnc_cellblock_clear_changes (table->current_cursor);
+ gnc_cellblock_clear_changes (table->current_cursor);
}
void
gnc_table_save_current_cursor (Table *table, CursorBuffer *buffer)
{
- if (!table || !buffer)
- return;
+ if (!table || !buffer)
+ return;
- gnc_table_layout_save_cursor (table->layout, table->current_cursor, buffer);
+ gnc_table_layout_save_cursor (table->layout, table->current_cursor, buffer);
}
void
gnc_table_restore_current_cursor (Table *table,
CursorBuffer *buffer)
{
- if (!table || !buffer)
- return;
+ if (!table || !buffer)
+ return;
- gnc_table_layout_restore_cursor (table->layout,
- table->current_cursor, buffer);
+ gnc_table_layout_restore_cursor (table->layout,
+ table->current_cursor, buffer);
}
const char *
gnc_table_get_current_cell_name (Table *table)
{
- if (table == NULL)
- return NULL;
+ if (table == NULL)
+ return NULL;
- return gnc_table_get_cell_name (table, table->current_cursor_loc);
+ return gnc_table_get_cell_name (table, table->current_cursor_loc);
}
gboolean
@@ -195,315 +195,315 @@
const char *cell_name,
VirtualLocation *virt_loc)
{
- if (table == NULL)
- return FALSE;
+ if (table == NULL)
+ return FALSE;
- return gnc_table_get_cell_location (table, cell_name,
- table->current_cursor_loc.vcell_loc,
- virt_loc);
+ return gnc_table_get_cell_location (table, cell_name,
+ table->current_cursor_loc.vcell_loc,
+ virt_loc);
}
gboolean
gnc_table_virtual_cell_out_of_bounds (Table *table,
VirtualCellLocation vcell_loc)
{
- if (!table)
- return TRUE;
+ if (!table)
+ return TRUE;
- return ((vcell_loc.virt_row < 0) ||
- (vcell_loc.virt_row >= table->num_virt_rows) ||
- (vcell_loc.virt_col < 0) ||
- (vcell_loc.virt_col >= table->num_virt_cols));
+ return ((vcell_loc.virt_row < 0) ||
+ (vcell_loc.virt_row >= table->num_virt_rows) ||
+ (vcell_loc.virt_col < 0) ||
+ (vcell_loc.virt_col >= table->num_virt_cols));
}
gboolean
gnc_table_virtual_location_in_header (Table *table,
VirtualLocation virt_loc)
{
- return (virt_loc.vcell_loc.virt_row == 0);
+ return (virt_loc.vcell_loc.virt_row == 0);
}
VirtualCell *
gnc_table_get_virtual_cell (Table *table, VirtualCellLocation vcell_loc)
{
- if (table == NULL)
- return NULL;
+ if (table == NULL)
+ return NULL;
- return g_table_index (table->virt_cells,
- vcell_loc.virt_row, vcell_loc.virt_col);
+ return g_table_index (table->virt_cells,
+ vcell_loc.virt_row, vcell_loc.virt_col);
}
VirtualCell *
gnc_table_get_header_cell (Table *table)
{
- VirtualCellLocation vcell_loc = { 0, 0 };
+ VirtualCellLocation vcell_loc = { 0, 0 };
- return gnc_table_get_virtual_cell (table, vcell_loc);
+ return gnc_table_get_virtual_cell (table, vcell_loc);
}
static const char *
gnc_table_get_entry_internal (Table *table, VirtualLocation virt_loc,
gboolean *conditionally_changed)
{
- TableGetEntryHandler entry_handler;
- const char *cell_name;
- const char *entry;
+ TableGetEntryHandler entry_handler;
+ const char *cell_name;
+ const char *entry;
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- entry_handler = gnc_table_model_get_entry_handler (table->model, cell_name);
- if (!entry_handler) return "";
+ entry_handler = gnc_table_model_get_entry_handler (table->model, cell_name);
+ if (!entry_handler) return "";
- entry = entry_handler (virt_loc, FALSE,
- conditionally_changed,
- table->model->handler_user_data);
- if (!entry)
- entry = "";
+ entry = entry_handler (virt_loc, FALSE,
+ conditionally_changed,
+ table->model->handler_user_data);
+ if (!entry)
+ entry = "";
- return entry;
+ return entry;
}
const char *
gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
{
- TableGetEntryHandler entry_handler;
- const char *entry;
- BasicCell *cell;
+ TableGetEntryHandler entry_handler;
+ const char *entry;
+ BasicCell *cell;
- cell = gnc_table_get_cell (table, virt_loc);
- if (!cell || !cell->cell_name)
- return "";
+ cell = gnc_table_get_cell (table, virt_loc);
+ if (!cell || !cell->cell_name)
+ return "";
- if (virt_cell_loc_equal (table->current_cursor_loc.vcell_loc,
- virt_loc.vcell_loc))
- {
- CellIOFlags io_flags;
+ if (virt_cell_loc_equal (table->current_cursor_loc.vcell_loc,
+ virt_loc.vcell_loc))
+ {
+ CellIOFlags io_flags;
- io_flags = gnc_table_get_io_flags (table, virt_loc);
+ io_flags = gnc_table_get_io_flags (table, virt_loc);
- if (io_flags & XACC_CELL_ALLOW_INPUT)
- return cell->value;
- }
+ if (io_flags & XACC_CELL_ALLOW_INPUT)
+ return cell->value;
+ }
- entry_handler = gnc_table_model_get_entry_handler (table->model,
- cell->cell_name);
- if (!entry_handler) return "";
+ entry_handler = gnc_table_model_get_entry_handler (table->model,
+ cell->cell_name);
+ if (!entry_handler) return "";
- entry = entry_handler (virt_loc, TRUE, NULL,
- table->model->handler_user_data);
- if (!entry)
- entry = "";
+ entry = entry_handler (virt_loc, TRUE, NULL,
+ table->model->handler_user_data);
+ if (!entry)
+ entry = "";
- return entry;
+ return entry;
}
CellIOFlags
gnc_table_get_io_flags (Table *table, VirtualLocation virt_loc)
{
- TableGetCellIOFlagsHandler io_flags_handler;
- const char *cell_name;
- CellIOFlags flags;
+ TableGetCellIOFlagsHandler io_flags_handler;
+ const char *cell_name;
+ CellIOFlags flags;
- if (!table || !table->model)
- return XACC_CELL_ALLOW_NONE;
+ if (!table || !table->model)
+ return XACC_CELL_ALLOW_NONE;
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- io_flags_handler = gnc_table_model_get_io_flags_handler (table->model,
- cell_name);
- if (!io_flags_handler)
- return XACC_CELL_ALLOW_NONE;
+ io_flags_handler = gnc_table_model_get_io_flags_handler (table->model,
+ cell_name);
+ if (!io_flags_handler)
+ return XACC_CELL_ALLOW_NONE;
- flags = io_flags_handler (virt_loc, table->model->handler_user_data);
+ flags = io_flags_handler (virt_loc, table->model->handler_user_data);
- if (gnc_table_model_read_only (table->model))
- flags &= XACC_CELL_ALLOW_SHADOW;
+ if (gnc_table_model_read_only (table->model))
+ flags &= XACC_CELL_ALLOW_SHADOW;
- return flags;
+ return flags;
}
const char *
gnc_table_get_label (Table *table, VirtualLocation virt_loc)
{
- TableGetLabelHandler label_handler;
- const char *cell_name;
- const char *label;
+ TableGetLabelHandler label_handler;
+ const char *cell_name;
+ const char *label;
- if (!table || !table->model)
- return "";
+ if (!table || !table->model)
+ return "";
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- label_handler = gnc_table_model_get_label_handler (table->model, cell_name);
- if (!label_handler)
- return "";
+ label_handler = gnc_table_model_get_label_handler (table->model, cell_name);
+ if (!label_handler)
+ return "";
- label = label_handler (virt_loc, table->model->handler_user_data);
- if (!label)
- return "";
+ label = label_handler (virt_loc, table->model->handler_user_data);
+ if (!label)
+ return "";
- return label;
+ return label;
}
guint32
gnc_table_get_fg_color (Table *table, VirtualLocation virt_loc)
{
- TableGetFGColorHandler fg_color_handler;
- const char *cell_name;
+ TableGetFGColorHandler fg_color_handler;
+ const char *cell_name;
- if (!table || !table->model)
- return 0x0; /* black */
+ if (!table || !table->model)
+ return 0x0; /* black */
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- fg_color_handler = gnc_table_model_get_fg_color_handler (table->model,
- cell_name);
- if (!fg_color_handler)
- return 0x0;
+ fg_color_handler = gnc_table_model_get_fg_color_handler (table->model,
+ cell_name);
+ if (!fg_color_handler)
+ return 0x0;
- return fg_color_handler (virt_loc, table->model->handler_user_data);
+ return fg_color_handler (virt_loc, table->model->handler_user_data);
}
guint32
gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
gboolean *hatching)
{
- TableGetBGColorHandler bg_color_handler;
- const char *cell_name;
+ TableGetBGColorHandler bg_color_handler;
+ const char *cell_name;
- if (hatching)
- *hatching = FALSE;
+ if (hatching)
+ *hatching = FALSE;
- if (!table || !table->model)
- return 0xffffff; /* white */
+ if (!table || !table->model)
+ return 0xffffff; /* white */
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- bg_color_handler = gnc_table_model_get_bg_color_handler (table->model,
- cell_name);
- if (!bg_color_handler)
- return 0xffffff;
+ bg_color_handler = gnc_table_model_get_bg_color_handler (table->model,
+ cell_name);
+ if (!bg_color_handler)
+ return 0xffffff;
- return bg_color_handler (virt_loc, hatching,
- table->model->handler_user_data);
+ return bg_color_handler (virt_loc, hatching,
+ table->model->handler_user_data);
}
guint32
gnc_table_get_gtkrc_bg_color (Table *table, VirtualLocation virt_loc,
- gboolean *hatching)
+ gboolean *hatching)
{
- TableGetBGColorHandler bg_color_handler;
- const char *cell_name;
+ TableGetBGColorHandler bg_color_handler;
+ const char *cell_name;
- if (hatching)
- *hatching = FALSE;
+ if (hatching)
+ *hatching = FALSE;
- if (!table || !table->model)
- return 0xffffff; /* white */
+ if (!table || !table->model)
+ return 0xffffff; /* white */
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- bg_color_handler = gnc_table_model_get_bg_color_handler (table->model,
- "gtkrc");
- if (!bg_color_handler)
- return 0xffffff;
+ bg_color_handler = gnc_table_model_get_bg_color_handler (table->model,
+ "gtkrc");
+ if (!bg_color_handler)
+ return 0xffffff;
- return bg_color_handler (virt_loc, hatching,
- table->model->handler_user_data);
+ return bg_color_handler (virt_loc, hatching,
+ table->model->handler_user_data);
}
void
gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
PhysicalCellBorders *borders)
{
- TableGetCellBorderHandler cell_border_handler;
- const char *cell_name;
+ TableGetCellBorderHandler cell_border_handler;
+ const char *cell_name;
- if (!table || !table->model)
- return;
+ if (!table || !table->model)
+ return;
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- cell_border_handler = gnc_table_model_get_cell_border_handler (table->model,
- cell_name);
- if (!cell_border_handler)
- return;
+ cell_border_handler = gnc_table_model_get_cell_border_handler (table->model,
+ cell_name);
+ if (!cell_border_handler)
+ return;
- cell_border_handler (virt_loc, borders, table->model->handler_user_data);
+ cell_border_handler (virt_loc, borders, table->model->handler_user_data);
}
CellAlignment
gnc_table_get_align (Table *table, VirtualLocation virt_loc)
{
- BasicCell *cell;
+ BasicCell *cell;
- cell = gnc_table_get_cell (table, virt_loc);
- if (!cell)
- return CELL_ALIGN_RIGHT;
+ cell = gnc_table_get_cell (table, virt_loc);
+ if (!cell)
+ return CELL_ALIGN_RIGHT;
- return cell->alignment;
+ return cell->alignment;
}
gboolean
gnc_table_is_popup (Table *table, VirtualLocation virt_loc)
{
- BasicCell *cell;
+ BasicCell *cell;
- cell = gnc_table_get_cell (table, virt_loc);
- if (!cell)
- return FALSE;
+ cell = gnc_table_get_cell (table, virt_loc);
+ if (!cell)
+ return FALSE;
- return cell->is_popup;
+ return cell->is_popup;
}
char *
gnc_table_get_help (Table *table)
{
- TableGetHelpHandler help_handler;
- VirtualLocation virt_loc;
- const char * cell_name;
+ TableGetHelpHandler help_handler;
+ VirtualLocation virt_loc;
+ const char * cell_name;
- if (!table)
- return NULL;
+ if (!table)
+ return NULL;
- virt_loc = table->current_cursor_loc;
+ virt_loc = table->current_cursor_loc;
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- help_handler = gnc_table_model_get_help_handler (table->model, cell_name);
- if (!help_handler)
- return NULL;
+ help_handler = gnc_table_model_get_help_handler (table->model, cell_name);
+ if (!help_handler)
+ return NULL;
- return help_handler (virt_loc, table->model->handler_user_data);
+ return help_handler (virt_loc, table->model->handler_user_data);
}
BasicCell *
gnc_table_get_cell (Table *table, VirtualLocation virt_loc)
{
- VirtualCell *vcell;
+ VirtualCell *vcell;
- if (!table)
- return NULL;
+ if (!table)
+ return NULL;
- vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc);
- if (!vcell)
- return NULL;
+ vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc);
+ if (!vcell)
+ return NULL;
- return gnc_cellblock_get_cell (vcell->cellblock,
- virt_loc.phys_row_offset,
- virt_loc.phys_col_offset);
+ return gnc_cellblock_get_cell (vcell->cellblock,
+ virt_loc.phys_row_offset,
+ virt_loc.phys_col_offset);
}
const char *
gnc_table_get_cell_name (Table *table, VirtualLocation virt_loc)
{
- BasicCell *cell;
+ BasicCell *cell;
- cell = gnc_table_get_cell (table, virt_loc);
- if (cell == NULL)
- return NULL;
+ cell = gnc_table_get_cell (table, virt_loc);
+ if (cell == NULL)
+ return NULL;
- return cell->cell_name;
+ return cell->cell_name;
}
gboolean
@@ -512,162 +512,162 @@
VirtualCellLocation vcell_loc,
VirtualLocation *virt_loc)
{
- VirtualCell *vcell;
- CellBlock *cellblock;
- int cell_row, cell_col;
+ VirtualCell *vcell;
+ CellBlock *cellblock;
+ int cell_row, cell_col;
- if (table == NULL)
- return FALSE;
+ if (table == NULL)
+ return FALSE;
- vcell = gnc_table_get_virtual_cell (table, vcell_loc);
- if (vcell == NULL)
- return FALSE;
+ vcell = gnc_table_get_virtual_cell (table, vcell_loc);
+ if (vcell == NULL)
+ return FALSE;
- cellblock = vcell->cellblock;
+ cellblock = vcell->cellblock;
- for (cell_row = 0; cell_row < cellblock->num_rows; cell_row++)
- for (cell_col = 0; cell_col < cellblock->num_cols; cell_col++)
- {
- BasicCell *cell;
+ for (cell_row = 0; cell_row < cellblock->num_rows; cell_row++)
+ for (cell_col = 0; cell_col < cellblock->num_cols; cell_col++)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (cellblock, cell_row, cell_col);
- if (!cell)
- continue;
+ cell = gnc_cellblock_get_cell (cellblock, cell_row, cell_col);
+ if (!cell)
+ continue;
- if (gnc_basic_cell_has_name (cell, cell_name))
- {
- if (virt_loc != NULL)
- {
- virt_loc->vcell_loc = vcell_loc;
+ if (gnc_basic_cell_has_name (cell, cell_name))
+ {
+ if (virt_loc != NULL)
+ {
+ virt_loc->vcell_loc = vcell_loc;
- virt_loc->phys_row_offset = cell_row;
- virt_loc->phys_col_offset = cell_col;
+ virt_loc->phys_row_offset = cell_row;
+ virt_loc->phys_col_offset = cell_col;
+ }
+
+ return TRUE;
+ }
}
- return TRUE;
- }
- }
-
- return FALSE;
+ return FALSE;
}
void
gnc_table_save_cells (Table *table, gpointer save_data)
{
- TableSaveHandler save_handler;
- GList * cells;
- GList * node;
+ TableSaveHandler save_handler;
+ GList * cells;
+ GList * node;
- g_return_if_fail (table);
+ g_return_if_fail (table);
- /* ignore any changes to read-only tables */
- if (gnc_table_model_read_only (table->model))
- return;
+ /* ignore any changes to read-only tables */
+ if (gnc_table_model_read_only (table->model))
+ return;
- // gnc_table_leave_update (table, table->current_cursor_loc);
+ // gnc_table_leave_update (table, table->current_cursor_loc);
- save_handler = gnc_table_model_get_pre_save_handler (table->model);
- if (save_handler)
- save_handler (save_data, table->model->handler_user_data);
+ save_handler = gnc_table_model_get_pre_save_handler (table->model);
+ if (save_handler)
+ save_handler (save_data, table->model->handler_user_data);
- cells = gnc_table_layout_get_cells (table->layout);
- for (node = cells; node; node = node->next)
- {
- BasicCell * cell = node->data;
- TableSaveCellHandler save_cell_handler;
+ cells = gnc_table_layout_get_cells (table->layout);
+ for (node = cells; node; node = node->next)
+ {
+ BasicCell * cell = node->data;
+ TableSaveCellHandler save_cell_handler;
- if (!cell) continue;
+ if (!cell) continue;
- if (!gnc_table_layout_get_cell_changed (table->layout,
- cell->cell_name, TRUE))
- continue;
+ if (!gnc_table_layout_get_cell_changed (table->layout,
+ cell->cell_name, TRUE))
+ continue;
- save_cell_handler = gnc_table_model_get_save_handler (table->model,
- cell->cell_name);
- if (save_cell_handler)
- save_cell_handler (cell, save_data, table->model->handler_user_data);
- }
+ save_cell_handler = gnc_table_model_get_save_handler (table->model,
+ cell->cell_name);
+ if (save_cell_handler)
+ save_cell_handler (cell, save_data, table->model->handler_user_data);
+ }
- save_handler = gnc_table_model_get_post_save_handler (table->model);
- if (save_handler)
- save_handler (save_data, table->model->handler_user_data);
+ save_handler = gnc_table_model_get_post_save_handler (table->model);
+ if (save_handler)
+ save_handler (save_data, table->model->handler_user_data);
}
-void
+void
gnc_table_set_size (Table * table, int virt_rows, int virt_cols)
{
- /* Invalidate the current cursor position, if the array is
- * shrinking. This must be done since the table is probably
- * shrinking because some rows were deleted, and the cursor
- * could be on the deleted rows. */
- if ((virt_rows < table->num_virt_rows) ||
- (virt_cols < table->num_virt_cols))
- {
- gnc_virtual_location_init (&table->current_cursor_loc);
- table->current_cursor = NULL;
- }
+ /* Invalidate the current cursor position, if the array is
+ * shrinking. This must be done since the table is probably
+ * shrinking because some rows were deleted, and the cursor
+ * could be on the deleted rows. */
+ if ((virt_rows < table->num_virt_rows) ||
+ (virt_cols < table->num_virt_cols))
+ {
+ gnc_virtual_location_init (&table->current_cursor_loc);
+ table->current_cursor = NULL;
+ }
- gnc_table_resize (table, virt_rows, virt_cols);
+ gnc_table_resize (table, virt_rows, virt_cols);
}
static void
gnc_table_free_data (Table * table)
{
- if (table == NULL)
- return;
+ if (table == NULL)
+ return;
- g_table_resize (table->virt_cells, 0, 0);
+ g_table_resize (table->virt_cells, 0, 0);
}
void
gnc_virtual_location_init (VirtualLocation *vloc)
{
- if (vloc == NULL)
- return;
+ if (vloc == NULL)
+ return;
- vloc->phys_row_offset = -1;
- vloc->phys_col_offset = -1;
- vloc->vcell_loc.virt_row = -1;
- vloc->vcell_loc.virt_col = -1;
+ vloc->phys_row_offset = -1;
+ vloc->phys_col_offset = -1;
+ vloc->vcell_loc.virt_row = -1;
+ vloc->vcell_loc.virt_col = -1;
}
static void
gnc_virtual_cell_construct (gpointer _vcell, gpointer user_data)
{
- VirtualCell *vcell = _vcell;
- Table *table = user_data;
+ VirtualCell *vcell = _vcell;
+ Table *table = user_data;
- vcell->cellblock = NULL;
+ vcell->cellblock = NULL;
- if (table && table->model->cell_data_allocator)
- vcell->vcell_data = table->model->cell_data_allocator ();
- else
- vcell->vcell_data = NULL;
+ if (table && table->model->cell_data_allocator)
+ vcell->vcell_data = table->model->cell_data_allocator ();
+ else
+ vcell->vcell_data = NULL;
- vcell->visible = 1;
+ vcell->visible = 1;
}
static void
gnc_virtual_cell_destroy (gpointer _vcell, gpointer user_data)
{
- VirtualCell *vcell = _vcell;
- Table *table = user_data;
+ VirtualCell *vcell = _vcell;
+ Table *table = user_data;
- if (vcell->vcell_data && table && table->model->cell_data_deallocator)
- table->model->cell_data_deallocator (vcell->vcell_data);
+ if (vcell->vcell_data && table && table->model->cell_data_deallocator)
+ table->model->cell_data_deallocator (vcell->vcell_data);
- vcell->vcell_data = NULL;
+ vcell->vcell_data = NULL;
}
-static void
+static void
gnc_table_resize (Table * table, int new_virt_rows, int new_virt_cols)
{
- if (!table) return;
+ if (!table) return;
- g_table_resize (table->virt_cells, new_virt_rows, new_virt_cols);
+ g_table_resize (table->virt_cells, new_virt_rows, new_virt_cols);
- table->num_virt_rows = new_virt_rows;
- table->num_virt_cols = new_virt_cols;
+ table->num_virt_rows = new_virt_rows;
+ table->num_virt_cols = new_virt_cols;
}
void
@@ -678,32 +678,32 @@
gboolean start_primary_color,
VirtualCellLocation vcell_loc)
{
- VirtualCell *vcell;
+ VirtualCell *vcell;
- if ((table == NULL) || (cursor == NULL))
- return;
+ if ((table == NULL) || (cursor == NULL))
+ return;
- if ((vcell_loc.virt_row >= table->num_virt_rows) ||
- (vcell_loc.virt_col >= table->num_virt_cols))
- gnc_table_resize (table,
- MAX (table->num_virt_rows, vcell_loc.virt_row + 1),
- MAX (table->num_virt_cols, vcell_loc.virt_col + 1));
+ if ((vcell_loc.virt_row >= table->num_virt_rows) ||
+ (vcell_loc.virt_col >= table->num_virt_cols))
+ gnc_table_resize (table,
+ MAX (table->num_virt_rows, vcell_loc.virt_row + 1),
+ MAX (table->num_virt_cols, vcell_loc.virt_col + 1));
- vcell = gnc_table_get_virtual_cell (table, vcell_loc);
- if (vcell == NULL)
- return;
+ vcell = gnc_table_get_virtual_cell (table, vcell_loc);
+ if (vcell == NULL)
+ return;
- /* this cursor is the handler for this block */
- vcell->cellblock = cursor;
+ /* this cursor is the handler for this block */
+ vcell->cellblock = cursor;
- /* copy the vcell user data */
- if (table->model->cell_data_copy)
- table->model->cell_data_copy (vcell->vcell_data, vcell_data);
- else
- vcell->vcell_data = (gpointer) vcell_data;
+ /* copy the vcell user data */
+ if (table->model->cell_data_copy)
+ table->model->cell_data_copy (vcell->vcell_data, vcell_data);
+ else
+ vcell->vcell_data = (gpointer) vcell_data;
- vcell->visible = visible ? 1 : 0;
- vcell->start_primary_color = start_primary_color ? 1 : 0;
+ vcell->visible = visible ? 1 : 0;
+ vcell->start_primary_color = start_primary_color ? 1 : 0;
}
void
@@ -711,19 +711,19 @@
VirtualCellLocation vcell_loc,
gconstpointer vcell_data)
{
- VirtualCell *vcell;
+ VirtualCell *vcell;
- if (table == NULL)
- return;
+ if (table == NULL)
+ return;
- vcell = gnc_table_get_virtual_cell (table, vcell_loc);
- if (vcell == NULL)
- return;
+ vcell = gnc_table_get_virtual_cell (table, vcell_loc);
+ if (vcell == NULL)
+ return;
- if (table->model->cell_data_copy)
- table->model->cell_data_copy (vcell->vcell_data, vcell_data);
- else
- vcell->vcell_data = (gpointer) vcell_data;
+ if (table->model->cell_data_copy)
+ table->model->cell_data_copy (vcell->vcell_data, vcell_data);
+ else
+ vcell->vcell_data = (gpointer) vcell_data;
}
void
@@ -731,16 +731,16 @@
VirtualCellLocation vcell_loc,
gboolean visible)
{
- VirtualCell *vcell;
+ VirtualCell *vcell;
- if (table == NULL)
- return;
+ if (table == NULL)
+ return;
- vcell = gnc_table_get_virtual_cell (table, vcell_loc);
- if (vcell == NULL)
- return;
+ vcell = gnc_table_get_virtual_cell (table, vcell_loc);
+ if (vcell == NULL)
+ return;
- vcell->visible = visible ? 1 : 0;
+ vcell->visible = visible ? 1 : 0;
}
void
@@ -748,157 +748,157 @@
VirtualCellLocation vcell_loc,
CellBlock *cursor)
{
- VirtualCell *vcell;
+ VirtualCell *vcell;
- if (table == NULL)
- return;
+ if (table == NULL)
+ return;
- vcell = gnc_table_get_virtual_cell (table, vcell_loc);
- if (vcell == NULL)
- return;
+ vcell = gnc_table_get_virtual_cell (table, vcell_loc);
+ if (vcell == NULL)
+ return;
- vcell->cellblock = cursor;
+ vcell->cellblock = cursor;
}
-static void
+static void
gnc_table_move_cursor_internal (Table *table,
VirtualLocation new_virt_loc,
gboolean do_move_gui)
{
- int cell_row, cell_col;
- VirtualLocation virt_loc;
- VirtualCell *vcell;
- CellBlock *curs;
+ int cell_row, cell_col;
+ VirtualLocation virt_loc;
+ VirtualCell *vcell;
+ CellBlock *curs;
- ENTER("new_virt=(%d %d) do_move_gui=%d\n",
- new_virt_loc.vcell_loc.virt_row,
- new_virt_loc.vcell_loc.virt_col, do_move_gui);
+ ENTER("new_virt=(%d %d) do_move_gui=%d\n",
+ new_virt_loc.vcell_loc.virt_row,
+ new_virt_loc.vcell_loc.virt_col, do_move_gui);
- /* call the callback, allowing the app to commit any changes
- * associated with the current location of the cursor. Note that
- * this callback may recursively call this routine. */
- if (table->control->move_cursor && table->control->allow_move)
- {
- table->control->move_cursor (&new_virt_loc, table->control->user_data);
+ /* call the callback, allowing the app to commit any changes
+ * associated with the current location of the cursor. Note that
+ * this callback may recursively call this routine. */
+ if (table->control->move_cursor && table->control->allow_move)
+ {
+ table->control->move_cursor (&new_virt_loc, table->control->user_data);
- /* The above callback can cause this routine to be called
- * recursively. As a result of this recursion, the cursor may
- * have gotten repositioned. We need to make sure we make
- * passive again. */
- if (do_move_gui)
- gnc_table_refresh_current_cursor_gui (table, FALSE);
- }
+ /* The above callback can cause this routine to be called
+ * recursively. As a result of this recursion, the cursor may
+ * have gotten repositioned. We need to make sure we make
+ * passive again. */
+ if (do_move_gui)
+ gnc_table_refresh_current_cursor_gui (table, FALSE);
+ }
- /* invalidate the cursor for now; we'll fix it back up below */
- gnc_virtual_location_init (&table->current_cursor_loc);
+ /* invalidate the cursor for now; we'll fix it back up below */
+ gnc_virtual_location_init (&table->current_cursor_loc);
- curs = table->current_cursor;
- table->current_cursor = NULL;
+ curs = table->current_cursor;
+ table->current_cursor = NULL;
- /* check for out-of-bounds conditions (which may be deliberate) */
- if ((new_virt_loc.vcell_loc.virt_row < 0) ||
- (new_virt_loc.vcell_loc.virt_col < 0))
- {
- /* if the location is invalid, then we should take this
- * as a command to unmap the cursor gui. */
- if (do_move_gui && curs)
+ /* check for out-of-bounds conditions (which may be deliberate) */
+ if ((new_virt_loc.vcell_loc.virt_row < 0) ||
+ (new_virt_loc.vcell_loc.virt_col < 0))
{
- for (cell_row = 0; cell_row < curs->num_rows; cell_row++)
- for (cell_col = 0; cell_col < curs->num_cols; cell_col++)
+ /* if the location is invalid, then we should take this
+ * as a command to unmap the cursor gui. */
+ if (do_move_gui && curs)
{
- BasicCell *cell;
+ for (cell_row = 0; cell_row < curs->num_rows; cell_row++)
+ for (cell_col = 0; cell_col < curs->num_cols; cell_col++)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (curs, cell_row, cell_col);
- if (cell)
- {
- cell->changed = FALSE;
- cell->conditionally_changed = FALSE;
+ cell = gnc_cellblock_get_cell (curs, cell_row, cell_col);
+ if (cell)
+ {
+ cell->changed = FALSE;
+ cell->conditionally_changed = FALSE;
- if (cell->gui_move)
- cell->gui_move (cell);
- }
+ if (cell->gui_move)
+ cell->gui_move (cell);
+ }
+ }
}
+
+ LEAVE("out of bounds\n");
+ return;
}
- LEAVE("out of bounds\n");
- return;
- }
+ if (!gnc_table_virtual_loc_valid (table, new_virt_loc, TRUE))
+ {
+ PWARN("bad table location");
+ LEAVE("");
+ return;
+ }
- if (!gnc_table_virtual_loc_valid (table, new_virt_loc, TRUE))
- {
- PWARN("bad table location");
- LEAVE("");
- return;
- }
+ /* ok, we now have a valid position. Find the new cursor to use,
+ * and initialize its cells */
+ vcell = gnc_table_get_virtual_cell (table, new_virt_loc.vcell_loc);
+ curs = vcell->cellblock;
+ table->current_cursor = curs;
- /* ok, we now have a valid position. Find the new cursor to use,
- * and initialize its cells */
- vcell = gnc_table_get_virtual_cell (table, new_virt_loc.vcell_loc);
- curs = vcell->cellblock;
- table->current_cursor = curs;
+ /* record the new position */
+ table->current_cursor_loc = new_virt_loc;
- /* record the new position */
- table->current_cursor_loc = new_virt_loc;
+ virt_loc.vcell_loc = new_virt_loc.vcell_loc;
- virt_loc.vcell_loc = new_virt_loc.vcell_loc;
+ /* update the cell values to reflect the new position */
+ for (cell_row = 0; cell_row < curs->num_rows; cell_row++)
+ for (cell_col = 0; cell_col < curs->num_cols; cell_col++)
+ {
+ BasicCell *cell;
+ CellIOFlags io_flags;
- /* update the cell values to reflect the new position */
- for (cell_row = 0; cell_row < curs->num_rows; cell_row++)
- for (cell_col = 0; cell_col < curs->num_cols; cell_col++)
- {
- BasicCell *cell;
- CellIOFlags io_flags;
+ virt_loc.phys_row_offset = cell_row;
+ virt_loc.phys_col_offset = cell_col;
- virt_loc.phys_row_offset = cell_row;
- virt_loc.phys_col_offset = cell_col;
+ cell = gnc_cellblock_get_cell(curs, cell_row, cell_col);
+ if (cell)
+ {
+ /* if a cell has a GUI, move that first, before setting
+ * the cell value. Otherwise, we'll end up putting the
+ * new values in the old cell locations, and that would
+ * lead to confusion of all sorts. */
+ if (do_move_gui && cell->gui_move)
+ cell->gui_move (cell);
- cell = gnc_cellblock_get_cell(curs, cell_row, cell_col);
- if (cell)
- {
- /* if a cell has a GUI, move that first, before setting
- * the cell value. Otherwise, we'll end up putting the
- * new values in the old cell locations, and that would
- * lead to confusion of all sorts. */
- if (do_move_gui && cell->gui_move)
- cell->gui_move (cell);
+ /* OK, now copy the string value from the table at large
+ * into the cell handler. */
+ io_flags = gnc_table_get_io_flags (table, virt_loc);
+ if (io_flags & XACC_CELL_ALLOW_SHADOW)
+ {
+ const char *entry;
+ gboolean conditionally_changed = FALSE;
- /* OK, now copy the string value from the table at large
- * into the cell handler. */
- io_flags = gnc_table_get_io_flags (table, virt_loc);
- if (io_flags & XACC_CELL_ALLOW_SHADOW)
- {
- const char *entry;
- gboolean conditionally_changed = FALSE;
+ entry = gnc_table_get_entry_internal (table, virt_loc,
+ &conditionally_changed);
- entry = gnc_table_get_entry_internal (table, virt_loc,
- &conditionally_changed);
+ gnc_basic_cell_set_value (cell, entry);
- gnc_basic_cell_set_value (cell, entry);
-
- cell->changed = FALSE;
- cell->conditionally_changed = conditionally_changed;
+ cell->changed = FALSE;
+ cell->conditionally_changed = conditionally_changed;
+ }
+ }
}
- }
- }
- LEAVE("did move\n");
+ LEAVE("did move\n");
}
void
gnc_table_move_cursor (Table *table, VirtualLocation new_virt_loc)
{
- if (!table) return;
+ if (!table) return;
- gnc_table_move_cursor_internal (table, new_virt_loc, FALSE);
+ gnc_table_move_cursor_internal (table, new_virt_loc, FALSE);
}
/* same as above, but be sure to deal with GUI elements as well */
void
gnc_table_move_cursor_gui (Table *table, VirtualLocation new_virt_loc)
{
- if (!table) return;
+ if (!table) return;
- gnc_table_move_cursor_internal (table, new_virt_loc, TRUE);
+ gnc_table_move_cursor_internal (table, new_virt_loc, TRUE);
}
/* gnc_table_verify_cursor_position checks the location of the cursor
@@ -907,107 +907,107 @@
gboolean
gnc_table_verify_cursor_position (Table *table, VirtualLocation virt_loc)
{
- gboolean do_move = FALSE;
- gboolean moved_cursor = FALSE;
+ gboolean do_move = FALSE;
+ gboolean moved_cursor = FALSE;
- if (!table) return FALSE;
+ if (!table) return FALSE;
- /* Someone may be trying to intentionally invalidate the cursor, in
- * which case the physical addresses could be out of bounds. For
- * example, in order to unmap it in preparation for a reconfig.
- * So, if the specified location is out of bounds, then the cursor
- * MUST be moved. */
- if (gnc_table_virtual_cell_out_of_bounds (table, virt_loc.vcell_loc))
- do_move = TRUE;
+ /* Someone may be trying to intentionally invalidate the cursor, in
+ * which case the physical addresses could be out of bounds. For
+ * example, in order to unmap it in preparation for a reconfig.
+ * So, if the specified location is out of bounds, then the cursor
+ * MUST be moved. */
+ if (gnc_table_virtual_cell_out_of_bounds (table, virt_loc.vcell_loc))
+ do_move = TRUE;
- if (!virt_cell_loc_equal (virt_loc.vcell_loc,
- table->current_cursor_loc.vcell_loc))
- do_move = TRUE;
+ if (!virt_cell_loc_equal (virt_loc.vcell_loc,
+ table->current_cursor_loc.vcell_loc))
+ do_move = TRUE;
- if (do_move)
- {
- gnc_table_move_cursor_gui (table, virt_loc);
- moved_cursor = TRUE;
- }
- else if (!virt_loc_equal (virt_loc, table->current_cursor_loc))
- {
- table->current_cursor_loc = virt_loc;
- moved_cursor = TRUE;
- }
+ if (do_move)
+ {
+ gnc_table_move_cursor_gui (table, virt_loc);
+ moved_cursor = TRUE;
+ }
+ else if (!virt_loc_equal (virt_loc, table->current_cursor_loc))
+ {
+ table->current_cursor_loc = virt_loc;
+ moved_cursor = TRUE;
+ }
- return moved_cursor;
+ return moved_cursor;
}
gpointer
gnc_table_get_vcell_data (Table *table, VirtualCellLocation vcell_loc)
{
- VirtualCell *vcell;
+ VirtualCell *vcell;
- if (!table) return NULL;
+ if (!table) return NULL;
- vcell = gnc_table_get_virtual_cell (table, vcell_loc);
- if (vcell == NULL)
- return NULL;
+ vcell = gnc_table_get_virtual_cell (table, vcell_loc);
+ if (vcell == NULL)
+ return NULL;
- return vcell->vcell_data;
+ return vcell->vcell_data;
}
-/* If any of the cells have GUI specific components that need
+/* If any of the cells have GUI specific components that need
* initialization, initialize them now. The realize() callback
- * on the cursor cell is how we inform the cell handler that
+ * on the cursor cell is how we inform the cell handler that
* now is the time to initialize its GUI. */
void
gnc_table_realize_gui (Table * table)
{
- GList *cells;
- GList *node;
+ GList *cells;
+ GList *node;
- if (!table) return;
- if (!table->ui_data) return;
+ if (!table) return;
+ if (!table->ui_data) return;
- cells = gnc_table_layout_get_cells (table->layout);
+ cells = gnc_table_layout_get_cells (table->layout);
- for (node = cells; node; node = node->next)
- {
- BasicCell *cell = node->data;
+ for (node = cells; node; node = node->next)
+ {
+ BasicCell *cell = node->data;
- if (cell->gui_realize)
- cell->gui_realize (cell, table->ui_data);
- }
+ if (cell->gui_realize)
+ cell->gui_realize (cell, table->ui_data);
+ }
}
void
gnc_table_wrap_verify_cursor_position (Table *table, VirtualLocation virt_loc)
{
- VirtualLocation save_loc;
- gboolean moved_cursor;
+ VirtualLocation save_loc;
+ gboolean moved_cursor;
- if (!table) return;
+ if (!table) return;
- ENTER("(%d %d)", virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_col);
+ ENTER("(%d %d)", virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_col);
- save_loc = table->current_cursor_loc;
+ save_loc = table->current_cursor_loc;
- /* VerifyCursor will do all sorts of gui-independent machinations */
- moved_cursor = gnc_table_verify_cursor_position (table, virt_loc);
+ /* VerifyCursor will do all sorts of gui-independent machinations */
+ moved_cursor = gnc_table_verify_cursor_position (table, virt_loc);
- if (moved_cursor)
- {
- /* make sure *both* the old and the new cursor rows get redrawn */
- gnc_table_refresh_current_cursor_gui (table, TRUE);
- gnc_table_refresh_cursor_gui (table, save_loc.vcell_loc, FALSE);
- }
+ if (moved_cursor)
+ {
+ /* make sure *both* the old and the new cursor rows get redrawn */
+ gnc_table_refresh_current_cursor_gui (table, TRUE);
+ gnc_table_refresh_cursor_gui (table, save_loc.vcell_loc, FALSE);
+ }
- LEAVE ("");
+ LEAVE ("");
}
-void
+void
gnc_table_refresh_current_cursor_gui (Table * table, gboolean do_scroll)
{
- if (!table) return;
+ if (!table) return;
- gnc_table_refresh_cursor_gui (table, table->current_cursor_loc.vcell_loc,
- do_scroll);
+ gnc_table_refresh_cursor_gui (table, table->current_cursor_loc.vcell_loc,
+ do_scroll);
}
gboolean
@@ -1015,48 +1015,48 @@
VirtualLocation virt_loc,
gboolean exact_pointer)
{
- VirtualCell *vcell;
- CellIOFlags io_flags;
+ VirtualCell *vcell;
+ CellIOFlags io_flags;
- if (!table) return FALSE;
+ if (!table) return FALSE;
- /* header rows cannot be modified */
- if (virt_loc.vcell_loc.virt_row == 0)
- return FALSE;
+ /* header rows cannot be modified */
+ if (virt_loc.vcell_loc.virt_row == 0)
+ return FALSE;
- vcell = gnc_table_get_virtual_cell(table, virt_loc.vcell_loc);
- if (vcell == NULL)
- return FALSE;
+ vcell = gnc_table_get_virtual_cell(table, virt_loc.vcell_loc);
+ if (vcell == NULL)
+ return FALSE;
- if (!vcell->visible)
- return FALSE;
+ if (!vcell->visible)
+ return FALSE;
- /* verify that offsets are valid. This may occur if the app that is
- * using the table has a paritally initialized cursor. (probably due
- * to a programming error, but maybe they meant to do this). */
- if ((0 > virt_loc.phys_row_offset) || (0 > virt_loc.phys_col_offset))
- return FALSE;
+ /* verify that offsets are valid. This may occur if the app that is
+ * using the table has a paritally initialized cursor. (probably due
+ * to a programming error, but maybe they meant to do this). */
+ if ((0 > virt_loc.phys_row_offset) || (0 > virt_loc.phys_col_offset))
+ return FALSE;
- /* check for a cell handler, but only if cell address is valid */
- if (vcell->cellblock == NULL) return FALSE;
+ /* check for a cell handler, but only if cell address is valid */
+ if (vcell->cellblock == NULL) return FALSE;
- /* if table is read-only, any cell is ok :) */
- if (gnc_table_model_read_only (table->model)) return TRUE;
+ /* if table is read-only, any cell is ok :) */
+ if (gnc_table_model_read_only (table->model)) return TRUE;
- io_flags = gnc_table_get_io_flags (table, virt_loc);
+ io_flags = gnc_table_get_io_flags (table, virt_loc);
- /* if the cell allows ENTER, then it is ok */
- if (io_flags & XACC_CELL_ALLOW_ENTER) return TRUE;
+ /* if the cell allows ENTER, then it is ok */
+ if (io_flags & XACC_CELL_ALLOW_ENTER) return TRUE;
- /* if cell is marked as output-only, you can't enter */
- if (0 == (XACC_CELL_ALLOW_INPUT & io_flags)) return FALSE;
+ /* if cell is marked as output-only, you can't enter */
+ if (0 == (XACC_CELL_ALLOW_INPUT & io_flags)) return FALSE;
- /* if cell is pointer only and this is not an exact pointer test,
- * it cannot be entered. */
- if (!exact_pointer && ((XACC_CELL_ALLOW_EXACT_ONLY & io_flags) != 0))
- return FALSE;
+ /* if cell is pointer only and this is not an exact pointer test,
+ * it cannot be entered. */
+ if (!exact_pointer && ((XACC_CELL_ALLOW_EXACT_ONLY & io_flags) != 0))
+ return FALSE;
- return TRUE;
+ return TRUE;
}
/* Handle the non gui-specific parts of a cell enter callback */
@@ -1067,147 +1067,147 @@
int *start_selection,
int *end_selection)
{
- gboolean can_edit = TRUE;
- CellEnterFunc enter;
- BasicCell *cell;
- CellBlock *cb;
- int cell_row;
- int cell_col;
- CellIOFlags io_flags;
+ gboolean can_edit = TRUE;
+ CellEnterFunc enter;
+ BasicCell *cell;
+ CellBlock *cb;
+ int cell_row;
+ int cell_col;
+ CellIOFlags io_flags;
- if (table == NULL)
- return FALSE;
+ if (table == NULL)
+ return FALSE;
- cb = table->current_cursor;
+ cb = table->current_cursor;
- cell_row = virt_loc.phys_row_offset;
- cell_col = virt_loc.phys_col_offset;
+ cell_row = virt_loc.phys_row_offset;
+ cell_col = virt_loc.phys_col_offset;
- ENTER("enter %d %d (relrow=%d relcol=%d)",
- virt_loc.vcell_loc.virt_row,
- virt_loc.vcell_loc.virt_col,
- cell_row, cell_col);
+ ENTER("enter %d %d (relrow=%d relcol=%d)",
+ virt_loc.vcell_loc.virt_row,
+ virt_loc.vcell_loc.virt_col,
+ cell_row, cell_col);
- /* OK, if there is a callback for this cell, call it */
- cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
- if (!cell)
- {
- LEAVE("no cell");
- return FALSE;
- }
-
- io_flags = gnc_table_get_io_flags (table, virt_loc);
- if (io_flags == XACC_CELL_ALLOW_READ_ONLY)
- {
- LEAVE("read only cell");
- return FALSE;
- }
+ /* OK, if there is a callback for this cell, call it */
+ cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
+ if (!cell)
+ {
+ LEAVE("no cell");
+ return FALSE;
+ }
- enter = cell->enter_cell;
+ io_flags = gnc_table_get_io_flags (table, virt_loc);
+ if (io_flags == XACC_CELL_ALLOW_READ_ONLY)
+ {
+ LEAVE("read only cell");
+ return FALSE;
+ }
- if (enter)
- {
- char * old_value;
+ enter = cell->enter_cell;
- DEBUG("gnc_table_enter_update(): %d %d has enter handler\n",
- cell_row, cell_col);
+ if (enter)
+ {
+ char * old_value;
- old_value = g_strdup (cell->value);
+ DEBUG("gnc_table_enter_update(): %d %d has enter handler\n",
+ cell_row, cell_col);
- can_edit = enter (cell, cursor_position, start_selection, end_selection);
+ old_value = g_strdup (cell->value);
- if (safe_strcmp (old_value, cell->value) != 0)
- {
- if (gnc_table_model_read_only (table->model))
- {
- PWARN ("enter update changed read-only table");
- }
+ can_edit = enter (cell, cursor_position, start_selection, end_selection);
- cell->changed = TRUE;
+ if (safe_strcmp (old_value, cell->value) != 0)
+ {
+ if (gnc_table_model_read_only (table->model))
+ {
+ PWARN ("enter update changed read-only table");
+ }
+
+ cell->changed = TRUE;
+ }
+
+ g_free (old_value);
}
- g_free (old_value);
- }
+ if (table->gui_handlers.redraw_help)
+ table->gui_handlers.redraw_help (table);
- if (table->gui_handlers.redraw_help)
- table->gui_handlers.redraw_help (table);
-
- LEAVE("return %d\n", can_edit);
- return can_edit;
+ LEAVE("return %d\n", can_edit);
+ return can_edit;
}
void
gnc_table_leave_update (Table *table, VirtualLocation virt_loc)
{
- CellLeaveFunc leave;
- BasicCell *cell;
- CellBlock *cb;
- int cell_row;
- int cell_col;
+ CellLeaveFunc leave;
+ BasicCell *cell;
+ CellBlock *cb;
+ int cell_row;
+ int cell_col;
- if (table == NULL)
- return;
+ if (table == NULL)
+ return;
- cb = table->current_cursor;
+ cb = table->current_cursor;
- cell_row = virt_loc.phys_row_offset;
- cell_col = virt_loc.phys_col_offset;
+ cell_row = virt_loc.phys_row_offset;
+ cell_col = virt_loc.phys_col_offset;
- ENTER("proposed (%d %d) rel(%d %d)\n",
- virt_loc.vcell_loc.virt_row,
- virt_loc.vcell_loc.virt_col,
- cell_row, cell_col);
+ ENTER("proposed (%d %d) rel(%d %d)\n",
+ virt_loc.vcell_loc.virt_row,
+ virt_loc.vcell_loc.virt_col,
+ cell_row, cell_col);
- /* OK, if there is a callback for this cell, call it */
- cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
- if (!cell)
- {
- LEAVE("no cell");
- return;
- }
+ /* OK, if there is a callback for this cell, call it */
+ cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
+ if (!cell)
+ {
+ LEAVE("no cell");
+ return;
+ }
- leave = cell->leave_cell;
+ leave = cell->leave_cell;
- if (leave)
- {
- char * old_value;
+ if (leave)
+ {
+ char * old_value;
- old_value = g_strdup (cell->value);
+ old_value = g_strdup (cell->value);
- leave (cell);
+ leave (cell);
- if (safe_strcmp (old_value, cell->value) != 0)
- {
- if (gnc_table_model_read_only (table->model))
- {
- PWARN ("leave update changed read-only table");
- }
+ if (safe_strcmp (old_value, cell->value) != 0)
+ {
+ if (gnc_table_model_read_only (table->model))
+ {
+ PWARN ("leave update changed read-only table");
+ }
- cell->changed = TRUE;
+ cell->changed = TRUE;
+ }
+
+ g_free (old_value);
}
-
- g_free (old_value);
- }
- LEAVE("");
+ LEAVE("");
}
gboolean
gnc_table_confirm_change (Table *table, VirtualLocation virt_loc)
{
- TableConfirmHandler confirm_handler;
- const char *cell_name;
+ TableConfirmHandler confirm_handler;
+ const char *cell_name;
- if (!table || !table->model)
- return TRUE;
+ if (!table || !table->model)
+ return TRUE;
- cell_name = gnc_table_get_cell_name (table, virt_loc);
+ cell_name = gnc_table_get_cell_name (table, virt_loc);
- confirm_handler = gnc_table_model_get_confirm_handler (table->model,
- cell_name);
- if (!confirm_handler)
- return TRUE;
+ confirm_handler = gnc_table_model_get_confirm_handler (table->model,
+ cell_name);
+ if (!confirm_handler)
+ return TRUE;
- return confirm_handler (virt_loc, table->model->handler_user_data);
+ return confirm_handler (virt_loc, table->model->handler_user_data);
}
/* Returned result should not be touched by the caller.
@@ -1224,85 +1224,85 @@
int *end_selection,
gboolean *cancelled)
{
- gboolean changed = FALSE;
- CellModifyVerifyFunc mv;
- BasicCell *cell;
- CellBlock *cb;
- int cell_row;
- int cell_col;
- char * old_value;
+ gboolean changed = FALSE;
+ CellModifyVerifyFunc mv;
+ BasicCell *cell;
+ CellBlock *cb;
+ int cell_row;
+ int cell_col;
+ char * old_value;
- g_return_val_if_fail (table, NULL);
- g_return_val_if_fail (table->model, NULL);
+ g_return_val_if_fail (table, NULL);
+ g_return_val_if_fail (table->model, NULL);
- if (gnc_table_model_read_only (table->model))
- {
- PWARN ("change to read-only table");
- return NULL;
- }
+ if (gnc_table_model_read_only (table->model))
+ {
+ PWARN ("change to read-only table");
+ return NULL;
+ }
- cb = table->current_cursor;
+ cb = table->current_cursor;
- cell_row = virt_loc.phys_row_offset;
- cell_col = virt_loc.phys_col_offset;
+ cell_row = virt_loc.phys_row_offset;
+ cell_col = virt_loc.phys_col_offset;
- ENTER ("");
+ ENTER ("");
- if (!gnc_table_confirm_change (table, virt_loc))
- {
- if (cancelled)
- *cancelled = TRUE;
+ if (!gnc_table_confirm_change (table, virt_loc))
+ {
+ if (cancelled)
+ *cancelled = TRUE;
- LEAVE("change cancelled");
- return NULL;
- }
+ LEAVE("change cancelled");
+ return NULL;
+ }
- if (cancelled)
- *cancelled = FALSE;
+ if (cancelled)
+ *cancelled = FALSE;
- /* OK, if there is a callback for this cell, call it */
- cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
- if (!cell)
- {
- LEAVE("no cell");
- return NULL;
- }
+ /* OK, if there is a callback for this cell, call it */
+ cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
+ if (!cell)
+ {
+ LEAVE("no cell");
+ return NULL;
+ }
- mv = cell->modify_verify;
+ mv = cell->modify_verify;
- old_value = g_strdup (cell->value);
+ old_value = g_strdup (cell->value);
- if (mv)
- {
- mv (cell, change, change_len, newval, newval_len,
- cursor_position, start_selection, end_selection);
- }
- else
- {
- gnc_basic_cell_set_value (cell, newval);
- }
+ if (mv)
+ {
+ mv (cell, change, change_len, newval, newval_len,
+ cursor_position, start_selection, end_selection);
+ }
+ else
+ {
+ gnc_basic_cell_set_value (cell, newval);
+ }
- if (safe_strcmp (old_value, cell->value) != 0)
- {
- changed = TRUE;
- cell->changed = TRUE;
- }
+ if (safe_strcmp (old_value, cell->value) != 0)
+ {
+ changed = TRUE;
+ cell->changed = TRUE;
+ }
- g_free (old_value);
+ g_free (old_value);
- if (table->gui_handlers.redraw_help)
- table->gui_handlers.redraw_help (table);
+ if (table->gui_handlers.redraw_help)
+ table->gui_handlers.redraw_help (table);
- LEAVE ("change %d %d (relrow=%d relcol=%d) val=%s\n",
- virt_loc.vcell_loc.virt_row,
- virt_loc.vcell_loc.virt_col,
- cell_row, cell_col,
- cell->value ? cell->value : "(null)");
+ LEAVE ("change %d %d (relrow=%d relcol=%d) val=%s\n",
+ virt_loc.vcell_loc.virt_row,
+ virt_loc.vcell_loc.virt_col,
+ cell_row, cell_col,
+ cell->value ? cell->value : "(null)");
- if (changed)
- return cell->value;
- else
- return NULL;
+ if (changed)
+ return cell->value;
+ else
+ return NULL;
}
gboolean
@@ -1314,137 +1314,137 @@
int *end_selection,
gpointer gui_data)
{
- gboolean result;
- BasicCell *cell;
- CellBlock *cb;
- int cell_row;
- int cell_col;
- char * old_value;
+ gboolean result;
+ BasicCell *cell;
+ CellBlock *cb;
+ int cell_row;
+ int cell_col;
+ char * old_value;
- g_return_val_if_fail (table, FALSE);
- g_return_val_if_fail (table->model, FALSE);
+ g_return_val_if_fail (table, FALSE);
+ g_return_val_if_fail (table->model, FALSE);
- if (gnc_table_model_read_only (table->model))
- {
- PWARN ("input to read-only table");
- return FALSE;
- }
+ if (gnc_table_model_read_only (table->model))
+ {
+ PWARN ("input to read-only table");
+ return FALSE;
+ }
- cb = table->current_cursor;
+ cb = table->current_cursor;
- cell_row = virt_loc.phys_row_offset;
- cell_col = virt_loc.phys_col_offset;
+ cell_row = virt_loc.phys_row_offset;
+ cell_col = virt_loc.phys_col_offset;
- cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
- if (!cell)
- return FALSE;
+ cell = gnc_cellblock_get_cell (cb, cell_row, cell_col);
+ if (!cell)
+ return FALSE;
- ENTER ("");
+ ENTER ("");
- if (cell->direct_update == NULL)
- {
- LEAVE("no direct update");
- return FALSE;
- }
+ if (cell->direct_update == NULL)
+ {
+ LEAVE("no direct update");
+ return FALSE;
+ }
- old_value = g_strdup (cell->value);
+ old_value = g_strdup (cell->value);
- result = cell->direct_update (cell, cursor_position, start_selection,
- end_selection, gui_data);
+ result = cell->direct_update (cell, cursor_position, start_selection,
+ end_selection, gui_data);
- if (safe_strcmp (old_value, cell->value) != 0)
- {
- if (!gnc_table_confirm_change (table, virt_loc))
+ if (safe_strcmp (old_value, cell->value) != 0)
{
- gnc_basic_cell_set_value (cell, old_value);
- *newval_ptr = NULL;
- result = TRUE;
+ if (!gnc_table_confirm_change (table, virt_loc))
+ {
+ gnc_basic_cell_set_value (cell, old_value);
+ *newval_ptr = NULL;
+ result = TRUE;
+ }
+ else
+ {
+ cell->changed = TRUE;
+ *newval_ptr = cell->value;
+ }
}
else
- {
- cell->changed = TRUE;
- *newval_ptr = cell->value;
- }
- }
- else
- *newval_ptr = NULL;
+ *newval_ptr = NULL;
- g_free (old_value);
+ g_free (old_value);
- if (table->gui_handlers.redraw_help)
- table->gui_handlers.redraw_help (table);
+ if (table->gui_handlers.redraw_help)
+ table->gui_handlers.redraw_help (table);
- LEAVE("");
- return result;
+ LEAVE("");
+ return result;
}
static gboolean gnc_table_find_valid_cell_horiz (Table *table,
- VirtualLocation *virt_loc,
- gboolean exact_cell);
+ VirtualLocation *virt_loc,
+ gboolean exact_cell);
static gboolean
gnc_table_find_valid_row_vert (Table *table, VirtualLocation *virt_loc)
{
- VirtualLocation vloc;
- VirtualCell *vcell = NULL;
- int top;
- int bottom;
+ VirtualLocation vloc;
+ VirtualCell *vcell = NULL;
+ int top;
+ int bottom;
- if (table == NULL)
- return FALSE;
+ if (table == NULL)
+ return FALSE;
- if (virt_loc == NULL)
- return FALSE;
+ if (virt_loc == NULL)
+ return FALSE;
- vloc = *virt_loc;
+ vloc = *virt_loc;
- if (vloc.vcell_loc.virt_row < 1)
- vloc.vcell_loc.virt_row = 1;
- if (vloc.vcell_loc.virt_row >= table->num_virt_rows)
- vloc.vcell_loc.virt_row = table->num_virt_rows - 1;
+ if (vloc.vcell_loc.virt_row < 1)
+ vloc.vcell_loc.virt_row = 1;
+ if (vloc.vcell_loc.virt_row >= table->num_virt_rows)
+ vloc.vcell_loc.virt_row = table->num_virt_rows - 1;
- top = vloc.vcell_loc.virt_row;
- bottom = vloc.vcell_loc.virt_row + 1;
+ top = vloc.vcell_loc.virt_row;
+ bottom = vloc.vcell_loc.virt_row + 1;
- while (top >= 1 || bottom < table->num_virt_rows)
- {
- vloc.vcell_loc.virt_row = top;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- if (vcell && vcell->cellblock && vcell->visible)
+ while (top >= 1 || bottom < table->num_virt_rows)
{
- vloc.phys_row_offset = 0;
- vloc.phys_col_offset = 0;
+ vloc.vcell_loc.virt_row = top;
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ if (vcell && vcell->cellblock && vcell->visible)
+ {
+ vloc.phys_row_offset = 0;
+ vloc.phys_col_offset = 0;
- if (gnc_table_find_valid_cell_horiz (table, &vloc, FALSE))
- break;
- }
+ if (gnc_table_find_valid_cell_horiz (table, &vloc, FALSE))
+ break;
+ }
- vloc.vcell_loc.virt_row = bottom;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- if (vcell && vcell->cellblock && vcell->visible)
- {
- vloc.phys_row_offset = 0;
- vloc.phys_col_offset = 0;
+ vloc.vcell_loc.virt_row = bottom;
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ if (vcell && vcell->cellblock && vcell->visible)
+ {
+ vloc.phys_row_offset = 0;
+ vloc.phys_col_offset = 0;
- if (gnc_table_find_valid_cell_horiz (table, &vloc, FALSE))
- break;
+ if (gnc_table_find_valid_cell_horiz (table, &vloc, FALSE))
+ break;
+ }
+
+ top--;
+ bottom++;
}
- top--;
- bottom++;
- }
+ if (!vcell || !vcell->cellblock || !vcell->visible)
+ return FALSE;
- if (!vcell || !vcell->cellblock || !vcell->visible)
- return FALSE;
+ if (vloc.phys_row_offset < 0)
+ vloc.phys_row_offset = 0;
+ if (vloc.phys_row_offset >= vcell->cellblock->num_rows)
+ vloc.phys_row_offset = vcell->cellblock->num_rows - 1;
- if (vloc.phys_row_offset < 0)
- vloc.phys_row_offset = 0;
- if (vloc.phys_row_offset >= vcell->cellblock->num_rows)
- vloc.phys_row_offset = vcell->cellblock->num_rows - 1;
+ virt_loc->vcell_loc = vloc.vcell_loc;
- virt_loc->vcell_loc = vloc.vcell_loc;
-
- return TRUE;
+ return TRUE;
}
static gboolean
@@ -1452,81 +1452,81 @@
VirtualLocation *virt_loc,
gboolean exact_cell)
{
- VirtualLocation vloc;
- VirtualCell *vcell;
- int left;
- int right;
+ VirtualLocation vloc;
+ VirtualCell *vcell;
+ int left;
+ int right;
- if (table == NULL)
- return FALSE;
+ if (table == NULL)
+ return FALSE;
- if (virt_loc == NULL)
- return FALSE;
+ if (virt_loc == NULL)
+ return FALSE;
- if (gnc_table_virtual_cell_out_of_bounds (table, virt_loc->vcell_loc))
- return FALSE;
+ if (gnc_table_virtual_cell_out_of_bounds (table, virt_loc->vcell_loc))
+ return FALSE;
- if (gnc_table_virtual_loc_valid (table, *virt_loc, exact_cell))
- return TRUE;
+ if (gnc_table_virtual_loc_valid (table, *virt_loc, exact_cell))
+ return TRUE;
- vloc = *virt_loc;
+ vloc = *virt_loc;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- if (vcell == NULL)
- return FALSE;
- if (vcell->cellblock == NULL)
- return FALSE;
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ if (vcell == NULL)
+ return FALSE;
+ if (vcell->cellblock == NULL)
+ return FALSE;
- if (vloc.phys_col_offset < 0)
- vloc.phys_col_offset = 0;
- if (vloc.phys_col_offset >= vcell->cellblock->num_cols)
- vloc.phys_col_offset = vcell->cellblock->num_cols - 1;
+ if (vloc.phys_col_offset < 0)
+ vloc.phys_col_offset = 0;
+ if (vloc.phys_col_offset >= vcell->cellblock->num_cols)
+ vloc.phys_col_offset = vcell->cellblock->num_cols - 1;
- left = vloc.phys_col_offset - 1;
- right = vloc.phys_col_offset + 1;
+ left = vloc.phys_col_offset - 1;
+ right = vloc.phys_col_offset + 1;
- while (left >= 0 || right < vcell->cellblock->num_cols)
- {
- vloc.phys_col_offset = right;
- if (gnc_table_virtual_loc_valid(table, vloc, FALSE))
+ while (left >= 0 || right < vcell->cellblock->num_cols)
{
- *virt_loc = vloc;
- return TRUE;
- }
+ vloc.phys_col_offset = right;
+ if (gnc_table_virtual_loc_valid(table, vloc, FALSE))
+ {
+ *virt_loc = vloc;
+ return TRUE;
+ }
- vloc.phys_col_offset = left;
- if (gnc_table_virtual_loc_valid(table, vloc, FALSE))
- {
- *virt_loc = vloc;
- return TRUE;
+ vloc.phys_col_offset = left;
+ if (gnc_table_virtual_loc_valid(table, vloc, FALSE))
+ {
+ *virt_loc = vloc;
+ return TRUE;
+ }
+
+ left--;
+ right++;
}
- left--;
- right++;
- }
-
- return FALSE;
+ return FALSE;
}
gboolean
gnc_table_find_close_valid_cell (Table *table, VirtualLocation *virt_loc,
gboolean exact_pointer)
{
- if (!gnc_table_find_valid_row_vert (table, virt_loc))
- return FALSE;
+ if (!gnc_table_find_valid_row_vert (table, virt_loc))
+ return FALSE;
- return gnc_table_find_valid_cell_horiz (table, virt_loc, exact_pointer);
+ return gnc_table_find_valid_cell_horiz (table, virt_loc, exact_pointer);
}
-void
+void
gnc_table_refresh_cursor_gui (Table * table,
VirtualCellLocation vcell_loc,
gboolean do_scroll)
{
- g_return_if_fail (table != NULL);
- g_return_if_fail (table->gui_handlers.cursor_refresh != NULL);
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (table->gui_handlers.cursor_refresh != NULL);
- table->gui_handlers.cursor_refresh (table, vcell_loc, do_scroll);
+ table->gui_handlers.cursor_refresh (table, vcell_loc, do_scroll);
}
gboolean
@@ -1534,76 +1534,76 @@
VirtualLocation *virt_loc,
gboolean move_right)
{
- VirtualCell *vcell;
- VirtualLocation vloc;
- BasicCell *cell;
+ VirtualCell *vcell;
+ VirtualLocation vloc;
+ BasicCell *cell;
- if ((table == NULL) || (virt_loc == NULL))
- return FALSE;
+ if ((table == NULL) || (virt_loc == NULL))
+ return FALSE;
- vloc = *virt_loc;
+ vloc = *virt_loc;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- if ((vcell == NULL) || (vcell->cellblock == NULL) || !vcell->visible)
- return FALSE;
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ if ((vcell == NULL) || (vcell->cellblock == NULL) || !vcell->visible)
+ return FALSE;
- while (1)
- {
- CellIOFlags io_flags;
-
- if (move_right)
+ while (1)
{
- vloc.phys_col_offset++;
+ CellIOFlags io_flags;
- if (vloc.phys_col_offset >= vcell->cellblock->num_cols)
- {
- if (!gnc_table_move_vertical_position (table, &vloc, 1))
- return FALSE;
+ if (move_right)
+ {
+ vloc.phys_col_offset++;
- vloc.phys_col_offset = 0;
- }
- }
- else
- {
- vloc.phys_col_offset--;
+ if (vloc.phys_col_offset >= vcell->cellblock->num_cols)
+ {
+ if (!gnc_table_move_vertical_position (table, &vloc, 1))
+ return FALSE;
- if (vloc.phys_col_offset < 0)
- {
- if (!gnc_table_move_vertical_position (table, &vloc, -1))
- return FALSE;
+ vloc.phys_col_offset = 0;
+ }
+ }
+ else
+ {
+ vloc.phys_col_offset--;
- vloc.phys_col_offset = vcell->cellblock->num_cols - 1;
- }
- }
+ if (vloc.phys_col_offset < 0)
+ {
+ if (!gnc_table_move_vertical_position (table, &vloc, -1))
+ return FALSE;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- if ((vcell == NULL) || (vcell->cellblock == NULL) || !vcell->visible)
- return FALSE;
+ vloc.phys_col_offset = vcell->cellblock->num_cols - 1;
+ }
+ }
- cell = gnc_cellblock_get_cell (vcell->cellblock,
- vloc.phys_row_offset,
- vloc.phys_col_offset);
- if (!cell)
- continue;
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ if ((vcell == NULL) || (vcell->cellblock == NULL) || !vcell->visible)
+ return FALSE;
- io_flags = gnc_table_get_io_flags (table, vloc);
+ cell = gnc_cellblock_get_cell (vcell->cellblock,
+ vloc.phys_row_offset,
+ vloc.phys_col_offset);
+ if (!cell)
+ continue;
- if (!(io_flags & XACC_CELL_ALLOW_INPUT))
- continue;
+ io_flags = gnc_table_get_io_flags (table, vloc);
- if (io_flags & XACC_CELL_ALLOW_EXACT_ONLY)
- continue;
+ if (!(io_flags & XACC_CELL_ALLOW_INPUT))
+ continue;
- break;
- }
+ if (io_flags & XACC_CELL_ALLOW_EXACT_ONLY)
+ continue;
- {
- gboolean changed = !virt_loc_equal (vloc, *virt_loc);
+ break;
+ }
- *virt_loc = vloc;
+ {
+ gboolean changed = !virt_loc_equal (vloc, *virt_loc);
- return changed;
- }
+ *virt_loc = vloc;
+
+ return changed;
+ }
}
gboolean
@@ -1611,91 +1611,93 @@
VirtualLocation *virt_loc,
int phys_row_offset)
{
- VirtualLocation vloc;
- VirtualCell *vcell;
- gint last_visible_row;
+ VirtualLocation vloc;
+ VirtualCell *vcell;
+ gint last_visible_row;
- if ((table == NULL) || (virt_loc == NULL))
- return FALSE;
+ if ((table == NULL) || (virt_loc == NULL))
+ return FALSE;
- vloc = *virt_loc;
- last_visible_row = vloc.vcell_loc.virt_row;
+ vloc = *virt_loc;
+ last_visible_row = vloc.vcell_loc.virt_row;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- if ((vcell == NULL) || (vcell->cellblock == NULL))
- return FALSE;
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ if ((vcell == NULL) || (vcell->cellblock == NULL))
+ return FALSE;
- while (phys_row_offset != 0)
- {
- /* going up */
- if (phys_row_offset < 0)
+ while (phys_row_offset != 0)
{
- phys_row_offset++;
+ /* going up */
+ if (phys_row_offset < 0)
+ {
+ phys_row_offset++;
- /* room left in the current cursor */
- if (vloc.phys_row_offset > 0)
- {
- vloc.phys_row_offset--;
- continue;
- }
+ /* room left in the current cursor */
+ if (vloc.phys_row_offset > 0)
+ {
+ vloc.phys_row_offset--;
+ continue;
+ }
- /* end of the line */
- if (vloc.vcell_loc.virt_row == 1)
- break;
+ /* end of the line */
+ if (vloc.vcell_loc.virt_row == 1)
+ break;
- do
- {
- vloc.vcell_loc.virt_row--;
+ do
+ {
+ vloc.vcell_loc.virt_row--;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- } while (vcell && vcell->cellblock && !vcell->visible);
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ }
+ while (vcell && vcell->cellblock && !vcell->visible);
- if (!vcell || !vcell->cellblock)
- break;
+ if (!vcell || !vcell->cellblock)
+ break;
- last_visible_row = vloc.vcell_loc.virt_row;
- vloc.phys_row_offset = vcell->cellblock->num_rows - 1;
- }
- /* going down */
- else
- {
- phys_row_offset--;
+ last_visible_row = vloc.vcell_loc.virt_row;
+ vloc.phys_row_offset = vcell->cellblock->num_rows - 1;
+ }
+ /* going down */
+ else
+ {
+ phys_row_offset--;
- /* room left in the current cursor */
- if (vloc.phys_row_offset < (vcell->cellblock->num_rows - 1))
- {
- vloc.phys_row_offset++;
- continue;
- }
+ /* room left in the current cursor */
+ if (vloc.phys_row_offset < (vcell->cellblock->num_rows - 1))
+ {
+ vloc.phys_row_offset++;
+ continue;
+ }
- /* end of the line */
- if (vloc.vcell_loc.virt_row == (table->num_virt_rows - 1))
- break;
+ /* end of the line */
+ if (vloc.vcell_loc.virt_row == (table->num_virt_rows - 1))
+ break;
- do
- {
- vloc.vcell_loc.virt_row++;
+ do
+ {
+ vloc.vcell_loc.virt_row++;
- vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
- } while (vcell && vcell->cellblock && !vcell->visible);
+ vcell = gnc_table_get_virtual_cell (table, vloc.vcell_loc);
+ }
+ while (vcell && vcell->cellblock && !vcell->visible);
- if (!vcell || !vcell->cellblock)
- break;
+ if (!vcell || !vcell->cellblock)
+ break;
- last_visible_row = vloc.vcell_loc.virt_row;
- vloc.phys_row_offset = 0;
+ last_visible_row = vloc.vcell_loc.virt_row;
+ vloc.phys_row_offset = 0;
+ }
}
- }
- vloc.vcell_loc.virt_row = last_visible_row;
+ vloc.vcell_loc.virt_row = last_visible_row;
- {
- gboolean changed = !virt_loc_equal (vloc, *virt_loc);
+ {
+ gboolean changed = !virt_loc_equal (vloc, *virt_loc);
- *virt_loc = vloc;
+ *virt_loc = vloc;
- return changed;
- }
+ return changed;
+ }
}
gboolean
@@ -1704,113 +1706,113 @@
gncTableTraversalDir dir,
VirtualLocation *dest_loc)
{
- CellBlock *cb;
- gboolean abort_move;
+ CellBlock *cb;
+ gboolean abort_move;
- if ((table == NULL) || (dest_loc == NULL))
- return FALSE;
+ if ((table == NULL) || (dest_loc == NULL))
+ return FALSE;
- cb = table->current_cursor;
+ cb = table->current_cursor;
- ENTER("proposed (%d %d) -> (%d %d)\n",
- virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_row,
- dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col);
+ ENTER("proposed (%d %d) -> (%d %d)\n",
+ virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_row,
+ dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col);
- /* first, make sure our destination cell is valid. If it is out
- * of bounds report an error. I don't think this ever happens. */
- if (gnc_table_virtual_cell_out_of_bounds (table, dest_loc->vcell_loc))
- {
- PERR("destination (%d, %d) out of bounds (%d, %d)\n",
- dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col,
- table->num_virt_rows, table->num_virt_cols);
- LEAVE("");
- return TRUE;
- }
+ /* first, make sure our destination cell is valid. If it is out
+ * of bounds report an error. I don't think this ever happens. */
+ if (gnc_table_virtual_cell_out_of_bounds (table, dest_loc->vcell_loc))
+ {
+ PERR("destination (%d, %d) out of bounds (%d, %d)\n",
+ dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col,
+ table->num_virt_rows, table->num_virt_cols);
+ LEAVE("");
+ return TRUE;
+ }
- /* next, check the current row and column. If they are out of bounds
- * we can recover by treating the traversal as a mouse point. This can
- * occur whenever the register widget is resized smaller, maybe?. */
- if (!gnc_table_virtual_loc_valid (table, virt_loc, TRUE))
- {
- PINFO("source (%d, %d) out of bounds (%d, %d)\n",
- virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_col,
- table->num_virt_rows, table->num_virt_cols);
+ /* next, check the current row and column. If they are out of bounds
+ * we can recover by treating the traversal as a mouse point. This can
+ * occur whenever the register widget is resized smaller, maybe?. */
+ if (!gnc_table_virtual_loc_valid (table, virt_loc, TRUE))
+ {
+ PINFO("source (%d, %d) out of bounds (%d, %d)\n",
+ virt_loc.vcell_loc.virt_row, virt_loc.vcell_loc.virt_col,
+ table->num_virt_rows, table->num_virt_cols);
- dir = GNC_TABLE_TRAVERSE_POINTER;
- }
+ dir = GNC_TABLE_TRAVERSE_POINTER;
+ }
- /* process forward-moving traversals */
- switch (dir)
- {
+ /* process forward-moving traversals */
+ switch (dir)
+ {
case GNC_TABLE_TRAVERSE_RIGHT:
- case GNC_TABLE_TRAVERSE_LEFT:
- gnc_table_find_valid_cell_horiz(table, dest_loc, FALSE);
+ case GNC_TABLE_TRAVERSE_LEFT:
+ gnc_table_find_valid_cell_horiz(table, dest_loc, FALSE);
- break;
+ break;
case GNC_TABLE_TRAVERSE_UP:
case GNC_TABLE_TRAVERSE_DOWN:
- {
- VirtualLocation new_loc = *dest_loc;
- int increment;
+ {
+ VirtualLocation new_loc = *dest_loc;
+ int increment;
- /* Keep going in the specified direction until we find a valid
- * row to land on, or we hit the end of the table. At the end,
- * turn around and go back until we find a valid row or we get
- * to where we started. If we still can't find anything, try
- * going left and right. */
- increment = (dir == GNC_TABLE_TRAVERSE_DOWN) ? 1 : -1;
+ /* Keep going in the specified direction until we find a valid
+ * row to land on, or we hit the end of the table. At the end,
+ * turn around and go back until we find a valid row or we get
+ * to where we started. If we still can't find anything, try
+ * going left and right. */
+ increment = (dir == GNC_TABLE_TRAVERSE_DOWN) ? 1 : -1;
- while (!gnc_table_virtual_loc_valid(table, new_loc, FALSE))
- {
- if (virt_loc_equal (new_loc, virt_loc))
- {
- new_loc = *dest_loc;
- gnc_table_find_valid_cell_horiz(table, &new_loc, FALSE);
- break;
- }
+ while (!gnc_table_virtual_loc_valid(table, new_loc, FALSE))
+ {
+ if (virt_loc_equal (new_loc, virt_loc))
+ {
+ new_loc = *dest_loc;
+ gnc_table_find_valid_cell_horiz(table, &new_loc, FALSE);
+ break;
+ }
- if (!gnc_table_move_vertical_position (table, &new_loc, increment))
- {
- increment *= -1;
- new_loc = *dest_loc;
- }
- }
+ if (!gnc_table_move_vertical_position (table, &new_loc, increment))
+ {
+ increment *= -1;
+ new_loc = *dest_loc;
+ }
+ }
- *dest_loc = new_loc;
- }
+ *dest_loc = new_loc;
+ }
- if (!gnc_table_virtual_loc_valid(table, *dest_loc, FALSE))
- {
- LEAVE("");
- return TRUE;
- }
+ if (!gnc_table_virtual_loc_valid(table, *dest_loc, FALSE))
+ {
+ LEAVE("");
+ return TRUE;
+ }
- break;
+ break;
case GNC_TABLE_TRAVERSE_POINTER:
- if (!gnc_table_find_valid_cell_horiz(table, dest_loc, TRUE))
- {
- LEAVE("");
- return TRUE;
- }
+ if (!gnc_table_find_valid_cell_horiz(table, dest_loc, TRUE))
+ {
+ LEAVE("");
+ return TRUE;
+ }
- break;
+ break;
default:
- g_return_val_if_fail (FALSE, TRUE);
- break;
- }
+ g_return_val_if_fail (FALSE, TRUE);
+ break;
+ }
- /* Call the table traverse callback for any modifications. */
- if (table->control->traverse)
- abort_move = table->control->traverse (dest_loc, dir,
- table->control->user_data);
- else
- abort_move = FALSE;
+ /* Call the table traverse callback for any modifications. */
+ if (table->control->traverse)
+ abort_move = table->control->traverse (dest_loc, dir,
+ table->control->user_data);
+ else
+ abort_move = FALSE;
- LEAVE("dest_row = %d, dest_col = %d\n",
- dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col);
+ LEAVE("dest_row = %d, dest_col = %d\n",
+ dest_loc->vcell_loc.virt_row, dest_loc->vcell_loc.virt_col);
- return abort_move;
+ return abort_move;
}
Modified: gnucash/trunk/src/register/register-core/table-allgui.h
===================================================================
--- gnucash/trunk/src/register/register-core/table-allgui.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-allgui.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -35,7 +35,7 @@
*
* @details
* The Table object defines the structure and the GUI required
- * to display a two-dimensional grid. It provides several
+ * to display a two-dimensional grid. It provides several
* important functions:
* - An array of virtual cells. These cells contain:
* - the cellblock handler for that virtual cell.
@@ -45,7 +45,7 @@
*
* Please see src/doc/design/gnucash-design.info for additional information.
*
- * This implements the gui-independent parts of the table
+ * This implements the gui-independent parts of the table
* infrastructure. Additional, GUI-dependent parts are implemented
* in table-gnome.c.
*
@@ -54,9 +54,9 @@
* - there is only one cursor for a given virt row.
* - there is no overlap; a phys row can only belong to one virt row.
*
- * Lets say there are three cursors T(rans), S(plit), and B(lank).
+ * Lets say there are three cursors T(rans), S(plit), and B(lank).
* Lets say that these are used to 'print' the following table layout:
- *
+ *
@verbatim
virtual row 1 T
virtual row 2 S
@@ -72,7 +72,7 @@
* You can see there is only one cursor per virtual row. There is no overlap
* between cursors and virtual rows; the correspondence is one to one. Note
* that the three cursors T, S and B may consist of one, or more physical rows,
- * e.g. B and S may be one line each, but T may be two lines. Thus, we
+ * e.g. B and S may be one line each, but T may be two lines. Thus, we
* have the following physical layout:
*
@verbatim
@@ -89,7 +89,7 @@
physical row 11 virtual row 9 B
@endverbatim
*
- * This layout remains static until the next time that the table is
+ * This layout remains static until the next time that the table is
* re-'printed'.
*/
@@ -109,12 +109,12 @@
/* The VirtualCell structure holds information about each virtual cell. */
typedef struct
{
- CellBlock *cellblock; /* Array of physical cells */
- gpointer vcell_data; /* Used by higher-level code */
+ CellBlock *cellblock; /* Array of physical cells */
+ gpointer vcell_data; /* Used by higher-level code */
- /* flags */
- unsigned int visible : 1; /* visible in the GUI */
- unsigned int start_primary_color : 1; /* color usage flag */
+ /* flags */
+ unsigned int visible : 1; /* visible in the GUI */
+ unsigned int start_primary_color : 1; /* color usage flag */
} VirtualCell;
typedef struct table Table;
@@ -128,32 +128,32 @@
typedef struct
{
- TableCursorRefreshCB cursor_refresh;
+ TableCursorRefreshCB cursor_refresh;
- TableRedrawHelpCB redraw_help;
- TableDestroyCB destroy;
+ TableRedrawHelpCB redraw_help;
+ TableDestroyCB destroy;
} TableGUIHandlers;
struct table
{
- TableLayout *layout;
- TableModel *model;
- TableControl *control;
+ TableLayout *layout;
+ TableModel *model;
+ TableControl *control;
- int num_virt_rows;
- int num_virt_cols;
+ int num_virt_rows;
+ int num_virt_cols;
- CellBlock *current_cursor;
+ CellBlock *current_cursor;
- VirtualLocation current_cursor_loc;
+ VirtualLocation current_cursor_loc;
- /* private data */
+ /* private data */
- /* The virtual cell table */
- GTable *virt_cells;
+ /* The virtual cell table */
+ GTable *virt_cells;
- TableGUIHandlers gui_handlers;
- gpointer ui_data;
+ TableGUIHandlers gui_handlers;
+ gpointer ui_data;
};
@@ -172,35 +172,35 @@
/* Functions to work with current cursor */
int gnc_table_current_cursor_changed (Table *table,
- gboolean include_conditional);
+ gboolean include_conditional);
void gnc_table_clear_current_cursor_changes (Table *table);
void gnc_table_save_current_cursor (Table *table, CursorBuffer *buffer);
void gnc_table_restore_current_cursor (Table *table,
- CursorBuffer *buffer);
+ CursorBuffer *buffer);
const char * gnc_table_get_current_cell_name (Table *table);
gboolean gnc_table_get_current_cell_location (Table *table,
- const char *cell_name,
- VirtualLocation *virt_loc);
+ const char *cell_name,
+ VirtualLocation *virt_loc);
/* This function checks the given location and returns true
* if it is out of bounds of the table. */
gboolean gnc_table_virtual_cell_out_of_bounds (Table *table,
- VirtualCellLocation vcell_loc);
+ VirtualCellLocation vcell_loc);
gboolean gnc_table_virtual_location_in_header (Table *table,
- VirtualLocation virt_loc);
+ VirtualLocation virt_loc);
/* This function returns the virtual cell associated with a particular
* virtual location. If the location is out of bounds, NULL is *
* returned. */
VirtualCell * gnc_table_get_virtual_cell (Table *table,
- VirtualCellLocation vcell_loc);
+ VirtualCellLocation vcell_loc);
const char * gnc_table_get_entry (Table *table, VirtualLocation virt_loc);
@@ -213,7 +213,7 @@
guint32 gnc_table_get_bg_color (Table *table, VirtualLocation virt_loc,
gboolean *hatching);
guint32 gnc_table_get_gtkrc_bg_color (Table *table, VirtualLocation virt_loc,
- gboolean *hatching);
+ gboolean *hatching);
void gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
PhysicalCellBorders *borders);
@@ -230,9 +230,9 @@
VirtualLocation virt_loc);
gboolean gnc_table_get_cell_location (Table *table,
- const char * cell_name,
- VirtualCellLocation vcell_loc,
- VirtualLocation *virt_loc);
+ const char * cell_name,
+ VirtualCellLocation vcell_loc,
+ VirtualLocation *virt_loc);
void gnc_table_save_cells (Table *table, gpointer save_data);
@@ -253,18 +253,18 @@
/* Set the virtual cell data for a particular location. */
void gnc_table_set_virt_cell_data (Table *table,
- VirtualCellLocation vcell_loc,
- gconstpointer vcell_data);
+ VirtualCellLocation vcell_loc,
+ gconstpointer vcell_data);
/* Set the visibility flag for a particular location. */
void gnc_table_set_virt_cell_visible (Table *table,
- VirtualCellLocation vcell_loc,
- gboolean visible);
+ VirtualCellLocation vcell_loc,
+ gboolean visible);
/* Set the cellblock handler for a virtual cell. */
void gnc_table_set_virt_cell_cursor (Table *table,
- VirtualCellLocation vcell_loc,
- CellBlock *cursor);
+ VirtualCellLocation vcell_loc,
+ CellBlock *cursor);
/* The gnc_table_move_cursor() method will move the cursor (but not
* the cursor GUI) to the indicated location. This function is
@@ -284,7 +284,7 @@
* cursor and gui to the new position. Returns true if the cell
* cursor was repositioned. */
gboolean gnc_table_verify_cursor_position (Table *table,
- VirtualLocation virt_loc);
+ VirtualLocation virt_loc);
/* The gnc_table_get_vcell_data() method returns the virtual cell data
* associated with a cursor located at the given virtual coords, or
@@ -296,8 +296,8 @@
* be explicitly selected by the user (as opposed to just tabbing
* into), are considered valid cells. */
gboolean gnc_table_find_close_valid_cell (Table *table,
- VirtualLocation *virt_loc,
- gboolean exact_cell);
+ VirtualLocation *virt_loc,
+ gboolean exact_cell);
/** UI-specific functions *******************************/
@@ -308,7 +308,7 @@
/* Refresh the current cursor gui */
void gnc_table_refresh_current_cursor_gui (Table * table,
- gboolean do_scroll);
+ gboolean do_scroll);
/* Refresh the whole GUI from the table. */
void gnc_table_refresh_gui (Table *table, gboolean do_scroll);
@@ -321,17 +321,17 @@
/* Refresh the cursor in the given location. If do_scroll is TRUE,
* scroll the register so the location is in view. */
void gnc_table_refresh_cursor_gui (Table * table,
- VirtualCellLocation vcell_loc,
- gboolean do_scroll);
+ VirtualCellLocation vcell_loc,
+ gboolean do_scroll);
/* ==================================================== */
void gnc_table_wrap_verify_cursor_position (Table *table,
- VirtualLocation virt_loc);
+ VirtualLocation virt_loc);
gboolean gnc_table_virtual_loc_valid(Table *table,
- VirtualLocation virt_loc,
- gboolean exact_pointer);
+ VirtualLocation virt_loc,
+ gboolean exact_pointer);
gboolean gnc_table_move_tab (Table *table,
VirtualLocation *virt_loc,
@@ -351,8 +351,8 @@
* @return TRUE if the location changed, FALSE otherwise
*/
gboolean gnc_table_move_vertical_position (Table *table,
- VirtualLocation *virt_loc,
- int phys_row_offset);
+ VirtualLocation *virt_loc,
+ int phys_row_offset);
gboolean gnc_table_enter_update(Table *table,
VirtualLocation virt_loc,
Modified: gnucash/trunk/src/register/register-core/table-control.c
===================================================================
--- gnucash/trunk/src/register/register-core/table-control.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-control.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -30,24 +30,24 @@
TableControl *
gnc_table_control_new (void)
{
- TableControl *control;
+ TableControl *control;
- control = g_new0 (TableControl, 1);
+ control = g_new0 (TableControl, 1);
- return control;
+ return control;
}
void
gnc_table_control_destroy (TableControl *control)
{
- if (!control) return;
- g_free (control);
+ if (!control) return;
+ g_free (control);
}
void
gnc_table_control_allow_move (TableControl *control,
gboolean allow_move)
{
- if (!control) return;
- control->allow_move = allow_move;
+ if (!control) return;
+ control->allow_move = allow_move;
}
Modified: gnucash/trunk/src/register/register-core/table-control.h
===================================================================
--- gnucash/trunk/src/register/register-core/table-control.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-control.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -27,11 +27,11 @@
typedef enum
{
- GNC_TABLE_TRAVERSE_POINTER,
- GNC_TABLE_TRAVERSE_LEFT,
- GNC_TABLE_TRAVERSE_RIGHT,
- GNC_TABLE_TRAVERSE_UP,
- GNC_TABLE_TRAVERSE_DOWN
+ GNC_TABLE_TRAVERSE_POINTER,
+ GNC_TABLE_TRAVERSE_LEFT,
+ GNC_TABLE_TRAVERSE_RIGHT,
+ GNC_TABLE_TRAVERSE_UP,
+ GNC_TABLE_TRAVERSE_DOWN
} gncTableTraversalDir;
typedef void (*TableMoveFunc) (VirtualLocation *new_virt_loc,
@@ -43,15 +43,15 @@
typedef struct table_control
{
- /* called when the cursor is moved */
- TableMoveFunc move_cursor;
+ /* called when the cursor is moved */
+ TableMoveFunc move_cursor;
- gboolean allow_move;
+ gboolean allow_move;
- /* called to determine traversal when user requests a move */
- TableTraverseFunc traverse;
+ /* called to determine traversal when user requests a move */
+ TableTraverseFunc traverse;
- gpointer user_data;
+ gpointer user_data;
} TableControl;
Modified: gnucash/trunk/src/register/register-core/table-layout.c
===================================================================
--- gnucash/trunk/src/register/register-core/table-layout.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-layout.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -34,124 +34,124 @@
struct table_layout_struct
{
- GList *cells; /* The cells in the table */
- GList *cursors; /* The cursors in the table */
+ GList *cells; /* The cells in the table */
+ GList *cursors; /* The cursors in the table */
- CellBlock *primary_cursor;
+ CellBlock *primary_cursor;
};
typedef struct _CellBuffer CellBuffer;
struct _CellBuffer
{
- char * cell_name;
- char * value;
- guint32 changed;
- guint32 conditionally_changed;
+ char * cell_name;
+ char * value;
+ guint32 changed;
+ guint32 conditionally_changed;
};
struct cursor_buffer_struct
{
- GList *cell_buffers;
+ GList *cell_buffers;
};
TableLayout *
gnc_table_layout_new (void)
{
- TableLayout *layout;
+ TableLayout *layout;
- layout = g_new0 (TableLayout, 1);
+ layout = g_new0 (TableLayout, 1);
- return layout;
+ return layout;
}
void
gnc_table_layout_destroy (TableLayout *layout)
{
- GList *node;
+ GList *node;
- if (!layout)
- return;
+ if (!layout)
+ return;
- for (node = layout->cells; node; node = node->next)
- {
- BasicCell *cell = node->data;
+ for (node = layout->cells; node; node = node->next)
+ {
+ BasicCell *cell = node->data;
- gnc_basic_cell_destroy (cell);
- }
- g_list_free (layout->cells);
- layout->cells = NULL;
+ gnc_basic_cell_destroy (cell);
+ }
+ g_list_free (layout->cells);
+ layout->cells = NULL;
- for (node = layout->cursors; node; node = node->next)
- {
- CellBlock *cursor = node->data;
+ for (node = layout->cursors; node; node = node->next)
+ {
+ CellBlock *cursor = node->data;
- gnc_cellblock_destroy (cursor);
- }
- g_list_free (layout->cursors);
- layout->cursors = NULL;
+ gnc_cellblock_destroy (cursor);
+ }
+ g_list_free (layout->cursors);
+ layout->cursors = NULL;
- g_free (layout);
+ g_free (layout);
}
void
gnc_table_layout_add_cell (TableLayout *layout,
BasicCell *cell)
{
- GList *node;
+ GList *node;
- g_return_if_fail (layout != NULL);
- g_return_if_fail (cell != NULL);
+ g_return_if_fail (layout != NULL);
+ g_return_if_fail (cell != NULL);
- for (node = layout->cells; node; node = node->next)
- {
- BasicCell *list_cell = node->data;
-
- if (gnc_basic_cell_has_name (list_cell, cell->cell_name))
+ for (node = layout->cells; node; node = node->next)
{
- if (list_cell == cell)
- return;
+ BasicCell *list_cell = node->data;
- gnc_basic_cell_destroy (list_cell);
- break;
+ if (gnc_basic_cell_has_name (list_cell, cell->cell_name))
+ {
+ if (list_cell == cell)
+ return;
+
+ gnc_basic_cell_destroy (list_cell);
+ break;
+ }
}
- }
- if (!node)
- layout->cells = g_list_append (layout->cells, cell);
- else
- node->data = cell;
+ if (!node)
+ layout->cells = g_list_append (layout->cells, cell);
+ else
+ node->data = cell;
}
BasicCell *
gnc_table_layout_get_cell (TableLayout *layout, const char *cell_name)
{
- GList *node;
+ GList *node;
- g_return_val_if_fail (layout != NULL, NULL);
+ g_return_val_if_fail (layout != NULL, NULL);
- for (node = layout->cells; node; node = node->next)
- {
- BasicCell *list_cell = node->data;
+ for (node = layout->cells; node; node = node->next)
+ {
+ BasicCell *list_cell = node->data;
- if (gnc_basic_cell_has_name (list_cell, cell_name))
- return list_cell;
- }
+ if (gnc_basic_cell_has_name (list_cell, cell_name))
+ return list_cell;
+ }
- return NULL;
+ return NULL;
}
const char *
gnc_table_layout_get_cell_value (TableLayout *layout, const char * cell_name)
{
- BasicCell *cell;
+ BasicCell *cell;
- g_return_val_if_fail (layout != NULL, NULL);
+ g_return_val_if_fail (layout != NULL, NULL);
- cell = gnc_table_layout_get_cell (layout, cell_name);
- if (!cell) return NULL;
+ cell = gnc_table_layout_get_cell (layout, cell_name);
+ if (!cell) return NULL;
- return gnc_basic_cell_get_value (cell);
+ return gnc_basic_cell_get_value (cell);
}
gboolean
@@ -159,91 +159,91 @@
const char *cell_name,
gboolean include_conditional)
{
- BasicCell *cell;
+ BasicCell *cell;
- g_return_val_if_fail (layout != NULL, FALSE);
+ g_return_val_if_fail (layout != NULL, FALSE);
- cell = gnc_table_layout_get_cell (layout, cell_name);
- if (!cell) return FALSE;
+ cell = gnc_table_layout_get_cell (layout, cell_name);
+ if (!cell) return FALSE;
- if (!include_conditional)
- return gnc_basic_cell_get_changed (cell);
- else
- return (gnc_basic_cell_get_changed (cell) ||
- gnc_basic_cell_get_conditionally_changed (cell));
+ if (!include_conditional)
+ return gnc_basic_cell_get_changed (cell);
+ else
+ return (gnc_basic_cell_get_changed (cell) ||
+ gnc_basic_cell_get_conditionally_changed (cell));
}
GList *
gnc_table_layout_get_cells (TableLayout *layout)
{
- if (!layout)
- return NULL;
+ if (!layout)
+ return NULL;
- return layout->cells;
+ return layout->cells;
}
void
gnc_table_layout_add_cursor (TableLayout *layout,
CellBlock *cursor)
{
- GList *node;
+ GList *node;
- g_return_if_fail (layout != NULL);
- g_return_if_fail (cursor != NULL);
+ g_return_if_fail (layout != NULL);
+ g_return_if_fail (cursor != NULL);
- if (g_list_find (layout->cursors, cursor))
- return;
+ if (g_list_find (layout->cursors, cursor))
+ return;
- for (node = layout->cursors; node; node = node->next)
- {
- CellBlock *list_cursor = node->data;
+ for (node = layout->cursors; node; node = node->next)
+ {
+ CellBlock *list_cursor = node->data;
- if (strcmp (list_cursor->cursor_name, cursor->cursor_name) == 0)
- {
- layout->cursors = g_list_remove (layout->cursors, list_cursor);
- gnc_cellblock_destroy (list_cursor);
- break;
+ if (strcmp (list_cursor->cursor_name, cursor->cursor_name) == 0)
+ {
+ layout->cursors = g_list_remove (layout->cursors, list_cursor);
+ gnc_cellblock_destroy (list_cursor);
+ break;
+ }
}
- }
- layout->cursors = g_list_append (layout->cursors, cursor);
+ layout->cursors = g_list_append (layout->cursors, cursor);
}
CellBlock *
gnc_table_layout_get_cursor (TableLayout *layout,
const char *cursor_name)
{
- GList *node;
+ GList *node;
- g_return_val_if_fail (layout != NULL, NULL);
+ g_return_val_if_fail (layout != NULL, NULL);
- if (!cursor_name)
- return NULL;
+ if (!cursor_name)
+ return NULL;
- for (node = layout->cursors; node; node = node->next)
- {
- CellBlock *cursor = node->data;
+ for (node = layout->cursors; node; node = node->next)
+ {
+ CellBlock *cursor = node->data;
- if (strcmp (cursor_name, cursor->cursor_name) == 0)
- return cursor;
- }
+ if (strcmp (cursor_name, cursor->cursor_name) == 0)
+ return cursor;
+ }
- return NULL;
+ return NULL;
}
GList *
gnc_table_layout_get_cursors (TableLayout *layout)
{
- g_return_val_if_fail (layout != NULL, NULL);
- return layout->cursors;
+ g_return_val_if_fail (layout != NULL, NULL);
+ return layout->cursors;
}
void
gnc_table_layout_set_primary_cursor (TableLayout *layout,
CellBlock *cursor)
{
- g_return_if_fail (layout != NULL);
- layout->primary_cursor = cursor;
+ g_return_if_fail (layout != NULL);
+ layout->primary_cursor = cursor;
}
void
@@ -252,105 +252,105 @@
const char *cell_name,
int row, int col)
{
- CellBlock *header;
- BasicCell *cell;
+ CellBlock *header;
+ BasicCell *cell;
- g_return_if_fail (layout != NULL);
- g_return_if_fail (layout->primary_cursor != NULL);
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (cell_name != NULL);
- g_return_if_fail (row >= 0);
- g_return_if_fail (col >= 0);
- g_return_if_fail (row < cursor->num_rows);
- g_return_if_fail (col < cursor->num_cols);
+ g_return_if_fail (layout != NULL);
+ g_return_if_fail (layout->primary_cursor != NULL);
+ g_return_if_fail (cursor != NULL);
+ g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (row >= 0);
+ g_return_if_fail (col >= 0);
+ g_return_if_fail (row < cursor->num_rows);
+ g_return_if_fail (col < cursor->num_cols);
- header = gnc_table_layout_get_cursor (layout, CURSOR_HEADER);
- cell = gnc_table_layout_get_cell (layout, cell_name);
+ header = gnc_table_layout_get_cursor (layout, CURSOR_HEADER);
+ cell = gnc_table_layout_get_cell (layout, cell_name);
- g_return_if_fail (header != NULL);
- g_return_if_fail (cell != NULL);
+ g_return_if_fail (header != NULL);
+ g_return_if_fail (cell != NULL);
- cursor->start_col = MIN (cursor->start_col, col);
- cursor->stop_col = MAX (cursor->stop_col, col);
+ cursor->start_col = MIN (cursor->start_col, col);
+ cursor->stop_col = MAX (cursor->stop_col, col);
- header->start_col = MIN (header->start_col, col);
- header->stop_col = MAX (header->stop_col, col);
+ header->start_col = MIN (header->start_col, col);
+ header->stop_col = MAX (header->stop_col, col);
- gnc_cellblock_set_cell (cursor, row, col, cell);
+ gnc_cellblock_set_cell (cursor, row, col, cell);
- if (cursor == layout->primary_cursor)
- gnc_cellblock_set_cell (header, row, col, cell);
+ if (cursor == layout->primary_cursor)
+ gnc_cellblock_set_cell (header, row, col, cell);
}
CursorBuffer *
gnc_cursor_buffer_new (void)
{
- CursorBuffer *buffer;
+ CursorBuffer *buffer;
- buffer = g_new0 (CursorBuffer, 1);
+ buffer = g_new0 (CursorBuffer, 1);
- return buffer;
+ return buffer;
}
static void
destroy_cell_buffer (CellBuffer *cb)
{
- if (cb == NULL)
- return;
+ if (cb == NULL)
+ return;
- g_free (cb->cell_name);
- cb->cell_name = NULL;
+ g_free (cb->cell_name);
+ cb->cell_name = NULL;
- g_free (cb->value);
- cb->value = NULL;
+ g_free (cb->value);
+ cb->value = NULL;
- g_free (cb);
+ g_free (cb);
}
static void
gnc_cursor_buffer_clear (CursorBuffer *buffer)
{
- GList *node;
+ GList *node;
- if (!buffer) return;
+ if (!buffer) return;
- for (node = buffer->cell_buffers; node; node = node->next)
- {
- CellBuffer *cb = node->data;
+ for (node = buffer->cell_buffers; node; node = node->next)
+ {
+ CellBuffer *cb = node->data;
- destroy_cell_buffer (cb);
- }
+ destroy_cell_buffer (cb);
+ }
- g_list_free (buffer->cell_buffers);
- buffer->cell_buffers = NULL;
+ g_list_free (buffer->cell_buffers);
+ buffer->cell_buffers = NULL;
}
void
gnc_cursor_buffer_destroy (CursorBuffer *buffer)
{
- if (!buffer) return;
+ if (!buffer) return;
- gnc_cursor_buffer_clear (buffer);
+ gnc_cursor_buffer_clear (buffer);
- g_free (buffer);
+ g_free (buffer);
}
static CellBuffer *
save_cell (BasicCell *bcell)
{
- CellBuffer *cb;
+ CellBuffer *cb;
- if (!bcell)
- return NULL;
+ if (!bcell)
+ return NULL;
- cb = g_new0 (CellBuffer, 1);
+ cb = g_new0 (CellBuffer, 1);
- cb->cell_name = g_strdup (bcell->cell_name);
- cb->value = g_strdup (bcell->value);
- cb->changed = bcell->changed;
- cb->conditionally_changed = bcell->conditionally_changed;
+ cb->cell_name = g_strdup (bcell->cell_name);
+ cb->value = g_strdup (bcell->value);
+ cb->changed = bcell->changed;
+ cb->conditionally_changed = bcell->conditionally_changed;
- return cb;
+ return cb;
}
void
@@ -358,57 +358,57 @@
CellBlock *cursor,
CursorBuffer *buffer)
{
- GList *node;
+ GList *node;
- if (!layout || !cursor || !buffer)
- return;
+ if (!layout || !cursor || !buffer)
+ return;
- gnc_cursor_buffer_clear (buffer);
+ gnc_cursor_buffer_clear (buffer);
- for (node = layout->cells; node; node = node->next)
- {
- BasicCell *list_cell = node->data;
- CellBuffer *cb;
+ for (node = layout->cells; node; node = node->next)
+ {
+ BasicCell *list_cell = node->data;
+ CellBuffer *cb;
- if (!gnc_basic_cell_get_changed (list_cell) &&
- !gnc_basic_cell_get_conditionally_changed (list_cell))
- continue;
+ if (!gnc_basic_cell_get_changed (list_cell) &&
+ !gnc_basic_cell_get_conditionally_changed (list_cell))
+ continue;
- cb = save_cell (list_cell);
+ cb = save_cell (list_cell);
- buffer->cell_buffers = g_list_prepend (buffer->cell_buffers, cb);
- }
+ buffer->cell_buffers = g_list_prepend (buffer->cell_buffers, cb);
+ }
}
static void
restore_cell (BasicCell *bcell, CellBuffer *cb, CellBlock *cursor)
{
- int r, c;
+ int r, c;
- if (!bcell || !cb || !cursor)
- return;
+ if (!bcell || !cb || !cursor)
+ return;
- if (!cb->changed && !cb->conditionally_changed)
- return;
+ if (!cb->changed && !cb->conditionally_changed)
+ return;
- /* only restore if it's in the current cursor */
- for (r = 0; r < cursor->num_rows; r++)
- for (c = 0; c < cursor->num_cols; c++)
- {
- BasicCell *cell;
+ /* only restore if it's in the current cursor */
+ for (r = 0; r < cursor->num_rows; r++)
+ for (c = 0; c < cursor->num_cols; c++)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (cursor, r, c);
- if (!cell)
- continue;
+ cell = gnc_cellblock_get_cell (cursor, r, c);
+ if (!cell)
+ continue;
- if (cell == bcell)
- {
- gnc_basic_cell_set_value (bcell, cb->value);
- bcell->changed = cb->changed;
- bcell->conditionally_changed = cb->conditionally_changed;
- return;
- }
- }
+ if (cell == bcell)
+ {
+ gnc_basic_cell_set_value (bcell, cb->value);
+ bcell->changed = cb->changed;
+ bcell->conditionally_changed = cb->conditionally_changed;
+ return;
+ }
+ }
}
void
@@ -416,18 +416,18 @@
CellBlock *cursor,
CursorBuffer *buffer)
{
- GList *node;
+ GList *node;
- if (!layout || !cursor || !buffer)
- return;
+ if (!layout || !cursor || !buffer)
+ return;
- for (node = buffer->cell_buffers; node; node = node->next)
- {
- CellBuffer *cb = node->data;
- BasicCell *cell;
+ for (node = buffer->cell_buffers; node; node = node->next)
+ {
+ CellBuffer *cb = node->data;
+ BasicCell *cell;
- cell = gnc_table_layout_get_cell (layout, cb->cell_name);
+ cell = gnc_table_layout_get_cell (layout, cb->cell_name);
- restore_cell (cell, cb, cursor);
- }
+ restore_cell (cell, cb, cursor);
+ }
}
Modified: gnucash/trunk/src/register/register-core/table-layout.h
===================================================================
--- gnucash/trunk/src/register/register-core/table-layout.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-layout.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -47,10 +47,10 @@
BasicCell * gnc_table_layout_get_cell (TableLayout *layout,
const char *cell_name);
const char * gnc_table_layout_get_cell_value (TableLayout *layout,
- const char *cell_name);
+ const char *cell_name);
gboolean gnc_table_layout_get_cell_changed (TableLayout *layout,
- const char *cell_name,
- gboolean include_conditional);
+ const char *cell_name,
+ gboolean include_conditional);
GList * gnc_table_layout_get_cells (TableLayout *layout);
@@ -58,12 +58,12 @@
CellBlock *cursor);
CellBlock * gnc_table_layout_get_cursor (TableLayout *layout,
- const char *cursor_name);
+ const char *cursor_name);
GList * gnc_table_layout_get_cursors (TableLayout *layout);
void gnc_table_layout_set_primary_cursor (TableLayout *layout,
- CellBlock *cursor);
+ CellBlock *cursor);
void gnc_table_layout_set_cell (TableLayout *layout,
CellBlock *cursor,
Modified: gnucash/trunk/src/register/register-core/table-model.c
===================================================================
--- gnucash/trunk/src/register/register-core/table-model.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-model.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -33,53 +33,53 @@
typedef struct
{
- char *cell_name;
- gpointer handler;
+ char *cell_name;
+ gpointer handler;
} HandlerNode;
static GHashTable *
gnc_table_model_handler_hash_new (void)
{
- return g_hash_table_new (g_str_hash, g_str_equal);
+ return g_hash_table_new (g_str_hash, g_str_equal);
}
static void
hash_destroy_helper (gpointer key, gpointer value, gpointer user_data)
{
- HandlerNode *node = value;
+ HandlerNode *node = value;
- g_free (node->cell_name);
- node->cell_name = NULL;
+ g_free (node->cell_name);
+ node->cell_name = NULL;
- g_free (node);
+ g_free (node);
}
static void
gnc_table_model_handler_hash_destroy (GHashTable *hash)
{
- if (!hash) return;
+ if (!hash) return;
- g_hash_table_foreach (hash, hash_destroy_helper, NULL);
- g_hash_table_destroy (hash);
+ g_hash_table_foreach (hash, hash_destroy_helper, NULL);
+ g_hash_table_destroy (hash);
}
static void
gnc_table_model_handler_hash_remove (GHashTable *hash, const char *cell_name)
{
- HandlerNode *node;
+ HandlerNode *node;
- if (!hash) return;
+ if (!hash) return;
- node = g_hash_table_lookup (hash, cell_name);
- if (!node) return;
+ node = g_hash_table_lookup (hash, cell_name);
+ if (!node) return;
- g_hash_table_remove (hash, cell_name);
+ g_hash_table_remove (hash, cell_name);
- g_free (node->cell_name);
- node->cell_name = NULL;
+ g_free (node->cell_name);
+ node->cell_name = NULL;
- g_free (node);
+ g_free (node);
}
static void
@@ -87,114 +87,114 @@
const char *cell_name,
gpointer handler)
{
- HandlerNode *node;
+ HandlerNode *node;
- g_return_if_fail (hash != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (hash != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_remove (hash, cell_name);
- if (!handler) return;
+ gnc_table_model_handler_hash_remove (hash, cell_name);
+ if (!handler) return;
- node = g_new0 (HandlerNode, 1);
+ node = g_new0 (HandlerNode, 1);
- node->cell_name = g_strdup (cell_name);
- node->handler = handler;
+ node->cell_name = g_strdup (cell_name);
+ node->handler = handler;
- g_hash_table_insert (hash, node->cell_name, node);
+ g_hash_table_insert (hash, node->cell_name, node);
}
static gpointer
gnc_table_model_handler_hash_lookup (GHashTable *hash, const char *cell_name)
{
- HandlerNode *node;
+ HandlerNode *node;
- if (!hash) return NULL;
+ if (!hash) return NULL;
- if (cell_name)
- {
+ if (cell_name)
+ {
+ node = g_hash_table_lookup (hash, cell_name);
+ if (node) return node->handler;
+ }
+
+ cell_name = DEFAULT_HANDLER;
node = g_hash_table_lookup (hash, cell_name);
if (node) return node->handler;
- }
- cell_name = DEFAULT_HANDLER;
- node = g_hash_table_lookup (hash, cell_name);
- if (node) return node->handler;
-
- return NULL;
+ return NULL;
}
TableModel *
gnc_table_model_new (void)
{
- TableModel *model;
+ TableModel *model;
- model = g_new0 (TableModel, 1);
+ model = g_new0 (TableModel, 1);
- model->entry_handlers = gnc_table_model_handler_hash_new ();
- model->label_handlers = gnc_table_model_handler_hash_new ();
- model->help_handlers = gnc_table_model_handler_hash_new ();
- model->io_flags_handlers = gnc_table_model_handler_hash_new ();
- model->fg_color_handlers = gnc_table_model_handler_hash_new ();
- model->bg_color_handlers = gnc_table_model_handler_hash_new ();
- model->cell_border_handlers = gnc_table_model_handler_hash_new ();
- model->confirm_handlers = gnc_table_model_handler_hash_new ();
- model->save_handlers = gnc_table_model_handler_hash_new ();
+ model->entry_handlers = gnc_table_model_handler_hash_new ();
+ model->label_handlers = gnc_table_model_handler_hash_new ();
+ model->help_handlers = gnc_table_model_handler_hash_new ();
+ model->io_flags_handlers = gnc_table_model_handler_hash_new ();
+ model->fg_color_handlers = gnc_table_model_handler_hash_new ();
+ model->bg_color_handlers = gnc_table_model_handler_hash_new ();
+ model->cell_border_handlers = gnc_table_model_handler_hash_new ();
+ model->confirm_handlers = gnc_table_model_handler_hash_new ();
+ model->save_handlers = gnc_table_model_handler_hash_new ();
- model->read_only = FALSE;
- model->dividing_row = -1;
+ model->read_only = FALSE;
+ model->dividing_row = -1;
- return model;
+ return model;
}
void
gnc_table_model_destroy (TableModel *model)
{
- if (!model) return;
+ if (!model) return;
- gnc_table_model_handler_hash_destroy (model->entry_handlers);
- model->entry_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->entry_handlers);
+ model->entry_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->label_handlers);
- model->label_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->label_handlers);
+ model->label_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->help_handlers);
- model->help_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->help_handlers);
+ model->help_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->io_flags_handlers);
- model->io_flags_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->io_flags_handlers);
+ model->io_flags_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->fg_color_handlers);
- model->fg_color_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->fg_color_handlers);
+ model->fg_color_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->bg_color_handlers);
- model->bg_color_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->bg_color_handlers);
+ model->bg_color_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->cell_border_handlers);
- model->cell_border_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->cell_border_handlers);
+ model->cell_border_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->confirm_handlers);
- model->confirm_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->confirm_handlers);
+ model->confirm_handlers = NULL;
- gnc_table_model_handler_hash_destroy (model->save_handlers);
- model->save_handlers = NULL;
+ gnc_table_model_handler_hash_destroy (model->save_handlers);
+ model->save_handlers = NULL;
- g_free (model);
+ g_free (model);
}
void
gnc_table_model_set_read_only (TableModel *model, gboolean read_only)
{
- g_return_if_fail (model);
+ g_return_if_fail (model);
- model->read_only = read_only;
+ model->read_only = read_only;
}
gboolean
gnc_table_model_read_only (TableModel *model)
{
- g_return_val_if_fail (model, FALSE);
+ g_return_val_if_fail (model, FALSE);
- return model->read_only;
+ return model->read_only;
}
void
@@ -202,32 +202,32 @@
TableGetEntryHandler entry_handler,
const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->entry_handlers,
- cell_name,
- entry_handler);
+ gnc_table_model_handler_hash_insert (model->entry_handlers,
+ cell_name,
+ entry_handler);
}
void
gnc_table_model_set_default_entry_handler
(TableModel *model, TableGetEntryHandler entry_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->entry_handlers,
- DEFAULT_HANDLER,
- entry_handler);
+ gnc_table_model_handler_hash_insert (model->entry_handlers,
+ DEFAULT_HANDLER,
+ entry_handler);
}
TableGetEntryHandler
gnc_table_model_get_entry_handler (TableModel *model, const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->entry_handlers,
- cell_name);
+ return gnc_table_model_handler_hash_lookup (model->entry_handlers,
+ cell_name);
}
void
@@ -235,32 +235,32 @@
TableGetLabelHandler label_handler,
const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->label_handlers,
- cell_name,
- label_handler);
+ gnc_table_model_handler_hash_insert (model->label_handlers,
+ cell_name,
+ label_handler);
}
void
gnc_table_model_set_default_label_handler
(TableModel *model, TableGetLabelHandler label_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->label_handlers,
- DEFAULT_HANDLER,
- label_handler);
+ gnc_table_model_handler_hash_insert (model->label_handlers,
+ DEFAULT_HANDLER,
+ label_handler);
}
TableGetLabelHandler
gnc_table_model_get_label_handler (TableModel *model, const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->label_handlers,
- cell_name);
+ return gnc_table_model_handler_hash_lookup (model->label_handlers,
+ cell_name);
}
void
@@ -268,271 +268,271 @@
TableGetHelpHandler help_handler,
const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->help_handlers,
- cell_name,
- help_handler);
+ gnc_table_model_handler_hash_insert (model->help_handlers,
+ cell_name,
+ help_handler);
}
void
gnc_table_model_set_default_help_handler (TableModel *model,
- TableGetHelpHandler help_handler)
+ TableGetHelpHandler help_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->help_handlers,
- DEFAULT_HANDLER,
- help_handler);
+ gnc_table_model_handler_hash_insert (model->help_handlers,
+ DEFAULT_HANDLER,
+ help_handler);
}
TableGetHelpHandler
gnc_table_model_get_help_handler (TableModel *model, const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->help_handlers, cell_name);
+ return gnc_table_model_handler_hash_lookup (model->help_handlers, cell_name);
}
void
gnc_table_model_set_io_flags_handler
- (TableModel *model,
- TableGetCellIOFlagsHandler io_flags_handler,
- const char * cell_name)
+(TableModel *model,
+ TableGetCellIOFlagsHandler io_flags_handler,
+ const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->io_flags_handlers,
- cell_name,
- io_flags_handler);
+ gnc_table_model_handler_hash_insert (model->io_flags_handlers,
+ cell_name,
+ io_flags_handler);
}
void
gnc_table_model_set_default_io_flags_handler
- (TableModel *model,
- TableGetCellIOFlagsHandler io_flags_handler)
+(TableModel *model,
+ TableGetCellIOFlagsHandler io_flags_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->io_flags_handlers,
- DEFAULT_HANDLER,
- io_flags_handler);
+ gnc_table_model_handler_hash_insert (model->io_flags_handlers,
+ DEFAULT_HANDLER,
+ io_flags_handler);
}
TableGetCellIOFlagsHandler
gnc_table_model_get_io_flags_handler (TableModel *model,
const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->io_flags_handlers,
- cell_name);
+ return gnc_table_model_handler_hash_lookup (model->io_flags_handlers,
+ cell_name);
}
void
gnc_table_model_set_fg_color_handler
- (TableModel *model,
- TableGetFGColorHandler fg_color_handler,
- const char * cell_name)
+(TableModel *model,
+ TableGetFGColorHandler fg_color_handler,
+ const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->fg_color_handlers,
- cell_name,
- fg_color_handler);
+ gnc_table_model_handler_hash_insert (model->fg_color_handlers,
+ cell_name,
+ fg_color_handler);
}
void
gnc_table_model_set_default_fg_color_handler
- (TableModel *model,
- TableGetFGColorHandler fg_color_handler)
+(TableModel *model,
+ TableGetFGColorHandler fg_color_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->fg_color_handlers,
- DEFAULT_HANDLER,
- fg_color_handler);
+ gnc_table_model_handler_hash_insert (model->fg_color_handlers,
+ DEFAULT_HANDLER,
+ fg_color_handler);
}
TableGetFGColorHandler
gnc_table_model_get_fg_color_handler (TableModel *model,
const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->fg_color_handlers,
- cell_name);
+ return gnc_table_model_handler_hash_lookup (model->fg_color_handlers,
+ cell_name);
}
void
gnc_table_model_set_bg_color_handler
- (TableModel *model,
- TableGetBGColorHandler bg_color_handler,
- const char * cell_name)
+(TableModel *model,
+ TableGetBGColorHandler bg_color_handler,
+ const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->bg_color_handlers,
- cell_name,
- bg_color_handler);
+ gnc_table_model_handler_hash_insert (model->bg_color_handlers,
+ cell_name,
+ bg_color_handler);
}
void
gnc_table_model_set_default_bg_color_handler
- (TableModel *model,
- TableGetBGColorHandler bg_color_handler)
+(TableModel *model,
+ TableGetBGColorHandler bg_color_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->bg_color_handlers,
- DEFAULT_HANDLER,
- bg_color_handler);
+ gnc_table_model_handler_hash_insert (model->bg_color_handlers,
+ DEFAULT_HANDLER,
+ bg_color_handler);
}
TableGetBGColorHandler
gnc_table_model_get_bg_color_handler (TableModel *model,
const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->bg_color_handlers,
- cell_name);
+ return gnc_table_model_handler_hash_lookup (model->bg_color_handlers,
+ cell_name);
}
void
gnc_table_model_set_cell_border_handler
- (TableModel *model,
- TableGetCellBorderHandler cell_border_handler,
- const char * cell_name)
+(TableModel *model,
+ TableGetCellBorderHandler cell_border_handler,
+ const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->cell_border_handlers,
- cell_name,
- cell_border_handler);
+ gnc_table_model_handler_hash_insert (model->cell_border_handlers,
+ cell_name,
+ cell_border_handler);
}
void
gnc_table_model_set_default_cell_border_handler
- (TableModel *model,
- TableGetCellBorderHandler cell_border_handler)
+(TableModel *model,
+ TableGetCellBorderHandler cell_border_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->cell_border_handlers,
- DEFAULT_HANDLER,
- cell_border_handler);
+ gnc_table_model_handler_hash_insert (model->cell_border_handlers,
+ DEFAULT_HANDLER,
+ cell_border_handler);
}
TableGetCellBorderHandler
gnc_table_model_get_cell_border_handler (TableModel *model,
- const char * cell_name)
+ const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->cell_border_handlers,
- cell_name);
+ return gnc_table_model_handler_hash_lookup (model->cell_border_handlers,
+ cell_name);
}
void
gnc_table_model_set_confirm_handler
- (TableModel *model,
- TableConfirmHandler confirm_handler,
- const char * cell_name)
+(TableModel *model,
+ TableConfirmHandler confirm_handler,
+ const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->confirm_handlers,
- cell_name,
- confirm_handler);
+ gnc_table_model_handler_hash_insert (model->confirm_handlers,
+ cell_name,
+ confirm_handler);
}
void
gnc_table_model_set_default_confirm_handler
- (TableModel *model,
- TableConfirmHandler confirm_handler)
+(TableModel *model,
+ TableConfirmHandler confirm_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- gnc_table_model_handler_hash_insert (model->confirm_handlers,
- DEFAULT_HANDLER,
- confirm_handler);
+ gnc_table_model_handler_hash_insert (model->confirm_handlers,
+ DEFAULT_HANDLER,
+ confirm_handler);
}
TableConfirmHandler
gnc_table_model_get_confirm_handler (TableModel *model,
- const char * cell_name)
+ const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->confirm_handlers,
- cell_name);
+ return gnc_table_model_handler_hash_lookup (model->confirm_handlers,
+ cell_name);
}
void
gnc_table_model_set_save_handler
- (TableModel *model,
- TableSaveCellHandler save_handler,
- const char * cell_name)
+(TableModel *model,
+ TableSaveCellHandler save_handler,
+ const char * cell_name)
{
- g_return_if_fail (model != NULL);
- g_return_if_fail (cell_name != NULL);
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (cell_name != NULL);
- gnc_table_model_handler_hash_insert (model->save_handlers,
- cell_name,
- save_handler);
+ gnc_table_model_handler_hash_insert (model->save_handlers,
+ cell_name,
+ save_handler);
}
void
gnc_table_model_set_pre_save_handler
- (TableModel *model,
- TableSaveHandler save_handler)
+(TableModel *model,
+ TableSaveHandler save_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- model->pre_save_handler = save_handler;
+ model->pre_save_handler = save_handler;
}
void
gnc_table_model_set_post_save_handler
- (TableModel *model,
- TableSaveHandler save_handler)
+(TableModel *model,
+ TableSaveHandler save_handler)
{
- g_return_if_fail (model != NULL);
+ g_return_if_fail (model != NULL);
- model->post_save_handler = save_handler;
+ model->post_save_handler = save_handler;
}
TableSaveCellHandler
gnc_table_model_get_save_handler
- (TableModel *model,
- const char * cell_name)
+(TableModel *model,
+ const char * cell_name)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return gnc_table_model_handler_hash_lookup (model->save_handlers, cell_name);
+ return gnc_table_model_handler_hash_lookup (model->save_handlers, cell_name);
}
TableSaveHandler
gnc_table_model_get_pre_save_handler
- (TableModel *model)
+(TableModel *model)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return model->pre_save_handler;
+ return model->pre_save_handler;
}
TableSaveHandler
gnc_table_model_get_post_save_handler
- (TableModel *model)
+(TableModel *model)
{
- g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (model != NULL, NULL);
- return model->post_save_handler;
+ return model->post_save_handler;
}
Modified: gnucash/trunk/src/register/register-core/table-model.h
===================================================================
--- gnucash/trunk/src/register/register-core/table-model.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/table-model.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -32,59 +32,59 @@
typedef enum
{
- XACC_CELL_ALLOW_NONE = 0,
- XACC_CELL_ALLOW_INPUT = 1 << 0,
- XACC_CELL_ALLOW_SHADOW = 1 << 1,
- XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW,
- XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2,
- XACC_CELL_ALLOW_ENTER = 1 << 3,
- XACC_CELL_ALLOW_READ_ONLY = XACC_CELL_ALLOW_SHADOW | XACC_CELL_ALLOW_ENTER
+ XACC_CELL_ALLOW_NONE = 0,
+ XACC_CELL_ALLOW_INPUT = 1 << 0,
+ XACC_CELL_ALLOW_SHADOW = 1 << 1,
+ XACC_CELL_ALLOW_ALL = XACC_CELL_ALLOW_INPUT | XACC_CELL_ALLOW_SHADOW,
+ XACC_CELL_ALLOW_EXACT_ONLY = 1 << 2,
+ XACC_CELL_ALLOW_ENTER = 1 << 3,
+ XACC_CELL_ALLOW_READ_ONLY = XACC_CELL_ALLOW_SHADOW | XACC_CELL_ALLOW_ENTER
} CellIOFlags;
typedef enum
{
- CELL_BORDER_LINE_NONE,
- CELL_BORDER_LINE_LIGHT,
- CELL_BORDER_LINE_NORMAL,
- CELL_BORDER_LINE_HEAVY,
- CELL_BORDER_LINE_HIGHLIGHT
+ CELL_BORDER_LINE_NONE,
+ CELL_BORDER_LINE_LIGHT,
+ CELL_BORDER_LINE_NORMAL,
+ CELL_BORDER_LINE_HEAVY,
+ CELL_BORDER_LINE_HIGHLIGHT
} PhysicalCellBorderLineStyle;
typedef struct
{
- PhysicalCellBorderLineStyle top;
- PhysicalCellBorderLineStyle bottom;
- PhysicalCellBorderLineStyle left;
- PhysicalCellBorderLineStyle right;
+ PhysicalCellBorderLineStyle top;
+ PhysicalCellBorderLineStyle bottom;
+ PhysicalCellBorderLineStyle left;
+ PhysicalCellBorderLineStyle right;
} PhysicalCellBorders;
typedef const char * (*TableGetEntryHandler) (VirtualLocation virt_loc,
- gboolean translate,
- gboolean *conditionally_changed,
- gpointer user_data);
+ gboolean translate,
+ gboolean *conditionally_changed,
+ gpointer user_data);
typedef const char * (*TableGetLabelHandler) (VirtualLocation virt_loc,
- gpointer user_data);
+ gpointer user_data);
typedef char * (*TableGetHelpHandler) (VirtualLocation virt_loc,
gpointer user_data);
typedef CellIOFlags (*TableGetCellIOFlagsHandler) (VirtualLocation virt_loc,
- gpointer user_data);
+ gpointer user_data);
typedef guint32 (*TableGetFGColorHandler) (VirtualLocation virt_loc,
- gpointer user_data);
+ gpointer user_data);
typedef guint32 (*TableGetBGColorHandler) (VirtualLocation virt_loc,
- gboolean *hatching,
- gpointer user_data);
+ gboolean *hatching,
+ gpointer user_data);
typedef void (*TableGetCellBorderHandler) (VirtualLocation virt_loc,
- PhysicalCellBorders *borders,
- gpointer user_data);
+ PhysicalCellBorders *borders,
+ gpointer user_data);
typedef gboolean (*TableConfirmHandler) (VirtualLocation virt_loc,
- gpointer user_data);
+ gpointer user_data);
typedef void (*TableSaveCellHandler) (BasicCell * cell,
gpointer save_data,
@@ -99,32 +99,32 @@
typedef struct
{
- GHashTable *entry_handlers;
- GHashTable *label_handlers;
- GHashTable *help_handlers;
- GHashTable *io_flags_handlers;
- GHashTable *fg_color_handlers;
- GHashTable *bg_color_handlers;
- GHashTable *cell_border_handlers;
- GHashTable *confirm_handlers;
+ GHashTable *entry_handlers;
+ GHashTable *label_handlers;
+ GHashTable *help_handlers;
+ GHashTable *io_flags_handlers;
+ GHashTable *fg_color_handlers;
+ GHashTable *bg_color_handlers;
+ GHashTable *cell_border_handlers;
+ GHashTable *confirm_handlers;
- GHashTable *save_handlers;
- TableSaveHandler pre_save_handler;
- TableSaveHandler post_save_handler;
+ GHashTable *save_handlers;
+ TableSaveHandler pre_save_handler;
+ TableSaveHandler post_save_handler;
- gpointer handler_user_data;
+ gpointer handler_user_data;
- /* If true, denotes that this table is read-only
- * and edits should not be allowed. */
- gboolean read_only;
+ /* If true, denotes that this table is read-only
+ * and edits should not be allowed. */
+ gboolean read_only;
- /* If positive, denotes a row that marks a boundary that should
- * be visually distinguished. */
- int dividing_row;
+ /* If positive, denotes a row that marks a boundary that should
+ * be visually distinguished. */
+ int dividing_row;
- VirtCellDataAllocator cell_data_allocator;
- VirtCellDataDeallocator cell_data_deallocator;
- VirtCellDataCopy cell_data_copy;
+ VirtCellDataAllocator cell_data_allocator;
+ VirtCellDataDeallocator cell_data_deallocator;
+ VirtCellDataCopy cell_data_copy;
} TableModel;
@@ -132,113 +132,113 @@
void gnc_table_model_destroy (TableModel *model);
void gnc_table_model_set_read_only (TableModel *model,
- gboolean read_only);
+ gboolean read_only);
gboolean gnc_table_model_read_only (TableModel *model);
void gnc_table_model_set_entry_handler
- (TableModel *model,
- TableGetEntryHandler entry_handler,
- const char * cell_name);
+(TableModel *model,
+ TableGetEntryHandler entry_handler,
+ const char * cell_name);
void gnc_table_model_set_default_entry_handler
- (TableModel *model,
- TableGetEntryHandler entry_handler);
+(TableModel *model,
+ TableGetEntryHandler entry_handler);
TableGetEntryHandler gnc_table_model_get_entry_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_label_handler
- (TableModel *model,
- TableGetLabelHandler label_handler,
- const char * cell_name);
+(TableModel *model,
+ TableGetLabelHandler label_handler,
+ const char * cell_name);
void gnc_table_model_set_default_label_handler
- (TableModel *model,
- TableGetLabelHandler label_handler);
+(TableModel *model,
+ TableGetLabelHandler label_handler);
TableGetLabelHandler gnc_table_model_get_label_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_help_handler
- (TableModel *model,
- TableGetHelpHandler help_handler,
- const char * cell_name);
+(TableModel *model,
+ TableGetHelpHandler help_handler,
+ const char * cell_name);
void gnc_table_model_set_default_help_handler
- (TableModel *model,
- TableGetHelpHandler help_handler);
+(TableModel *model,
+ TableGetHelpHandler help_handler);
TableGetHelpHandler gnc_table_model_get_help_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_io_flags_handler
- (TableModel *model,
- TableGetCellIOFlagsHandler io_flags_handler,
- const char * cell_name);
+(TableModel *model,
+ TableGetCellIOFlagsHandler io_flags_handler,
+ const char * cell_name);
void gnc_table_model_set_default_io_flags_handler
- (TableModel *model,
- TableGetCellIOFlagsHandler io_flags_handler);
+(TableModel *model,
+ TableGetCellIOFlagsHandler io_flags_handler);
TableGetCellIOFlagsHandler gnc_table_model_get_io_flags_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_fg_color_handler
- (TableModel *model,
- TableGetFGColorHandler io_flags_handler,
- const char * cell_name);
+(TableModel *model,
+ TableGetFGColorHandler io_flags_handler,
+ const char * cell_name);
void gnc_table_model_set_default_fg_color_handler
- (TableModel *model,
- TableGetFGColorHandler io_flags_handler);
+(TableModel *model,
+ TableGetFGColorHandler io_flags_handler);
TableGetFGColorHandler gnc_table_model_get_fg_color_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_bg_color_handler
- (TableModel *model,
- TableGetBGColorHandler io_flags_handler,
- const char * cell_name);
+(TableModel *model,
+ TableGetBGColorHandler io_flags_handler,
+ const char * cell_name);
void gnc_table_model_set_default_bg_color_handler
- (TableModel *model,
- TableGetBGColorHandler io_flags_handler);
+(TableModel *model,
+ TableGetBGColorHandler io_flags_handler);
TableGetBGColorHandler gnc_table_model_get_bg_color_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_cell_border_handler
- (TableModel *model,
- TableGetCellBorderHandler io_flags_handler,
- const char * cell_name);
+(TableModel *model,
+ TableGetCellBorderHandler io_flags_handler,
+ const char * cell_name);
void gnc_table_model_set_default_cell_border_handler
- (TableModel *model,
- TableGetCellBorderHandler io_flags_handler);
+(TableModel *model,
+ TableGetCellBorderHandler io_flags_handler);
TableGetCellBorderHandler gnc_table_model_get_cell_border_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_confirm_handler
- (TableModel *model,
- TableConfirmHandler io_flags_handler,
- const char * cell_name);
+(TableModel *model,
+ TableConfirmHandler io_flags_handler,
+ const char * cell_name);
void gnc_table_model_set_default_confirm_handler
- (TableModel *model,
- TableConfirmHandler io_flags_handler);
+(TableModel *model,
+ TableConfirmHandler io_flags_handler);
TableConfirmHandler gnc_table_model_get_confirm_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
void gnc_table_model_set_save_handler
- (TableModel *model,
- TableSaveCellHandler save_handler,
- const char * cell_name);
+(TableModel *model,
+ TableSaveCellHandler save_handler,
+ const char * cell_name);
void gnc_table_model_set_pre_save_handler
- (TableModel *model,
- TableSaveHandler save_handler);
+(TableModel *model,
+ TableSaveHandler save_handler);
void gnc_table_model_set_post_save_handler
- (TableModel *model,
- TableSaveHandler save_handler);
+(TableModel *model,
+ TableSaveHandler save_handler);
TableSaveCellHandler gnc_table_model_get_save_handler
- (TableModel *model,
- const char * cell_name);
+(TableModel *model,
+ const char * cell_name);
TableSaveHandler gnc_table_model_get_pre_save_handler
- (TableModel *model);
+(TableModel *model);
TableSaveHandler gnc_table_model_get_post_save_handler
- (TableModel *model);
+(TableModel *model);
#endif
Modified: gnucash/trunk/src/register/register-core/test/test-link-module.c
===================================================================
--- gnucash/trunk/src/register/register-core/test/test-link-module.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-core/test/test-link-module.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -1,6 +1,7 @@
#include <stdlib.h>
int
-main(int argc, char ** argv) {
- exit(0);
+main(int argc, char ** argv)
+{
+ exit(0);
}
Modified: gnucash/trunk/src/register/register-gnome/combocell-gnome.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/combocell-gnome.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/combocell-gnome.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -50,27 +50,27 @@
typedef struct _PopBox
{
- GnucashSheet *sheet;
- GncItemEdit *item_edit;
- GncItemList *item_list;
- GtkListStore *tmp_store;
+ GnucashSheet *sheet;
+ GncItemEdit *item_edit;
+ GncItemList *item_list;
+ GtkListStore *tmp_store;
- gboolean signals_connected; /* list signals connected? */
+ gboolean signals_connected; /* list signals connected? */
- gboolean list_popped; /* list is popped up? */
+ gboolean list_popped; /* list is popped up? */
- gboolean autosize;
+ gboolean autosize;
- QuickFill *qf;
- gboolean use_quickfill_cache; /* If TRUE, we don't own the qf */
+ QuickFill *qf;
+ gboolean use_quickfill_cache; /* If TRUE, we don't own the qf */
- gboolean in_list_select;
+ gboolean in_list_select;
- gboolean strict;
+ gboolean strict;
- gunichar complete_char; /* char to be used for auto-completion */
+ gunichar complete_char; /* char to be used for auto-completion */
- GList *ignore_strings;
+ GList *ignore_strings;
} PopBox;
@@ -91,406 +91,410 @@
static void
gnc_combo_cell_set_autopop (GConfEntry *entry, gpointer user_data)
{
- GConfValue *value;
+ GConfValue *value;
- value = gconf_entry_get_value(entry);
- auto_pop_combos = gconf_value_get_bool(value);
+ value = gconf_entry_get_value(entry);
+ auto_pop_combos = gconf_value_get_bool(value);
}
static gpointer
gnc_combo_cell_autopop_init (gpointer unused)
{
- auto_pop_combos = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
- KEY_AUTO_RAISE_LISTS,
- NULL);
+ auto_pop_combos = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
+ KEY_AUTO_RAISE_LISTS,
+ NULL);
- gnc_gconf_general_register_cb(KEY_AUTO_RAISE_LISTS,
- gnc_combo_cell_set_autopop,
- NULL);
- return NULL;
+ gnc_gconf_general_register_cb(KEY_AUTO_RAISE_LISTS,
+ gnc_combo_cell_set_autopop,
+ NULL);
+ return NULL;
}
BasicCell *
gnc_combo_cell_new (void)
{
- ComboCell * cell;
+ ComboCell * cell;
- g_once(&auto_pop_init_once, gnc_combo_cell_autopop_init, NULL);
+ g_once(&auto_pop_init_once, gnc_combo_cell_autopop_init, NULL);
- cell = g_new0 (ComboCell, 1);
+ cell = g_new0 (ComboCell, 1);
- gnc_combo_cell_init (cell);
+ gnc_combo_cell_init (cell);
- return &cell->cell;
+ return &cell->cell;
}
void
gnc_combo_cell_init (ComboCell *cell)
{
- PopBox *box;
+ PopBox *box;
- gnc_basic_cell_init (&(cell->cell));
+ gnc_basic_cell_init (&(cell->cell));
- cell->cell.is_popup = TRUE;
+ cell->cell.is_popup = TRUE;
- cell->cell.destroy = gnc_combo_cell_destroy;
+ cell->cell.destroy = gnc_combo_cell_destroy;
- cell->cell.gui_realize = gnc_combo_cell_gui_realize;
- cell->cell.gui_destroy = gnc_combo_cell_gui_destroy;
+ cell->cell.gui_realize = gnc_combo_cell_gui_realize;
+ cell->cell.gui_destroy = gnc_combo_cell_gui_destroy;
- box = g_new0 (PopBox, 1);
+ box = g_new0 (PopBox, 1);
- box->sheet = NULL;
- box->item_edit = NULL;
- box->item_list = NULL;
- box->tmp_store = gtk_list_store_new (1, G_TYPE_STRING);
- box->signals_connected = FALSE;
- box->list_popped = FALSE;
- box->autosize = FALSE;
+ box->sheet = NULL;
+ box->item_edit = NULL;
+ box->item_list = NULL;
+ box->tmp_store = gtk_list_store_new (1, G_TYPE_STRING);
+ box->signals_connected = FALSE;
+ box->list_popped = FALSE;
+ box->autosize = FALSE;
- cell->cell.gui_private = box;
+ cell->cell.gui_private = box;
- box->qf = gnc_quickfill_new ();
- box->use_quickfill_cache = FALSE;
+ box->qf = gnc_quickfill_new ();
+ box->use_quickfill_cache = FALSE;
- box->in_list_select = FALSE;
+ box->in_list_select = FALSE;
- box->strict = TRUE;
+ box->strict = TRUE;
- box->complete_char = '\0';
+ box->complete_char = '\0';
- box->ignore_strings = NULL;
+ box->ignore_strings = NULL;
}
static void
select_item_cb (GncItemList *item_list, char *item_string, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell *cell = data;
+ PopBox *box = cell->cell.gui_private;
- box->in_list_select = TRUE;
- gnucash_sheet_modify_current_cell (box->sheet, item_string);
- box->in_list_select = FALSE;
+ box->in_list_select = TRUE;
+ gnucash_sheet_modify_current_cell (box->sheet, item_string);
+ box->in_list_select = FALSE;
- gnc_item_edit_hide_popup (box->item_edit);
- box->list_popped = FALSE;
+ gnc_item_edit_hide_popup (box->item_edit);
+ box->list_popped = FALSE;
}
static void
change_item_cb (GncItemList *item_list, char *item_string, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell *cell = data;
+ PopBox *box = cell->cell.gui_private;
- box->in_list_select = TRUE;
- gnucash_sheet_modify_current_cell (box->sheet, item_string);
- box->in_list_select = FALSE;
+ box->in_list_select = TRUE;
+ gnucash_sheet_modify_current_cell (box->sheet, item_string);
+ box->in_list_select = FALSE;
}
static void
activate_item_cb (GncItemList *item_list, char *item_string, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell *cell = data;
+ PopBox *box = cell->cell.gui_private;
- gnc_item_edit_hide_popup (box->item_edit);
- box->list_popped = FALSE;
+ gnc_item_edit_hide_popup (box->item_edit);
+ box->list_popped = FALSE;
}
static void
key_press_item_cb (GncItemList *item_list, GdkEventKey *event, gpointer data)
{
- ComboCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ ComboCell *cell = data;
+ PopBox *box = cell->cell.gui_private;
- switch (event->keyval)
- {
- case GDK_Escape:
- gnc_item_edit_hide_popup (box->item_edit);
- box->list_popped = FALSE;
- break;
+ switch (event->keyval)
+ {
+ case GDK_Escape:
+ gnc_item_edit_hide_popup (box->item_edit);
+ box->list_popped = FALSE;
+ break;
- default:
- gtk_widget_event (GTK_WIDGET(box->sheet),
- (GdkEvent *) event);
- break;
- }
+ default:
+ gtk_widget_event (GTK_WIDGET(box->sheet),
+ (GdkEvent *) event);
+ break;
+ }
}
static void
combo_disconnect_signals (ComboCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (!box->signals_connected)
- return;
+ if (!box->signals_connected)
+ return;
- g_signal_handlers_disconnect_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cell);
+ g_signal_handlers_disconnect_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, cell);
- box->signals_connected = FALSE;
+ box->signals_connected = FALSE;
}
static void
combo_connect_signals (ComboCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (box->signals_connected)
- return;
+ if (box->signals_connected)
+ return;
- g_signal_connect (G_OBJECT (box->item_list), "select_item",
- G_CALLBACK (select_item_cb), cell);
+ g_signal_connect (G_OBJECT (box->item_list), "select_item",
+ G_CALLBACK (select_item_cb), cell);
- g_signal_connect (G_OBJECT (box->item_list), "change_item",
- G_CALLBACK (change_item_cb), cell);
+ g_signal_connect (G_OBJECT (box->item_list), "change_item",
+ G_CALLBACK (change_item_cb), cell);
- g_signal_connect (G_OBJECT (box->item_list), "activate_item",
- G_CALLBACK (activate_item_cb), cell);
+ g_signal_connect (G_OBJECT (box->item_list), "activate_item",
+ G_CALLBACK (activate_item_cb), cell);
- g_signal_connect (G_OBJECT (box->item_list), "key_press_event",
- G_CALLBACK (key_press_item_cb), cell);
+ g_signal_connect (G_OBJECT (box->item_list), "key_press_event",
+ G_CALLBACK (key_press_item_cb), cell);
- box->signals_connected = TRUE;
+ box->signals_connected = TRUE;
}
static void
block_list_signals (ComboCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (!box->signals_connected)
- return;
+ if (!box->signals_connected)
+ return;
- g_signal_handlers_block_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cell);
+ g_signal_handlers_block_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, cell);
}
static void
unblock_list_signals (ComboCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (!box->signals_connected)
- return;
+ if (!box->signals_connected)
+ return;
- g_signal_handlers_unblock_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cell);
+ g_signal_handlers_unblock_matched (G_OBJECT (box->item_list), G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, cell);
}
static void
gnc_combo_cell_gui_destroy (BasicCell *bcell)
{
- PopBox *box = bcell->gui_private;
- ComboCell *cell = (ComboCell *) bcell;
+ PopBox *box = bcell->gui_private;
+ ComboCell *cell = (ComboCell *) bcell;
- if (cell->cell.gui_realize == NULL)
- {
- if (box != NULL && box->item_list != NULL)
- {
- combo_disconnect_signals(cell);
- g_object_unref (box->item_list);
- box->item_list = NULL;
- }
+ if (cell->cell.gui_realize == NULL)
+ {
+ if (box != NULL && box->item_list != NULL)
+ {
+ combo_disconnect_signals(cell);
+ g_object_unref (box->item_list);
+ box->item_list = NULL;
+ }
- /* allow the widget to be shown again */
- cell->cell.gui_realize = gnc_combo_cell_gui_realize;
- cell->cell.gui_move = NULL;
- cell->cell.enter_cell = NULL;
- cell->cell.leave_cell = NULL;
- cell->cell.gui_destroy = NULL;
- }
+ /* allow the widget to be shown again */
+ cell->cell.gui_realize = gnc_combo_cell_gui_realize;
+ cell->cell.gui_move = NULL;
+ cell->cell.enter_cell = NULL;
+ cell->cell.leave_cell = NULL;
+ cell->cell.gui_destroy = NULL;
+ }
}
static void
gnc_combo_cell_destroy (BasicCell *bcell)
{
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = cell->cell.gui_private;
+ ComboCell *cell = (ComboCell *) bcell;
+ PopBox *box = cell->cell.gui_private;
- gnc_combo_cell_gui_destroy (&(cell->cell));
+ gnc_combo_cell_gui_destroy (&(cell->cell));
- if (box != NULL)
+ if (box != NULL)
+ {
+ GList *node;
+
+ /* Don't destroy the qf if its not ours to destroy */
+ if (FALSE == box->use_quickfill_cache)
{
- GList *node;
+ gnc_quickfill_destroy (box->qf);
+ box->qf = NULL;
+ }
- /* Don't destroy the qf if its not ours to destroy */
- if (FALSE == box->use_quickfill_cache)
- {
- gnc_quickfill_destroy (box->qf);
- box->qf = NULL;
- }
+ for (node = box->ignore_strings; node; node = node->next)
+ {
+ g_free (node->data);
+ node->data = NULL;
+ }
- for (node = box->ignore_strings; node; node = node->next)
- {
- g_free (node->data);
- node->data = NULL;
- }
+ g_list_free (box->ignore_strings);
+ box->ignore_strings = NULL;
- g_list_free (box->ignore_strings);
- box->ignore_strings = NULL;
+ g_free (box);
+ cell->cell.gui_private = NULL;
+ }
- g_free (box);
- cell->cell.gui_private = NULL;
- }
-
- cell->cell.gui_private = NULL;
- cell->cell.gui_realize = NULL;
+ cell->cell.gui_private = NULL;
+ cell->cell.gui_realize = NULL;
}
void
gnc_combo_cell_set_sort_enabled (ComboCell *cell, gboolean enabled)
{
- PopBox *box;
+ PopBox *box;
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- box = cell->cell.gui_private;
- if (box->item_list == NULL)
- return;
+ box = cell->cell.gui_private;
+ if (box->item_list == NULL)
+ return;
- block_list_signals (cell);
- gnc_item_list_set_sort_enabled(box->item_list, enabled);
- unblock_list_signals (cell);
+ block_list_signals (cell);
+ gnc_item_list_set_sort_enabled(box->item_list, enabled);
+ unblock_list_signals (cell);
}
void
gnc_combo_cell_clear_menu (ComboCell * cell)
{
- PopBox *box;
+ PopBox *box;
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- box = cell->cell.gui_private;
- if (box == NULL)
- return;
+ box = cell->cell.gui_private;
+ if (box == NULL)
+ return;
- /* Don't destroy the qf if its not ours to destroy */
- if (FALSE == box->use_quickfill_cache)
- {
- gnc_quickfill_destroy (box->qf);
- box->qf = gnc_quickfill_new ();
- }
+ /* Don't destroy the qf if its not ours to destroy */
+ if (FALSE == box->use_quickfill_cache)
+ {
+ gnc_quickfill_destroy (box->qf);
+ box->qf = gnc_quickfill_new ();
+ }
- if (box->item_list != NULL)
- {
- block_list_signals (cell);
+ if (box->item_list != NULL)
+ {
+ block_list_signals (cell);
- gnc_item_list_clear (box->item_list);
+ gnc_item_list_clear (box->item_list);
- unblock_list_signals (cell);
- }
+ unblock_list_signals (cell);
+ }
}
void
gnc_combo_cell_use_quickfill_cache (ComboCell * cell, QuickFill *shared_qf)
{
- PopBox *box;
+ PopBox *box;
- if (cell == NULL) return;
+ if (cell == NULL) return;
- box = cell->cell.gui_private;
- if (NULL == box) return;
+ box = cell->cell.gui_private;
+ if (NULL == box) return;
- if (FALSE == box->use_quickfill_cache)
- {
- box->use_quickfill_cache = TRUE;
- gnc_quickfill_destroy (box->qf);
- }
- box->qf = shared_qf;
+ if (FALSE == box->use_quickfill_cache)
+ {
+ box->use_quickfill_cache = TRUE;
+ gnc_quickfill_destroy (box->qf);
+ }
+ box->qf = shared_qf;
}
void
gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data)
{
- if (cell == NULL) return;
+ if (cell == NULL) return;
- cell->shared_store = data;
+ cell->shared_store = data;
}
void
gnc_combo_cell_add_menu_item (ComboCell *cell, const char * menustr)
{
- PopBox *box;
+ PopBox *box;
- if (cell == NULL)
- return;
- if (menustr == NULL)
- return;
+ if (cell == NULL)
+ return;
+ if (menustr == NULL)
+ return;
- box = cell->cell.gui_private;
+ box = cell->cell.gui_private;
- if (box->item_list != NULL)
- {
- block_list_signals (cell);
+ if (box->item_list != NULL)
+ {
+ block_list_signals (cell);
- gnc_item_list_append (box->item_list, menustr);
- if (cell->cell.value &&
- (strcmp (menustr, cell->cell.value) == 0))
- gnc_item_list_select (box->item_list, menustr);
+ gnc_item_list_append (box->item_list, menustr);
+ if (cell->cell.value &&
+ (strcmp (menustr, cell->cell.value) == 0))
+ gnc_item_list_select (box->item_list, menustr);
- unblock_list_signals (cell);
- } else {
- GtkTreeIter iter;
+ unblock_list_signals (cell);
+ }
+ else
+ {
+ GtkTreeIter iter;
- gtk_list_store_append(box->tmp_store, &iter);
- gtk_list_store_set(box->tmp_store, &iter, 0, menustr, -1);
- }
+ gtk_list_store_append(box->tmp_store, &iter);
+ gtk_list_store_set(box->tmp_store, &iter, 0, menustr, -1);
+ }
- /* If we're going to be using a pre-fab quickfill,
- * then don't fill it in here */
- if (FALSE == box->use_quickfill_cache)
- {
- gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
- }
+ /* If we're going to be using a pre-fab quickfill,
+ * then don't fill it in here */
+ if (FALSE == box->use_quickfill_cache)
+ {
+ gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
+ }
}
void
gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr)
{
- PopBox *box;
- gchar *menu_copy, *value_copy;
+ PopBox *box;
+ gchar *menu_copy, *value_copy;
- if (cell == NULL)
- return;
- if (menustr == NULL)
- return;
+ if (cell == NULL)
+ return;
+ if (menustr == NULL)
+ return;
- box = cell->cell.gui_private;
+ box = cell->cell.gui_private;
- if (box->item_list != NULL)
+ if (box->item_list != NULL)
+ {
+ block_list_signals (cell);
+
+ gnc_item_list_append (box->item_list, menustr);
+ if (cell->cell.value)
{
- block_list_signals (cell);
-
- gnc_item_list_append (box->item_list, menustr);
- if (cell->cell.value) {
- menu_copy = g_strdelimit(g_strdup(menustr), "-:/\\.", ' ');
- value_copy =
- g_strdelimit(g_strdup(cell->cell.value), "-:/\\.", ' ');
- if (strcmp (menu_copy, value_copy) == 0) {
- gnc_combo_cell_set_value (cell, menustr);
- gnc_item_list_select (box->item_list, menustr);
- }
- g_free(value_copy);
- g_free(menu_copy);
- }
- unblock_list_signals (cell);
+ menu_copy = g_strdelimit(g_strdup(menustr), "-:/\\.", ' ');
+ value_copy =
+ g_strdelimit(g_strdup(cell->cell.value), "-:/\\.", ' ');
+ if (strcmp (menu_copy, value_copy) == 0)
+ {
+ gnc_combo_cell_set_value (cell, menustr);
+ gnc_item_list_select (box->item_list, menustr);
+ }
+ g_free(value_copy);
+ g_free(menu_copy);
}
+ unblock_list_signals (cell);
+ }
- /* If we're going to be using a pre-fab quickfill,
- * then don't fill it in here */
- if (FALSE == box->use_quickfill_cache)
- {
- gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
- }
+ /* If we're going to be using a pre-fab quickfill,
+ * then don't fill it in here */
+ if (FALSE == box->use_quickfill_cache)
+ {
+ gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
+ }
}
void
gnc_combo_cell_set_value (ComboCell *cell, const char *str)
{
- gnc_basic_cell_set_value (&cell->cell, str);
+ gnc_basic_cell_set_value (&cell->cell, str);
}
static void
@@ -503,77 +507,77 @@
int *start_selection,
int *end_selection)
{
- ComboCell *cell = (ComboCell *) _cell;
- PopBox *box = cell->cell.gui_private;
- const char *match_str;
- QuickFill *match;
- gboolean pop_list;
- glong newval_chars;
- glong change_chars;
+ ComboCell *cell = (ComboCell *) _cell;
+ PopBox *box = cell->cell.gui_private;
+ const char *match_str;
+ QuickFill *match;
+ gboolean pop_list;
+ glong newval_chars;
+ glong change_chars;
- newval_chars = g_utf8_strlen (newval, newval_len);
- change_chars = g_utf8_strlen (change, change_len);
+ newval_chars = g_utf8_strlen (newval, newval_len);
+ change_chars = g_utf8_strlen (change, change_len);
- if (box->in_list_select)
- {
- gnc_basic_cell_set_value_internal (_cell, newval);
+ if (box->in_list_select)
+ {
+ gnc_basic_cell_set_value_internal (_cell, newval);
- *cursor_position = -1;
- *start_selection = 0;
- *end_selection = -1;
+ *cursor_position = -1;
+ *start_selection = 0;
+ *end_selection = -1;
- return;
- }
+ return;
+ }
- /* If deleting, just accept */
- if (change == NULL)
- {
- gnc_basic_cell_set_value_internal (_cell, newval);
- return;
- }
+ /* If deleting, just accept */
+ if (change == NULL)
+ {
+ gnc_basic_cell_set_value_internal (_cell, newval);
+ return;
+ }
- /* If we are inserting in the middle, just accept */
- if (*cursor_position < _cell->value_chars)
- {
- gnc_basic_cell_set_value_internal (_cell, newval);
- return;
- }
+ /* If we are inserting in the middle, just accept */
+ if (*cursor_position < _cell->value_chars)
+ {
+ gnc_basic_cell_set_value_internal (_cell, newval);
+ return;
+ }
- match = gnc_quickfill_get_string_match (box->qf, newval);
+ match = gnc_quickfill_get_string_match (box->qf, newval);
- match_str = gnc_quickfill_string (match);
+ match_str = gnc_quickfill_string (match);
- if ((match == NULL) || (match_str == NULL))
- {
- gnc_basic_cell_set_value_internal (_cell, newval);
+ if ((match == NULL) || (match_str == NULL))
+ {
+ gnc_basic_cell_set_value_internal (_cell, newval);
- block_list_signals (cell);
- gnc_item_list_select (box->item_list, NULL);
- unblock_list_signals (cell);
+ block_list_signals (cell);
+ gnc_item_list_select (box->item_list, NULL);
+ unblock_list_signals (cell);
- return;
- }
+ return;
+ }
- *start_selection = newval_chars;
- *end_selection = -1;
- *cursor_position += change_chars;
+ *start_selection = newval_chars;
+ *end_selection = -1;
+ *cursor_position += change_chars;
- if (!box->list_popped)
- pop_list = auto_pop_combos;
- else
- pop_list = FALSE;
+ if (!box->list_popped)
+ pop_list = auto_pop_combos;
+ else
+ pop_list = FALSE;
- if (pop_list)
- {
- gnc_item_edit_show_popup (box->item_edit);
- box->list_popped = TRUE;
- }
+ if (pop_list)
+ {
+ gnc_item_edit_show_popup (box->item_edit);
+ box->list_popped = TRUE;
+ }
- block_list_signals (cell);
- gnc_item_list_select (box->item_list, match_str);
- unblock_list_signals (cell);
+ block_list_signals (cell);
+ gnc_item_list_select (box->item_list, match_str);
+ unblock_list_signals (cell);
- gnc_basic_cell_set_value_internal (_cell, match_str);
+ gnc_basic_cell_set_value_internal (_cell, match_str);
}
static gboolean
@@ -583,199 +587,200 @@
int *end_selection,
void *gui_data)
{
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = cell->cell.gui_private;
- GdkEventKey *event = gui_data;
- gboolean keep_on_going = FALSE;
- gboolean extra_colon;
- gunichar unicode_value;
- QuickFill *match;
- const char *match_str;
- int prefix_len;
- int find_pos;
- int new_pos;
+ ComboCell *cell = (ComboCell *) bcell;
+ PopBox *box = cell->cell.gui_private;
+ GdkEventKey *event = gui_data;
+ gboolean keep_on_going = FALSE;
+ gboolean extra_colon;
+ gunichar unicode_value;
+ QuickFill *match;
+ const char *match_str;
+ int prefix_len;
+ int find_pos;
+ int new_pos;
- if (event->type != GDK_KEY_PRESS)
- return FALSE;
+ if (event->type != GDK_KEY_PRESS)
+ return FALSE;
- unicode_value = gdk_keyval_to_unicode(event->keyval);
- switch (event->keyval) {
- case GDK_slash:
- if (!(event->state & GDK_MOD1_MASK))
- {
- if (unicode_value == box->complete_char)
- break;
+ unicode_value = gdk_keyval_to_unicode(event->keyval);
+ switch (event->keyval)
+ {
+ case GDK_slash:
+ if (!(event->state & GDK_MOD1_MASK))
+ {
+ if (unicode_value == box->complete_char)
+ break;
- return FALSE;
- }
- keep_on_going = TRUE;
- /* Fall through */
- case GDK_Tab:
- case GDK_ISO_Left_Tab:
- if (!(event->state & GDK_CONTROL_MASK) &&
- !keep_on_going)
- return FALSE;
+ return FALSE;
+ }
+ keep_on_going = TRUE;
+ /* Fall through */
+ case GDK_Tab:
+ case GDK_ISO_Left_Tab:
+ if (!(event->state & GDK_CONTROL_MASK) &&
+ !keep_on_going)
+ return FALSE;
- match = gnc_quickfill_get_string_len_match
- (box->qf, bcell->value, *cursor_position);
- if (match == NULL)
- return TRUE;
+ match = gnc_quickfill_get_string_len_match
+ (box->qf, bcell->value, *cursor_position);
+ if (match == NULL)
+ return TRUE;
- match = gnc_quickfill_get_unique_len_match
- (match, &prefix_len);
- if (match == NULL)
- return TRUE;
+ match = gnc_quickfill_get_unique_len_match
+ (match, &prefix_len);
+ if (match == NULL)
+ return TRUE;
- match_str = gnc_quickfill_string (match);
+ match_str = gnc_quickfill_string (match);
- if ((match_str != NULL) &&
- (strncmp (match_str, bcell->value,
- strlen (bcell->value)) == 0) &&
- (strcmp (match_str, bcell->value) != 0))
- {
- gnc_basic_cell_set_value_internal (bcell,
- match_str);
+ if ((match_str != NULL) &&
+ (strncmp (match_str, bcell->value,
+ strlen (bcell->value)) == 0) &&
+ (strcmp (match_str, bcell->value) != 0))
+ {
+ gnc_basic_cell_set_value_internal (bcell,
+ match_str);
- block_list_signals (cell);
- gnc_item_list_select (box->item_list,
- match_str);
- unblock_list_signals (cell);
- }
+ block_list_signals (cell);
+ gnc_item_list_select (box->item_list,
+ match_str);
+ unblock_list_signals (cell);
+ }
- *cursor_position += prefix_len;
- *start_selection = *cursor_position;
- *end_selection = -1;
+ *cursor_position += prefix_len;
+ *start_selection = *cursor_position;
+ *end_selection = -1;
- return TRUE;
- }
+ return TRUE;
+ }
- if (box->complete_char == 0)
- return FALSE;
+ if (box->complete_char == 0)
+ return FALSE;
- if (unicode_value != box->complete_char)
- return FALSE;
+ if (unicode_value != box->complete_char)
+ return FALSE;
- if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
- return FALSE;
+ if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
+ return FALSE;
- if ((*cursor_position < bcell->value_chars) &&
+ if ((*cursor_position < bcell->value_chars) &&
((*end_selection < bcell->value_chars) ||
(*cursor_position < *start_selection)))
- return FALSE;
+ return FALSE;
- if ((*cursor_position == bcell->value_chars) &&
+ if ((*cursor_position == bcell->value_chars) &&
(*start_selection != *end_selection) &&
(*end_selection < bcell->value_chars))
- return FALSE;
+ return FALSE;
- find_pos = -1;
- if (*start_selection < bcell->value_chars)
+ find_pos = -1;
+ if (*start_selection < bcell->value_chars)
+ {
+ int i = *start_selection;
+ const char *c;
+ gunichar uc;
+
+ c = g_utf8_offset_to_pointer (bcell->value, i);
+ while (*c)
{
- int i = *start_selection;
- const char *c;
- gunichar uc;
-
- c = g_utf8_offset_to_pointer (bcell->value, i);
- while (*c)
- {
- uc = g_utf8_get_char (c);
- if (uc == box->complete_char)
- {
- find_pos = (i + 1);
- break;
- }
- c = g_utf8_next_char (c);
- i++;
- }
+ uc = g_utf8_get_char (c);
+ if (uc == box->complete_char)
+ {
+ find_pos = (i + 1);
+ break;
+ }
+ c = g_utf8_next_char (c);
+ i++;
}
+ }
- new_pos = *cursor_position;
+ new_pos = *cursor_position;
- if (find_pos >= 0)
- {
- new_pos = find_pos;
- extra_colon = FALSE;
- }
- else
- {
- new_pos = bcell->value_chars;
- extra_colon = TRUE;
- }
+ if (find_pos >= 0)
+ {
+ new_pos = find_pos;
+ extra_colon = FALSE;
+ }
+ else
+ {
+ new_pos = bcell->value_chars;
+ extra_colon = TRUE;
+ }
- match = gnc_quickfill_get_string_len_match (box->qf,
- bcell->value, new_pos);
+ match = gnc_quickfill_get_string_len_match (box->qf,
+ bcell->value, new_pos);
+ if (match == NULL)
+ return FALSE;
+
+ if (extra_colon)
+ {
+ match = gnc_quickfill_get_char_match (match,
+ box->complete_char);
if (match == NULL)
- return FALSE;
+ return FALSE;
- if (extra_colon)
- {
- match = gnc_quickfill_get_char_match (match,
- box->complete_char);
- if (match == NULL)
- return FALSE;
+ new_pos++;
+ }
- new_pos++;
- }
+ match_str = gnc_quickfill_string (match);
- match_str = gnc_quickfill_string (match);
-
- if ((match_str != NULL) &&
+ if ((match_str != NULL) &&
(strncmp (match_str, bcell->value, strlen (bcell->value)) == 0) &&
(strcmp (match_str, bcell->value) != 0))
- {
- gnc_basic_cell_set_value_internal (bcell, match_str);
+ {
+ gnc_basic_cell_set_value_internal (bcell, match_str);
- block_list_signals (cell);
- gnc_item_list_select (box->item_list, match_str);
- unblock_list_signals (cell);
- }
+ block_list_signals (cell);
+ gnc_item_list_select (box->item_list, match_str);
+ unblock_list_signals (cell);
+ }
- *cursor_position = new_pos;
- *start_selection = new_pos;
- *end_selection = -1;
+ *cursor_position = new_pos;
+ *start_selection = new_pos;
+ *end_selection = -1;
- return TRUE;
+ return TRUE;
}
static void
gnc_combo_cell_gui_realize (BasicCell *bcell, gpointer data)
{
- GnucashSheet *sheet = data;
- GnomeCanvasItem *item = sheet->item_editor;
- GncItemEdit *item_edit = GNC_ITEM_EDIT (item);
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = cell->cell.gui_private;
+ GnucashSheet *sheet = data;
+ GnomeCanvasItem *item = sheet->item_editor;
+ GncItemEdit *item_edit = GNC_ITEM_EDIT (item);
+ ComboCell *cell = (ComboCell *) bcell;
+ PopBox *box = cell->cell.gui_private;
- /* initialize gui-specific, private data */
- box->sheet = sheet;
- box->item_edit = item_edit;
- if (cell->shared_store)
- box->item_list = gnc_item_edit_new_list(box->item_edit, cell->shared_store);
- else
- box->item_list = gnc_item_edit_new_list(box->item_edit, box->tmp_store);
- g_object_ref_sink(box->item_list);
+ /* initialize gui-specific, private data */
+ box->sheet = sheet;
+ box->item_edit = item_edit;
+ if (cell->shared_store)
+ box->item_list = gnc_item_edit_new_list(box->item_edit, cell->shared_store);
+ else
+ box->item_list = gnc_item_edit_new_list(box->item_edit, box->tmp_store);
+ g_object_ref_sink(box->item_list);
- /* to mark cell as realized, remove the realize method */
- cell->cell.gui_realize = NULL;
- cell->cell.gui_move = gnc_combo_cell_gui_move;
- cell->cell.enter_cell = gnc_combo_cell_enter;
- cell->cell.leave_cell = gnc_combo_cell_leave;
- cell->cell.gui_destroy = gnc_combo_cell_gui_destroy;
- cell->cell.modify_verify = gnc_combo_cell_modify_verify;
- cell->cell.direct_update = gnc_combo_cell_direct_update;
+ /* to mark cell as realized, remove the realize method */
+ cell->cell.gui_realize = NULL;
+ cell->cell.gui_move = gnc_combo_cell_gui_move;
+ cell->cell.enter_cell = gnc_combo_cell_enter;
+ cell->cell.leave_cell = gnc_combo_cell_leave;
+ cell->cell.gui_destroy = gnc_combo_cell_gui_destroy;
+ cell->cell.modify_verify = gnc_combo_cell_modify_verify;
+ cell->cell.direct_update = gnc_combo_cell_direct_update;
}
static void
gnc_combo_cell_gui_move (BasicCell *bcell)
{
- PopBox *box = bcell->gui_private;
+ PopBox *box = bcell->gui_private;
- combo_disconnect_signals ((ComboCell *) bcell);
+ combo_disconnect_signals ((ComboCell *) bcell);
- gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
+ gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
- box->list_popped = FALSE;
+ box->list_popped = FALSE;
}
static int
@@ -784,11 +789,11 @@
int row_height,
gpointer user_data)
{
- PopBox *box = user_data;
- int count, pad = 4;
+ PopBox *box = user_data;
+ int count, pad = 4;
- count = gnc_item_list_num_entries(box->item_list);
- return MIN(space_available, (count * (row_height + pad)) + pad);
+ count = gnc_item_list_num_entries(box->item_list);
+ return MIN(space_available, (count * (row_height + pad)) + pad);
}
static int
@@ -796,41 +801,41 @@
int max_width,
gpointer user_data)
{
- PopBox *box = user_data;
+ PopBox *box = user_data;
- if (!box || !box->autosize)
- return max_width;
+ if (!box || !box->autosize)
+ return max_width;
- return gnc_item_list_autosize (GNC_ITEM_LIST (item)) + 20;
+ return gnc_item_list_autosize (GNC_ITEM_LIST (item)) + 20;
}
static void
popup_set_focus (GnomeCanvasItem *item,
gpointer user_data)
{
- gtk_widget_grab_focus (GTK_WIDGET (GNC_ITEM_LIST (item)->tree_view));
+ gtk_widget_grab_focus (GTK_WIDGET (GNC_ITEM_LIST (item)->tree_view));
}
static void
popup_post_show (GnomeCanvasItem *item,
gpointer user_data)
{
- /* What the hell is this doing here? Well, under gtk+ 1.2.9,
- * the scrollbars never appear without it. Why does it work?
- * Why are you asking so many questions? There's nothing to
- * see here. These aren't the droids you're looking for.
- * Move along. */
- gtk_widget_size_request (GNC_ITEM_LIST (item)->frame, NULL);
+ /* What the hell is this doing here? Well, under gtk+ 1.2.9,
+ * the scrollbars never appear without it. Why does it work?
+ * Why are you asking so many questions? There's nothing to
+ * see here. These aren't the droids you're looking for.
+ * Move along. */
+ gtk_widget_size_request (GNC_ITEM_LIST (item)->frame, NULL);
- gnc_item_list_autosize (GNC_ITEM_LIST (item));
- gnc_item_list_show_selected (GNC_ITEM_LIST (item));
+ gnc_item_list_autosize (GNC_ITEM_LIST (item));
+ gnc_item_list_show_selected (GNC_ITEM_LIST (item));
}
static int
popup_get_width (GnomeCanvasItem *item,
gpointer user_data)
{
- return GTK_WIDGET (GNC_ITEM_LIST (item)->tree_view)->allocation.width;
+ return GTK_WIDGET (GNC_ITEM_LIST (item)->tree_view)->allocation.width;
}
static gboolean
@@ -839,120 +844,121 @@
int *start_selection,
int *end_selection)
{
- ComboCell *cell = (ComboCell *) bcell;
- PopBox *box = bcell->gui_private;
- GList *find = NULL;
+ ComboCell *cell = (ComboCell *) bcell;
+ PopBox *box = bcell->gui_private;
+ GList *find = NULL;
- if (bcell->value)
- find = g_list_find_custom (box->ignore_strings,
- bcell->value,
- (GCompareFunc) strcmp);
- if (find)
- return FALSE;
+ if (bcell->value)
+ find = g_list_find_custom (box->ignore_strings,
+ bcell->value,
+ (GCompareFunc) strcmp);
+ if (find)
+ return FALSE;
- gnc_item_edit_set_popup (box->item_edit,
+ gnc_item_edit_set_popup (box->item_edit,
GNOME_CANVAS_ITEM (box->item_list),
get_popup_height, popup_autosize,
popup_set_focus, popup_post_show,
popup_get_width, box);
- block_list_signals (cell);
- gnc_item_list_select (box->item_list, bcell->value);
- unblock_list_signals (cell);
+ block_list_signals (cell);
+ gnc_item_list_select (box->item_list, bcell->value);
+ unblock_list_signals (cell);
- combo_connect_signals (cell);
+ combo_connect_signals (cell);
- *cursor_position = -1;
- *start_selection = 0;
- *end_selection = -1;
+ *cursor_position = -1;
+ *start_selection = 0;
+ *end_selection = -1;
- return TRUE;
+ return TRUE;
}
static void
gnc_combo_cell_leave (BasicCell *bcell)
{
- PopBox *box = bcell->gui_private;
+ PopBox *box = bcell->gui_private;
- combo_disconnect_signals ((ComboCell *) bcell);
+ combo_disconnect_signals ((ComboCell *) bcell);
- gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
+ gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
- box->list_popped = FALSE;
+ box->list_popped = FALSE;
- if (box->strict)
+ if (box->strict)
+ {
+ if (bcell->value)
{
- if (bcell->value) {
- if (gnc_item_in_list (box->item_list, bcell->value))
- return;
+ if (gnc_item_in_list (box->item_list, bcell->value))
+ return;
- if (g_list_find_custom (box->ignore_strings,
- bcell->value,
- (GCompareFunc) strcmp))
- return;
- }
- gnc_basic_cell_set_value_internal (bcell, "");
+ if (g_list_find_custom (box->ignore_strings,
+ bcell->value,
+ (GCompareFunc) strcmp))
+ return;
}
+ gnc_basic_cell_set_value_internal (bcell, "");
+ }
}
void
gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict)
{
- PopBox *box;
+ PopBox *box;
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- box = cell->cell.gui_private;
+ box = cell->cell.gui_private;
- box->strict = strict;
+ box->strict = strict;
}
void
gnc_combo_cell_set_complete_char (ComboCell *cell, gunichar complete_char)
{
- PopBox *box;
+ PopBox *box;
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- box = cell->cell.gui_private;
+ box = cell->cell.gui_private;
- box->complete_char = complete_char;
+ box->complete_char = complete_char;
}
void
gnc_combo_cell_add_ignore_string (ComboCell *cell,
const char *ignore_string)
{
- PopBox *box;
+ PopBox *box;
- if (cell == NULL)
- return;
+ if (cell == NULL)
+ return;
- if (!ignore_string)
- return;
+ if (!ignore_string)
+ return;
- box = cell->cell.gui_private;
+ box = cell->cell.gui_private;
- box->ignore_strings = g_list_prepend (box->ignore_strings,
- g_strdup (ignore_string));
+ box->ignore_strings = g_list_prepend (box->ignore_strings,
+ g_strdup (ignore_string));
}
void
gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize)
{
- PopBox *box;
+ PopBox *box;
- if (!cell)
- return;
+ if (!cell)
+ return;
- box = cell->cell.gui_private;
- if (!box)
- return;
+ box = cell->cell.gui_private;
+ if (!box)
+ return;
- box->autosize = autosize;
+ box->autosize = autosize;
}
/*
Modified: gnucash/trunk/src/register/register-gnome/datecell-gnome.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/datecell-gnome.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/datecell-gnome.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -50,15 +50,15 @@
typedef struct _PopBox
{
- GnucashSheet *sheet;
- GncItemEdit *item_edit;
- GNCDatePicker *date_picker;
+ GnucashSheet *sheet;
+ GncItemEdit *item_edit;
+ GNCDatePicker *date_picker;
- gboolean signals_connected; /* date picker signals connected? */
- gboolean calendar_popped; /* calendar is popped up? */
- gboolean in_date_select;
+ gboolean signals_connected; /* date picker signals connected? */
+ gboolean calendar_popped; /* calendar is popped up? */
+ gboolean in_date_select;
- struct tm date;
+ struct tm date;
} PopBox;
@@ -66,23 +66,23 @@
static void unblock_picker_signals (DateCell *cell);
static void gnc_date_cell_realize (BasicCell *bcell, gpointer w);
static void gnc_date_cell_set_value_internal (BasicCell *bcell,
- const char *value);
+ const char *value);
static void gnc_date_cell_move (BasicCell *bcell);
static void gnc_date_cell_gui_destroy (BasicCell *bcell);
static void gnc_date_cell_destroy (BasicCell *bcell);
static void gnc_date_cell_modify_verify (BasicCell *_cell,
- const char *change,
- int change_len,
- const char *newval,
- int newval_len,
- int *cursor_position,
- int *start_selection,
- int *end_selection);
+ const char *change,
+ int change_len,
+ const char *newval,
+ int newval_len,
+ int *cursor_position,
+ int *start_selection,
+ int *end_selection);
static gboolean gnc_date_cell_direct_update (BasicCell *bcell,
- int *cursor_position,
- int *start_selection,
- int *end_selection,
- void *gui_data);
+ int *cursor_position,
+ int *start_selection,
+ int *end_selection,
+ void *gui_data);
static gboolean gnc_date_cell_enter (BasicCell *bcell,
int *cursor_position,
int *start_selection,
@@ -93,322 +93,322 @@
static void
gnc_parse_date (struct tm *parsed, const char * datestr)
{
- int day, month, year;
+ int day, month, year;
- if (!parsed) return;
- if (!datestr) return;
+ if (!parsed) return;
+ if (!datestr) return;
- qof_scan_date (datestr, &day, &month, &year);
+ qof_scan_date (datestr, &day, &month, &year);
- parsed->tm_mday = day;
- parsed->tm_mon = month - 1;
- parsed->tm_year = year - 1900;
+ parsed->tm_mday = day;
+ parsed->tm_mon = month - 1;
+ parsed->tm_year = year - 1900;
- gnc_tm_set_day_start(parsed);
- if (mktime (parsed) == -1)
- gnc_tm_get_today_start (parsed);
- mktime (parsed);
+ gnc_tm_set_day_start(parsed);
+ if (mktime (parsed) == -1)
+ gnc_tm_get_today_start (parsed);
+ mktime (parsed);
}
static void
gnc_date_cell_print_date (DateCell *cell, char *buff)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
- box->date.tm_mday,
- box->date.tm_mon + 1,
- box->date.tm_year+1900);
+ qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
+ box->date.tm_mday,
+ box->date.tm_mon + 1,
+ box->date.tm_year + 1900);
}
static void
gnc_date_cell_init (DateCell *cell)
{
- PopBox *box;
- time_t secs;
- char buff[DATE_BUF];
+ PopBox *box;
+ time_t secs;
+ char buff[DATE_BUF];
- gnc_basic_cell_init (&(cell->cell));
+ gnc_basic_cell_init (&(cell->cell));
- cell->cell.is_popup = TRUE;
+ cell->cell.is_popup = TRUE;
- cell->cell.destroy = gnc_date_cell_destroy;
+ cell->cell.destroy = gnc_date_cell_destroy;
- cell->cell.gui_realize = gnc_date_cell_realize;
- cell->cell.gui_destroy = gnc_date_cell_gui_destroy;
- cell->cell.modify_verify = gnc_date_cell_modify_verify;
- cell->cell.direct_update = gnc_date_cell_direct_update;
- cell->cell.set_value = gnc_date_cell_set_value_internal;
+ cell->cell.gui_realize = gnc_date_cell_realize;
+ cell->cell.gui_destroy = gnc_date_cell_gui_destroy;
+ cell->cell.modify_verify = gnc_date_cell_modify_verify;
+ cell->cell.direct_update = gnc_date_cell_direct_update;
+ cell->cell.set_value = gnc_date_cell_set_value_internal;
- box = g_new0 (PopBox, 1);
+ box = g_new0 (PopBox, 1);
- box->sheet = NULL;
- box->item_edit = NULL;
- box->date_picker = NULL;
+ box->sheet = NULL;
+ box->item_edit = NULL;
+ box->date_picker = NULL;
- box->signals_connected = FALSE;
- box->calendar_popped = FALSE;
- box->in_date_select = FALSE;
+ box->signals_connected = FALSE;
+ box->calendar_popped = FALSE;
+ box->in_date_select = FALSE;
- cell->cell.gui_private = box;
+ cell->cell.gui_private = box;
- /* default value is today's date */
- time (&secs);
- box->date = *localtime (&secs);
- gnc_date_cell_print_date (cell, buff);
+ /* default value is today's date */
+ time (&secs);
+ box->date = *localtime (&secs);
+ gnc_date_cell_print_date (cell, buff);
- gnc_basic_cell_set_value_internal (&cell->cell, buff);
+ gnc_basic_cell_set_value_internal (&cell->cell, buff);
}
BasicCell *
gnc_date_cell_new (void)
{
- DateCell *cell;
+ DateCell *cell;
- cell = g_new0 (DateCell, 1);
+ cell = g_new0 (DateCell, 1);
- gnc_date_cell_init (cell);
+ gnc_date_cell_init (cell);
- return &cell->cell;
+ return &cell->cell;
}
static void
date_picked_cb (GNCDatePicker *gdp, gpointer data)
{
- DateCell *cell = data;
- PopBox *box = cell->cell.gui_private;
- guint day, month, year;
- char buffer[DATE_BUF];
+ DateCell *cell = data;
+ PopBox *box = cell->cell.gui_private;
+ guint day, month, year;
+ char buffer[DATE_BUF];
- gtk_calendar_get_date (gdp->calendar, &year, &month, &day);
+ gtk_calendar_get_date (gdp->calendar, &year, &month, &day);
- qof_print_date_dmy_buff (buffer, MAX_DATE_LENGTH, day, month + 1, year);
+ qof_print_date_dmy_buff (buffer, MAX_DATE_LENGTH, day, month + 1, year);
- box->in_date_select = TRUE;
- gnucash_sheet_modify_current_cell (box->sheet, buffer);
- box->in_date_select = FALSE;
+ box->in_date_select = TRUE;
+ gnucash_sheet_modify_current_cell (box->sheet, buffer);
+ box->in_date_select = FALSE;
- gnc_item_edit_hide_popup (box->item_edit);
- box->calendar_popped = FALSE;
+ gnc_item_edit_hide_popup (box->item_edit);
+ box->calendar_popped = FALSE;
}
static void
date_selected_cb (GNCDatePicker *gdp, gpointer data)
{
- DateCell *cell = data;
- PopBox *box = cell->cell.gui_private;
- guint day, month, year;
- char buffer[DATE_BUF];
+ DateCell *cell = data;
+ PopBox *box = cell->cell.gui_private;
+ guint day, month, year;
+ char buffer[DATE_BUF];
- gtk_calendar_get_date (gdp->calendar, &year, &month, &day);
+ gtk_calendar_get_date (gdp->calendar, &year, &month, &day);
- qof_print_date_dmy_buff (buffer, MAX_DATE_LENGTH, day, month + 1, year);
+ qof_print_date_dmy_buff (buffer, MAX_DATE_LENGTH, day, month + 1, year);
- box->in_date_select = TRUE;
- gnucash_sheet_modify_current_cell (box->sheet, buffer);
- box->in_date_select = FALSE;
+ box->in_date_select = TRUE;
+ gnucash_sheet_modify_current_cell (box->sheet, buffer);
+ box->in_date_select = FALSE;
}
static void
key_press_item_cb (GNCDatePicker *gdp, GdkEventKey *event, gpointer data)
{
- DateCell *cell = data;
- PopBox *box = cell->cell.gui_private;
+ DateCell *cell = data;
+ PopBox *box = cell->cell.gui_private;
- switch(event->keyval)
- {
+ switch (event->keyval)
+ {
case GDK_Escape:
- gnc_item_edit_hide_popup (box->item_edit);
- box->calendar_popped = FALSE;
- break;
+ gnc_item_edit_hide_popup (box->item_edit);
+ box->calendar_popped = FALSE;
+ break;
default:
- gtk_widget_event(GTK_WIDGET (box->sheet), (GdkEvent *) event);
- break;
- }
+ gtk_widget_event(GTK_WIDGET (box->sheet), (GdkEvent *) event);
+ break;
+ }
}
static void
date_picker_disconnect_signals (DateCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (!box->signals_connected)
- return;
+ if (!box->signals_connected)
+ return;
- g_signal_handlers_disconnect_matched (box->date_picker, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cell);
+ g_signal_handlers_disconnect_matched (box->date_picker, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, cell);
- box->signals_connected = FALSE;
+ box->signals_connected = FALSE;
}
static void
date_picker_connect_signals (DateCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (box->signals_connected)
- return;
+ if (box->signals_connected)
+ return;
- g_signal_connect (box->date_picker, "date_selected",
- G_CALLBACK(date_selected_cb), cell);
+ g_signal_connect (box->date_picker, "date_selected",
+ G_CALLBACK(date_selected_cb), cell);
- g_signal_connect(box->date_picker, "date_picked",
- G_CALLBACK(date_picked_cb), cell);
+ g_signal_connect(box->date_picker, "date_picked",
+ G_CALLBACK(date_picked_cb), cell);
- g_signal_connect(box->date_picker, "key_press_event",
- G_CALLBACK(key_press_item_cb), cell);
+ g_signal_connect(box->date_picker, "key_press_event",
+ G_CALLBACK(key_press_item_cb), cell);
- box->signals_connected = TRUE;
+ box->signals_connected = TRUE;
}
static void
block_picker_signals (DateCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (!box->signals_connected)
- return;
+ if (!box->signals_connected)
+ return;
- g_signal_handlers_block_matched (box->date_picker, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cell);
+ g_signal_handlers_block_matched (box->date_picker, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, cell);
}
static void
unblock_picker_signals (DateCell *cell)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (!box->signals_connected)
- return;
+ if (!box->signals_connected)
+ return;
- g_signal_handlers_unblock_matched (box->date_picker, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, cell);
+ g_signal_handlers_unblock_matched (box->date_picker, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, cell);
}
static void
gnc_date_cell_gui_destroy (BasicCell *bcell)
{
- PopBox *box = bcell->gui_private;
- DateCell *cell = (DateCell *) bcell;
+ PopBox *box = bcell->gui_private;
+ DateCell *cell = (DateCell *) bcell;
- if (cell->cell.gui_realize == NULL)
- {
- if (box != NULL && box->date_picker != NULL)
+ if (cell->cell.gui_realize == NULL)
{
- date_picker_disconnect_signals (cell);
- g_object_unref (box->date_picker);
- box->date_picker = NULL;
+ if (box != NULL && box->date_picker != NULL)
+ {
+ date_picker_disconnect_signals (cell);
+ g_object_unref (box->date_picker);
+ box->date_picker = NULL;
+ }
+
+ /* allow the widget to be shown again */
+ cell->cell.gui_realize = gnc_date_cell_realize;
+ cell->cell.gui_move = NULL;
+ cell->cell.enter_cell = NULL;
+ cell->cell.leave_cell = NULL;
+ cell->cell.gui_destroy = NULL;
}
-
- /* allow the widget to be shown again */
- cell->cell.gui_realize = gnc_date_cell_realize;
- cell->cell.gui_move = NULL;
- cell->cell.enter_cell = NULL;
- cell->cell.leave_cell = NULL;
- cell->cell.gui_destroy = NULL;
- }
}
static void
gnc_date_cell_destroy (BasicCell *bcell)
{
- DateCell *cell = (DateCell *) bcell;
- PopBox *box = cell->cell.gui_private;
+ DateCell *cell = (DateCell *) bcell;
+ PopBox *box = cell->cell.gui_private;
- gnc_date_cell_gui_destroy (&(cell->cell));
+ gnc_date_cell_gui_destroy (&(cell->cell));
- g_free (box);
+ g_free (box);
- cell->cell.gui_private = NULL;
- cell->cell.gui_realize = NULL;
+ cell->cell.gui_private = NULL;
+ cell->cell.gui_realize = NULL;
}
void
gnc_date_cell_set_value (DateCell *cell, int day, int mon, int year)
{
- PopBox *box = cell->cell.gui_private;
- struct tm dada;
- char buff[DATE_BUF];
+ PopBox *box = cell->cell.gui_private;
+ struct tm dada;
+ char buff[DATE_BUF];
- dada.tm_mday = day;
- dada.tm_mon = mon - 1;
- dada.tm_year = year - 1900;
+ dada.tm_mday = day;
+ dada.tm_mon = mon - 1;
+ dada.tm_year = year - 1900;
- gnc_tm_set_day_start(&dada);
- mktime (&dada);
+ gnc_tm_set_day_start(&dada);
+ mktime (&dada);
- box->date.tm_mday = dada.tm_mday;
- box->date.tm_mon = dada.tm_mon;
- box->date.tm_year = dada.tm_year;
+ box->date.tm_mday = dada.tm_mday;
+ box->date.tm_mon = dada.tm_mon;
+ box->date.tm_year = dada.tm_year;
- qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, dada.tm_mday, dada.tm_mon + 1, dada.tm_year + 1900);
+ qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, dada.tm_mday, dada.tm_mon + 1, dada.tm_year + 1900);
- gnc_basic_cell_set_value_internal (&cell->cell, buff);
+ gnc_basic_cell_set_value_internal (&cell->cell, buff);
- if (!box->date_picker)
- return;
+ if (!box->date_picker)
+ return;
- block_picker_signals (cell);
- gnc_date_picker_set_date (box->date_picker, day, mon - 1, year);
- unblock_picker_signals (cell);
+ block_picker_signals (cell);
+ gnc_date_picker_set_date (box->date_picker, day, mon - 1, year);
+ unblock_picker_signals (cell);
}
void
gnc_date_cell_set_value_secs (DateCell *cell, time_t secs)
{
- PopBox *box = cell->cell.gui_private;
- char buff[DATE_BUF];
- struct tm * stm;
+ PopBox *box = cell->cell.gui_private;
+ char buff[DATE_BUF];
+ struct tm * stm;
- stm = localtime (&secs);
- box->date = *stm;
+ stm = localtime (&secs);
+ box->date = *stm;
- qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
- box->date.tm_mday,
- box->date.tm_mon + 1,
- box->date.tm_year + 1900);
+ qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
+ box->date.tm_mday,
+ box->date.tm_mon + 1,
+ box->date.tm_year + 1900);
- gnc_basic_cell_set_value_internal (&cell->cell, buff);
+ gnc_basic_cell_set_value_internal (&cell->cell, buff);
- if (!box->date_picker)
- return;
+ if (!box->date_picker)
+ return;
- block_picker_signals (cell);
- gnc_date_picker_set_date (box->date_picker,
- box->date.tm_mday,
- box->date.tm_mon,
- box->date.tm_year + 1900);
- unblock_picker_signals (cell);
+ block_picker_signals (cell);
+ gnc_date_picker_set_date (box->date_picker,
+ box->date.tm_mday,
+ box->date.tm_mon,
+ box->date.tm_year + 1900);
+ unblock_picker_signals (cell);
}
void
gnc_date_cell_commit (DateCell *cell)
{
- PopBox *box = cell->cell.gui_private;
- char buff[DATE_BUF];
+ PopBox *box = cell->cell.gui_private;
+ char buff[DATE_BUF];
- if (!cell)
- return;
+ if (!cell)
+ return;
- gnc_parse_date (&(box->date), cell->cell.value);
+ gnc_parse_date (&(box->date), cell->cell.value);
- qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
- box->date.tm_mday,
- box->date.tm_mon + 1,
- box->date.tm_year + 1900);
+ qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
+ box->date.tm_mday,
+ box->date.tm_mon + 1,
+ box->date.tm_year + 1900);
- gnc_basic_cell_set_value_internal (&cell->cell, buff);
+ gnc_basic_cell_set_value_internal (&cell->cell, buff);
- if (!box->date_picker)
- return;
+ if (!box->date_picker)
+ return;
- block_picker_signals (cell);
- gnc_date_picker_set_date (box->date_picker,
- box->date.tm_mday,
- box->date.tm_mon,
- box->date.tm_year + 1900);
- unblock_picker_signals (cell);
+ block_picker_signals (cell);
+ gnc_date_picker_set_date (box->date_picker,
+ box->date.tm_mday,
+ box->date.tm_mon,
+ box->date.tm_year + 1900);
+ unblock_picker_signals (cell);
}
static gboolean
@@ -418,35 +418,35 @@
int *end_selection,
void *gui_data)
{
- DateCell *cell = (DateCell *) bcell;
- PopBox *box = cell->cell.gui_private;
- GdkEventKey *event = gui_data;
- char buff[DATE_BUF];
+ DateCell *cell = (DateCell *) bcell;
+ PopBox *box = cell->cell.gui_private;
+ GdkEventKey *event = gui_data;
+ char buff[DATE_BUF];
- if (!gnc_handle_date_accelerator (event, &(box->date), bcell->value))
- return FALSE;
+ if (!gnc_handle_date_accelerator (event, &(box->date), bcell->value))
+ return FALSE;
- qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
- box->date.tm_mday,
- box->date.tm_mon + 1,
- box->date.tm_year + 1900);
+ qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
+ box->date.tm_mday,
+ box->date.tm_mon + 1,
+ box->date.tm_year + 1900);
- gnc_basic_cell_set_value_internal (&cell->cell, buff);
+ gnc_basic_cell_set_value_internal (&cell->cell, buff);
- *start_selection = 0;
- *end_selection = -1;
+ *start_selection = 0;
+ *end_selection = -1;
- if (!box->date_picker)
- return TRUE;
+ if (!box->date_picker)
+ return TRUE;
- block_picker_signals (cell);
- gnc_date_picker_set_date (box->date_picker,
- box->date.tm_mday,
- box->date.tm_mon,
- box->date.tm_year + 1900);
- unblock_picker_signals (cell);
+ block_picker_signals (cell);
+ gnc_date_picker_set_date (box->date_picker,
+ box->date.tm_mday,
+ box->date.tm_mon,
+ box->date.tm_year + 1900);
+ unblock_picker_signals (cell);
- return TRUE;
+ return TRUE;
}
static void
@@ -459,116 +459,116 @@
int *start_selection,
int *end_selection)
{
- DateCell *cell = (DateCell *) _cell;
- PopBox *box = cell->cell.gui_private;
- gboolean accept = FALSE;
+ DateCell *cell = (DateCell *) _cell;
+ PopBox *box = cell->cell.gui_private;
+ gboolean accept = FALSE;
- if (box->in_date_select)
- {
- gnc_basic_cell_set_value (_cell, newval);
- return;
- }
+ if (box->in_date_select)
+ {
+ gnc_basic_cell_set_value (_cell, newval);
+ return;
+ }
- /* if user hit backspace, accept the change */
- if (change == NULL)
- accept = TRUE;
- else if (change_len == 0)
- accept = TRUE;
- else
- {
- int count = 0;
- unsigned char separator = dateSeparator ();
- gboolean ok = TRUE;
- const gchar *c;
- gunichar uc;
-
- /* accept only numbers or a date separator. Note that the
- * separator of '-' (for DATE_FORMAT_ISO) takes precedence
- * over the accelerator below! */
- c = change;
- while (*c)
+ /* if user hit backspace, accept the change */
+ if (change == NULL)
+ accept = TRUE;
+ else if (change_len == 0)
+ accept = TRUE;
+ else
{
- uc = g_utf8_get_char (c);
+ int count = 0;
+ unsigned char separator = dateSeparator ();
+ gboolean ok = TRUE;
+ const gchar *c;
+ gunichar uc;
- if (!g_unichar_isdigit (uc) && (separator != uc))
- ok = FALSE;
+ /* accept only numbers or a date separator. Note that the
+ * separator of '-' (for DATE_FORMAT_ISO) takes precedence
+ * over the accelerator below! */
+ c = change;
+ while (*c)
+ {
+ uc = g_utf8_get_char (c);
- if (separator == uc)
- count++;
+ if (!g_unichar_isdigit (uc) && (separator != uc))
+ ok = FALSE;
- c = g_utf8_next_char (c);
- }
+ if (separator == uc)
+ count++;
- c = _cell->value;
- while (*c)
- {
- uc = g_utf8_get_char (c);
+ c = g_utf8_next_char (c);
+ }
- if (separator == uc)
- count++;
+ c = _cell->value;
+ while (*c)
+ {
+ uc = g_utf8_get_char (c);
- c = g_utf8_next_char (c);
- }
+ if (separator == uc)
+ count++;
- if (2 < count)
- ok = FALSE;
+ c = g_utf8_next_char (c);
+ }
- if (ok)
- accept = TRUE;
- }
+ if (2 < count)
+ ok = FALSE;
- /* keep a copy of the new value */
- if (accept)
- {
+ if (ok)
+ accept = TRUE;
+ }
- gnc_basic_cell_set_value_internal (&cell->cell, newval);
- gnc_parse_date (&(box->date), newval);
+ /* keep a copy of the new value */
+ if (accept)
+ {
- if (!box->date_picker)
- return;
+ gnc_basic_cell_set_value_internal (&cell->cell, newval);
+ gnc_parse_date (&(box->date), newval);
- block_picker_signals (cell);
- gnc_date_picker_set_date (box->date_picker,
- box->date.tm_mday,
- box->date.tm_mon,
- box->date.tm_year + 1900);
- unblock_picker_signals (cell);
- }
+ if (!box->date_picker)
+ return;
+
+ block_picker_signals (cell);
+ gnc_date_picker_set_date (box->date_picker,
+ box->date.tm_mday,
+ box->date.tm_mon,
+ box->date.tm_year + 1900);
+ unblock_picker_signals (cell);
+ }
}
static void
gnc_date_cell_realize (BasicCell *bcell, gpointer data)
{
- GnucashSheet *sheet = data;
- GnomeCanvasItem *item = sheet->item_editor;
- GncItemEdit *item_edit = GNC_ITEM_EDIT (item);
- DateCell *cell = (DateCell *) bcell;
- PopBox *box = cell->cell.gui_private;
+ GnucashSheet *sheet = data;
+ GnomeCanvasItem *item = sheet->item_editor;
+ GncItemEdit *item_edit = GNC_ITEM_EDIT (item);
+ DateCell *cell = (DateCell *) bcell;
+ PopBox *box = cell->cell.gui_private;
- /* initialize gui-specific, private data */
- box->sheet = sheet;
- box->item_edit = item_edit;
- box->date_picker = gnc_item_edit_new_date_picker (box->item_edit);
- g_object_ref_sink(box->date_picker);
+ /* initialize gui-specific, private data */
+ box->sheet = sheet;
+ box->item_edit = item_edit;
+ box->date_picker = gnc_item_edit_new_date_picker (box->item_edit);
+ g_object_ref_sink(box->date_picker);
- /* to mark cell as realized, remove the realize method */
- cell->cell.gui_realize = NULL;
- cell->cell.gui_move = gnc_date_cell_move;
- cell->cell.enter_cell = gnc_date_cell_enter;
- cell->cell.leave_cell = gnc_date_cell_leave;
+ /* to mark cell as realized, remove the realize method */
+ cell->cell.gui_realize = NULL;
+ cell->cell.gui_move = gnc_date_cell_move;
+ cell->cell.enter_cell = gnc_date_cell_enter;
+ cell->cell.leave_cell = gnc_date_cell_leave;
}
static void
gnc_date_cell_move (BasicCell *bcell)
{
- PopBox *box = bcell->gui_private;
+ PopBox *box = bcell->gui_private;
- date_picker_disconnect_signals ((DateCell *) bcell);
+ date_picker_disconnect_signals ((DateCell *) bcell);
- gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL);
+ gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL);
- box->calendar_popped = FALSE;
+ box->calendar_popped = FALSE;
}
static int
@@ -577,22 +577,22 @@
int row_height,
gpointer user_data)
{
- GtkWidget *cal = GTK_WIDGET (GNC_DATE_PICKER (item)->calendar);
- GtkRequisition req;
+ GtkWidget *cal = GTK_WIDGET (GNC_DATE_PICKER (item)->calendar);
+ GtkRequisition req;
- req.height = 0;
- req.width = 0;
+ req.height = 0;
+ req.width = 0;
- gtk_widget_size_request (cal, &req);
+ gtk_widget_size_request (cal, &req);
- return req.height;
+ return req.height;
}
static void
popup_set_focus (GnomeCanvasItem *item,
gpointer user_data)
{
- gtk_widget_grab_focus (GTK_WIDGET (GNC_DATE_PICKER (item)->calendar));
+ gtk_widget_grab_focus (GTK_WIDGET (GNC_DATE_PICKER (item)->calendar));
}
static gboolean
@@ -601,83 +601,83 @@
int *start_selection,
int *end_selection)
{
- DateCell *cell = (DateCell *) bcell;
- PopBox *box = bcell->gui_private;
+ DateCell *cell = (DateCell *) bcell;
+ PopBox *box = bcell->gui_private;
- gnc_item_edit_set_popup (box->item_edit, GNOME_CANVAS_ITEM (box->date_picker),
- get_popup_height, NULL, popup_set_focus,
- NULL, NULL, NULL);
+ gnc_item_edit_set_popup (box->item_edit, GNOME_CANVAS_ITEM (box->date_picker),
+ get_popup_height, NULL, popup_set_focus,
+ NULL, NULL, NULL);
- block_picker_signals (cell);
- gnc_date_picker_set_date (box->date_picker,
- box->date.tm_mday,
- box->date.tm_mon,
- box->date.tm_year + 1900);
- unblock_picker_signals (cell);
+ block_picker_signals (cell);
+ gnc_date_picker_set_date (box->date_picker,
+ box->date.tm_mday,
+ box->date.tm_mon,
+ box->date.tm_year + 1900);
+ unblock_picker_signals (cell);
- date_picker_connect_signals ((DateCell *) bcell);
+ date_picker_connect_signals ((DateCell *) bcell);
- *start_selection = 0;
- *end_selection = -1;
+ *start_selection = 0;
+ *end_selection = -1;
- return TRUE;
+ return TRUE;
}
static void
gnc_date_cell_leave (BasicCell *bcell)
{
- Timespec ts;
- PopBox *box = bcell->gui_private;
+ Timespec ts;
+ PopBox *box = bcell->gui_private;
- date_picker_disconnect_signals ((DateCell *) bcell);
+ date_picker_disconnect_signals ((DateCell *) bcell);
- gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL);
+ gnc_item_edit_set_popup (box->item_edit, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL);
- box->calendar_popped = FALSE;
+ box->calendar_popped = FALSE;
- /* Refresh the date to expand any shortcuts. */
- gnc_date_cell_get_date ((DateCell *)bcell, &ts);
- gnc_date_cell_set_value_secs ((DateCell *)bcell, ts.tv_sec);
+ /* Refresh the date to expand any shortcuts. */
+ gnc_date_cell_get_date ((DateCell *)bcell, &ts);
+ gnc_date_cell_set_value_secs ((DateCell *)bcell, ts.tv_sec);
}
void
gnc_date_cell_get_date (DateCell *cell, Timespec *ts)
{
- PopBox *box = cell->cell.gui_private;
+ PopBox *box = cell->cell.gui_private;
- if (!cell || !ts)
- return;
+ if (!cell || !ts)
+ return;
- gnc_parse_date (&(box->date), cell->cell.value);
+ gnc_parse_date (&(box->date), cell->cell.value);
- ts->tv_sec = mktime (&box->date);
- ts->tv_nsec = 0;
+ ts->tv_sec = mktime (&box->date);
+ ts->tv_nsec = 0;
}
static void
gnc_date_cell_set_value_internal (BasicCell *_cell, const char *str)
{
- DateCell *cell = (DateCell *) _cell;
- PopBox *box = cell->cell.gui_private;
- char buff[DATE_BUF];
+ DateCell *cell = (DateCell *) _cell;
+ PopBox *box = cell->cell.gui_private;
+ char buff[DATE_BUF];
- gnc_parse_date (&(box->date), str);
+ gnc_parse_date (&(box->date), str);
- qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
- box->date.tm_mday,
- box->date.tm_mon + 1,
- box->date.tm_year + 1900);
+ qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH,
+ box->date.tm_mday,
+ box->date.tm_mon + 1,
+ box->date.tm_year + 1900);
- gnc_basic_cell_set_value_internal (_cell, buff);
+ gnc_basic_cell_set_value_internal (_cell, buff);
- if (!box->date_picker)
- return;
+ if (!box->date_picker)
+ return;
- block_picker_signals (cell);
- gnc_date_picker_set_date (box->date_picker,
- box->date.tm_mday,
- box->date.tm_mon,
- box->date.tm_year + 1900);
- unblock_picker_signals (cell);
+ block_picker_signals (cell);
+ gnc_date_picker_set_date (box->date_picker,
+ box->date.tm_mday,
+ box->date.tm_mon,
+ box->date.tm_year + 1900);
+ unblock_picker_signals (cell);
}
Modified: gnucash/trunk/src/register/register-gnome/formulacell-gnome.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/formulacell-gnome.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/formulacell-gnome.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -69,28 +69,28 @@
*/
switch (event->keyval)
{
- case GDK_Return:
- if (!(event->state &
- (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)))
- is_return = TRUE;
- /* FALL THROUGH TO NEXT CASE */
+ case GDK_Return:
+ if (!(event->state &
+ (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)))
+ is_return = TRUE;
+ /* FALL THROUGH TO NEXT CASE */
- case GDK_KP_Enter:
- {
- gnc_formula_cell_set_value( cell, cell->cell.value );
+ case GDK_KP_Enter:
+ {
+ gnc_formula_cell_set_value( cell, cell->cell.value );
- /* If it's not a plain return, stay put. This
- * allows a 'calculator' style operation using
- * keypad enter where you can keep entering more
- * items to add, say. */
- return !is_return;
- }
+ /* If it's not a plain return, stay put. This
+ * allows a 'calculator' style operation using
+ * keypad enter where you can keep entering more
+ * items to add, say. */
+ return !is_return;
+ }
- case GDK_KP_Decimal:
- break;
+ case GDK_KP_Decimal:
+ break;
- default:
- return FALSE;
+ default:
+ return FALSE;
}
gnc_basic_cell_insert_decimal(bcell,
@@ -107,9 +107,9 @@
BasicCell *
gnc_formula_cell_gnome_new (void)
{
- BasicCell *cell;
+ BasicCell *cell;
- cell = gnc_formula_cell_new ();
- cell->direct_update = gnc_formula_cell_direct_update;
- return cell;
+ cell = gnc_formula_cell_new ();
+ cell->direct_update = gnc_formula_cell_direct_update;
+ return cell;
}
Modified: gnucash/trunk/src/register/register-gnome/gnucash-color.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-color.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/gnucash-color.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -53,66 +53,66 @@
static guint
color_hash (gconstpointer v)
{
- const guint32 *c = (guint32 *) v;
+ const guint32 *c = (guint32 *) v;
- return *c;
+ return *c;
}
static gint
color_equal (gconstpointer v, gconstpointer w)
{
- const guint32 *c1 = (guint32 *) v;
- const guint32 *c2 = (guint32 *) w;
+ const guint32 *c1 = (guint32 *) v;
+ const guint32 *c2 = (guint32 *) w;
- return (*c1 == *c2);
+ return (*c1 == *c2);
}
gulong
gnucash_color_alloc (gushort red, gushort green, gushort blue)
{
- GdkColormap *colormap = gtk_widget_get_default_colormap ();
- GdkColor *c;
-
- if (!color_inited)
- gnucash_color_init ();
+ GdkColormap *colormap = gtk_widget_get_default_colormap ();
+ GdkColor *c;
- c = g_new0 (GdkColor, 1);
- c->red = red;
- c->green = green;
- c->blue = blue;
+ if (!color_inited)
+ gnucash_color_init ();
- g_return_val_if_fail (gdk_colormap_alloc_color (colormap, c, FALSE, TRUE), 0);
+ c = g_new0 (GdkColor, 1);
+ c->red = red;
+ c->green = green;
+ c->blue = blue;
- return c->pixel;
+ g_return_val_if_fail (gdk_colormap_alloc_color (colormap, c, FALSE, TRUE), 0);
+
+ return c->pixel;
}
void
gnucash_color_alloc_gdk (GdkColor *c)
{
- GdkColormap *colormap = gtk_widget_get_default_colormap ();
+ GdkColormap *colormap = gtk_widget_get_default_colormap ();
- g_return_if_fail (c != NULL);
+ g_return_if_fail (c != NULL);
- g_assert (gdk_colormap_alloc_color (colormap, c,
- FALSE, TRUE));
+ g_assert (gdk_colormap_alloc_color (colormap, c,
+ FALSE, TRUE));
}
void
gnucash_color_alloc_name (const char *name, GdkColor *c)
{
- GdkColormap *colormap = gtk_widget_get_default_colormap ();
+ GdkColormap *colormap = gtk_widget_get_default_colormap ();
- g_return_if_fail (name != NULL);
- g_return_if_fail (c != NULL);
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (c != NULL);
- gdk_color_parse (name, c);
- c->pixel = 0;
- g_assert (gdk_colormap_alloc_color (colormap, c,
- FALSE, TRUE));
+ gdk_color_parse (name, c);
+ c->pixel = 0;
+ g_assert (gdk_colormap_alloc_color (colormap, c,
+ FALSE, TRUE));
}
@@ -123,49 +123,49 @@
GdkColor *
gnucash_color_argb_to_gdk (guint32 argb)
{
- GdkColor *color;
- const guint32 key = argb;
- guint32 *newkey;
+ GdkColor *color;
+ const guint32 key = argb;
+ guint32 *newkey;
- color = g_hash_table_lookup (color_hash_table, &key);
+ color = g_hash_table_lookup (color_hash_table, &key);
- if (color)
- return color;
+ if (color)
+ return color;
- color = g_new0(GdkColor, 1);
- newkey = g_new0(guint32, 1);
+ color = g_new0(GdkColor, 1);
+ newkey = g_new0(guint32, 1);
- *newkey = key;
-
- color->red = (argb & 0xff0000) >> 8;
- color->green = argb & 0xff00;
- color->blue = (argb & 0xff) << 8;
+ *newkey = key;
- gnucash_color_alloc_gdk(color);
+ color->red = (argb & 0xff0000) >> 8;
+ color->green = argb & 0xff00;
+ color->blue = (argb & 0xff) << 8;
- g_hash_table_insert (color_hash_table, newkey, color);
+ gnucash_color_alloc_gdk(color);
- return color;
+ g_hash_table_insert (color_hash_table, newkey, color);
+
+ return color;
}
void
gnucash_color_init (void)
{
- /* Allocate the default colors */
- gnucash_color_alloc_name ("white", &gn_white);
- gnucash_color_alloc_name ("black", &gn_black);
+ /* Allocate the default colors */
+ gnucash_color_alloc_name ("white", &gn_white);
+ gnucash_color_alloc_name ("black", &gn_black);
- gnucash_color_alloc_name ("gray60", &gn_light_gray);
- gnucash_color_alloc_name ("gray40", &gn_dark_gray);
- gnucash_color_alloc_name ("blue", &gn_blue);
- gnucash_color_alloc_name ("red", &gn_red);
- gnucash_color_alloc_name ("yellow", &gn_yellow);
+ gnucash_color_alloc_name ("gray60", &gn_light_gray);
+ gnucash_color_alloc_name ("gray40", &gn_dark_gray);
+ gnucash_color_alloc_name ("blue", &gn_blue);
+ gnucash_color_alloc_name ("red", &gn_red);
+ gnucash_color_alloc_name ("yellow", &gn_yellow);
- if (!color_hash_table)
- color_hash_table = g_hash_table_new (color_hash, color_equal);
+ if (!color_hash_table)
+ color_hash_table = g_hash_table_new (color_hash, color_equal);
- color_inited = 1;
+ color_inited = 1;
}
Modified: gnucash/trunk/src/register/register-gnome/gnucash-cursor.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-cursor.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/gnucash-cursor.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -39,399 +39,404 @@
static GnomeCanvasItem *gnucash_cursor_parent_class;
static GnomeCanvasItem *gnucash_item_cursor_parent_class;
-enum {
- PROP_0,
- PROP_SHEET,
- PROP_GRID,
+enum
+{
+ PROP_0,
+ PROP_SHEET,
+ PROP_GRID,
};
static void
gnucash_cursor_get_pixel_coords (GnucashCursor *cursor,
gint *x, gint *y,
- gint *w, gint *h)
+ gint *w, gint *h)
{
- GnucashSheet *sheet = cursor->sheet;
- GnucashItemCursor *item_cursor;
- VirtualCellLocation vcell_loc;
- CellDimensions *cd;
- VirtualCell *vcell;
- SheetBlock *block;
- gint col;
+ GnucashSheet *sheet = cursor->sheet;
+ GnucashItemCursor *item_cursor;
+ VirtualCellLocation vcell_loc;
+ CellDimensions *cd;
+ VirtualCell *vcell;
+ SheetBlock *block;
+ gint col;
- item_cursor =
- GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK]);
+ item_cursor =
+ GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK]);
- vcell_loc.virt_row = item_cursor->row;
- vcell_loc.virt_col = item_cursor->col;
+ vcell_loc.virt_row = item_cursor->row;
+ vcell_loc.virt_col = item_cursor->col;
- block = gnucash_sheet_get_block (sheet, vcell_loc);
- if (!block)
- return;
+ block = gnucash_sheet_get_block (sheet, vcell_loc);
+ if (!block)
+ return;
- vcell = gnc_table_get_virtual_cell (sheet->table, vcell_loc);
- if (!vcell)
- return;
+ vcell = gnc_table_get_virtual_cell (sheet->table, vcell_loc);
+ if (!vcell)
+ return;
- for (col = 0; col < vcell->cellblock->num_cols; col++)
- {
- BasicCell *cell;
+ for (col = 0; col < vcell->cellblock->num_cols; col++)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (vcell->cellblock, 0, col);
- if (cell && cell->cell_name)
- break;
- }
+ cell = gnc_cellblock_get_cell (vcell->cellblock, 0, col);
+ if (cell && cell->cell_name)
+ break;
+ }
- *y = block->origin_y;
+ *y = block->origin_y;
- cd = gnucash_style_get_cell_dimensions (block->style, 0, col);
- if (cd)
- *x = cd->origin_x;
- else
- *x = block->origin_x;
+ cd = gnucash_style_get_cell_dimensions (block->style, 0, col);
+ if (cd)
+ *x = cd->origin_x;
+ else
+ *x = block->origin_x;
- for (col = vcell->cellblock->num_cols - 1; col >= 0; col--)
- {
- BasicCell *cell;
+ for (col = vcell->cellblock->num_cols - 1; col >= 0; col--)
+ {
+ BasicCell *cell;
- cell = gnc_cellblock_get_cell (vcell->cellblock, 0, col);
- if (cell && cell->cell_name)
- break;
- }
+ cell = gnc_cellblock_get_cell (vcell->cellblock, 0, col);
+ if (cell && cell->cell_name)
+ break;
+ }
- *h = block->style->dimensions->height;
+ *h = block->style->dimensions->height;
- cd = gnucash_style_get_cell_dimensions (block->style, 0, col);
- if (cd)
- *w = cd->origin_x + cd->pixel_width - *x;
- else
- *w = block->style->dimensions->width - *x;
+ cd = gnucash_style_get_cell_dimensions (block->style, 0, col);
+ if (cd)
+ *w = cd->origin_x + cd->pixel_width - *x;
+ else
+ *w = block->style->dimensions->width - *x;
}
static void
gnucash_cursor_request_redraw (GnucashCursor *cursor)
{
- GnomeCanvas *canvas = GNOME_CANVAS_ITEM(cursor)->canvas;
- int x, y, w,h;
+ GnomeCanvas *canvas = GNOME_CANVAS_ITEM(cursor)->canvas;
+ int x, y, w, h;
- x = cursor->x;
- y = cursor->y;
- w = cursor->w;
- h = cursor->h;
+ x = cursor->x;
+ y = cursor->y;
+ w = cursor->w;
+ h = cursor->h;
- gnome_canvas_request_redraw (canvas, x, y, x+w+1, y+h+1);
+ gnome_canvas_request_redraw (canvas, x, y, x + w + 1, y + h + 1);
}
void
gnucash_cursor_set_style (GnucashCursor *cursor, SheetBlockStyle *style)
{
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (GNUCASH_IS_CURSOR(cursor));
+ g_return_if_fail (cursor != NULL);
+ g_return_if_fail (GNUCASH_IS_CURSOR(cursor));
- cursor->style = style;
+ cursor->style = style;
}
void
gnucash_cursor_get_virt (GnucashCursor *cursor, VirtualLocation *virt_loc)
{
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
+ g_return_if_fail (cursor != NULL);
+ g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
- virt_loc->vcell_loc.virt_row =
- GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK])->row;
- virt_loc->vcell_loc.virt_col =
- GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK])->col;
+ virt_loc->vcell_loc.virt_row =
+ GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK])->row;
+ virt_loc->vcell_loc.virt_col =
+ GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK])->col;
- virt_loc->phys_row_offset =
- GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL])->row;
- virt_loc->phys_col_offset =
- GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL])->col;
+ virt_loc->phys_row_offset =
+ GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL])->row;
+ virt_loc->phys_col_offset =
+ GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL])->col;
}
void
gnucash_cursor_configure (GnucashCursor *cursor)
{
- GnomeCanvasItem *item;
- GnucashItemCursor *block_cursor;
- GnucashItemCursor *cell_cursor;
- GnomeCanvas *canvas;
- gint x, y, w, h;
- double wx, wy;
+ GnomeCanvasItem *item;
+ GnucashItemCursor *block_cursor;
+ GnucashItemCursor *cell_cursor;
+ GnomeCanvas *canvas;
+ gint x, y, w, h;
+ double wx, wy;
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
+ g_return_if_fail (cursor != NULL);
+ g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
- canvas = GNOME_CANVAS(GNOME_CANVAS_ITEM(cursor)->canvas);
+ canvas = GNOME_CANVAS(GNOME_CANVAS_ITEM(cursor)->canvas);
- item = GNOME_CANVAS_ITEM (cursor);
+ item = GNOME_CANVAS_ITEM (cursor);
- gnucash_cursor_get_pixel_coords (cursor, &x, &y, &w, &h);
- gnome_canvas_item_set (GNOME_CANVAS_ITEM(cursor),
- "GnomeCanvasGroup::x", (double)x,
- "GnomeCanvasGroup::y", (double)y,
- NULL);
+ gnucash_cursor_get_pixel_coords (cursor, &x, &y, &w, &h);
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(cursor),
+ "GnomeCanvasGroup::x", (double)x,
+ "GnomeCanvasGroup::y", (double)y,
+ NULL);
- cursor->w = w;
- cursor->h = h + 1;
+ cursor->w = w;
+ cursor->h = h + 1;
- item->x1 = cursor->x = x;
- item->y1 = cursor->y = y;
- item->x2 = x + w;
- item->y2 = y + h + 1;
+ item->x1 = cursor->x = x;
+ item->y1 = cursor->y = y;
+ item->x2 = x + w;
+ item->y2 = y + h + 1;
- item = cursor->cursor[GNUCASH_CURSOR_BLOCK];
- block_cursor = GNUCASH_ITEM_CURSOR (item);
+ item = cursor->cursor[GNUCASH_CURSOR_BLOCK];
+ block_cursor = GNUCASH_ITEM_CURSOR (item);
- wx = 0;
- wy = 0;
+ wx = 0;
+ wy = 0;
- gnome_canvas_item_i2w (item, &wx, &wy);
- gnome_canvas_w2c (canvas, wx, wy, &block_cursor->x, &block_cursor->y);
- block_cursor->w = w;
- block_cursor->h = h + 1;
+ gnome_canvas_item_i2w (item, &wx, &wy);
+ gnome_canvas_w2c (canvas, wx, wy, &block_cursor->x, &block_cursor->y);
+ block_cursor->w = w;
+ block_cursor->h = h + 1;
- item->x1 = block_cursor->x;
- item->y1 = block_cursor->y;
- item->x2 = block_cursor->x + w;
- item->y2 = block_cursor->y + h + 1;
+ item->x1 = block_cursor->x;
+ item->y1 = block_cursor->y;
+ item->x2 = block_cursor->x + w;
+ item->y2 = block_cursor->y + h + 1;
- item = cursor->cursor[GNUCASH_CURSOR_CELL];
- cell_cursor = GNUCASH_ITEM_CURSOR(item);
+ item = cursor->cursor[GNUCASH_CURSOR_CELL];
+ cell_cursor = GNUCASH_ITEM_CURSOR(item);
- gnucash_sheet_style_get_cell_pixel_rel_coords (cursor->style,
- cell_cursor->row,
- cell_cursor->col,
- &x, &y, &w, &h);
- wx = x - block_cursor->x;
- wy = y;
+ gnucash_sheet_style_get_cell_pixel_rel_coords (cursor->style,
+ cell_cursor->row,
+ cell_cursor->col,
+ &x, &y, &w, &h);
+ wx = x - block_cursor->x;
+ wy = y;
- gnome_canvas_item_i2w (item, &wx, &wy);
- gnome_canvas_w2c (canvas, wx, wy, &cell_cursor->x, &cell_cursor->y);
- cell_cursor->w = w;
- cell_cursor->h = h;
+ gnome_canvas_item_i2w (item, &wx, &wy);
+ gnome_canvas_w2c (canvas, wx, wy, &cell_cursor->x, &cell_cursor->y);
+ cell_cursor->w = w;
+ cell_cursor->h = h;
- item->x1 = cell_cursor->x;
- item->y1 = cell_cursor->y;
- item->x2 = cell_cursor->x + w;
- item->y2 = cell_cursor->y + h;
+ item->x1 = cell_cursor->x;
+ item->y1 = cell_cursor->y;
+ item->x2 = cell_cursor->x + w;
+ item->y2 = cell_cursor->y + h;
}
static void
gnucash_item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
- int x, int y, int width, int height)
+ int x, int y, int width, int height)
{
- GnucashItemCursor *item_cursor = GNUCASH_ITEM_CURSOR (item);
- GnucashCursor *cursor = GNUCASH_CURSOR(item->parent);
- gint dx, dy, dw, dh;
+ GnucashItemCursor *item_cursor = GNUCASH_ITEM_CURSOR (item);
+ GnucashCursor *cursor = GNUCASH_CURSOR(item->parent);
+ gint dx, dy, dw, dh;
- switch (item_cursor->type) {
- case GNUCASH_CURSOR_BLOCK:
- dx = item_cursor->x - x;
- dy = item_cursor->y - y;
- dw = item_cursor->w;
- dh = item_cursor->h;
+ switch (item_cursor->type)
+ {
+ case GNUCASH_CURSOR_BLOCK:
+ dx = item_cursor->x - x;
+ dy = item_cursor->y - y;
+ dw = item_cursor->w;
+ dh = item_cursor->h;
- /* draw the rectangle around the entire active
- virtual row */
- gdk_gc_set_line_attributes (cursor->gc, 1,
- GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
+ /* draw the rectangle around the entire active
+ virtual row */
+ gdk_gc_set_line_attributes (cursor->gc, 1,
+ GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
- gdk_gc_set_foreground (cursor->gc, &gn_black);
+ gdk_gc_set_foreground (cursor->gc, &gn_black);
- gdk_draw_rectangle (drawable, cursor->gc, FALSE,
- dx, dy, dw, dh - 1);
- gdk_draw_line (drawable, cursor->gc,
- dx, dy + dh, dx + dw, dy + dh);
+ gdk_draw_rectangle (drawable, cursor->gc, FALSE,
+ dx, dy, dw, dh - 1);
+ gdk_draw_line (drawable, cursor->gc,
+ dx, dy + dh, dx + dw, dy + dh);
- break;
+ break;
- case GNUCASH_CURSOR_CELL:
- dx = item_cursor->x - x;
- dy = item_cursor->y - y;
- dw = item_cursor->w;
- dh = item_cursor->h;
+ case GNUCASH_CURSOR_CELL:
+ dx = item_cursor->x - x;
+ dy = item_cursor->y - y;
+ dw = item_cursor->w;
+ dh = item_cursor->h;
- gdk_gc_set_line_attributes (cursor->gc, 1,
- GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
+ gdk_gc_set_line_attributes (cursor->gc, 1,
+ GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
- gdk_gc_set_foreground (cursor->gc, &gn_black);
+ gdk_gc_set_foreground (cursor->gc, &gn_black);
- gdk_draw_rectangle (drawable, cursor->gc, FALSE,
- dx, dy, dw, dh);
- }
+ gdk_draw_rectangle (drawable, cursor->gc, FALSE,
+ dx, dy, dw, dh);
+ }
}
static void
gnucash_cursor_set_block (GnucashCursor *cursor, VirtualCellLocation vcell_loc)
{
- GnucashSheet *sheet;
- GnucashItemCursor *item_cursor;
+ GnucashSheet *sheet;
+ GnucashItemCursor *item_cursor;
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
+ g_return_if_fail (cursor != NULL);
+ g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
- sheet = cursor->sheet;
- item_cursor =
- GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK]);
+ sheet = cursor->sheet;
+ item_cursor =
+ GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_BLOCK]);
- if (vcell_loc.virt_row < 0 ||
+ if (vcell_loc.virt_row < 0 ||
vcell_loc.virt_row >= sheet->num_virt_rows ||
vcell_loc.virt_col < 0 ||
vcell_loc.virt_col >= sheet->num_virt_cols)
- return;
+ return;
- cursor->style = gnucash_sheet_get_style (sheet, vcell_loc);
+ cursor->style = gnucash_sheet_get_style (sheet, vcell_loc);
- item_cursor->row = vcell_loc.virt_row;
- item_cursor->col = vcell_loc.virt_col;
+ item_cursor->row = vcell_loc.virt_row;
+ item_cursor->col = vcell_loc.virt_col;
}
static void
gnucash_cursor_set_cell (GnucashCursor *cursor, gint cell_row, gint cell_col)
{
- GnucashSheet *sheet;
- GnucashItemCursor *item_cursor;
- SheetBlockStyle *style;
+ GnucashSheet *sheet;
+ GnucashItemCursor *item_cursor;
+ SheetBlockStyle *style;
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
+ g_return_if_fail (cursor != NULL);
+ g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
- sheet = cursor->sheet;
- item_cursor = GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL]);
- style = cursor->style;
+ sheet = cursor->sheet;
+ item_cursor = GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL]);
+ style = cursor->style;
- if (cell_row < 0 || cell_row >= style->nrows ||
+ if (cell_row < 0 || cell_row >= style->nrows ||
cell_col < 0 || cell_col >= style->ncols)
- return;
+ return;
- item_cursor->row = cell_row;
- item_cursor->col = cell_col;
+ item_cursor->row = cell_row;
+ item_cursor->col = cell_col;
}
void
gnucash_cursor_set (GnucashCursor *cursor, VirtualLocation virt_loc)
{
- GnucashSheet *sheet;
-
- g_return_if_fail (cursor != NULL);
- g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
+ GnucashSheet *sheet;
- sheet = cursor->sheet;
+ g_return_if_fail (cursor != NULL);
+ g_return_if_fail (GNUCASH_IS_CURSOR (cursor));
- gnucash_cursor_request_redraw (cursor);
+ sheet = cursor->sheet;
- gnucash_cursor_set_block (cursor, virt_loc.vcell_loc);
- gnucash_cursor_set_cell (cursor,
- virt_loc.phys_row_offset,
- virt_loc.phys_col_offset);
+ gnucash_cursor_request_redraw (cursor);
- gnucash_cursor_configure (cursor);
+ gnucash_cursor_set_block (cursor, virt_loc.vcell_loc);
+ gnucash_cursor_set_cell (cursor,
+ virt_loc.phys_row_offset,
+ virt_loc.phys_col_offset);
- gnome_canvas_item_set (GNOME_CANVAS_ITEM(sheet->header_item),
- "cursor_name",
- cursor->style->cursor->cursor_name,
- NULL);
+ gnucash_cursor_configure (cursor);
- gnucash_cursor_request_redraw (cursor);
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(sheet->header_item),
+ "cursor_name",
+ cursor->style->cursor->cursor_name,
+ NULL);
+
+ gnucash_cursor_request_redraw (cursor);
}
static void
gnucash_item_cursor_init (GnucashItemCursor *cursor)
{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (cursor);
+ GnomeCanvasItem *item = GNOME_CANVAS_ITEM (cursor);
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 1;
- item->y2 = 1;
+ item->x1 = 0;
+ item->y1 = 0;
+ item->x2 = 1;
+ item->y2 = 1;
- cursor->col = 0;
- cursor->row = 0;
+ cursor->col = 0;
+ cursor->row = 0;
}
static void
gnucash_cursor_realize (GnomeCanvasItem *item)
{
- GnucashCursor *cursor = GNUCASH_CURSOR (item);
- GdkWindow *window;
+ GnucashCursor *cursor = GNUCASH_CURSOR (item);
+ GdkWindow *window;
- if (GNOME_CANVAS_ITEM_CLASS (gnucash_cursor_parent_class)->realize)
- (*GNOME_CANVAS_ITEM_CLASS
- (gnucash_cursor_parent_class)->realize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (gnucash_cursor_parent_class)->realize)
+ (*GNOME_CANVAS_ITEM_CLASS
+ (gnucash_cursor_parent_class)->realize)(item);
- window = GTK_WIDGET (item->canvas)->window;
+ window = GTK_WIDGET (item->canvas)->window;
- cursor->gc = gdk_gc_new (window);
+ cursor->gc = gdk_gc_new (window);
}
static void
gnucash_cursor_unrealize (GnomeCanvasItem *item)
{
- GnucashCursor *cursor = GNUCASH_CURSOR (item);
+ GnucashCursor *cursor = GNUCASH_CURSOR (item);
- if (cursor->gc != NULL) {
- g_object_unref (cursor->gc);
- cursor->gc = NULL;
- }
+ if (cursor->gc != NULL)
+ {
+ g_object_unref (cursor->gc);
+ cursor->gc = NULL;
+ }
- if (GNOME_CANVAS_ITEM_CLASS (gnucash_cursor_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS
- (gnucash_cursor_parent_class)->unrealize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (gnucash_cursor_parent_class)->unrealize)
+ (*GNOME_CANVAS_ITEM_CLASS
+ (gnucash_cursor_parent_class)->unrealize)(item);
}
static void
gnucash_item_cursor_class_init (GnucashItemCursorClass *class)
{
- GObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
+ GObjectClass *object_class;
+ GnomeCanvasItemClass *item_class;
- object_class = G_OBJECT_CLASS (class);
- item_class = GNOME_CANVAS_ITEM_CLASS (class);
+ object_class = G_OBJECT_CLASS (class);
+ item_class = GNOME_CANVAS_ITEM_CLASS (class);
- gnucash_item_cursor_parent_class = g_type_class_peek_parent (class);
+ gnucash_item_cursor_parent_class = g_type_class_peek_parent (class);
- /* GnomeCanvasItem method overrides */
- item_class->draw = gnucash_item_cursor_draw;
+ /* GnomeCanvasItem method overrides */
+ item_class->draw = gnucash_item_cursor_draw;
}
GType
gnucash_item_cursor_get_type (void)
{
- static GType gnucash_item_cursor_type = 0;
+ static GType gnucash_item_cursor_type = 0;
- if (!gnucash_item_cursor_type) {
- static const GTypeInfo gnucash_item_cursor_info = {
- sizeof (GnucashItemCursorClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gnucash_item_cursor_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GnucashItemCursor),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gnucash_item_cursor_init
- };
+ if (!gnucash_item_cursor_type)
+ {
+ static const GTypeInfo gnucash_item_cursor_info =
+ {
+ sizeof (GnucashItemCursorClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gnucash_item_cursor_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GnucashItemCursor),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gnucash_item_cursor_init
+ };
- gnucash_item_cursor_type =
- g_type_register_static (gnome_canvas_item_get_type (),
- "GnucashItemCursor",
- &gnucash_item_cursor_info, 0);
- }
+ gnucash_item_cursor_type =
+ g_type_register_static (gnome_canvas_item_get_type (),
+ "GnucashItemCursor",
+ &gnucash_item_cursor_info, 0);
+ }
- return gnucash_item_cursor_type;
+ return gnucash_item_cursor_type;
}
@@ -441,24 +446,25 @@
const GValue *value,
GParamSpec *pspec)
{
- GnomeCanvasItem *item;
- GnucashCursor *cursor;
+ GnomeCanvasItem *item;
+ GnucashCursor *cursor;
- item = GNOME_CANVAS_ITEM (object);
- cursor = GNUCASH_CURSOR (object);
+ item = GNOME_CANVAS_ITEM (object);
+ cursor = GNUCASH_CURSOR (object);
- switch (prop_id){
- case PROP_SHEET:
- cursor->sheet =
- GNUCASH_SHEET (g_value_get_object (value));
- break;
- case PROP_GRID:
- cursor->grid =
- GNUCASH_GRID (g_value_get_object (value));
- break;
- default:
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_SHEET:
+ cursor->sheet =
+ GNUCASH_SHEET (g_value_get_object (value));
+ break;
+ case PROP_GRID:
+ cursor->grid =
+ GNUCASH_GRID (g_value_get_object (value));
+ break;
+ default:
+ break;
+ }
}
@@ -468,140 +474,143 @@
GValue *value,
GParamSpec *pspec)
{
- GnomeCanvasItem *item;
- GnucashCursor *cursor;
+ GnomeCanvasItem *item;
+ GnucashCursor *cursor;
- item = GNOME_CANVAS_ITEM (object);
- cursor = GNUCASH_CURSOR (object);
+ item = GNOME_CANVAS_ITEM (object);
+ cursor = GNUCASH_CURSOR (object);
- switch (prop_id){
- case PROP_SHEET:
- g_value_set_object (value, cursor->sheet);
- break;
- case PROP_GRID:
- g_value_set_object (value, cursor->grid);
- break;
- default:
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_SHEET:
+ g_value_set_object (value, cursor->sheet);
+ break;
+ case PROP_GRID:
+ g_value_set_object (value, cursor->grid);
+ break;
+ default:
+ break;
+ }
}
static void
gnucash_cursor_init (GnucashCursor *cursor)
{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (cursor);
+ GnomeCanvasItem *item = GNOME_CANVAS_ITEM (cursor);
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 1;
- item->y2 = 1;
+ item->x1 = 0;
+ item->y1 = 0;
+ item->x2 = 1;
+ item->y2 = 1;
}
static void
gnucash_cursor_class_init (GnucashCursorClass *class)
{
- GObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
+ GObjectClass *object_class;
+ GnomeCanvasItemClass *item_class;
- object_class = G_OBJECT_CLASS (class);
- item_class = GNOME_CANVAS_ITEM_CLASS (class);
+ object_class = G_OBJECT_CLASS (class);
+ item_class = GNOME_CANVAS_ITEM_CLASS (class);
- gnucash_cursor_parent_class = g_type_class_peek_parent (class);
+ gnucash_cursor_parent_class = g_type_class_peek_parent (class);
- /* GObject method overrides */
- object_class->set_property = gnucash_cursor_set_property;
- object_class->get_property = gnucash_cursor_get_property;
+ /* GObject method overrides */
+ object_class->set_property = gnucash_cursor_set_property;
+ object_class->get_property = gnucash_cursor_get_property;
- /* GnomeCanvasItem method overrides */
- item_class->realize = gnucash_cursor_realize;
- item_class->unrealize = gnucash_cursor_unrealize;
-
- /* properties */
- g_object_class_install_property
- (object_class,
- PROP_SHEET,
- g_param_spec_object ("sheet",
- "Sheet Value",
- "Sheet Value",
- GNUCASH_TYPE_SHEET,
- G_PARAM_READWRITE));
- g_object_class_install_property
- (object_class,
- PROP_GRID,
- g_param_spec_object ("grid",
- "Grid Value",
- "Grid Value",
- GNUCASH_TYPE_GRID,
- G_PARAM_READWRITE));
+ /* GnomeCanvasItem method overrides */
+ item_class->realize = gnucash_cursor_realize;
+ item_class->unrealize = gnucash_cursor_unrealize;
+
+ /* properties */
+ g_object_class_install_property
+ (object_class,
+ PROP_SHEET,
+ g_param_spec_object ("sheet",
+ "Sheet Value",
+ "Sheet Value",
+ GNUCASH_TYPE_SHEET,
+ G_PARAM_READWRITE));
+ g_object_class_install_property
+ (object_class,
+ PROP_GRID,
+ g_param_spec_object ("grid",
+ "Grid Value",
+ "Grid Value",
+ GNUCASH_TYPE_GRID,
+ G_PARAM_READWRITE));
}
GType
gnucash_cursor_get_type (void)
{
- static GType gnucash_cursor_type = 0;
+ static GType gnucash_cursor_type = 0;
- if (!gnucash_cursor_type) {
- static const GTypeInfo gnucash_cursor_info = {
- sizeof (GnucashCursorClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gnucash_cursor_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GnucashCursor),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gnucash_cursor_init
- };
+ if (!gnucash_cursor_type)
+ {
+ static const GTypeInfo gnucash_cursor_info =
+ {
+ sizeof (GnucashCursorClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gnucash_cursor_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GnucashCursor),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gnucash_cursor_init
+ };
- gnucash_cursor_type =
- g_type_register_static (gnome_canvas_group_get_type (),
- "GnucashCursor",
- &gnucash_cursor_info, 0);
- }
+ gnucash_cursor_type =
+ g_type_register_static (gnome_canvas_group_get_type (),
+ "GnucashCursor",
+ &gnucash_cursor_info, 0);
+ }
- return gnucash_cursor_type;
+ return gnucash_cursor_type;
}
GnomeCanvasItem *
-gnucash_cursor_new (GnomeCanvasGroup *parent)
+gnucash_cursor_new (GnomeCanvasGroup *parent)
{
- GnomeCanvasItem *item;
- GnomeCanvasItem *cursor_item;
- GnucashCursor *cursor;
- GnucashItemCursor *item_cursor;
+ GnomeCanvasItem *item;
+ GnomeCanvasItem *cursor_item;
+ GnucashCursor *cursor;
+ GnucashItemCursor *item_cursor;
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CANVAS_GROUP(parent), NULL);
+ g_return_val_if_fail (parent != NULL, NULL);
+ g_return_val_if_fail (GNOME_IS_CANVAS_GROUP(parent), NULL);
- item = gnome_canvas_item_new (parent,
- gnucash_cursor_get_type(),
- NULL);
+ item = gnome_canvas_item_new (parent,
+ gnucash_cursor_get_type(),
+ NULL);
- cursor = GNUCASH_CURSOR(item);
+ cursor = GNUCASH_CURSOR(item);
- cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
- gnucash_item_cursor_get_type(),
- NULL);
+ cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
+ gnucash_item_cursor_get_type(),
+ NULL);
- item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
- item_cursor->type = GNUCASH_CURSOR_CELL;
+ item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
+ item_cursor->type = GNUCASH_CURSOR_CELL;
- cursor->cursor[GNUCASH_CURSOR_CELL] = cursor_item;
+ cursor->cursor[GNUCASH_CURSOR_CELL] = cursor_item;
- cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
- gnucash_item_cursor_get_type(),
- NULL);
+ cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
+ gnucash_item_cursor_get_type(),
+ NULL);
- item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
- item_cursor->type = GNUCASH_CURSOR_BLOCK;
+ item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
+ item_cursor->type = GNUCASH_CURSOR_BLOCK;
- cursor->cursor[GNUCASH_CURSOR_BLOCK] = cursor_item;
+ cursor->cursor[GNUCASH_CURSOR_BLOCK] = cursor_item;
- return item;
+ return item;
}
Modified: gnucash/trunk/src/register/register-gnome/gnucash-cursor.h
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-cursor.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/gnucash-cursor.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -44,52 +44,52 @@
enum
{
- GNUCASH_CURSOR_CELL,
- GNUCASH_CURSOR_BLOCK,
- GNUCASH_CURSOR_NUM
+ GNUCASH_CURSOR_CELL,
+ GNUCASH_CURSOR_BLOCK,
+ GNUCASH_CURSOR_NUM
};
typedef struct
{
- GnomeCanvasItem canvas_item;
+ GnomeCanvasItem canvas_item;
- gint type;
+ gint type;
- gint row;
- gint col;
+ gint row;
+ gint col;
- /* precomputed pixel coords for the item cursor*/
- gint x, y, w, h;
+ /* precomputed pixel coords for the item cursor*/
+ gint x, y, w, h;
} GnucashItemCursor;
-typedef struct
+typedef struct
{
- GnomeCanvasGroup canvas_group;
+ GnomeCanvasGroup canvas_group;
- GnomeCanvasItem *cursor[GNUCASH_CURSOR_NUM];
+ GnomeCanvasItem *cursor[GNUCASH_CURSOR_NUM];
- GnucashSheet *sheet;
- GnucashGrid *grid;
+ GnucashSheet *sheet;
+ GnucashGrid *grid;
- /* precomputed pixel coords for the block cursor*/
- gint x, y, w, h;
+ /* precomputed pixel coords for the block cursor*/
+ gint x, y, w, h;
- GdkGC *gc;
- SheetBlockStyle *style;
+ GdkGC *gc;
+ SheetBlockStyle *style;
} GnucashCursor;
typedef struct
{
- GnomeCanvasItemClass parent_class;
+ GnomeCanvasItemClass parent_class;
} GnucashItemCursorClass;
-typedef struct
+typedef struct
{
- GnomeCanvasGroupClass parent_class;
+ GnomeCanvasGroupClass parent_class;
} GnucashCursorClass;
Modified: gnucash/trunk/src/register/register-gnome/gnucash-date-picker.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-date-picker.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/gnucash-date-picker.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -34,10 +34,10 @@
/* Item list signals */
enum
{
- DATE_SELECTED,
- DATE_PICKED,
- KEY_PRESS_EVENT,
- LAST_SIGNAL
+ DATE_SELECTED,
+ DATE_PICKED,
+ KEY_PRESS_EVENT,
+ LAST_SIGNAL
};
static GnomeCanvasWidgetClass *gnc_date_picker_parent_class;
@@ -48,217 +48,217 @@
gnc_date_picker_set_date (GNCDatePicker *date_picker,
guint day, guint mon, guint year)
{
- g_return_if_fail (IS_GNC_DATE_PICKER (date_picker));
- g_return_if_fail (date_picker->calendar != NULL);
+ g_return_if_fail (IS_GNC_DATE_PICKER (date_picker));
+ g_return_if_fail (date_picker->calendar != NULL);
- gtk_calendar_select_day (date_picker->calendar, 1);
- gtk_calendar_select_month (date_picker->calendar, mon, year);
- gtk_calendar_select_day (date_picker->calendar, day);
+ gtk_calendar_select_day (date_picker->calendar, 1);
+ gtk_calendar_select_month (date_picker->calendar, mon, year);
+ gtk_calendar_select_day (date_picker->calendar, day);
}
void
gnc_date_picker_get_date (GNCDatePicker *date_picker,
guint *day, guint *mon, guint *year)
{
- g_return_if_fail (IS_GNC_DATE_PICKER (date_picker));
- g_return_if_fail (date_picker->calendar != NULL);
+ g_return_if_fail (IS_GNC_DATE_PICKER (date_picker));
+ g_return_if_fail (date_picker->calendar != NULL);
- gtk_calendar_get_date (date_picker->calendar, year, mon, day);
+ gtk_calendar_get_date (date_picker->calendar, year, mon, day);
}
static void
gnc_date_picker_init (GNCDatePicker *date_picker)
{
- date_picker->calendar = NULL;
+ date_picker->calendar = NULL;
}
static gboolean
gnc_date_picker_button_event (GtkWidget *widget, GdkEventButton *event,
gpointer data)
{
- /* So the sheet doesn't use it. */
- g_signal_stop_emission_by_name (widget, "button_press_event");
+ /* So the sheet doesn't use it. */
+ g_signal_stop_emission_by_name (widget, "button_press_event");
- return TRUE;
+ return TRUE;
}
static gboolean
gnc_date_picker_key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
- GNCDatePicker *date_picker = GNC_DATE_PICKER (data);
+ GNCDatePicker *date_picker = GNC_DATE_PICKER (data);
- switch (event->keyval)
- {
+ switch (event->keyval)
+ {
case GDK_Return:
case GDK_KP_Enter:
- g_signal_emit (date_picker, gnc_date_picker_signals[DATE_PICKED], 0);
- g_signal_stop_emission_by_name (widget, "key_press_event");
+ g_signal_emit (date_picker, gnc_date_picker_signals[DATE_PICKED], 0);
+ g_signal_stop_emission_by_name (widget, "key_press_event");
- return TRUE;
+ return TRUE;
case GDK_Up:
case GDK_Down:
case GDK_Left:
case GDK_Right:
case GDK_space:
- /* these go to the calendar */
- return FALSE;
+ /* these go to the calendar */
+ return FALSE;
default:
- break;
- }
+ break;
+ }
- /* These go to the sheet */
- g_signal_stop_emission_by_name (widget, "key_press_event");
+ /* These go to the sheet */
+ g_signal_stop_emission_by_name (widget, "key_press_event");
- g_signal_emit (date_picker,
- gnc_date_picker_signals[KEY_PRESS_EVENT], 0, event);
+ g_signal_emit (date_picker,
+ gnc_date_picker_signals[KEY_PRESS_EVENT], 0, event);
- return TRUE;
+ return TRUE;
}
static void
gnc_date_picker_class_init (GNCDatePickerClass *date_picker_class)
{
- GtkObjectClass *object_class;
+ GtkObjectClass *object_class;
- gnc_date_picker_parent_class =
- gtk_type_class (gnome_canvas_widget_get_type());
+ gnc_date_picker_parent_class =
+ gtk_type_class (gnome_canvas_widget_get_type());
- object_class = GTK_OBJECT_CLASS (date_picker_class);
+ object_class = GTK_OBJECT_CLASS (date_picker_class);
- gnc_date_picker_signals[DATE_SELECTED] =
- g_signal_new("date_selected",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GNCDatePickerClass, date_selected),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ gnc_date_picker_signals[DATE_SELECTED] =
+ g_signal_new("date_selected",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GNCDatePickerClass, date_selected),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
- gnc_date_picker_signals[DATE_PICKED] =
- g_signal_new("date_picked",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GNCDatePickerClass, date_picked),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ gnc_date_picker_signals[DATE_PICKED] =
+ g_signal_new("date_picked",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GNCDatePickerClass, date_picked),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
- gnc_date_picker_signals[KEY_PRESS_EVENT] =
- g_signal_new ("key_press_event",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(GNCDatePickerClass, key_press_event),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOXED,
- G_TYPE_NONE, 1,
- GDK_TYPE_EVENT);
+ gnc_date_picker_signals[KEY_PRESS_EVENT] =
+ g_signal_new ("key_press_event",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GNCDatePickerClass, key_press_event),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ GDK_TYPE_EVENT);
- date_picker_class->date_selected = NULL;
- date_picker_class->date_picked = NULL;
- date_picker_class->key_press_event = NULL;
+ date_picker_class->date_selected = NULL;
+ date_picker_class->date_picked = NULL;
+ date_picker_class->key_press_event = NULL;
}
GType
gnc_date_picker_get_type (void)
{
- static GType gnc_date_picker_type = 0;
+ static GType gnc_date_picker_type = 0;
- if (gnc_date_picker_type == 0)
- {
- GTypeInfo type_info =
+ if (gnc_date_picker_type == 0)
{
- sizeof(GNCDatePickerClass), /* class_size */
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)gnc_date_picker_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(GNCDatePicker), /* */
- 0, /* n_preallocs */
- (GInstanceInitFunc)gnc_date_picker_init,
- };
+ GTypeInfo type_info =
+ {
+ sizeof(GNCDatePickerClass), /* class_size */
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc)gnc_date_picker_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof(GNCDatePicker), /* */
+ 0, /* n_preallocs */
+ (GInstanceInitFunc)gnc_date_picker_init,
+ };
- gnc_date_picker_type =
- g_type_register_static (gnome_canvas_widget_get_type(),
- "GNCDatePicker",
- &type_info, 0);
- }
+ gnc_date_picker_type =
+ g_type_register_static (gnome_canvas_widget_get_type(),
+ "GNCDatePicker",
+ &type_info, 0);
+ }
- return gnc_date_picker_type;
+ return gnc_date_picker_type;
}
static void
day_selected (GtkCalendar *calendar, GNCDatePicker *gdp)
{
- g_signal_emit (gdp, gnc_date_picker_signals [DATE_SELECTED], 0);
+ g_signal_emit (gdp, gnc_date_picker_signals [DATE_SELECTED], 0);
}
static void
day_selected_double_click (GtkCalendar *calendar, GNCDatePicker *gdp)
{
- g_signal_emit (gdp, gnc_date_picker_signals [DATE_PICKED], 0);
+ g_signal_emit (gdp, gnc_date_picker_signals [DATE_PICKED], 0);
}
GnomeCanvasItem *
gnc_date_picker_new (GnomeCanvasGroup *parent)
{
- GtkWidget *calendar;
- GnomeCanvasItem *item;
- GNCDatePicker *date_picker;
+ GtkWidget *calendar;
+ GnomeCanvasItem *item;
+ GNCDatePicker *date_picker;
- calendar = gtk_calendar_new ();
+ calendar = gtk_calendar_new ();
- {
- GtkWidget *hbox;
- GtkAllocation allocation;
- GtkRequisition requisition;
+ {
+ GtkWidget *hbox;
+ GtkAllocation allocation;
+ GtkRequisition requisition;
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_set_direction (hbox, GTK_TEXT_DIR_LTR);
- gtk_box_pack_start (GTK_BOX(hbox), calendar, TRUE, TRUE, 0);
+ gtk_widget_set_direction (hbox, GTK_TEXT_DIR_LTR);
+ gtk_box_pack_start (GTK_BOX(hbox), calendar, TRUE, TRUE, 0);
- item = gnome_canvas_item_new (parent, gnc_date_picker_get_type (),
- "widget", hbox,
- "size_pixels", TRUE,
- "x", -10000.0,
- "y", -10000.0,
- NULL);
- gtk_widget_show_all( hbox );
+ item = gnome_canvas_item_new (parent, gnc_date_picker_get_type (),
+ "widget", hbox,
+ "size_pixels", TRUE,
+ "x", -10000.0,
+ "y", -10000.0,
+ NULL);
+ gtk_widget_show_all( hbox );
- gtk_widget_size_request (calendar, &requisition);
+ gtk_widget_size_request (calendar, &requisition);
- allocation.x = 0;
- allocation.y = 0;
- allocation.width = requisition.width;
- allocation.height = requisition.height;
+ allocation.x = 0;
+ allocation.y = 0;
+ allocation.width = requisition.width;
+ allocation.height = requisition.height;
- gtk_widget_size_allocate (calendar, &allocation);
- }
+ gtk_widget_size_allocate (calendar, &allocation);
+ }
- date_picker = GNC_DATE_PICKER (item);
+ date_picker = GNC_DATE_PICKER (item);
- date_picker->calendar = GTK_CALENDAR (calendar);
+ date_picker->calendar = GTK_CALENDAR (calendar);
- g_signal_connect_after (calendar, "button_press_event",
- G_CALLBACK (gnc_date_picker_button_event),
- date_picker);
+ g_signal_connect_after (calendar, "button_press_event",
+ G_CALLBACK (gnc_date_picker_button_event),
+ date_picker);
- g_signal_connect (calendar, "key_press_event",
- G_CALLBACK (gnc_date_picker_key_event),
- date_picker);
+ g_signal_connect (calendar, "key_press_event",
+ G_CALLBACK (gnc_date_picker_key_event),
+ date_picker);
- g_signal_connect (calendar, "day_selected",
- G_CALLBACK (day_selected),
- date_picker);
+ g_signal_connect (calendar, "day_selected",
+ G_CALLBACK (day_selected),
+ date_picker);
- g_signal_connect (calendar, "day_selected_double_click",
- G_CALLBACK (day_selected_double_click),
- date_picker);
+ g_signal_connect (calendar, "day_selected_double_click",
+ G_CALLBACK (day_selected_double_click),
+ date_picker);
- return item;
+ return item;
}
Modified: gnucash/trunk/src/register/register-gnome/gnucash-date-picker.h
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-date-picker.h 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/gnucash-date-picker.h 2010-03-02 21:41:39 UTC (rev 18790)
@@ -30,11 +30,11 @@
#define IS_GNC_DATE_PICKER(o) (GTK_CHECK_TYPE((o), gnc_date_picker_get_type ()))
-typedef struct
+typedef struct
{
- GnomeCanvasWidget canvas_widget;
+ GnomeCanvasWidget canvas_widget;
- GtkCalendar *calendar;
+ GtkCalendar *calendar;
} GNCDatePicker;
@@ -51,14 +51,14 @@
typedef struct
{
- GnomeCanvasWidgetClass parent_class;
+ GnomeCanvasWidgetClass parent_class;
- void (*date_selected) (GNCDatePicker *date_picker);
+ void (*date_selected) (GNCDatePicker *date_picker);
- void (*date_picked) (GNCDatePicker *date_picker);
+ void (*date_picked) (GNCDatePicker *date_picker);
- void (*key_press_event) (GNCDatePicker *date_picker,
- GdkEventKey *event);
+ void (*key_press_event) (GNCDatePicker *date_picker,
+ GdkEventKey *event);
} GNCDatePickerClass;
Modified: gnucash/trunk/src/register/register-gnome/gnucash-grid.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-grid.c 2010-03-02 21:41:05 UTC (rev 18789)
+++ gnucash/trunk/src/register/register-gnome/gnucash-grid.c 2010-03-02 21:41:39 UTC (rev 18790)
@@ -39,84 +39,88 @@
static GnomeCanvasItem *gnucash_grid_parent_class;
/* Our arguments */
-enum {
- PROP_0,
- PROP_SHEET
+enum
+{
+ PROP_0,
+ PROP_SHEET
};
static void
gnucash_grid_realize (GnomeCanvasItem *item)
{
- GdkWindow *window;
- GnucashGrid *gnucash_grid;
- GdkGC *gc;
+ GdkWindow *window;
+ GnucashGrid *gnucash_grid;
+ GdkGC *gc;
- if (GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->realize)
- (GNOME_CANVAS_ITEM_CLASS
- (gnucash_grid_parent_class)->realize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->realize)
+ (GNOME_CANVAS_ITEM_CLASS
+ (gnucash_grid_parent_class)->realize)(item);
- gnucash_grid = GNUCASH_GRID (item);
- window = GTK_WIDGET (item->canvas)->window;
+ gnucash_grid = GNUCASH_GRID (item);
+ window = GTK_WIDGET (item->canvas)->window;
- /* Configure the default grid gc */
- gnucash_grid->grid_gc = gc = gdk_gc_new (window);
- gnucash_grid->fill_gc = gdk_gc_new (window);
- gnucash_grid->gc = gdk_gc_new (window);
+ /* Configure the default grid gc */
+ gnucash_grid->grid_gc = gc = gdk_gc_new (window);
+ gnucash_grid->fill_gc = gdk_gc_new (window);
+ gnucash_grid->gc = gdk_gc_new (window);
- /* Allocate the default colors */
- gnucash_grid->background = gn_white;
- gnucash_grid->grid_color = gn_black;
- gnucash_grid->default_color = gn_black;
+ /* Allocate the default colors */
+ gnucash_grid->background = gn_white;
+ gnucash_grid->grid_color = gn_black;
+ gnucash_grid->default_color = gn_black;
- gdk_gc_set_foreground (gc, &gnucash_grid->grid_color);
- gdk_gc_set_background (gc, &gnucash_grid->background);
+ gdk_gc_set_foreground (gc, &gnucash_grid->grid_color);
+ gdk_gc_set_background (gc, &gnucash_grid->background);
- gdk_gc_set_foreground (gnucash_grid->fill_gc,
- &gnucash_grid->background);
- gdk_gc_set_background (gnucash_grid->fill_gc,
- &gnucash_grid->grid_color);
+ gdk_gc_set_foreground (gnucash_grid->fill_gc,
+ &gnucash_grid->background);
+ gdk_gc_set_background (gnucash_grid->fill_gc,
+ &gnucash_grid->grid_color);
}
static void
gnucash_grid_unrealize (GnomeCanvasItem *item)
{
- GnucashGrid *gnucash_grid = GNUCASH_GRID (item);
+ GnucashGrid *gnucash_grid = GNUCASH_GRID (item);
- if (gnucash_grid->grid_gc != NULL) {
- g_object_unref(gnucash_grid->grid_gc);
- gnucash_grid->grid_gc = NULL;
- }
+ if (gnucash_grid->grid_gc != NULL)
+ {
+ g_object_unref(gnucash_grid->grid_gc);
+ gnucash_grid->grid_gc = NULL;
+ }
- if (gnucash_grid->fill_gc != NULL) {
- g_object_unref(gnucash_grid->fill_gc);
- gnucash_grid->fill_gc = NULL;
- }
+ if (gnucash_grid->fill_gc != NULL)
+ {
+ g_object_unref(gnucash_grid->fill_gc);
+ gnucash_grid->fill_gc = NULL;
+ }
- if (gnucash_grid->gc != NULL) {
- g_object_unref(gnucash_grid->gc);
- gnucash_grid->gc = NULL;
- }
+ if (gnucash_grid->gc != NULL)
+ {
+ g_object_unref(gnucash_grid->gc);
+ gnucash_grid->gc = NULL;
+ }
- if (GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->unrealize)
- (*GNOME_CANVAS_ITEM_CLASS
- (gnucash_grid_parent_class)->unrealize)(item);
+ if (GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->unrealize)
+ (*GNOME_CANVAS_ITEM_CLASS
+ (gnucash_grid_parent_class)->unrealize)(item);
}
static void
gnucash_grid_update (GnomeCanvasItem *item, double *affine,
- ArtSVP *clip_path, int flags)
+ ArtSVP *clip_path, int flags)
{
- if (GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->update)
- (* GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->update)
- (item, affine, clip_path, flags);
+ if (GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->update)
+ (* GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->update)
+ (item, affine, clip_path, flags);
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = INT_MAX/2 -1;
- item->y2 = INT_MAX/2 -1;
+ item->x1 = 0;
+ item->y1 = 0;
+ item->x2 = INT_MAX / 2 - 1;
+ item->y2 = INT_MAX / 2 - 1;
}
@@ -134,122 +138,132 @@
gint x, gint y,
VirtualCellLocation *vcell_loc)
{
- SheetBlock *block;
- VirtualCellLocation vc_loc = { 1, 0 };
+ SheetBlock *block;
+ VirtualCellLocation vc_loc = { 1, 0 };
- g_return_val_if_fail(y >= 0, NULL);
- g_return_val_if_fail(x >= 0, NULL);
+ g_return_val_if_fail(y >= 0, NULL);
+ g_return_val_if_fail(x >= 0, NULL);
- do {
- block = gnucash_sheet_get_block (grid->sheet, vc_loc);
- if (!block)
- return NULL;
+ do
+ {
+ block = gnucash_sheet_get_block (grid->sheet, vc_loc);
+ if (!block)
+ return NULL;
- if (block->visible &&
- y >= block->origin_y &&
- y < block->origin_y + block->style->dimensions->height) {
- if (vcell_loc)
- vcell_loc->virt_row = vc_loc.virt_row;
- break;
- }
- vc_loc.virt_row++;
- } while (vc_loc.virt_row < grid->sheet->num_virt_rows);
+ if (block->visible &&
+ y >= block->origin_y &&
+ y < block->origin_y + block->style->dimensions->height)
+ {
+ if (vcell_loc)
+ vcell_loc->virt_row = vc_loc.virt_row;
+ break;
+ }
+ vc_loc.virt_row++;
+ }
+ while (vc_loc.virt_row < grid->sheet->num_virt_rows);
- if (vc_loc.virt_row == grid->sheet->num_virt_rows)
- return NULL;
+ if (vc_loc.virt_row == grid->sheet->num_virt_rows)
+ return NULL;
- do {
- block = gnucash_sheet_get_block (grid->sheet, vc_loc);
- if (!block)
- return NULL;
+ do
+ {
+ block = gnucash_sheet_get_block (grid->sheet, vc_loc);
+ if (!block)
+ return NULL;
- if (block->visible &&
- x >= block->origin_x &&
- x < block->origin_x + block->style->dimensions->width) {
- if (vcell_loc)
- vcell_loc->virt_col = vc_loc.virt_col;
- break;
- }
- vc_loc.virt_col++;
- } while (vc_loc.virt_col < grid->sheet->num_virt_cols);
+ if (block->visible &&
+ x >= block->origin_x &&
+ x < block->origin_x + block->style->dimensions->width)
+ {
+ if (vcell_loc)
+ vcell_loc->virt_col = vc_loc.virt_col;
+ break;
+ }
+ vc_loc.virt_col++;
+ }
+ while (vc_loc.virt_col < grid->sheet->num_virt_cols);
- if (vc_loc.virt_col == grid->sheet->num_virt_cols)
- return NULL;
+ if (vc_loc.virt_col == grid->sheet->num_virt_cols)
+ return NULL;
- return block;
+ return block;
}
static gboolean
gnucash_grid_find_cell_by_pixel (GnucashGrid *grid, gint x, gint y,
VirtualLocation *virt_loc)
{
- SheetBlock *block;
- SheetBlockStyle *style;
- CellDimensions *cd;
- gint row = 0;
- gint col = 0;
+ SheetBlock *block;
+ SheetBlockStyle *style;
+ CellDimensions *cd;
+ gint row = 0;
+ gint col = 0;
- g_return_val_if_fail (virt_loc != NULL, FALSE);
+ g_return_val_if_fail (virt_loc != NULL, FALSE);
- block = gnucash_sheet_get_block (grid->sheet, virt_loc->vcell_loc);
- if (block == NULL)
- return FALSE;
+ block = gnucash_sheet_get_block (grid->sheet, virt_loc->vcell_loc);
+ if (block == NULL)
+ return FALSE;
- /* now make x, y relative to the block origin */
- x -= block->origin_x;
- y -= block->origin_y;
+ /* now make x, y relative to the block origin */
+ x -= block->origin_x;
+ y -= block->origin_y;
- style = block->style;
- if (style == NULL)
- return FALSE;
+ style = block->style;
+ if (style == NULL)
+ return FALSE;
- do {
- cd = gnucash_style_get_cell_dimensions (style, row, 0);
+ do
+ {
+ cd = gnucash_style_get_cell_dimensions (style, row, 0);
- if (y >= cd->origin_y && y < cd->origin_y + cd->pixel_height)
- break;
+ if (y >= cd->origin_y && y < cd->origin_y + cd->pixel_height)
+ break;
- row++;
- } while (row < style->nrows);
+ row++;
+ }
+ while (row < style->nrows);
- if (row == style->nrows)
- return FALSE;
+ if (row == style->nrows)
+ return FALSE;
- do {
- cd = gnucash_style_get_cell_dimensions (style, row, col);
+ do
+ {
+ cd = gnucash_style_get_cell_dimensions (style, row, col);
- if (x >= cd->origin_x && x < cd->origin_x + cd->pixel_width)
- break;
+ if (x >= cd->origin_x && x < cd->origin_x + cd->pixel_width)
+ break;
- col++;
- } while (col < style->ncols);
+ col++;
+ }
+ while (col < style->ncols);
- if (col == style->ncols)
- return FALSE;
+ if (col == style->ncols)
+ return FALSE;
- if (virt_loc)
- virt_loc->phys_row_offset = row;
- if (virt_loc)
- virt_loc->phys_col_offset = col;
+ if (virt_loc)
+ virt_loc->phys_row_offset = row;
+ if (virt_loc)
+ virt_loc->phys_col_offset = col;
- return TRUE;
+ return TRUE;
}
gboolean
gnucash_grid_find_loc_by_pixel (GnucashGrid *grid, gint x, gint y,
VirtualLocation *virt_loc)
{
- SheetBlock *block;
+ SheetBlock *block;
- if (virt_loc == NULL)
- return FALSE;
+ if (virt_loc == NULL)
+ return FALSE;
- block = gnucash_grid_find_block_by_pixel (grid, x, y,
- &virt_loc->vcell_loc);
- if (block == NULL)
- return FALSE;
+ block = gnucash_grid_find_block_by_pixel (grid, x, y,
+ &virt_loc->vcell_loc);
+ if (block == NULL)
+ return FALSE;
- return gnucash_grid_find_cell_by_pixel (grid, x, y, virt_loc);
+ return gnucash_grid_find_cell_by_pixel (grid, x, y, virt_loc);
}
G_INLINE_FUNC void
@@ -264,93 +278,93 @@
int x1, int y1, int x2, int y2,
PhysicalCellBorderLineStyle style)
{
- GdkColor *fg_color;
+ GdkColor *fg_color;
- switch (style)
- {
- case CELL_BORDER_LINE_NONE:
- fg_color = bg_color;
- break;
+ switch (style)
+ {
+ case CELL_BORDER_LINE_NONE:
+ fg_color = bg_color;
+ break;
- case CELL_BORDER_LINE_LIGHT:
- fg_color = &gn_light_gray;
- break;
+ case CELL_BORDER_LINE_LIGHT:
+ fg_color = &gn_light_gray;
+ break;
- case CELL_BORDER_LINE_NORMAL:
- case CELL_BORDER_LINE_HEAVY:
- fg_color = &gn_black;
- break;
+ case CELL_BORDER_LINE_NORMAL:
+ case CELL_BORDER_LINE_HEAVY:
+ fg_color = &gn_black;
+ break;
- case CELL_BORDER_LINE_HIGHLIGHT:
- fg_color = &gn_red;
- break;
+ case CELL_BORDER_LINE_HIGHLIGHT:
+ fg_color = &gn_red;
+ break;
- default:
- return;
- }
+ default:
+ return;
+ }
- gdk_gc_set_foreground (gc, fg_color);
- gdk_draw_line (drawable, gc, x1, y1, x2, y2);
+ gdk_gc_set_foreground (gc, fg_color);
+ gdk_draw_line (drawable, gc, x1, y1, x2, y2);
}
static void
get_cell_borders (GnucashSheet *sheet, VirtualLocation virt_loc,
PhysicalCellBorders *borders)
{
- VirtualLocation v_loc;
- PhysicalCellBorders neighbor;
+ VirtualLocation v_loc;
+ PhysicalCellBorders neighbor;
- gnucash_sheet_get_borders (sheet, virt_loc, borders);
+ gnucash_sheet_get_borders (sheet, virt_loc, borders);
- /* top */
- v_loc = virt_loc;
- if (gnc_table_move_vertical_position (sheet->table, &v_loc, -1))
- {
- gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
- borders->top = MAX (borders->top, neighbor.bottom);
- }
+ /* top */
+ v_loc = virt_loc;
+ if (gnc_table_move_vertical_position (sheet->table, &v_loc, -1))
+ {
+ gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
+ borders->top = MAX (borders->top, neighbor.bottom);
+ }
- /* bottom */
- v_loc = virt_loc;
- if (gnc_table_move_vertical_position (sheet->table, &v_loc, 1))
- {
- gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
- borders->bottom = MAX (borders->bottom, neighbor.top);
- }
+ /* bottom */
+ v_loc = virt_loc;
+ if (gnc_table_move_vertical_position (sheet->table, &v_loc, 1))
+ {
+ gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
+ borders->bottom = MAX (borders->bottom, neighbor.top);
+ }
- /* left */
- v_loc = virt_loc;
- v_loc.phys_col_offset--;
- if (gnc_table_virtual_loc_valid (sheet->table, v_loc, TRUE))
- {
- gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
- borders->left = MAX (borders->left, neighbor.right);
- }
+ /* left */
+ v_loc = virt_loc;
+ v_loc.phys_col_offset--;
+ if (gnc_table_virtual_loc_valid (sheet->table, v_loc, TRUE))
+ {
+ gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
+ borders->left = MAX (borders->left, neighbor.right);
+ }
- /* right */
- v_loc = virt_loc;
- v_loc.phys_col_offset++;
- if (gnc_table_virtual_loc_valid (sheet->table, v_loc, TRUE))
- {
- gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
- borders->right = MAX (borders->right, neighbor.left);
- }
+ /* right */
+ v_loc = virt_loc;
+ v_loc.phys_col_offset++;
+ if (gnc_table_virtual_loc_valid (sheet->table, v_loc, TRUE))
+ {
+ gnucash_sheet_get_borders (sheet, v_loc, &neighbor);
+ borders->right = MAX (borders->right, neighbor.left);
+ }
}
void
gnucash_draw_hatching (GdkDrawable *drawable, GdkGC *gc,
int x, int y, int width, int height)
{
- gdk_gc_set_foreground (gc, &gn_light_gray);
+ gdk_gc_set_foreground (gc, &gn_light_gray);
- gdk_draw_rectangle (drawable, gc, FALSE,
- x + 2, y + 2, height / 3, height / 3);
+ gdk_draw_rectangle (drawable, gc, FALSE,
+ x + 2, y + 2, height / 3, height / 3);
- gdk_draw_line (drawable, gc,
- x + 2, y + 2 + height / 3, x + 2 + height / 3, y + 2);
+ gdk_draw_line (drawable, gc,
+ x + 2, y + 2 + height / 3, x + 2 + height / 3, y + 2);
- gdk_draw_line (drawable, gc,
- x + 2, y + 2, x + 2 + height / 3, y + 2 + height / 3);
+ gdk_draw_line (drawable, gc,
+ x + 2, y + 2, x + 2 + height / 3, y + 2 + height / 3);
}
static void
@@ -360,189 +374,194 @@
GdkDrawable *drawable,
int x, int y, int width, int height)
{
- Table *table = grid->sheet->table;
- PhysicalCellBorders borders;
- const char *text;
- PangoLayout *layout;
- PangoContext *context;
- PangoFontDescription *font;
- PangoRectangle logical_rect;
- GdkColor *bg_color;
- GdkColor *fg_color;
-/* gint x_offset, y_offset;*/
- GdkRectangle rect;
- gboolean hatching;
- guint32 argb, color_type;
- int x_offset;
+ Table *table = grid->sheet->table;
+ PhysicalCellBorders borders;
+ const char *text;
+ PangoLayout *layout;
+ PangoContext *context;
+ PangoFontDescription *font;
+ PangoRectangle logical_rect;
+ GdkColor *bg_color;
+ GdkColor *fg_color;
+ /* gint x_offset, y_offset;*/
+ GdkRectangle rect;
+ gboolean hatching;
+ guint32 argb, color_type;
+ int x_offset;
- gdk_gc_set_background (grid->gc, &gn_white);
+ gdk_gc_set_background (grid->gc, &gn_white);
- if (grid->sheet->use_theme_colors) {
- color_type = gnc_table_get_gtkrc_bg_color (table, virt_loc,
- &hatching);
- bg_color = get_gtkrc_color(grid->sheet, color_type);
- } else {
- argb = gnc_table_get_bg_color (table, virt_loc, &hatching);
- bg_color = gnucash_color_argb_to_gdk (argb);
- }
+ if (grid->sheet->use_theme_colors)
+ {
+ color_type = gnc_table_get_gtkrc_bg_color (table, virt_loc,
+ &hatching);
+ bg_color = get_gtkrc_color(grid->sheet, color_type);
+ }
+ else
+ {
+ argb = gnc_table_get_bg_color (table, virt_loc, &hatching);
+ bg_color = gnucash_color_argb_to_gdk (argb);
+ }
- gdk_gc_set_foreground (grid->gc, bg_color);
- gdk_draw_rectangle (drawable, grid->gc, TRUE,
- x + 1, y + 1, width - 1, height - 1);
+ gdk_gc_set_foreground (grid->gc, bg_color);
+ gdk_draw_rectangle (drawable, grid->gc, TRUE,
+ x + 1, y + 1, width - 1, height - 1);
- get_cell_borders (grid->sheet, virt_loc, &borders);
-
- /* top */
- draw_cell_line (drawable, grid->gc, bg_color,
- borders.top >= borders.left ? x : x + 1,
- y,
- (borders.top >= borders.right ?
- x + width : x + width - 1),
- y,
- borders.top);
+ get_cell_borders (grid->sheet, virt_loc, &borders);
- /* bottom */
- draw_cell_line (drawable, grid->gc, bg_color,
- borders.bottom >= borders.left ? x : x + 1,
- y + height,
- (borders.bottom >= borders.right ?
- x + width : x + width - 1),
- y + height,
- borders.bottom);
+ /* top */
+ draw_cell_line (drawable, grid->gc, bg_color,
+ borders.top >= borders.left ? x : x + 1,
+ y,
+ (borders.top >= borders.right ?
+ x + width : x + width - 1),
+ y,
+ borders.top);
- /* left */
- draw_cell_line (drawable, grid->gc, bg_color,
- x,
- borders.left > borders.top ? y : y + 1,
- x,
- (borders.left > borders.bottom ?
- y + height : y + height - 1),
- borders.left);
+ /* bottom */
+ draw_cell_line (drawable, grid->gc, bg_color,
+ borders.bottom >= borders.left ? x : x + 1,
+ y + height,
+ (borders.bottom >= borders.right ?
+ x + width : x + width - 1),
+ y + height,
+ borders.bottom);
- /* right */
- draw_cell_line (drawable, grid->gc, bg_color,
- x + width,
- borders.right > borders.top ? y : y + 1,
- x + width,
- (borders.right > borders.bottom ?
- y + height : y + height - 1),
- borders.right);
+ /* left */
+ draw_cell_line (drawable, grid->gc, bg_color,
+ x,
+ borders.left > borders.top ? y : y + 1,
+ x,
+ (borders.left > borders.bottom ?
+ y + height : y + height - 1),
+ borders.left);
- if (hatching)
- gnucash_draw_hatching (drawable, grid->gc,
- x, y, width, height);
+ /* right */
+ draw_cell_line (drawable, grid->gc, bg_color,
+ x + width,
+ borders.right > borders.top ? y : y + 1,
+ x + width,
+ (borders.right > borders.bottom ?
+ y + height : y + height - 1),
+ borders.right);
- /* dividing line */
- if ((virt_loc.phys_row_offset == 0) &&
+ if (hatching)
+ gnucash_draw_hatching (drawable, grid->gc,
+ x, y, width, height);
+
+ /* dividing line */
+ if ((virt_loc.phys_row_offset == 0) &&
(table->model->dividing_row >= 0))
+ {
+ if (virt_loc.vcell_loc.virt_row == table->model->dividing_row)
{
- if (virt_loc.vcell_loc.virt_row == table->model->dividing_row)
- {
- gdk_gc_set_foreground (grid->gc, &gn_blue);
- gdk_draw_line (drawable, grid->gc, x, y-1, x + width, y-1);
- gdk_draw_line (drawable, grid->gc, x, y, x + width, y);
- gdk_draw_line (drawable, grid->gc, x, y+1, x + width, y+1);
- }
+ gdk_gc_set_foreground (grid->gc, &gn_blue);
+ gdk_draw_line (drawable, grid->gc, x, y - 1, x + width, y - 1);
+ gdk_draw_line (drawable, grid->gc, x, y, x + width, y);
+ gdk_draw_line (drawable, grid->gc, x, y + 1, x + width, y + 1);
}
+ }
- if ((virt_loc.phys_row_offset == (block->style->nrows - 1)) &&
+ if ((virt_loc.phys_row_offset == (block->style->nrows - 1)) &&
(table->model->dividing_row >= 0))
+ {
+ if (virt_loc.vcell_loc.virt_row ==
+ (table->model->dividing_row - 1))
{
- if (virt_loc.vcell_loc.virt_row ==
- (table->model->dividing_row - 1))
- {
- gdk_gc_set_foreground (grid->gc, &gn_blue);
- gdk_draw_line (drawable, grid->gc, x, y + height - 1,
- x + width, y + height - 1);
- gdk_draw_line (drawable, grid->gc, x, y + height,
- x + width, y + height);
- gdk_draw_line (drawable, grid->gc, x, y + height + 1,
- x + width, y + height + 1);
- }
+ gdk_gc_set_foreground (grid->gc, &gn_blue);
+ gdk_draw_line (drawable, grid->gc, x, y + height - 1,
+ x + width, y + height - 1);
+ gdk_draw_line (drawable, grid->gc, x, y + height,
+ x + width, y + height);
+ gdk_draw_line (drawable, grid->gc, x, y + height + 1,
+ x + width, y + height + 1);
}
+ }
- text = gnc_table_get_entry (table, virt_loc);
+ text = gnc_table_get_entry (table, virt_loc);
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (grid->sheet), text);
- // We don't need word wrap or line wrap
- pango_layout_set_width (layout, -1);
- context = pango_layout_get_context (layout);
- font = pango_font_description_copy (pango_context_get_font_description (context));
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (grid->sheet), text);
+ // We don't need word wrap or line wrap
+ pango_layout_set_width (layout, -1);
+ context = pango_layout_get_context (layout);
+ font = pango_font_description_copy (pango_context_get_font_description (context));
- argb = gnc_table_get_fg_color (table, virt_loc);
- fg_color = gnucash_color_argb_to_gdk (argb);
+ argb = gnc_table_get_fg_color (table, virt_loc);
+ fg_color = gnucash_color_argb_to_gdk (argb);
- gdk_gc_set_foreground (grid->gc, fg_color);
+ gdk_gc_set_foreground (grid->gc, fg_color);
- /* If this is the currently open transaction and
- there is no text in this cell */
- if ((table->current_cursor_loc.vcell_loc.virt_row ==
- virt_loc.vcell_loc.virt_row) &&
- (!text || strlen(text) == 0)) {
- text = gnc_table_get_label (table, virt_loc);
- if ((text == NULL) || (*text == '\0'))
- goto exit;
- gdk_gc_set_foreground (grid->gc, &gn_light_gray);
- pango_layout_set_text (layout, text, strlen (text));
- pango_font_description_set_style (font, PANGO_STYLE_ITALIC);
- pango_context_set_font_description (context, font);
- }
+ /* If this is the currently open transaction and
+ there is no text in this cell */
+ if ((table->current_cursor_loc.vcell_loc.virt_row ==
+ virt_loc.vcell_loc.virt_row) &&
+ (!text || strlen(text) == 0))
+ {
+ text = gnc_table_get_label (table, virt_loc);
+ if ((text == NULL) || (*text == '\0'))
+ goto exit;
+ gdk_gc_set_foreground (grid->gc, &gn_light_gray);
+ pango_layout_set_text (layout, text, strlen (text));
+ pango_font_description_set_style (font, PANGO_STYLE_ITALIC);
+ pango_context_set_font_description (context, font);
+ }
- if ((text == NULL) || (*text == '\0')) {
- goto exit;
- }
+ if ((text == NULL) || (*text == '\0'))
+ {
+ goto exit;
+ }
- /*y_offset = ((height / 2) +
- (((font->ascent + font->descent) / 2) - font->descent));
- y_offset++;*/
+ /*y_offset = ((height / 2) +
+ (((font->ascent + font->descent) / 2) - font->descent));
+ y_offset++;*/
- pango_layout_get_pixel_extents(layout,
- NULL,
- &logical_rect);
+ pango_layout_get_pixel_extents(layout,
+ NULL,
+ &logical_rect);
- rect.x = x + CELL_HPADDING;
- rect.y = y + CELL_VPADDING;
- rect.width = MAX (0, width - (2 * CELL_HPADDING));
- rect.height = height - 2;
+ rect.x = x + CELL_HPADDING;
+ rect.y = y + CELL_VPADDING;
+ rect.width = MAX (0, width - (2 * CELL_HPADDING));
+ rect.height = height - 2;
- gdk_gc_set_clip_rectangle (grid->gc, &rect);
+ gdk_gc_set_clip_rectangle (grid->gc, &rect);
- switch (gnc_table_get_align (table, virt_loc))
- {
- default:
- case CELL_ALIGN_LEFT:
- x_offset = 0;
- break;
+ switch (gnc_table_get_align (table, virt_loc))
+ {
+ default:
+ case CELL_ALIGN_LEFT:
+ x_offset = 0;
+ break;
- case CELL_ALIGN_RIGHT:
- x_offset = width - 2 * CELL_HPADDING - logical_rect.width;
- break;
+ case CELL_ALIGN_RIGHT:
+ x_offset = width - 2 * CELL_HPADDING - logical_rect.width;
+ break;
- case CELL_ALIGN_CENTER:
- if (logical_rect.width > width - 2 * CELL_HPADDING)
- x_offset = 0;
- else
- x_offset = (width - 2 * CELL_HPADDING -
- logical_rect.width) / 2;
- break;
- }
+ case CELL_ALIGN_CENTER:
+ if (logical_rect.width > width - 2 * CELL_HPADDING)
+ x_offset = 0;
+ else
+ x_offset = (width - 2 * CELL_HPADDING -
+ logical_rect.width) / 2;
+ break;
+ }
- gdk_draw_layout (drawable,
- grid->gc,
- x + CELL_HPADDING + x_offset,
- y + CELL_VPADDING + 1,
- layout);
+ gdk_draw_layout (drawable,
+ grid->gc,
+ x + CELL_HPADDING + x_offset,
+ y + CELL_VPADDING + 1,
+ layout);
- gdk_gc_set_clip_rectangle (grid->gc, NULL);
+ gdk_gc_set_clip_rectangle (grid->gc, NULL);
- exit:
- pango_font_description_set_style (font, PANGO_STYLE_NORMAL);
- pango_context_set_font_description (context, font);
- pango_font_description_free (font);
- g_object_unref (layout);
+exit:
+ pango_font_description_set_style (font, PANGO_STYLE_NORMAL);
+ pango_context_set_font_description (context, font);
+ pango_font_description_free (font);
+ g_object_unref (layout);
}
static void
@@ -552,212 +571,216 @@
GdkDrawable *drawable,
int x, int y, int width, int height)
{
- CellDimensions *cd;
- gint x_paint;
- gint y_paint;
- gint w, h;
+ CellDimensions *cd;
+ gint x_paint;
+ gint y_paint;
+ gint w, h;
- for ( virt_loc.phys_row_offset = 0;
- virt_loc.phys_row_offset < block->style->nrows ;
- virt_loc.phys_row_offset++ )
+ for ( virt_loc.phys_row_offset = 0;
+ virt_loc.phys_row_offset < block->style->nrows ;
+ virt_loc.phys_row_offset++ )
+ {
+ for ( virt_loc.phys_col_offset = 0;
+ virt_loc.phys_col_offset < block->style->ncols ;
+ virt_loc.phys_col_offset++ )
{
- for ( virt_loc.phys_col_offset = 0;
- virt_loc.phys_col_offset < block->style->ncols ;
- virt_loc.phys_col_offset++ )
- {
- cd = gnucash_style_get_cell_dimensions
- (block->style,
- virt_loc.phys_row_offset,
- virt_loc.phys_col_offset);
+ cd = gnucash_style_get_cell_dimensions
+ (block->style,
+ virt_loc.phys_row_offset,
+ virt_loc.phys_col_offset);
- x_paint = block->origin_x + cd->origin_x;
- if (x_paint > x + width)
- break;
+ x_paint = block->origin_x + cd->origin_x;
+ if (x_paint > x + width)
+ b