* use the checkbox cell in the EntryLedger

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7273 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2002-10-05 23:24:29 +00:00
parent 6510d59d7b
commit d3db2e6750
7 changed files with 34 additions and 98 deletions

View File

@@ -14,6 +14,8 @@
* Implement a core CheckboxCell register type (note, still needs a
pretty Gnome implementation)
* use the checkbox cell in the EntryLedger
2002-10-03 Christian Stimming <stimming@tuhh.de>

View File

@@ -15,6 +15,7 @@
#include "combocell.h"
#include "pricecell.h"
#include "recncell.h"
#include "checkboxcell.h"
#include "messages.h"
#include "gnc-component-manager.h"
@@ -77,31 +78,13 @@ GncTaxTable * gnc_entry_ledger_get_taxtable (GncEntryLedger *ledger,
gboolean gnc_entry_ledger_get_checkmark (GncEntryLedger *ledger,
const char * cell_name)
{
const char *value =
gnc_table_layout_get_cell_value (ledger->table->layout, cell_name);
CheckboxCell *cell =
(CheckboxCell *) gnc_table_layout_get_cell (ledger->table->layout, cell_name);
if (!value || *value == '\0')
if (!cell)
return FALSE;
switch (*value) {
case 'X':
return TRUE;
case ' ':
return FALSE;
default:
g_warning ("Invalid checkmark character: %d", *value);
return FALSE;
}
}
char gnc_entry_ledger_get_inv (GncEntryLedger *ledger, const char * cell_name)
{
const char *value =
gnc_table_layout_get_cell_value (ledger->table->layout, cell_name);
if (value)
return *value;
return '\0';
return cell->flag;
}
gint gnc_entry_ledger_get_type (GncEntryLedger *ledger, const char * cell_name)

View File

@@ -482,7 +482,7 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
switch (ledger->type) {
case GNCENTRY_INVOICE_ENTRY:
{
char inv_value;
gboolean inv_value;
gboolean only_inv_changed = FALSE;
if (changed == 1 &&
@@ -490,9 +490,9 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
ENTRY_INV_CELL, TRUE))
only_inv_changed = TRUE;
inv_value = gnc_entry_ledger_get_inv (ledger, ENTRY_INV_CELL);
inv_value = gnc_entry_ledger_get_checkmark (ledger, ENTRY_INV_CELL);
if (inv_value == 'X' && only_inv_changed) {
if (inv_value && only_inv_changed) {
/* If the only change is that the 'inv' entry was clicked
* "on", then just accept the change it without question.
*/
@@ -633,7 +633,7 @@ gnc_entry_ledger_check_close (GtkWidget *parent, GncEntryLedger *ledger)
gboolean dontask = FALSE;
if (ledger->type == GNCENTRY_INVOICE_ENTRY) {
char inv_value;
gboolean inv_value;
gboolean only_inv_changed = FALSE;
if (gnc_table_current_cursor_changed (ledger->table, FALSE) == 1 &&
@@ -641,9 +641,9 @@ gnc_entry_ledger_check_close (GtkWidget *parent, GncEntryLedger *ledger)
ENTRY_INV_CELL, TRUE))
only_inv_changed = TRUE;
inv_value = gnc_entry_ledger_get_inv (ledger, ENTRY_INV_CELL);
inv_value = gnc_entry_ledger_get_checkmark (ledger, ENTRY_INV_CELL);
if (inv_value == 'X' && only_inv_changed) {
if (inv_value && only_inv_changed) {
/* If the only change is that the 'inv' entry was clicked
* "on", then just accept the change it without question.
*/

View File

@@ -51,7 +51,7 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
gboolean expandable;
gboolean span;
} cells[] = {
{ ENTRY_INV_CELL, RECN_CELL_TYPE_NAME, N_("sample:X")+7,
{ ENTRY_INV_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:X")+7,
CELL_ALIGN_LEFT, FALSE, FALSE },
{ ENTRY_DATE_CELL, DATE_CELL_TYPE_NAME, N_("sample:12/12/2000")+7,
CELL_ALIGN_RIGHT, FALSE, FALSE },
@@ -74,9 +74,9 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
CELL_ALIGN_RIGHT, FALSE, FALSE },
{ ENTRY_BACCT_CELL, COMBO_CELL_TYPE_NAME, N_("sample:Xfer:Account")+7,
CELL_ALIGN_RIGHT, FALSE, FALSE },
{ ENTRY_TAXABLE_CELL, RECN_CELL_TYPE_NAME, N_("sample:T?")+7,
{ ENTRY_TAXABLE_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:T?")+7,
CELL_ALIGN_LEFT, FALSE, FALSE },
{ ENTRY_TAXINCLUDED_CELL, RECN_CELL_TYPE_NAME, N_("sample:TI")+7,
{ ENTRY_TAXINCLUDED_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:TI")+7,
CELL_ALIGN_LEFT, FALSE, FALSE },
{ ENTRY_TAXTABLE_CELL, COMBO_CELL_TYPE_NAME, N_("sample:Tax Table 1")+7,
CELL_ALIGN_RIGHT, FALSE, FALSE },
@@ -84,7 +84,7 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
CELL_ALIGN_RIGHT, FALSE, FALSE },
{ ENTRY_TAXVAL_CELL, PRICE_CELL_TYPE_NAME, N_("sample:999.00")+7,
CELL_ALIGN_RIGHT, FALSE, FALSE },
{ ENTRY_BILLABLE_CELL, RECN_CELL_TYPE_NAME, N_("sample:BI")+7,
{ ENTRY_BILLABLE_CELL, CHECKBOX_CELL_TYPE_NAME, N_("sample:BI")+7,
CELL_ALIGN_LEFT, FALSE, FALSE },
};
int i;

View File

@@ -76,22 +76,6 @@ static void load_discount_how_cells (GncEntryLedger *ledger)
gnc_recn_cell_set_string_getter (cell, gnc_entry_ledger_how_string_getter);
}
static void load_inv_type_cells (GncEntryLedger *ledger, char *cell_name,
gboolean default_is_true)
{
RecnCell *cell;
if (!ledger) return;
cell = (RecnCell *)
gnc_table_layout_get_cell (ledger->table->layout, cell_name);
if (!cell) return;
gnc_recn_cell_set_valid_flags (cell, " X", (default_is_true ? 'X' : ' '));
gnc_recn_cell_set_flag_order (cell, " X");
}
static void load_xfer_cell (ComboCell * cell, AccountGroup * grp)
{
GList *list;
@@ -183,10 +167,6 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
/* Load up cells */
load_discount_type_cells (ledger);
load_discount_how_cells (ledger);
load_inv_type_cells (ledger, ENTRY_INV_CELL, FALSE);
load_inv_type_cells (ledger, ENTRY_TAXABLE_CELL, TRUE);
load_inv_type_cells (ledger, ENTRY_TAXINCLUDED_CELL, FALSE);
load_inv_type_cells (ledger, ENTRY_BILLABLE_CELL, FALSE);
gnc_entry_ledger_load_xfer_cells (ledger);
blank_entry = gnc_entry_ledger_get_blank_entry (ledger);

View File

@@ -15,6 +15,7 @@
#include "gnc-ui-util.h"
#include "datecell.h"
#include "checkboxcell.h"
#include "gncEntryLedgerP.h"
#include "gncEntryLedgerModel.h"
@@ -298,7 +299,6 @@ static const char * get_taxable_entry (VirtualLocation virt_loc,
GncEntryLedger *ledger = user_data;
GncEntry *entry;
gboolean taxable;
static char s[2] = { ' ', '\0' };
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
if (ledger->is_invoice)
@@ -306,12 +306,7 @@ static const char * get_taxable_entry (VirtualLocation virt_loc,
else
taxable = gncEntryGetBillTaxable (entry);
if (taxable)
s[0] = 'X';
else
s[0] = ' ';
return s;
return gnc_checkbox_cell_get_string (taxable);
}
static gboolean
@@ -372,7 +367,6 @@ static const char * get_taxincluded_entry (VirtualLocation virt_loc,
{
GncEntryLedger *ledger = user_data;
GncEntry *entry;
static char s[2] = { ' ', '\0' };
gboolean taxable, taxincluded;
/* load the cell properly; just shadow the value */
@@ -390,12 +384,7 @@ static const char * get_taxincluded_entry (VirtualLocation virt_loc,
else
taxincluded = gncEntryGetBillTaxIncluded (entry);
if (taxincluded)
s[0] = 'X';
else
s[0] = ' ';
return s;
return gnc_checkbox_cell_get_string (taxincluded);
}
static const char * get_inv_entry (VirtualLocation virt_loc,
@@ -405,21 +394,16 @@ static const char * get_inv_entry (VirtualLocation virt_loc,
{
GncEntryLedger *ledger = user_data;
GncEntry *entry;
static char s[2] = { ' ', '\0' };
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
if (gncEntryGetInvoice (entry) == NULL)
s[0] = ' ';
else
s[0] = 'X';
return gnc_checkbox_cell_get_string (gncEntryGetInvoice (entry) != NULL);
/* XXX: what if this entry doesn't belong to this invoice?
* Or, better question, what if this is the blank_entry on
* an invoice page? For the latter, don't worry about it;
* it will be added automatically during the Save operation
*/
return s;
}
static const char * get_value_entry (VirtualLocation virt_loc,
@@ -476,15 +460,9 @@ static const char * get_billable_entry (VirtualLocation virt_loc,
{
GncEntryLedger *ledger = user_data;
GncEntry *entry;
static char s[2] = { ' ', '\0' };
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
if (gncEntryGetBillable (entry))
s[0] = 'X';
else
s[0] = ' ';
return s;
return gnc_checkbox_cell_get_string (gncEntryGetBillable (entry));
}
/* GET_HELP */
@@ -1026,26 +1004,20 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
}
if (ledger->type == GNCENTRY_INVOICE_ENTRY) {
char inv_value;
gboolean inv_value;
inv_value = gnc_entry_ledger_get_inv (ledger, ENTRY_INV_CELL);
inv_value = gnc_entry_ledger_get_checkmark (ledger, ENTRY_INV_CELL);
if (inv_value != '\0') {
/* It's changed. Note that this should only be changed in
* INVOICE_ENTRY. But we don't check here (should we)?
*/
if (inv_value) {
/* Add this to the invoice (if it's not already attached) */
if (gncEntryGetInvoice (entry) == NULL)
gncInvoiceAddEntry (ledger->invoice, entry);
if (inv_value == 'X') {
/* Add this to the invoice (if it's not already attached) */
if (gncEntryGetInvoice (entry) == NULL)
gncInvoiceAddEntry (ledger->invoice, entry);
} else {
/* Remove from the invoice iff we're attached to an order or bill */
if ((gncEntryGetOrder (entry) != NULL) ||
(gncEntryGetBill (entry) != NULL))
gncInvoiceRemoveEntry (ledger->invoice, entry);
}
} else {
/* Remove from the invoice iff we're attached to an order or bill */
if ((gncEntryGetOrder (entry) != NULL) ||
(gncEntryGetBill (entry) != NULL))
gncInvoiceRemoveEntry (ledger->invoice, entry);
}
}
}

View File

@@ -48,7 +48,6 @@ gint gnc_entry_ledger_get_type (GncEntryLedger *ledger,
const char * cell_name);
gboolean gnc_entry_ledger_get_checkmark (GncEntryLedger *ledger,
const char * cell_name);
char gnc_entry_ledger_get_inv (GncEntryLedger *ledger, const char * cell_name);
gboolean gnc_entry_ledger_get_numeric (GncEntryLedger *ledger,
const char *cell_name,
gnc_numeric *value);