Pick a reasonable entry date

Re-use the color scheme
Load Orders.

Note, there is still an initialization problem with the RecnCell
such that the initial value is incorrect.  Also, all the cell sizes
are b0rked; I need to fix that.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6158 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2001-12-01 04:48:59 +00:00
parent 95f25bdbc2
commit d6e3359cc5
7 changed files with 259 additions and 15 deletions

View File

@ -9,6 +9,7 @@
#include <gnome.h>
#include "dialog-utils.h"
#include "global-options.h"
#include "gnc-component-manager.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
@ -170,6 +171,39 @@ gnc_order_window_refresh_handler (GHashTable *changes, gpointer user_data)
}
}
static void
gnc_configure_register_colors (void)
{
GncEntryLedgerColors reg_colors;
reg_colors.header_bg_color =
gnc_lookup_color_option_argb("Register Colors",
"Header color",
0xffffff);
reg_colors.primary_bg_color =
gnc_lookup_color_option_argb("Register Colors",
"Primary color",
0xffffff);
reg_colors.secondary_bg_color =
gnc_lookup_color_option_argb("Register Colors",
"Secondary color",
0xffffff);
reg_colors.primary_active_bg_color =
gnc_lookup_color_option_argb("Register Colors",
"Primary active color",
0xffffff);
reg_colors.secondary_active_bg_color =
gnc_lookup_color_option_argb("Register Colors",
"Secondary active color",
0xffffff);
gnc_entry_ledger_set_colors (reg_colors);
}
static OrderWindow *
gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
GncOrder *order)
@ -181,8 +215,9 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
GnomeDialog *owd;
GList *entries;
ow = g_new0 (OrderWindow, 1);
gnc_configure_register_colors ();
ow = g_new0 (OrderWindow, 1);
ow->book = bookp;
/* Find the dialog */

View File

@ -6,6 +6,7 @@ libgnc_business_ledger_la_SOURCES = \
gncEntryLedger.c \
gncEntryLedgerControl.c \
gncEntryLedgerLayout.c \
gncEntryLedgerLoad.c \
gncEntryLedgerModel.c
noinst_HEADERS = \

View File

@ -79,13 +79,6 @@ GncEntry * gnc_entry_ledger_get_current_entry (GncEntryLedger *ledger)
ledger->table->current_cursor_loc.vcell_loc);
}
/* Copy GncEntry information from the list to the rows of the Ledger. */
void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
{
GncEntry *entry;
}
/* Create and return a new GncEntry Ledger */
GncEntryLedger * gnc_entry_ledger_new (GNCBook *book, GncEntryLedgerType type)
{
@ -98,10 +91,20 @@ GncEntryLedger * gnc_entry_ledger_new (GNCBook *book, GncEntryLedgerType type)
ledger->type = type;
ledger->book = book;
ledger->blank_entry_guid = *xaccGUIDNULL();
ledger->blank_entry_edited = FALSE;
{
Timespec ts = { 0, 0 };
ts.tv_sec = time (NULL);
ledger->last_date_entered = timespecCanonicalDayTime (ts);
}
{
TableLayout *layout = gnc_entry_ledger_layout_new (ledger);
TableModel *model = gnc_entry_ledger_model_new ();
TableControl *control = gnc_entry_ledger_control_new ();
model->handler_user_data = ledger;
control->user_data = ledger;
ledger->table = gnc_table_new (layout, model, control);

View File

@ -54,7 +54,7 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
{ ENTRY_DATE_CELL, DATE_CELL_TYPE_NAME, N_("sample:12/12/2000")+7,
CELL_ALIGN_RIGHT, FALSE, FALSE },
{ ENTRY_DESC_CELL, QUICKFILL_CELL_TYPE_NAME,
N_("sample:Description of an Entry")+7, CELL_ALIGN_LEFT, TRUE, FALSE },
N_("sample:Description of an Entry")+7, CELL_ALIGN_LEFT, FALSE, FALSE },
{ ENTRY_ACTN_CELL, COMBO_CELL_TYPE_NAME,
N_("sample:Expenses:Automobile:Gasoline")+7, CELL_ALIGN_RIGHT,
FALSE, FALSE },
@ -70,9 +70,9 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
CELL_ALIGN_LEFT, FALSE, FALSE },
{ ENTRY_TAXACC_CELL, COMBO_CELL_TYPE_NAME, N_("sample:Tax:Account")+7,
CELL_ALIGN_LEFT, FALSE, FALSE },
{ ENTRY_TAXTYPE_CELL, COMBO_CELL_TYPE_NAME, N_("sample:TaxType")+7,
{ ENTRY_TAXTYPE_CELL, RECN_CELL_TYPE_NAME, N_("sample:TaxType")+7,
CELL_ALIGN_LEFT, FALSE, FALSE },
{ ENTRY_DISTYPE_CELL, COMBO_CELL_TYPE_NAME, N_("sample:DiscountType")+7,
{ ENTRY_DISTYPE_CELL, RECN_CELL_TYPE_NAME, N_("sample:DiscountType")+7,
CELL_ALIGN_LEFT, FALSE, FALSE }
};
int i;

View File

@ -0,0 +1,195 @@
/*
* gncEntryLedgerLoad.c -- a Ledger widget for entering GncEntry objects
* Copyright (C) 2001 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#define _GNU_SOURCE
#include "config.h"
#include <glib.h>
#include "Account.h"
#include "gnc-ui-util.h"
#include "recncell.h"
#include "messages.h"
#include "gncEntry.h"
#include "gncEntryLedger.h"
#include "gncEntryLedgerP.h"
/* XXX: This should go elsewhere */
const char *
gnc_entry_ledger_type_string_getter (char flag)
{
switch (flag) {
case '0': return _("$");
case '1': return _("%");
case '2': return _("+$");
case '3': return _("+%");
default:
return "?";
};
}
static void
load_tax_type_cells (GncEntryLedger *ledger)
{
RecnCell *cell;
const char * s;
if (!ledger) return;
cell = (RecnCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_TAXTYPE_CELL);
if (!cell) return;
gnc_recn_cell_set_valid_flags (cell, "01", '0');
gnc_recn_cell_set_flag_order (cell, "01");
gnc_recn_cell_set_string_getter (cell, gnc_entry_ledger_type_string_getter);
}
static void
load_discount_type_cells (GncEntryLedger *ledger)
{
RecnCell *cell;
const char * s;
if (!ledger) return;
cell = (RecnCell *)
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_DISTYPE_CELL);
if (!cell) return;
gnc_recn_cell_set_valid_flags (cell, "0123", '0');
gnc_recn_cell_set_flag_order (cell, "0123");
gnc_recn_cell_set_string_getter (cell, gnc_entry_ledger_type_string_getter);
}
/* Copy GncEntry information from the list to the rows of the Ledger. */
void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
{
GncEntry *blank_entry;
Table *table;
GList *node;
CellBlock *cursor_header, *cursor;
VirtualCellLocation vcell_loc;
VirtualLocation save_loc;
time_t present;
gboolean start_primary_color = TRUE;
if (!ledger) return;
blank_entry = gncEntryLookup (ledger->book, &(ledger->blank_entry_guid));
if (blank_entry == NULL) {
blank_entry = gncEntryCreate (ledger->book);
gncEntrySetDate (blank_entry, &ledger->last_date_entered);
ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry);
ledger->blank_entry_edited = FALSE;
}
table = ledger->table;
gnc_table_leave_update (table, table->current_cursor_loc);
save_loc = table->current_cursor_loc;
/* 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;
virt_loc.vcell_loc.virt_row = -1;
virt_loc.vcell_loc.virt_col = -1;
virt_loc.phys_row_offset = -1;
virt_loc.phys_col_offset = -1;
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++;
/* get the current time and reset the dividing row */
{
struct tm *tm;
present = time (NULL);
tm = localtime (&present);
tm->tm_sec = 59;
tm->tm_min = 59;
tm->tm_hour = 23;
tm->tm_isdst = -1;
present = mktime (tm);
}
table->model->dividing_row = -1;
cursor = gnc_table_layout_get_cursor (table->layout, "cursor");
/* Populate the table */
for (node = entry_list; node; node = node->next) {
GncEntry *entry = node->data;
/* Don't load the blank entry */
if (entry == blank_entry)
continue;
/* If this is the first load of the ledger, fill the quickfill cells */
{
/* XXX */
}
gnc_table_set_vcell (table, cursor, gncEntryGetGUID (entry),
TRUE, start_primary_color, vcell_loc);
vcell_loc.virt_row++;
/* Flip color for the next guy */
start_primary_color = !start_primary_color;
}
/* Add the blank entry at the end. */
gnc_table_set_vcell (table, cursor, gncEntryGetGUID (blank_entry),
TRUE, start_primary_color, vcell_loc);
vcell_loc.virt_row++;
/* Resize the table */
gnc_table_set_size (table, vcell_loc.virt_row, 1);
/* Restore the cursor */
if (gnc_table_find_close_valid_cell (table, &save_loc, FALSE)) {
gnc_table_move_cursor_gui (table, save_loc);
/* restore_current_cursor()? */
}
/* Set the cell fractions */
gnc_table_refresh_gui (table, TRUE);
/* Show_entry ??? */
/* Set completion character */
/* enable callback for cursor user-driven moves */
gnc_table_control_allow_move (table->control, TRUE);
/* Set the confirmation callbacks and load the combo cells */
load_discount_type_cells (ledger);
load_tax_type_cells (ledger);
}

View File

@ -61,7 +61,7 @@ static const char * get_disc_label (VirtualLocation virt_loc, gpointer data)
static const char * get_distype_label (VirtualLocation virt_loc, gpointer data)
{
return _("Discount Type");
return _("DT");
}
static const char * get_pric_label (VirtualLocation virt_loc, gpointer data)
@ -81,7 +81,7 @@ static const char * get_taxacc_label (VirtualLocation virt_loc, gpointer data)
static const char * get_taxtype_label (VirtualLocation virt_loc, gpointer data)
{
return _("Tax Type");
return _("TT");
}
static const char * get_tax_label (VirtualLocation virt_loc, gpointer data)
@ -174,7 +174,8 @@ static const char * get_distype_entry (VirtualLocation virt_loc,
GncEntry *entry;
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
return gncEntryGetDiscountTypeStr (gncEntryGetDiscountType (entry));
return gnc_entry_ledger_type_string_getter ('0' +
gncEntryGetDiscountType (entry));
}
static const char * get_pric_entry (VirtualLocation virt_loc,
@ -240,7 +241,8 @@ static const char * get_taxtype_entry (VirtualLocation virt_loc,
GncEntry *entry;
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
return gncEntryGetTaxTypeStr (gncEntryGetTaxType (entry));
return gnc_entry_ledger_type_string_getter ('0' +
gncEntryGetTaxType (entry));
}
static const char * get_tax_entry (VirtualLocation virt_loc,

View File

@ -7,11 +7,17 @@
#ifndef GNC_ENTRY_LEDGERP_H
#define GNC_ENTRY_LEDGERP_H
#include "guid.h"
#include "gnc-book.h"
#include "table-allgui.h"
#include "gncEntryLedger.h"
struct GncEntryLedger_s {
GUID blank_entry_guid;
gboolean blank_entry_edited;
Timespec last_date_entered;
GNCBook *book;
Table *table;
GncEntryLedgerType type;
@ -23,4 +29,6 @@ Account * gnc_entry_ledger_get_account (GncEntryLedger *ledger,
const char * cell_name);
gint gnc_entry_ledger_get_type (GncEntryLedger *ledger, const char * cell_name);
const char * gnc_entry_ledger_type_string_getter (char flag);
#endif /* GNC_ENTRY_LEDGERP_H */