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

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18790 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming
2010-03-02 21:41:39 +00:00
parent 3cb8499445
commit 136ac8f6e1
73 changed files with 16747 additions and 16458 deletions

View File

@@ -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 @@ typedef struct
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 @@ gboolean
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;
}

File diff suppressed because it is too large Load Diff

View File

@@ -44,13 +44,13 @@ typedef struct gnc_ledger_display GNCLedgerDisplay;
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 @@ GNCLedgerDisplay * gnc_ledger_display_template_gl (char *id);
/* 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,

File diff suppressed because it is too large Load Diff

View File

@@ -43,47 +43,47 @@ gnc_register_add_cell (TableLayout *layout,
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 @@ gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
case EXPENSE_REGISTER:
case EQUITY_REGISTER:
case TRADING_REGISTER:
{
{
curs = gnc_table_layout_get_cursor (layout,
CURSOR_SINGLE_LEDGER);
@@ -104,13 +104,13 @@ gnc_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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_split_register_set_cells (SplitRegister *reg, TableLayout *layout)
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 @@ gnc_split_register_layout_add_cursors (SplitRegister *reg,
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;
}

View File

@@ -31,16 +31,16 @@
/** @file split-register-layout.h
* @brief Create the actual register visual layout
* @author Copyright (C) 1998, 2004 Linas Vepstas <linas@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.
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -33,8 +33,8 @@ void gnc_template_register_model_add_save_handlers (TableModel *model);
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);

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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 @@ Split * gnc_split_register_get_split (SplitRegister *reg,
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 @@ void gnc_split_register_show_trans (SplitRegister *reg,
// 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 @@ void gnc_split_register_set_last_num (SplitRegister *reg, const char *num);
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);

View File

@@ -39,114 +39,114 @@ static QofLogModule log_module = GNC_MOD_LEDGER;
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);
/* 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);
/* This split could be NULL during register initialization. */
if (split == NULL)
return NULL;
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 = gnc_split_register_get_split (reg, vcell_loc);
/* This split could be NULL during register initialization. */
if (split == NULL)
return NULL;
return xaccSplitGetParent(split);
}
Split *
@@ -154,45 +154,45 @@ gnc_split_register_get_trans_split (SplitRegister *reg,
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);
if (cursor_class == CURSOR_CLASS_TRANS)
{
if (trans_split_loc)
*trans_split_loc = vcell_loc;
return gnc_split_register_get_split (reg, vcell_loc);
}
vcell_loc.virt_row--;
}
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;
return gnc_split_register_get_split (reg, vcell_loc);
}
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 @@ gnc_split_register_find_split (SplitRegister *reg,
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 };
s = gnc_split_register_get_split (reg, vc_loc);
t = xaccSplitGetParent(s);
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 (cursor_class == CURSOR_CLASS_TRANS)
for (v_row = 1; v_row < table->num_virt_rows; v_row++)
for (v_col = 0; v_col < table->num_virt_cols; v_col++)
{
/* 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;
VirtualCellLocation vc_loc = { v_row, v_col };
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;
}
s = gnc_split_register_get_split (reg, vc_loc);
t = xaccSplitGetParent(s);
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 (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 (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;
}
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;
}
}
}
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;
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 (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;
cursor_class = gnc_split_register_get_cursor_class (reg, vc_loc);
if (cursor_class == CURSOR_CLASS_TRANS)
break;
if (cursor_class != CURSOR_CLASS_SPLIT)
for (v_row = end_loc.virt_row + 1;
v_row < reg->table->num_virt_rows; v_row++)
{
v_row--;
break;
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;
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 @@ gnc_split_register_set_trans_visible (SplitRegister *reg,
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)
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_SPLIT) == 0)
return CURSOR_CLASS_SPLIT;
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_SPLIT) == 0)
return CURSOR_CLASS_SPLIT;
return CURSOR_CLASS_NONE;
}

File diff suppressed because it is too large Load Diff

View File

@@ -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 @@ typedef enum
/** 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 @@ typedef struct sr_info SRInfo;
/** @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 @@ void gnc_split_register_config (SplitRegister *reg,
* @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 @@ void gnc_split_register_set_read_only (SplitRegister *reg, gboolean read_only);
* @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 @@ CursorClass gnc_split_register_get_current_cursor_class (SplitRegister *reg);
* @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 @@ Transaction * gnc_split_register_get_current_trans (SplitRegister *reg);
*/
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 @@ gnc_split_register_get_split_virt_loc (SplitRegister *reg, Split *split,
*/
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 @@ void gnc_split_register_delete_current_trans (SplitRegister *reg);
/** 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 @@ gboolean gnc_split_register_changed (SplitRegister *reg);
* 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);

View File

@@ -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 @@ gboolean
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);
}

View File

@@ -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 @@ typedef void (*CellModifyVerifyFunc) (BasicCell *cell,
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 void (*CellDestroyFunc) (BasicCell *cell);
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 @@ void gnc_basic_cell_set_name (BasicCell *cell, const char *name);
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 @@ gboolean gnc_basic_cell_get_conditionally_changed (BasicCell *cell);
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 */

View File

@@ -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 @@ gnc_cell_factory_add_cell_type (CellFactory *cf,
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 ();
}

View File

@@ -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 @@ static void gnc_cellblock_init (CellBlock *cellblock, int rows, int cols);
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 @@ gnc_cellblock_set_cell (CellBlock *cellblock,
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 @@ gnc_cellblock_get_cell_by_name(CellBlock *cellblock,
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 (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;
}
}
if (cellblock == 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;
}
}
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);
}
}

View File

@@ -34,7 +34,7 @@
* @author Copyright (c) 2000-2001 Dave Peticolas <dave@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 @@ BasicCell * gnc_cellblock_get_cell (CellBlock *cellblock,
* @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,

View File

@@ -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" : " ");
}

View File

@@ -41,9 +41,9 @@
typedef struct
{
BasicCell cell;
BasicCell cell;
gboolean flag;
gboolean flag;
} CheckboxCell;

View File

@@ -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@linas.org>
* @author Created Jan 1998 Linas Vepstas
* @author Copyright (c) 1998 Linas Vepstas <linas@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 @@ void gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict);
/** 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.

View File

@@ -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@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 @@ BasicCell * gnc_date_cell_new (void);
/* 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);

View File

@@ -43,48 +43,48 @@ static gboolean gnc_formula_cell_enter( BasicCell *_cell,
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 @@ gnc_formula_cell_enter( BasicCell *_cell,
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 @@ gnc_formula_cell_modify_verify( BasicCell *_cell,
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;
}
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);
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))
/* accept the newval string if user action was delete */
if (change == NULL)
{
gnc_basic_cell_set_value_internal( &cell->cell, newval );
return;
c = g_utf8_next_char (c);
}
}
gnc_basic_cell_set_value_internal( &cell->cell, newval );
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);
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 );
}
static
@@ -185,7 +185,7 @@ void
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 );
}

View File

@@ -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@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 */

View File

@@ -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_new (guint entry_size,
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 &gtable->array->data[index];
return &gtable->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;
entry = &gtable->array->data[new_len * gtable->entry_size];
for (i = new_len; i < old_len; i++)
/* If shrinking, destroy extra cells */
if ((new_len < old_len) && gtable->destroyer)
{
gtable->destroyer(entry, gtable->user_data);
entry += gtable->entry_size;
gchar *entry;
guint i;
entry = &gtable->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;
entry = &gtable->array->data[old_len * gtable->entry_size];
for (i = old_len; i < new_len; i++)
/* If expanding, construct the new cells */
if ((new_len > old_len) && gtable->constructor)
{
gtable->constructor(entry, gtable->user_data);
entry += gtable->entry_size;
}
}
gchar *entry;
guint i;
gtable->rows = rows;
gtable->cols = cols;
entry = &gtable->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;
}
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;
}

View File

@@ -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 (??)
*/

View File

@@ -52,27 +52,27 @@ static void gnc_num_cell_init (NumCell *cell);
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 @@ gnc_num_cell_modify_verify (BasicCell *_cell,
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 (gnc_parse_num (str, &number))
{
cell->next_num = number + 1;
cell->next_num_set = TRUE;
return TRUE;
}
if (!cell)
return FALSE;
if (gnc_parse_num (str, &number))
{
cell->next_num = number + 1;
cell->next_num_set = TRUE;
return TRUE;
}
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;
}

View File

@@ -31,7 +31,7 @@
* HISTORY:
* Copyright (c) 2000 Dave Peticolas <dave@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);

View File

@@ -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 @@ gnc_price_cell_enter (BasicCell *_cell,
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 @@ gnc_price_cell_modify_verify (BasicCell *_cell,
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;
}
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);
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);
}
/* 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)
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);
}
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)
if (!update_value)
return -1;
newval = gnc_price_cell_print_value (cell);
/* 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;
newval = gnc_price_cell_print_value (cell);
/* 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;
}
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 @@ gnc_price_cell_set_debt_credit_value (PriceCell * debit,
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);
}

View File

@@ -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 @@ void gnc_price_cell_blank (PriceCell *cell);
/* 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

View File

@@ -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 @@ gnc_quickfill_cell_enter (BasicCell *_cell,
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 @@ gnc_quickfill_cell_modify_verify (BasicCell *_cell,
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);
}

View File

@@ -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

View File

@@ -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 void gnc_recn_cell_set_value (BasicCell *_cell, const char *value);
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 @@ gnc_recn_cell_enter (BasicCell *_cell,
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;
}

View File

@@ -47,17 +47,17 @@ typedef gboolean (*RecnCellConfirm) (char old_flag, gpointer data);
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 @@ void gnc_recn_cell_set_flag (RecnCell *cell, char flag);
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 @@ void gnc_recn_cell_set_string_getter (RecnCell *cell,
* 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

View File

@@ -42,69 +42,69 @@ static CellFactory *global_factory = NULL;
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));
}

View File

@@ -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 @@ BasicCell * gnc_register_make_cell (const char *cell_type_name);
* 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 @@ gboolean virt_cell_loc_equal (VirtualCellLocation vcl1,
* 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;
};

File diff suppressed because it is too large Load Diff

View File

@@ -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 @@ virtual row 9 B
* 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 10 virtual row 8 S
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 @@ physical row 11 virtual row 9 B
/* 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 void (*TableDestroyCB) (Table *table);
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 @@ void gnc_table_destroy (Table *table);
/* 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_fg_color (Table *table, VirtualLocation virt_loc);
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 @@ const char * gnc_table_get_cell_name (Table *table,
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 @@ void gnc_table_set_vcell (Table *table, CellBlock *cursor,
/* 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 @@ void gnc_table_move_cursor_gui (Table *table, VirtualLocation virt_loc);
* 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 @@ gpointer gnc_table_get_vcell_data (Table *table,
* 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 @@ void gnc_table_realize_gui (Table *table);
/* 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 @@ void gnc_table_show_range (Table *table,
/* 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 @@ gboolean gnc_table_move_tab (Table *table,
* @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,

View File

@@ -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;
}

View File

@@ -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 gboolean (*TableTraverseFunc) (VirtualLocation *new_virt_loc,
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;

View File

@@ -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 @@ gnc_table_layout_get_cell_changed (TableLayout *layout,
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;
if (strcmp (list_cursor->cursor_name, cursor->cursor_name) == 0)
for (node = layout->cursors; node; node = node->next)
{
layout->cursors = g_list_remove (layout->cursors, list_cursor);
gnc_cellblock_destroy (list_cursor);
break;
}
}
CellBlock *list_cursor = node->data;
layout->cursors = g_list_append (layout->cursors, cursor);
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);
}
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;
for (node = layout->cursors; node; node = node->next)
{
CellBlock *cursor = node->data;
if (strcmp (cursor_name, cursor->cursor_name) == 0)
return cursor;
}
if (!cursor_name)
return NULL;
for (node = layout->cursors; node; node = node->next)
{
CellBlock *cursor = node->data;
if (strcmp (cursor_name, cursor->cursor_name) == 0)
return cursor;
}
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 @@ gnc_table_layout_set_cell (TableLayout *layout,
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 @@ gnc_table_layout_save_cursor (TableLayout *layout,
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 (!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;
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;
if (!bcell || !cb || !cursor)
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;
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;
}
}
}
void
@@ -416,18 +416,18 @@ gnc_table_layout_restore_cursor (TableLayout *layout,
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);
}
}

View File

@@ -47,10 +47,10 @@ void gnc_table_layout_add_cell (TableLayout *layout, BasicCell *cell);
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 @@ void gnc_table_layout_add_cursor (TableLayout *layout,
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,

View File

@@ -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 @@ gnc_table_model_handler_hash_insert (GHashTable *hash,
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 @@ gnc_table_model_set_entry_handler (TableModel *model,
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 @@ gnc_table_model_set_label_handler (TableModel *model,
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 @@ gnc_table_model_set_help_handler (TableModel *model,
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;
}

View File

@@ -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 void (*VirtCellDataCopy) (gpointer to, gconstpointer from);
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 @@ TableModel * gnc_table_model_new (void);
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

View File

@@ -1,6 +1,7 @@
#include <stdlib.h>
int
main(int argc, char ** argv) {
exit(0);
main(int argc, char ** argv)
{
exit(0);
}

File diff suppressed because it is too large Load Diff

View File

@@ -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 block_picker_signals (DateCell *cell);
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_date_cell_leave (BasicCell *bcell);
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 @@ gnc_date_cell_direct_update (BasicCell *bcell,
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;
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 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);
return TRUE;
}
static void
@@ -459,116 +459,116 @@ gnc_date_cell_modify_verify (BasicCell *_cell,
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 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 (box->in_date_select)
{
uc = g_utf8_get_char (c);
if (!g_unichar_isdigit (uc) && (separator != uc))
ok = FALSE;
if (separator == uc)
count++;
c = g_utf8_next_char (c);
gnc_basic_cell_set_value (_cell, newval);
return;
}
c = _cell->value;
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 (separator == uc)
count++;
/* 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);
c = g_utf8_next_char (c);
if (!g_unichar_isdigit (uc) && (separator != uc))
ok = FALSE;
if (separator == uc)
count++;
c = g_utf8_next_char (c);
}
c = _cell->value;
while (*c)
{
uc = g_utf8_get_char (c);
if (separator == uc)
count++;
c = g_utf8_next_char (c);
}
if (2 < count)
ok = FALSE;
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);
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 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 @@ get_popup_height (GnomeCanvasItem *item,
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 @@ gnc_date_cell_enter (BasicCell *bcell,
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);
}

View File

@@ -69,28 +69,28 @@ gnc_formula_cell_direct_update( BasicCell *bcell,
*/
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 @@ gnc_formula_cell_direct_update( BasicCell *bcell,
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;
}

View File

@@ -53,66 +53,66 @@ static GHashTable *color_hash_table = NULL;
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 @@ gnucash_color_alloc_name (const char *name, GdkColor *c)
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);
if (color)
return color;
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;
gnucash_color_alloc_gdk(color);
g_hash_table_insert (color_hash_table, newkey, color);
color = g_hash_table_lookup (color_hash_table, &key);
if (color)
return color;
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;
gnucash_color_alloc_gdk(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;
}

View File

@@ -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 @@ gnucash_cursor_set_property (GObject *object,
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 @@ gnucash_cursor_get_property (GObject *object,
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;
}

View File

@@ -44,52 +44,52 @@ GType gnucash_cursor_get_type (void);
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;

View File

@@ -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 @@ void
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;
}

View File

@@ -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 @@ void gnc_date_picker_get_date (GNCDatePicker *date_picker,
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;

File diff suppressed because it is too large Load Diff

View File

@@ -33,31 +33,33 @@
#define GNUCASH_IS_GRID(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNUCASH_TYPE_GRID))
typedef struct {
GnomeCanvasItem canvas_item;
typedef struct
{
GnomeCanvasItem canvas_item;
GnucashSheet *sheet;
GnucashSheet *sheet;
/* The first and last displayed block */
int top_block;
int bottom_block;
/* The first and last displayed block */
int top_block;
int bottom_block;
/* Offset from spreadsheet origin in units */
long top_offset;
long left_offset;
/* Offset from spreadsheet origin in units */
long top_offset;
long left_offset;
GdkGC *grid_gc; /* Draw grid gc */
GdkGC *fill_gc; /* Default background fill gc */
GdkGC *gc; /* Color used for the cell */
GdkGC *grid_gc; /* Draw grid gc */
GdkGC *fill_gc; /* Default background fill gc */
GdkGC *gc; /* Color used for the cell */
GdkColor background;
GdkColor grid_color;
GdkColor default_color;
GdkColor background;
GdkColor grid_color;
GdkColor default_color;
} GnucashGrid;
typedef struct {
GnomeCanvasItemClass parent_class;
typedef struct
{
GnomeCanvasItemClass parent_class;
} GnucashGridClass;
@@ -65,7 +67,7 @@ GType gnucash_grid_get_type (void);
GtkWidget *gnucash_grid_new (GnucashSheet *sheet);
gboolean gnucash_grid_find_loc_by_pixel (GnucashGrid *grid, gint x, gint y,
VirtualLocation *vcell_loc);
VirtualLocation *vcell_loc);
void gnucash_draw_hatching (GdkDrawable *drawable, GdkGC *gc,
int x, int y, int width, int height);

File diff suppressed because it is too large Load Diff

View File

@@ -31,34 +31,36 @@
GType gnc_header_get_type (void);
typedef struct {
GnomeCanvasItem canvas_item;
typedef struct
{
GnomeCanvasItem canvas_item;
GnucashSheet *sheet;
SheetBlockStyle *style;
GnucashSheet *sheet;
SheetBlockStyle *style;
char *cursor_name;
char *cursor_name;
int num_phys_rows;
int num_phys_rows;
int in_resize;
int resize_col_width;
int resize_x;
int resize_col;
int in_resize;
int resize_col_width;
int resize_x;
int resize_col;
gboolean needs_ungrab;
gboolean needs_ungrab;
int height;
int width;
int height;
int width;
GdkGC *gc;
GdkCursor *normal_cursor;
GdkCursor *resize_cursor;
GdkGC *gc;
GdkCursor *normal_cursor;
GdkCursor *resize_cursor;
} GncHeader;
typedef struct {
GnomeCanvasItemClass parent_class;
typedef struct
{
GnomeCanvasItemClass parent_class;
} GncHeaderClass;
@@ -66,7 +68,7 @@ GtkWidget *gnc_header_new (GnucashSheet *sheet);
void gnc_header_reconfigure (GncHeader *header);
void gnc_header_set_header_rows (GncHeader *header,
int num_phys_rows);
int num_phys_rows);
#endif /* GNUCASH_HEADER_H */

File diff suppressed because it is too large Load Diff

View File

@@ -53,58 +53,60 @@ typedef int (*PopupGetWidth) (GnomeCanvasItem *item,
typedef struct _PopupToggle PopupToggle;
struct _PopupToggle
{
GtkToggleButton *toggle_button;
GnomeCanvasItem *toggle_button_item;
GtkToggleButton *toggle_button;
GnomeCanvasItem *toggle_button_item;
gint toggle_offset;
gint toggle_offset;
GtkArrow *arrow;
GtkArrow *arrow;
gboolean signals_connected;
gboolean signals_connected;
};
typedef struct {
GnomeCanvasItem canvas_item;
typedef struct
{
GnomeCanvasItem canvas_item;
GnomeCanvasGroup *parent;
GnomeCanvasGroup *parent;
GnucashSheet *sheet;
GnucashSheet *sheet;
/* The editor whose status we reflect on the sheet */
GtkWidget *editor;
/* The editor whose status we reflect on the sheet */
GtkWidget *editor;
gchar *clipboard;
gchar *clipboard;
gboolean has_selection;
gboolean has_selection;
gboolean is_popup;
gboolean show_popup;
gboolean is_popup;
gboolean show_popup;
PopupToggle popup_toggle;
PopupToggle popup_toggle;
GnomeCanvasItem *popup_item;
GetPopupHeight get_popup_height;
PopupAutosize popup_autosize;
PopupSetFocus popup_set_focus;
PopupPostShow popup_post_show;
PopupGetWidth popup_get_width;
gpointer popup_user_data;
GnomeCanvasItem *popup_item;
GetPopupHeight get_popup_height;
PopupAutosize popup_autosize;
PopupSetFocus popup_set_focus;
PopupPostShow popup_post_show;
PopupGetWidth popup_get_width;
gpointer popup_user_data;
GdkGC *gc;
GdkGC *gc;
gboolean reset_pos;
gint x_offset;
gint anchor_pos;
gboolean reset_pos;
gint x_offset;
gint anchor_pos;
/* Where are we */
VirtualLocation virt_loc;
/* Where are we */
VirtualLocation virt_loc;
SheetBlockStyle *style;
SheetBlockStyle *style;
} GncItemEdit;
typedef struct {
GnomeCanvasItemClass parent_class;
typedef struct
{
GnomeCanvasItemClass parent_class;
} GncItemEditClass;
@@ -113,23 +115,23 @@ GType gnc_item_edit_get_type (void);
void gnc_item_edit_configure (GncItemEdit *item_edit);
void gnc_item_edit_get_pixel_coords (GncItemEdit *item_edit,
int *x, int *y,
int *w, int *h);
int *x, int *y,
int *w, int *h);
GnomeCanvasItem *gnc_item_edit_new (GnomeCanvasGroup *parent,
GnucashSheet *sheet, GtkWidget *entry);
GnucashSheet *sheet, GtkWidget *entry);
GncItemList * gnc_item_edit_new_list (GncItemEdit *item_edit, GtkListStore *shared_store);
GNCDatePicker * gnc_item_edit_new_date_picker (GncItemEdit *item_edit);
void gnc_item_edit_set_popup (GncItemEdit *item_edit,
GnomeCanvasItem *popup_item,
GetPopupHeight get_popup_height,
PopupAutosize popup_autosize,
PopupSetFocus popup_set_focus,
PopupPostShow popup_post_show,
PopupGetWidth popup_get_width,
gpointer popup_user_data);
GnomeCanvasItem *popup_item,
GetPopupHeight get_popup_height,
PopupAutosize popup_autosize,
PopupSetFocus popup_set_focus,
PopupPostShow popup_post_show,
PopupGetWidth popup_get_width,
gpointer popup_user_data);
void gnc_item_edit_show_popup (GncItemEdit *item_edit);
void gnc_item_edit_hide_popup (GncItemEdit *item_edit);
@@ -137,9 +139,9 @@ void gnc_item_edit_hide_popup (GncItemEdit *item_edit);
int gnc_item_edit_get_toggle_offset (int row_height);
gboolean gnc_item_edit_set_cursor_pos (GncItemEdit *item_edit,
VirtualLocation virt_loc, int x,
gboolean changed_cells,
gboolean extend_selection);
VirtualLocation virt_loc, int x,
gboolean changed_cells,
gboolean extend_selection);
void gnc_item_edit_redraw (GncItemEdit *item_edit);
@@ -152,16 +154,16 @@ void gnc_item_edit_set_has_selection (GncItemEdit *item_edit, gboolean has_selec
gboolean gnc_item_edit_get_has_selection (GncItemEdit *item_edit);
gboolean gnc_item_edit_selection_clear (GncItemEdit *item_edit,
GdkEventSelection *event);
GdkEventSelection *event);
void gnc_item_edit_selection_get (GncItemEdit *item_edit,
GtkSelectionData *selection_data,
guint info,
guint time);
GtkSelectionData *selection_data,
guint info,
guint time);
void gnc_item_edit_selection_received (GncItemEdit *item_edit,
GtkSelectionData *selection_data,
guint time);
GtkSelectionData *selection_data,
guint time);
void gnc_item_edit_focus_in (GncItemEdit *item_edit);
void gnc_item_edit_focus_out (GncItemEdit *item_edit);

View File

@@ -37,12 +37,13 @@
#include "gnucash-scrolled-window.h"
/* Item list signals */
enum {
SELECT_ITEM,
CHANGE_ITEM,
ACTIVATE_ITEM,
KEY_PRESS_EVENT,
LAST_SIGNAL
enum
{
SELECT_ITEM,
CHANGE_ITEM,
ACTIVATE_ITEM,
KEY_PRESS_EVENT,
LAST_SIGNAL
};
static GnomeCanvasWidgetClass *gnc_item_list_parent_class;
@@ -53,462 +54,468 @@ gboolean _gnc_item_find_selection(GtkTreeModel *model, GtkTreePath *path, GtkTre
gint
gnc_item_list_num_entries (GncItemList *item_list)
{
GtkTreeModel *model;
GtkTreeModel *model;
g_return_val_if_fail(item_list != NULL, 0);
g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), 0);
g_return_val_if_fail(item_list != NULL, 0);
g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), 0);
model = GTK_TREE_MODEL(item_list->list_store);
return gtk_tree_model_iter_n_children(model, NULL);
model = GTK_TREE_MODEL(item_list->list_store);
return gtk_tree_model_iter_n_children(model, NULL);
}
void
gnc_item_list_clear (GncItemList *item_list)
{
GtkTreeSelection* selection;
GtkTreeSelection* selection;
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
g_return_if_fail(item_list->list_store != NULL);
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
g_return_if_fail(item_list->list_store != NULL);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (item_list->tree_view));
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (item_list->tree_view));
g_signal_handlers_block_matched (G_OBJECT (selection), G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, item_list);
gtk_list_store_clear (item_list->list_store);
g_signal_handlers_unblock_matched (G_OBJECT (selection), G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, item_list);
g_signal_handlers_block_matched (G_OBJECT (selection), G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, item_list);
gtk_list_store_clear (item_list->list_store);
g_signal_handlers_unblock_matched (G_OBJECT (selection), G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, item_list);
}
void
gnc_item_list_append (GncItemList *item_list, const char *string)
{
GtkTreeIter iter;
GtkTreeIter iter;
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
g_return_if_fail(item_list->list_store != NULL);
g_return_if_fail(string != NULL);
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
g_return_if_fail(item_list->list_store != NULL);
g_return_if_fail(string != NULL);
gtk_list_store_append (item_list->list_store, &iter);
gtk_list_store_set (item_list->list_store, &iter, 0, string, -1);
gtk_list_store_append (item_list->list_store, &iter);
gtk_list_store_set (item_list->list_store, &iter, 0, string, -1);
}
void
gnc_item_list_set_sort_enabled(GncItemList *item_list, gboolean enabled)
{
if (enabled) {
gtk_tree_sortable_set_sort_column_id
(GTK_TREE_SORTABLE (item_list->list_store),
0,
GTK_SORT_ASCENDING);
} else {
gtk_tree_sortable_set_sort_column_id
(GTK_TREE_SORTABLE (item_list->list_store),
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
GTK_SORT_ASCENDING);
}
if (enabled)
{
gtk_tree_sortable_set_sort_column_id
(GTK_TREE_SORTABLE (item_list->list_store),
0,
GTK_SORT_ASCENDING);
}
else
{
gtk_tree_sortable_set_sort_column_id
(GTK_TREE_SORTABLE (item_list->list_store),
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
GTK_SORT_ASCENDING);
}
}
typedef struct _findSelectionData
{
GncItemList *item_list;
const char *string_to_find;
GtkTreePath *found_path;
GncItemList *item_list;
const char *string_to_find;
GtkTreePath *found_path;
} FindSelectionData;
gboolean
_gnc_item_find_selection(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
{
FindSelectionData *to_find = (FindSelectionData*)data;
gchar *iterStr;
gboolean found;
FindSelectionData *to_find = (FindSelectionData*)data;
gchar *iterStr;
gboolean found;
gtk_tree_model_get(model, iter, 0, &iterStr, -1);
found = safe_strcmp(to_find->string_to_find, iterStr) == 0;
g_free(iterStr);
if (found)
{
to_find->found_path = gtk_tree_path_copy(path);
return TRUE;
}
return FALSE;
gtk_tree_model_get(model, iter, 0, &iterStr, -1);
found = safe_strcmp(to_find->string_to_find, iterStr) == 0;
g_free(iterStr);
if (found)
{
to_find->found_path = gtk_tree_path_copy(path);
return TRUE;
}
return FALSE;
}
gboolean
gnc_item_in_list (GncItemList *item_list, const char *string)
{
FindSelectionData *to_find_data;
gboolean result;
FindSelectionData *to_find_data;
gboolean result;
g_return_val_if_fail(item_list != NULL, FALSE);
g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), FALSE);
g_return_val_if_fail(item_list != NULL, FALSE);
g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), FALSE);
to_find_data = (FindSelectionData*)g_new0(FindSelectionData, 1);
to_find_data->item_list = item_list;
to_find_data->string_to_find = string;
to_find_data = (FindSelectionData*)g_new0(FindSelectionData, 1);
to_find_data->item_list = item_list;
to_find_data->string_to_find = string;
gtk_tree_model_foreach(GTK_TREE_MODEL(item_list->list_store),
_gnc_item_find_selection,
to_find_data);
gtk_tree_model_foreach(GTK_TREE_MODEL(item_list->list_store),
_gnc_item_find_selection,
to_find_data);
result = (to_find_data->found_path != NULL);
g_free(to_find_data);
return result;
result = (to_find_data->found_path != NULL);
g_free(to_find_data);
return result;
}
void
gnc_item_list_select (GncItemList *item_list, const char *string)
{
GtkTreeSelection *tree_sel = NULL;
FindSelectionData *to_find_data;
GtkTreeSelection *tree_sel = NULL;
FindSelectionData *to_find_data;
g_return_if_fail(item_list != NULL);
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
g_return_if_fail(item_list != NULL);
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
tree_sel = gtk_tree_view_get_selection(item_list->tree_view);
tree_sel = gtk_tree_view_get_selection(item_list->tree_view);
if (string == NULL)
{
gtk_tree_selection_unselect_all(tree_sel);
return;
}
if (string == NULL)
{
gtk_tree_selection_unselect_all(tree_sel);
return;
}
to_find_data = (FindSelectionData*)g_new0(FindSelectionData, 1);
to_find_data->item_list = item_list;
to_find_data->string_to_find = string;
to_find_data = (FindSelectionData*)g_new0(FindSelectionData, 1);
to_find_data->item_list = item_list;
to_find_data->string_to_find = string;
gtk_tree_model_foreach(GTK_TREE_MODEL(item_list->list_store),
_gnc_item_find_selection,
to_find_data);
gtk_tree_model_foreach(GTK_TREE_MODEL(item_list->list_store),
_gnc_item_find_selection,
to_find_data);
if (to_find_data->found_path != NULL)
{
gtk_tree_view_set_cursor(item_list->tree_view, to_find_data->found_path, NULL, FALSE);
gtk_tree_path_free(to_find_data->found_path);
if (to_find_data->found_path != NULL)
{
gtk_tree_view_set_cursor(item_list->tree_view, to_find_data->found_path, NULL, FALSE);
gtk_tree_path_free(to_find_data->found_path);
gnc_item_list_show_selected(item_list);
}
gnc_item_list_show_selected(item_list);
}
g_free(to_find_data);
g_free(to_find_data);
}
void
gnc_item_list_show_selected (GncItemList *item_list)
{
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeModel *model;
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeModel *model;
g_return_if_fail(item_list != NULL);
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
g_return_if_fail(item_list != NULL);
g_return_if_fail(IS_GNC_ITEM_LIST(item_list));
selection = gtk_tree_view_get_selection (item_list->tree_view);
selection = gtk_tree_view_get_selection (item_list->tree_view);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
path = gtk_tree_model_get_path (model, &iter);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
path = gtk_tree_model_get_path (model, &iter);
gtk_tree_view_scroll_to_cell (item_list->tree_view,
path, NULL, TRUE, 0.5, 0.0);
}
gtk_tree_view_scroll_to_cell (item_list->tree_view,
path, NULL, TRUE, 0.5, 0.0);
}
}
int
gnc_item_list_autosize (GncItemList *item_list)
{
g_return_val_if_fail(item_list != NULL, 0);
g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), 0);
g_return_val_if_fail(item_list != NULL, 0);
g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), 0);
#if 0
return gtk_clist_columns_autosize (item_list->clist);
return gtk_clist_columns_autosize (item_list->clist);
#endif
return 100;
return 100;
}
static void
gnc_item_list_init (GncItemList *item_list)
{
item_list->tree_view = NULL;
item_list->list_store = NULL;
item_list->frame = NULL;
item_list->tree_view = NULL;
item_list->list_store = NULL;
item_list->frame = NULL;
}
static gboolean
gnc_item_list_button_event(GtkWidget *widget, GdkEventButton *event,
gpointer data)
gpointer data)
{
GncItemList *item_list;
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeModel *model;
gchar *string;
gboolean success;
GncItemList *item_list;
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeModel *model;
gchar *string;
gboolean success;
g_return_val_if_fail(IS_GNC_ITEM_LIST (data), FALSE);
g_return_val_if_fail(IS_GNC_ITEM_LIST (data), FALSE);
item_list = GNC_ITEM_LIST (data);
item_list = GNC_ITEM_LIST (data);
switch (event->button)
switch (event->button)
{
case 1:
if (!gtk_tree_view_get_path_at_pos (item_list->tree_view,
event->x,
event->y,
&path,
NULL,
NULL,
NULL))
{
case 1:
if(!gtk_tree_view_get_path_at_pos (item_list->tree_view,
event->x,
event->y,
&path,
NULL,
NULL,
NULL))
{
return FALSE;
}
gtk_tree_view_set_cursor (item_list->tree_view, path, NULL, FALSE);
model = GTK_TREE_MODEL (item_list->list_store);
success = gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_path_free (path);
if (!success)
return FALSE;
gtk_tree_model_get (model, &iter, 0, &string, -1);
g_signal_emit (G_OBJECT (item_list),
gnc_item_list_signals[ACTIVATE_ITEM],
0,
string);
g_free(string);
return TRUE;
default:
return FALSE;
return FALSE;
}
return FALSE;
gtk_tree_view_set_cursor (item_list->tree_view, path, NULL, FALSE);
model = GTK_TREE_MODEL (item_list->list_store);
success = gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_path_free (path);
if (!success)
return FALSE;
gtk_tree_model_get (model, &iter, 0, &string, -1);
g_signal_emit (G_OBJECT (item_list),
gnc_item_list_signals[ACTIVATE_ITEM],
0,
string);
g_free(string);
return TRUE;
default:
return FALSE;
}
return FALSE;
}
static gboolean
gnc_item_list_key_event (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
GncItemList *item_list = GNC_ITEM_LIST (data);
GtkTreeSelection *selection = NULL;
GtkTreeIter iter;
GtkTreeModel *model;
gchar *string;
GncItemList *item_list = GNC_ITEM_LIST (data);
GtkTreeSelection *selection = NULL;
GtkTreeIter iter;
GtkTreeModel *model;
gchar *string;
switch (event->keyval) {
case GDK_Return:
selection = gtk_tree_view_get_selection (item_list->tree_view);
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return FALSE;
switch (event->keyval)
{
case GDK_Return:
selection = gtk_tree_view_get_selection (item_list->tree_view);
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return FALSE;
gtk_tree_model_get (model, &iter, 0, &string, -1);
gtk_tree_model_get (model, &iter, 0, &string, -1);
g_signal_emit (G_OBJECT (item_list),
gnc_item_list_signals[ACTIVATE_ITEM],
0,
string);
g_free(string);
return TRUE;
g_signal_emit (G_OBJECT (item_list),
gnc_item_list_signals[ACTIVATE_ITEM],
0,
string);
g_free(string);
return TRUE;
case GDK_Page_Up:
case GDK_Page_Down:
case GDK_Up:
case GDK_Down:
/* These go to the clist */
return FALSE;
}
case GDK_Page_Up:
case GDK_Page_Down:
case GDK_Up:
case GDK_Down:
/* These go to the clist */
return FALSE;
}
/* These go to the sheet */
g_signal_stop_emission_by_name (G_OBJECT (widget), "key_press_event");
/* These go to the sheet */
g_signal_stop_emission_by_name (G_OBJECT (widget), "key_press_event");
g_signal_emit (G_OBJECT (item_list),
gnc_item_list_signals[KEY_PRESS_EVENT], 0, event);
g_signal_emit (G_OBJECT (item_list),
gnc_item_list_signals[KEY_PRESS_EVENT], 0, event);
return TRUE;
return TRUE;
}
static void
gnc_item_list_class_init (GncItemListClass *item_list_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (item_list_class);
GObjectClass *object_class = G_OBJECT_CLASS (item_list_class);
gnc_item_list_parent_class = g_type_class_peek_parent (item_list_class);
gnc_item_list_parent_class = g_type_class_peek_parent (item_list_class);
gnc_item_list_signals[SELECT_ITEM] =
g_signal_new ("select_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, select_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gnc_item_list_signals[SELECT_ITEM] =
g_signal_new ("select_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, select_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gnc_item_list_signals[CHANGE_ITEM] =
g_signal_new ("change_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, change_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gnc_item_list_signals[CHANGE_ITEM] =
g_signal_new ("change_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, change_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gnc_item_list_signals[ACTIVATE_ITEM] =
g_signal_new ("activate_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, activate_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gnc_item_list_signals[ACTIVATE_ITEM] =
g_signal_new ("activate_item",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, activate_item),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
gnc_item_list_signals[KEY_PRESS_EVENT] =
g_signal_new ("key_press_event",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, key_press_event),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
GDK_TYPE_EVENT);
gnc_item_list_signals[KEY_PRESS_EVENT] =
g_signal_new ("key_press_event",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(GncItemListClass, key_press_event),
NULL, NULL,
g_cclosure_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
GDK_TYPE_EVENT);
item_list_class->select_item = NULL;
item_list_class->change_item = NULL;
item_list_class->activate_item = NULL;
item_list_class->key_press_event = NULL;
item_list_class->select_item = NULL;
item_list_class->change_item = NULL;
item_list_class->activate_item = NULL;
item_list_class->key_press_event = NULL;
}
GType
gnc_item_list_get_type (void)
{
static GType gnc_item_list_type = 0;
static GType gnc_item_list_type = 0;
if (gnc_item_list_type == 0) {
static const GTypeInfo gnc_item_list_info = {
sizeof(GncItemListClass),
NULL,
NULL,
(GClassInitFunc) gnc_item_list_class_init,
NULL,
NULL,
sizeof(GncItemList),
0,
(GInstanceInitFunc) gnc_item_list_init
};
if (gnc_item_list_type == 0)
{
static const GTypeInfo gnc_item_list_info =
{
sizeof(GncItemListClass),
NULL,
NULL,
(GClassInitFunc) gnc_item_list_class_init,
NULL,
NULL,
sizeof(GncItemList),
0,
(GInstanceInitFunc) gnc_item_list_init
};
gnc_item_list_type =
g_type_register_static (gnome_canvas_widget_get_type(), "GncItemList",
&gnc_item_list_info, 0);
}
gnc_item_list_type =
g_type_register_static (gnome_canvas_widget_get_type(), "GncItemList",
&gnc_item_list_info, 0);
}
return gnc_item_list_type;
return gnc_item_list_type;
}
static void
tree_view_selection_changed (GtkTreeSelection *selection,
gpointer data)
gpointer data)
{
GncItemList *item_list = GNC_ITEM_LIST (data);
GtkTreeModel *model;
GtkTreeIter iter;
char *string;
GncItemList *item_list = GNC_ITEM_LIST (data);
GtkTreeModel *model;
GtkTreeIter iter;
char *string;
g_return_if_fail(data);
g_return_if_fail(selection);
g_return_if_fail(data);
g_return_if_fail(selection);
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return;
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return;
gtk_tree_model_get (model, &iter, 0, &string, -1);
gtk_tree_model_get (model, &iter, 0, &string, -1);
g_signal_emit (G_OBJECT (item_list), gnc_item_list_signals[CHANGE_ITEM], 0, string);
g_signal_emit (G_OBJECT (item_list), gnc_item_list_signals[CHANGE_ITEM], 0, string);
g_free (string);
g_free (string);
}
GnomeCanvasItem *
gnc_item_list_new(GnomeCanvasGroup *parent, GtkListStore *list_store)
{
GtkWidget *frame;
GtkWidget *tree_view;
GtkWidget *scrollwin;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GnomeCanvasItem *item;
GncItemList *item_list;
GtkWidget *frame;
GtkWidget *tree_view;
GtkWidget *scrollwin;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GnomeCanvasItem *item;
GncItemList *item_list;
frame = gtk_frame_new (NULL);
frame = gtk_frame_new (NULL);
scrollwin = gnc_scrolled_window_new ();
gtk_container_add (GTK_CONTAINER (frame), scrollwin);
scrollwin = gnc_scrolled_window_new ();
gtk_container_add (GTK_CONTAINER (frame), scrollwin);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
if (NULL == list_store)
list_store = gtk_list_store_new (1, G_TYPE_STRING);
else
g_object_ref(list_store);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
g_object_unref(list_store);
/* Removed code to enable sorting. Enable it after the list is
* fully populated by calling gnc_item_list_finished_loading(). */
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
GTK_SELECTION_BROWSE);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list_store),
0, GTK_SORT_ASCENDING);
if (NULL == list_store)
list_store = gtk_list_store_new (1, G_TYPE_STRING);
else
g_object_ref(list_store);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
g_object_unref(list_store);
/* Removed code to enable sorting. Enable it after the list is
* fully populated by calling gnc_item_list_finished_loading(). */
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("List"),
renderer,
"text", 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
GTK_SELECTION_BROWSE);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list_store),
0, GTK_SORT_ASCENDING);
gtk_container_add (GTK_CONTAINER (scrollwin), tree_view);
gtk_widget_show_all (frame);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("List"),
renderer,
"text", 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
item = gnome_canvas_item_new (parent, gnc_item_list_get_type(),
"widget", frame,
"size_pixels", TRUE,
"x", -10000.0,
"y", -10000.0,
NULL);
gtk_container_add (GTK_CONTAINER (scrollwin), tree_view);
gtk_widget_show_all (frame);
item_list = GNC_ITEM_LIST (item);
item = gnome_canvas_item_new (parent, gnc_item_list_get_type(),
"widget", frame,
"size_pixels", TRUE,
"x", -10000.0,
"y", -10000.0,
NULL);
item_list->tree_view = GTK_TREE_VIEW (tree_view);
item_list->list_store = list_store;
item_list->frame = frame;
item_list = GNC_ITEM_LIST (item);
g_signal_connect (G_OBJECT(tree_view), "button_press_event",
G_CALLBACK (gnc_item_list_button_event), item_list);
item_list->tree_view = GTK_TREE_VIEW (tree_view);
item_list->list_store = list_store;
item_list->frame = frame;
g_signal_connect (G_OBJECT (tree_view), "key_press_event",
G_CALLBACK (gnc_item_list_key_event), item_list);
g_signal_connect (G_OBJECT(tree_view), "button_press_event",
G_CALLBACK (gnc_item_list_button_event), item_list);
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view))), "changed",
G_CALLBACK (tree_view_selection_changed), item_list);
g_signal_connect (G_OBJECT (tree_view), "key_press_event",
G_CALLBACK (gnc_item_list_key_event), item_list);
return item;
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view))), "changed",
G_CALLBACK (tree_view_selection_changed), item_list);
return item;
}

View File

@@ -29,30 +29,30 @@
#define GNC_ITEM_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_ITEM_LIST, GncItemListClass))
#define IS_GNC_ITEM_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_ITEM_LIST))
typedef struct
typedef struct
{
GnomeCanvasWidget canvas_widget;
GnomeCanvasWidget canvas_widget;
GtkTreeView *tree_view;
GtkListStore *list_store; /* Contains the list items */
GtkWidget *frame; /* frame around everything */
GtkTreeView *tree_view;
GtkListStore *list_store; /* Contains the list items */
GtkWidget *frame; /* frame around everything */
} GncItemList;
typedef struct
{
GnomeCanvasWidgetClass parent_class;
GnomeCanvasWidgetClass parent_class;
void (*select_item) (GncItemList *item_list,
char *item_string);
void (*select_item) (GncItemList *item_list,
char *item_string);
void (*change_item) (GncItemList *item_list,
char *item_string);
void (*change_item) (GncItemList *item_list,
char *item_string);
void (*activate_item) (GncItemList *item_list,
char *item_string);
void (*activate_item) (GncItemList *item_list,
char *item_string);
void (*key_press_event) (GncItemList *item_list,
GdkEventKey *event);
void (*key_press_event) (GncItemList *item_list,
GdkEventKey *event);
} GncItemListClass;

View File

@@ -40,48 +40,50 @@ static void gnc_scrolled_window_init (GncScrolledWindow *scrollwin);
GType
gnc_scrolled_window_get_type (void)
{
static GType gnc_scrolled_window_type = 0;
static GType gnc_scrolled_window_type = 0;
if (!gnc_scrolled_window_type) {
static const GTypeInfo gnc_scrolled_window_info = {
sizeof (GncScrolledWindowClass),
NULL,
NULL,
(GClassInitFunc) gnc_scrolled_window_class_init,
NULL,
NULL,
sizeof (GncScrolledWindow),
0,
(GInstanceInitFunc) gnc_scrolled_window_init
};
gnc_scrolled_window_type = g_type_register_static (GTK_TYPE_SCROLLED_WINDOW,
"GncScrolledWindow",
&gnc_scrolled_window_info, 0);
}
if (!gnc_scrolled_window_type)
{
static const GTypeInfo gnc_scrolled_window_info =
{
sizeof (GncScrolledWindowClass),
NULL,
NULL,
(GClassInitFunc) gnc_scrolled_window_class_init,
NULL,
NULL,
sizeof (GncScrolledWindow),
0,
(GInstanceInitFunc) gnc_scrolled_window_init
};
return gnc_scrolled_window_type;
gnc_scrolled_window_type = g_type_register_static (GTK_TYPE_SCROLLED_WINDOW,
"GncScrolledWindow",
&gnc_scrolled_window_info, 0);
}
return gnc_scrolled_window_type;
}
GtkWidget *
gnc_scrolled_window_new (void)
{
return gtk_widget_new (GNC_TYPE_SCROLLED_WINDOW,
"hadjustment", NULL,
"vadjustment", NULL,
NULL);
return gtk_widget_new (GNC_TYPE_SCROLLED_WINDOW,
"hadjustment", NULL,
"vadjustment", NULL,
NULL);
}
static void
gnc_scrolled_window_class_init (GncScrolledWindowClass *class)
{
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS (class);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS (class);
parent_class = g_type_class_peek_parent (class);
parent_class = g_type_class_peek_parent (class);
scroll_class->scrollbar_spacing = 0;
scroll_class->scrollbar_spacing = 0;
}
static void

View File

@@ -35,12 +35,14 @@ G_BEGIN_DECLS
#define GNC_IS_SCROLLED_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCROLLED_WINDOW))
typedef struct {
GtkScrolledWindow scrollwin;
typedef struct
{
GtkScrolledWindow scrollwin;
} GncScrolledWindow;
typedef struct {
GtkScrolledWindowClass parent_class;
typedef struct
{
GtkScrolledWindowClass parent_class;
} GncScrolledWindowClass;

File diff suppressed because it is too large Load Diff

View File

@@ -45,118 +45,118 @@
typedef struct _SheetBlockStyle SheetBlockStyle;
typedef struct
typedef struct
{
/* The style for this block */
SheetBlockStyle *style;
/* The style for this block */
SheetBlockStyle *style;
gint origin_x; /* x origin of block */
gint origin_y; /* y origin of block */
gint origin_x; /* x origin of block */
gint origin_y; /* y origin of block */
gboolean visible; /* is block visible */
gboolean visible; /* is block visible */
} SheetBlock;
typedef struct
{
GnomeCanvas canvas;
GnomeCanvas canvas;
GtkWidget *window;
GtkWidget *window;
GtkWidget *popup;
gpointer popup_data;
GtkWidget *popup;
gpointer popup_data;
Table *table;
Table *table;
GtkWidget *reg;
GtkWidget *reg;
gint num_virt_rows;
gint num_virt_cols;
gint num_virt_rows;
gint num_virt_cols;
GnomeCanvasItem *header_item;
GnomeCanvasItem *cursor;
GnomeCanvasItem *grid;
GnomeCanvasItem *header_item;
GnomeCanvasItem *cursor;
GnomeCanvasItem *grid;
GHashTable *cursor_styles;
GHashTable *cursor_styles;
/* some style information associated to a sheet */
GHashTable *dimensions_hash_table;
/* some style information associated to a sheet */
GHashTable *dimensions_hash_table;
GTable *blocks;
GTable *blocks;
GnomeCanvasItem *item_editor;
GtkWidget *entry;
GnomeCanvasItem *item_editor;
GtkWidget *entry;
gboolean use_theme_colors;
gboolean use_horizontal_lines;
gboolean use_vertical_lines;
GtkWidget *header_color;
GtkWidget *primary_color;
GtkWidget *secondary_color;
GtkWidget *split_color;
gboolean use_theme_colors;
gboolean use_horizontal_lines;
gboolean use_vertical_lines;
GtkWidget *header_color;
GtkWidget *primary_color;
GtkWidget *secondary_color;
GtkWidget *split_color;
gboolean input_cancelled;
gboolean input_cancelled;
gint top_block; /* maybe not fully visible */
gint bottom_block;
gint left_block;
gint right_block;
gint top_block; /* maybe not fully visible */
gint bottom_block;
gint left_block;
gint right_block;
gint num_visible_blocks;
gint num_visible_phys_rows;
gint num_visible_blocks;
gint num_visible_phys_rows;
gint width; /* the width in pixels of the sheet */
gint height;
gint width; /* the width in pixels of the sheet */
gint height;
gint window_height;
gint window_width;
gint window_height;
gint window_width;
gint cell_borders;
gint cell_borders;
gint editing;
gint editing;
guint button; /* mouse button being held down */
gboolean grabbed; /* has the grab */
guint button; /* mouse button being held down */
gboolean grabbed; /* has the grab */
guint insert_signal;
guint delete_signal;
guint changed_signal;
guint insert_signal;
guint delete_signal;
guint changed_signal;
GtkAdjustment *hadj, *vadj;
GtkAdjustment *hadj, *vadj;
GFunc moved_cb;
gpointer moved_cb_data;
GFunc moved_cb;
gpointer moved_cb_data;
/* IMContext */
GtkIMContext *im_context;
gint preedit_length; /* num of bytes */
gint preedit_char_length; /* num of chars in UTF-8 */
gint preedit_start_position; /* save preedit start position *
/* IMContext */
GtkIMContext *im_context;
gint preedit_length; /* num of bytes */
gint preedit_char_length; /* num of chars in UTF-8 */
gint preedit_start_position; /* save preedit start position *
* combined with selection start */
gint preedit_cursor_position; /* save preedit cursor position */
gint preedit_selection_length;
PangoAttrList *preedit_attrs;
gboolean need_im_reset;
gboolean direct_update_cell;
guint commit_signal;
guint preedit_changed_signal;
guint retrieve_surrounding_signal;
guint delete_surrounding_signal;
gint preedit_cursor_position; /* save preedit cursor position */
gint preedit_selection_length;
PangoAttrList *preedit_attrs;
gboolean need_im_reset;
gboolean direct_update_cell;
guint commit_signal;
guint preedit_changed_signal;
guint retrieve_surrounding_signal;
guint delete_surrounding_signal;
guint shift_state;
guint shift_state;
} GnucashSheet;
typedef struct
{
GtkTable table;
GtkTable table;
GtkWidget *vscrollbar;
GtkWidget *hscrollbar;
GtkWidget *sheet;
GtkWidget *header_canvas;
gboolean hscrollbar_visible;
GtkWidget *vscrollbar;
GtkWidget *hscrollbar;
GtkWidget *sheet;
GtkWidget *header_canvas;
gboolean hscrollbar_visible;
} GnucashRegister;
@@ -187,15 +187,15 @@ void gnucash_sheet_redraw_block (GnucashSheet *sheet,
void gnucash_sheet_cursor_set (GnucashSheet *gsheet, VirtualLocation virt_loc);
const char * gnucash_sheet_modify_current_cell(GnucashSheet *sheet,
const gchar *new_text);
const gchar *new_text);
gboolean gnucash_sheet_block_set_from_table (GnucashSheet *sheet,
VirtualCellLocation vcell_loc);
VirtualCellLocation vcell_loc);
void gnucash_sheet_set_scroll_region (GnucashSheet *sheet);
void gnucash_sheet_cursor_set_from_table (GnucashSheet *sheet,
gboolean do_scroll);
gboolean do_scroll);
void gnucash_sheet_compute_visible_range (GnucashSheet *sheet);
@@ -217,11 +217,11 @@ void gnucash_register_goto_virt_loc (GnucashRegister *reg,
void gnucash_register_goto_next_virt_row (GnucashRegister *reg);
typedef gboolean (*VirtualLocationMatchFunc) (VirtualLocation virt_loc,
gpointer user_data);
gpointer user_data);
void gnucash_register_goto_next_matching_row (GnucashRegister *reg,
VirtualLocationMatchFunc match,
gpointer user_data);
VirtualLocationMatchFunc match,
gpointer user_data);
void gnucash_register_attach_popup(GnucashRegister *reg, GtkWidget *popup,
gpointer data);
@@ -234,21 +234,21 @@ void gnucash_register_copy_clipboard (GnucashRegister *reg);
void gnucash_register_paste_clipboard (GnucashRegister *reg);
void gnucash_register_refresh_from_gconf (GnucashRegister *reg);
void gnucash_register_set_moved_cb (GnucashRegister *reg,
GFunc cb, gpointer cb_data);
GFunc cb, gpointer cb_data);
typedef struct
{
GnomeCanvasClass parent_class;
GnomeCanvasClass parent_class;
} GnucashSheetClass;
typedef struct
{
GtkTableClass parent_class;
GtkTableClass parent_class;
void (*activate_cursor) (GnucashRegister *reg);
void (*redraw_all) (GnucashRegister *reg);
void (*redraw_help) (GnucashRegister *reg);
void (*activate_cursor) (GnucashRegister *reg);
void (*redraw_all) (GnucashRegister *reg);
void (*redraw_help) (GnucashRegister *reg);
} GnucashRegisterClass;
GdkColor *get_gtkrc_color (GnucashSheet *sheet, RegisterColor field_type);

File diff suppressed because it is too large Load Diff

View File

@@ -27,40 +27,40 @@
typedef struct
{
gint pixel_height;
gint pixel_width;
gint pixel_height;
gint pixel_width;
gint origin_x;
gint origin_y;
gint origin_x;
gint origin_y;
gboolean can_span_over;
gboolean can_span_over;
} CellDimensions;
typedef struct
{
gint nrows;
gint ncols;
gint nrows;
gint ncols;
/* totals, in pixels */
gint height;
gint width;
/* totals, in pixels */
gint height;
gint width;
/* per cell parameters */
GTable *cell_dimensions;
/* per cell parameters */
GTable *cell_dimensions;
gint refcount;
gint refcount;
} BlockDimensions;
struct _SheetBlockStyle
{
CellBlock * cursor;
CellBlock * cursor;
gint nrows;
gint ncols;
gint nrows;
gint ncols;
BlockDimensions *dimensions;
BlockDimensions *dimensions;
gint refcount;
gint refcount;
};
@@ -71,7 +71,7 @@ void gnucash_sheet_style_init(void);
gint gnucash_style_col_is_resizable (SheetBlockStyle *style, int col);
CellDimensions * gnucash_style_get_cell_dimensions (SheetBlockStyle *style,
int row, int col);
int row, int col);
void gnucash_sheet_set_col_width (GnucashSheet *sheet, int col, int width);
@@ -89,7 +89,7 @@ void gnucash_sheet_compile_styles (GnucashSheet *sheet);
void gnucash_sheet_styles_recompile (GnucashSheet *sheet);
SheetBlockStyle *gnucash_sheet_get_style (GnucashSheet *sheet,
VirtualCellLocation vcell_loc);
VirtualCellLocation vcell_loc);
SheetBlockStyle *
gnucash_sheet_get_style_from_table (GnucashSheet *sheet,
@@ -100,10 +100,10 @@ gnucash_sheet_get_style_from_cursor (GnucashSheet *sheet,
const char *cursor_name);
void gnucash_sheet_style_get_cell_pixel_rel_coords (SheetBlockStyle *style,
gint cell_row,
gint cell_col,
gint *x, gint *y,
gint *w, gint *h);
gint cell_row,
gint cell_col,
gint *x, gint *y,
gint *w, gint *h);
void gnucash_style_ref (SheetBlockStyle *style);
void gnucash_style_unref (SheetBlockStyle *style);

View File

@@ -21,9 +21,9 @@
/* pricecell-gnome.c
*
* Implements gnome dependent price cell functions :
*
* Often the decimal key in the keypad is not mapped to the correct locale
* decimal point, the function PriceDirect handle this case.
*
* Often the decimal key in the keypad is not mapped to the correct locale
* decimal point, the function PriceDirect handle this case.
*/
#include "config.h"
@@ -50,7 +50,7 @@ gnc_price_cell_direct_update (BasicCell *bcell,
gboolean is_return;
if (event->type != GDK_KEY_PRESS)
return FALSE;
return FALSE;
lc = gnc_localeconv ();
@@ -58,55 +58,55 @@ gnc_price_cell_direct_update (BasicCell *bcell,
switch (event->keyval)
{
case GDK_Return:
if (!(event->state &
(GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)))
is_return = TRUE;
/* fall through */
case GDK_Return:
if (!(event->state &
(GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)))
is_return = TRUE;
/* fall through */
case GDK_KP_Enter:
{
char *error_loc;
gnc_numeric amount;
gboolean parse_ok;
gboolean changed = FALSE;
case GDK_KP_Enter:
{
char *error_loc;
gnc_numeric amount;
gboolean parse_ok;
gboolean changed = FALSE;
if (!cell->need_to_parse)
return FALSE;
parse_ok = gnc_exp_parser_parse (cell->cell.value,
&amount, &error_loc);
if (parse_ok)
changed = gnc_price_cell_set_value (cell, amount);
else if (!cell->cell.value || cell->cell.value[0] == '\0')
changed = gnc_price_cell_set_value (cell,
gnc_numeric_zero ());
else
*cursor_position = error_loc - cell->cell.value;
/* If there is a problem with the parse, swallow
* the key so we stay put. */
if (!parse_ok)
return TRUE;
/* If nothing has changed, let the key cause a
* cursor activation no matter what. */
if (!changed)
return FALSE;
/* 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;
default:
if (!cell->need_to_parse)
return FALSE;
parse_ok = gnc_exp_parser_parse (cell->cell.value,
&amount, &error_loc);
if (parse_ok)
changed = gnc_price_cell_set_value (cell, amount);
else if (!cell->cell.value || cell->cell.value[0] == '\0')
changed = gnc_price_cell_set_value (cell,
gnc_numeric_zero ());
else
*cursor_position = error_loc - cell->cell.value;
/* If there is a problem with the parse, swallow
* the key so we stay put. */
if (!parse_ok)
return TRUE;
/* If nothing has changed, let the key cause a
* cursor activation no matter what. */
if (!changed)
return FALSE;
/* 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;
default:
return FALSE;
}
/* This point is only reached when the KP_Decimal key is pressed. */
@@ -119,20 +119,20 @@ gnc_price_cell_direct_update (BasicCell *bcell,
end_selection);
cell->need_to_parse = TRUE;
return TRUE;
}
BasicCell *
gnc_price_cell_gnome_new (void)
{
BasicCell *cell;
BasicCell *cell;
cell = gnc_price_cell_new ();
cell = gnc_price_cell_new ();
cell->direct_update = gnc_price_cell_direct_update;
cell->direct_update = gnc_price_cell_direct_update;
return cell;
return cell;
}
void
@@ -142,34 +142,34 @@ gnc_basic_cell_insert_decimal(BasicCell *bcell,
int *start_selection,
int *end_selection)
{
GString *newval_gs;
gint start, end;
gchar *buf;
GString *newval_gs;
gint start, end;
gchar *buf;
/* allocate space for newval_ptr : oldval + one letter ( the
decimal_point ) */
newval_gs = g_string_new("");
/* allocate space for newval_ptr : oldval + one letter ( the
decimal_point ) */
newval_gs = g_string_new("");
start = MIN(*start_selection, *end_selection);
end = MAX(*start_selection, *end_selection);
start = MIN(*start_selection, *end_selection);
end = MAX(*start_selection, *end_selection);
/* length in bytes, not chars. do not use g_utf8_strlen. */
buf = malloc(strlen(bcell->value)+1);
memset(buf, 0, strlen(bcell->value)+1);
g_utf8_strncpy(buf, bcell->value, start);
g_string_append(newval_gs, buf);
free(buf);
/* length in bytes, not chars. do not use g_utf8_strlen. */
buf = malloc(strlen(bcell->value) + 1);
memset(buf, 0, strlen(bcell->value) + 1);
g_utf8_strncpy(buf, bcell->value, start);
g_string_append(newval_gs, buf);
free(buf);
g_string_append_unichar(newval_gs, decimal_point);
g_string_append_unichar(newval_gs, decimal_point);
buf = g_utf8_offset_to_pointer(bcell->value, end);
g_string_append(newval_gs, buf);
buf = g_utf8_offset_to_pointer(bcell->value, end);
g_string_append(newval_gs, buf);
/* update the cursor position */
*cursor_position = start + 1;
/* update the cursor position */
*cursor_position = start + 1;
gnc_basic_cell_set_value_internal (bcell, newval_gs->str);
gnc_basic_cell_set_value_internal (bcell, newval_gs->str);
g_string_free (newval_gs, TRUE);
g_string_free (newval_gs, TRUE);
}

View File

@@ -43,70 +43,71 @@ gnc_quickfill_cell_direct_update (BasicCell *bcell,
int *end_selection,
void *gui_data)
{
QuickFillCell *cell = (QuickFillCell *) bcell;
GdkEventKey *event = gui_data;
const char *match_str;
QuickFill *match;
int prefix_len;
QuickFillCell *cell = (QuickFillCell *) bcell;
GdkEventKey *event = gui_data;
const char *match_str;
QuickFill *match;
int prefix_len;
if (event->type != GDK_KEY_PRESS)
return FALSE;
if (event->type != GDK_KEY_PRESS)
return FALSE;
switch (event->keyval) {
case GDK_slash:
if (!(event->state & GDK_MOD1_MASK))
return FALSE;
break;
case GDK_Tab:
case GDK_ISO_Left_Tab:
if (!(event->state & GDK_CONTROL_MASK))
return FALSE;
break;
default:
return FALSE;
}
switch (event->keyval)
{
case GDK_slash:
if (!(event->state & GDK_MOD1_MASK))
return FALSE;
break;
case GDK_Tab:
case GDK_ISO_Left_Tab:
if (!(event->state & GDK_CONTROL_MASK))
return FALSE;
break;
default:
return FALSE;
}
if ((*start_selection <= *cursor_position) &&
if ((*start_selection <= *cursor_position) &&
(*end_selection >= *cursor_position))
*cursor_position = *start_selection;
else if ((*end_selection <= *cursor_position) &&
(*start_selection >= *cursor_position))
*cursor_position = *end_selection;
*cursor_position = *start_selection;
else if ((*end_selection <= *cursor_position) &&
(*start_selection >= *cursor_position))
*cursor_position = *end_selection;
match = gnc_quickfill_get_string_len_match (cell->qf, bcell->value,
*cursor_position);
match = gnc_quickfill_get_string_len_match (cell->qf, bcell->value,
*cursor_position);
if (match == NULL)
return TRUE;
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) &&
if ((match_str != NULL) &&
(strncmp (match_str, bcell->value, strlen (bcell->value)) == 0) &&
(strcmp (match_str, bcell->value) != 0))
gnc_basic_cell_set_value (bcell, match_str);
gnc_basic_cell_set_value (bcell, match_str);
*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;
}
BasicCell *
gnc_quickfill_cell_gnome_new (void)
{
BasicCell *cell;
BasicCell *cell;
cell = gnc_quickfill_cell_new ();
cell = gnc_quickfill_cell_new ();
cell->direct_update = gnc_quickfill_cell_direct_update;
cell->direct_update = gnc_quickfill_cell_direct_update;
return cell;
return cell;
}
/*

View File

@@ -67,79 +67,80 @@ static QofLogModule log_module = GNC_MOD_REGISTER;
void
gnc_table_save_state (Table *table)
{
GnucashSheet *sheet;
GNCHeaderWidths widths;
GList *node;
gchar *key;
GnucashSheet *sheet;
GNCHeaderWidths widths;
GList *node;
gchar *key;
if (!table)
return;
if (!table)
return;
if (table->ui_data == NULL)
return;
if (table->ui_data == NULL)
return;
if (!gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL))
return;
if (!gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL))
return;
sheet = GNUCASH_SHEET (table->ui_data);
sheet = GNUCASH_SHEET (table->ui_data);
widths = gnc_header_widths_new ();
widths = gnc_header_widths_new ();
gnucash_sheet_get_header_widths (sheet, widths);
gnucash_sheet_get_header_widths (sheet, widths);
node = gnc_table_layout_get_cells (table->layout);
for (; node; node = node->next) {
BasicCell *cell = node->data;
int width;
node = gnc_table_layout_get_cells (table->layout);
for (; node; node = node->next)
{
BasicCell *cell = node->data;
int width;
width = gnc_header_widths_get_width (widths, cell->cell_name);
if (width <= 0)
continue;
width = gnc_header_widths_get_width (widths, cell->cell_name);
if (width <= 0)
continue;
if (cell->expandable)
continue;
if (cell->expandable)
continue;
/* Remember whether the column is visible */
key = g_strdup_printf("%s_width", cell->cell_name);
gnc_gconf_set_int(GCONF_SECTION, key, width, NULL);
g_free(key);
}
/* Remember whether the column is visible */
key = g_strdup_printf("%s_width", cell->cell_name);
gnc_gconf_set_int(GCONF_SECTION, key, width, NULL);
g_free(key);
}
gnc_header_widths_destroy (widths);
gnc_header_widths_destroy (widths);
}
static void
table_ui_redraw_cb (Table *table)
{
GnucashSheet *sheet;
GnucashSheet *sheet;
if (table == NULL)
return;
if (table == NULL)
return;
if (table->ui_data == NULL)
return;
if (table->ui_data == NULL)
return;
sheet = GNUCASH_SHEET (table->ui_data);
sheet = GNUCASH_SHEET (table->ui_data);
gnucash_sheet_redraw_help (sheet);
gnucash_sheet_redraw_help (sheet);
}
static void
table_destroy_cb (Table *table)
{
GnucashSheet *sheet;
GnucashSheet *sheet;
if (table == NULL)
return;
if (table == NULL)
return;
if (table->ui_data == NULL)
return;
if (table->ui_data == NULL)
return;
sheet = GNUCASH_SHEET (table->ui_data);
sheet = GNUCASH_SHEET (table->ui_data);
g_object_unref (sheet);
g_object_unref (sheet);
table->ui_data = NULL;
table->ui_data = NULL;
}
@@ -149,114 +150,116 @@ table_destroy_cb (Table *table)
void
gnc_table_init_gui (gncUIWidget widget, void *data)
{
GNCHeaderWidths widths;
GnucashSheet *sheet;
GnucashRegister *greg;
Table *table;
GList *node;
gchar *key;
guint value;
GNCHeaderWidths widths;
GnucashSheet *sheet;
GnucashRegister *greg;
Table *table;
GList *node;
gchar *key;
guint value;
g_return_if_fail (widget != NULL);
g_return_if_fail (GNUCASH_IS_REGISTER (widget));
g_return_if_fail (data != NULL);
g_return_if_fail (widget != NULL);
g_return_if_fail (GNUCASH_IS_REGISTER (widget));
g_return_if_fail (data != NULL);
ENTER("widget=%p, data=%p", widget, data);
ENTER("widget=%p, data=%p", widget, data);
greg = GNUCASH_REGISTER (widget);
sheet = GNUCASH_SHEET (greg->sheet);
table = sheet->table;
greg = GNUCASH_REGISTER (widget);
sheet = GNUCASH_SHEET (greg->sheet);
table = sheet->table;
table->gui_handlers.redraw_help = table_ui_redraw_cb;
table->gui_handlers.destroy = table_destroy_cb;
table->ui_data = sheet;
table->gui_handlers.redraw_help = table_ui_redraw_cb;
table->gui_handlers.destroy = table_destroy_cb;
table->ui_data = sheet;
g_object_ref (sheet);
g_object_ref (sheet);
/* config the cell-block styles */
/* config the cell-block styles */
widths = gnc_header_widths_new ();
widths = gnc_header_widths_new ();
if (gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL)) {
node = gnc_table_layout_get_cells (table->layout);
for (; node; node = node->next) {
BasicCell *cell = node->data;
if (gnc_gconf_get_bool(GCONF_GENERAL, KEY_SAVE_GEOMETRY, NULL))
{
node = gnc_table_layout_get_cells (table->layout);
for (; node; node = node->next)
{
BasicCell *cell = node->data;
if (cell->expandable)
continue;
if (cell->expandable)
continue;
/* Remember whether the column is visible */
key = g_strdup_printf("%s_width", cell->cell_name);
value = gnc_gconf_get_int(GCONF_SECTION, key, NULL);
if (value != 0)
gnc_header_widths_set_width (widths, cell->cell_name, value);
g_free(key);
}
}
/* Remember whether the column is visible */
key = g_strdup_printf("%s_width", cell->cell_name);
value = gnc_gconf_get_int(GCONF_SECTION, key, NULL);
if (value != 0)
gnc_header_widths_set_width (widths, cell->cell_name, value);
g_free(key);
}
}
gnucash_sheet_create_styles (sheet);
gnucash_sheet_create_styles (sheet);
gnucash_sheet_set_header_widths (sheet, widths);
gnucash_sheet_set_header_widths (sheet, widths);
gnucash_sheet_compile_styles (sheet);
gnucash_sheet_compile_styles (sheet);
gnucash_sheet_table_load (sheet, TRUE);
gnucash_sheet_cursor_set_from_table (sheet, TRUE);
gnucash_sheet_redraw_all (sheet);
gnucash_sheet_table_load (sheet, TRUE);
gnucash_sheet_cursor_set_from_table (sheet, TRUE);
gnucash_sheet_redraw_all (sheet);
gnc_header_widths_destroy (widths);
gnc_header_widths_destroy (widths);
LEAVE(" ");
LEAVE(" ");
}
void
gnc_table_refresh_gui (Table * table, gboolean do_scroll)
{
GnucashSheet *sheet;
GnucashSheet *sheet;
if (!table)
return;
if (!table->ui_data)
return;
if (!table)
return;
if (!table->ui_data)
return;
g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
sheet = GNUCASH_SHEET(table->ui_data);
sheet = GNUCASH_SHEET(table->ui_data);
gnucash_sheet_styles_recompile (sheet);
gnucash_sheet_table_load (sheet, do_scroll);
gnucash_sheet_redraw_all (sheet);
gnucash_sheet_styles_recompile (sheet);
gnucash_sheet_table_load (sheet, do_scroll);
gnucash_sheet_redraw_all (sheet);
}
static void
static void
gnc_table_refresh_cursor_gnome (Table * table,
VirtualCellLocation vcell_loc,
gboolean do_scroll)
{
GnucashSheet *sheet;
GnucashSheet *sheet;
if (!table || !table->ui_data)
return;
if (!table || !table->ui_data)
return;
g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
if (gnc_table_virtual_cell_out_of_bounds (table, vcell_loc))
return;
if (gnc_table_virtual_cell_out_of_bounds (table, vcell_loc))
return;
sheet = GNUCASH_SHEET (table->ui_data);
sheet = GNUCASH_SHEET (table->ui_data);
gnucash_sheet_cursor_set_from_table (sheet, do_scroll);
gnucash_sheet_cursor_set_from_table (sheet, do_scroll);
if (gnucash_sheet_block_set_from_table (sheet, vcell_loc))
{
gnucash_sheet_recompute_block_offsets (sheet);
gnucash_sheet_set_scroll_region (sheet);
gnucash_sheet_compute_visible_range (sheet);
gnucash_sheet_redraw_all (sheet);
}
else
gnucash_sheet_redraw_block (sheet, vcell_loc);
if (gnucash_sheet_block_set_from_table (sheet, vcell_loc))
{
gnucash_sheet_recompute_block_offsets (sheet);
gnucash_sheet_set_scroll_region (sheet);
gnucash_sheet_compute_visible_range (sheet);
gnucash_sheet_redraw_all (sheet);
}
else
gnucash_sheet_redraw_block (sheet, vcell_loc);
}
void
@@ -264,32 +267,32 @@ gnc_table_show_range (Table *table,
VirtualCellLocation start_loc,
VirtualCellLocation end_loc)
{
GnucashSheet *sheet;
GnucashSheet *sheet;
if (!table || !table->ui_data)
return;
if (!table || !table->ui_data)
return;
g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
g_return_if_fail (GNUCASH_IS_SHEET (table->ui_data));
if (gnc_table_virtual_cell_out_of_bounds (table, start_loc))
return;
if (gnc_table_virtual_cell_out_of_bounds (table, start_loc))
return;
if (gnc_table_virtual_cell_out_of_bounds (table, end_loc))
return;
if (gnc_table_virtual_cell_out_of_bounds (table, end_loc))
return;
sheet = GNUCASH_SHEET (table->ui_data);
sheet = GNUCASH_SHEET (table->ui_data);
gnucash_sheet_show_range (sheet, start_loc, end_loc);
gnucash_sheet_show_range (sheet, start_loc, end_loc);
}
void
gnc_table_gnome_init (void)
{
TableGUIHandlers gui_handlers;
TableGUIHandlers gui_handlers;
gui_handlers.cursor_refresh = gnc_table_refresh_cursor_gnome;
gui_handlers.cursor_refresh = gnc_table_refresh_cursor_gnome;
gnc_table_set_default_gui_handlers (&gui_handlers);
gnc_table_set_default_gui_handlers (&gui_handlers);
}
/*

View File

@@ -1,6 +1,7 @@
#include <stdlib.h>
int
main(int argc, char ** argv) {
exit(0);
main(int argc, char ** argv)
{
exit(0);
}