mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
2002-07-12 Joshua Sled <jsled@asynchronous.org>
* src/gnome/glade/sched-xact.glade: Glade-side UI cleanup. * src/gnome/druid-loan.c: Many updates; now uses GNCAccountSel, more inter-page consistency checks. UI cleanup * src/gnome-utils/gnc-account-sel.[ch]: Added; GTK combobox for selecting an Account. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7118 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7a4f46c88f
commit
b553819fba
@ -442,10 +442,6 @@ Frequency :
|
||||
[ same as Insurance ]
|
||||
--------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
|
||||
@ -473,3 +469,29 @@ Options in repayment:
|
||||
. sx grouping
|
||||
|
||||
http://www.interest.com/hugh/calc/mort_links.html
|
||||
|
||||
|
||||
===========================================================================
|
||||
===========================================================================
|
||||
|
||||
Druid Feedback:
|
||||
|
||||
|
||||
<Wilddev> jsled: <auspex> Wilddev: The labels need colons, mnemonics, and right-alignment.
|
||||
<Wilddev> <auspex> Wilddev: It may be worthwhile for gnucash to create GtkSpinButton subclasses which show the percent symbol and others within the field.
|
||||
<Wilddev> <auspex> Wilddev: I don't know how complicated that will be.
|
||||
<Wilddev> <Wilddev> me either :P
|
||||
<Wilddev> <auspex> Wilddev: The strings need review, but there may be other changes to make first.
|
||||
<Wilddev> <auspex> Wilddev: "Interest Rate Change Frequency" should perhaps be on the next page?
|
||||
<Wilddev> jsled: I dont know if you did another page for this, but shouldn't there be a field for ballon amount too?
|
||||
<jsled> Excellent feedback; thanks. I don't presently handle baloon payments; how do they work?
|
||||
<Wilddev> I think, from what I've read before, the are an amount you pay at the end of the loan to close it
|
||||
<jsled> gnc-account-sel == combo box account selection with pull-down account list [like the register] and auto-completion [hopefully]
|
||||
|
||||
<Wilddev> <auspex> Is "Length" the length of a period, or the sum of the periods?
|
||||
<jsled> The sum of all periods; the length of the loan.
|
||||
<Wilddev> he's suggesting to think of a better label for that
|
||||
<Wilddev> ah I thought it was the period between loan transactions
|
||||
<jsled> Hmm. Okay. The between-transaction period is a frequency editor on the Repayment page.
|
||||
<Wilddev> <auspex> I'm wondering if "Original Principal" should be a vulgate
|
||||
such as "Loan Amount"
|
||||
|
@ -25,6 +25,7 @@ libgncmod_gnome_utils_la_SOURCES = \
|
||||
dialog-options.c \
|
||||
dialog-utils.c \
|
||||
druid-utils.c \
|
||||
gnc-account-sel.c \
|
||||
gnc-account-tree.c \
|
||||
gnc-amount-edit.c \
|
||||
gnc-commodity-edit.c \
|
||||
@ -52,6 +53,7 @@ gncinclude_HEADERS = \
|
||||
dialog-options.h \
|
||||
dialog-utils.h \
|
||||
druid-utils.h \
|
||||
gnc-account-sel.h \
|
||||
gnc-account-tree.h \
|
||||
gnc-amount-edit.h \
|
||||
gnc-commodity-edit.h \
|
||||
|
301
src/gnome-utils/gnc-account-sel.c
Normal file
301
src/gnome-utils/gnc-account-sel.c
Normal file
@ -0,0 +1,301 @@
|
||||
/**
|
||||
* gnc-account-sel.c -- combobox style account selection widget, with
|
||||
* auto-completion.
|
||||
*
|
||||
* Copyright (C) 2002 Joshua Sled <jsled@asynchronous.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Gnucash is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License
|
||||
* as published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Gnucash is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gnc-account-sel.h"
|
||||
#include "gnc-exp-parser.h"
|
||||
#include "messages.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "gnc-engine-util.h"
|
||||
|
||||
#define ACCT_DATA_TAG "gnc-account-sel_acct"
|
||||
|
||||
/* Signal codes */
|
||||
enum
|
||||
{
|
||||
ACCOUNT_SEL_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static gint account_sel_signals [LAST_SIGNAL] = { 0 };
|
||||
|
||||
static void gnc_account_sel_init (GNCAccountSel *gas);
|
||||
static void gnc_account_sel_class_init (GNCAccountSelClass *class);
|
||||
static void gas_accounts_to_names( gpointer data, gpointer user_data );
|
||||
|
||||
#if 0
|
||||
static void gnc_account_sel_changed( GtkEditable *entry, gpointer ud );
|
||||
static void gnc_account_sel_list_clicked( GtkButton *b, gpointer ud );
|
||||
static gint gnc_account_sel_key_press( GtkWidget *widget,
|
||||
GdkEventKey *event );
|
||||
#endif /* 0 */
|
||||
|
||||
static GtkHBox *parent_class;
|
||||
|
||||
guint
|
||||
gnc_account_sel_get_type (void)
|
||||
{
|
||||
static guint account_sel_type = 0;
|
||||
|
||||
if (!account_sel_type){
|
||||
GtkTypeInfo account_sel_info = {
|
||||
"GNCAccountSel",
|
||||
sizeof (GNCAccountSel),
|
||||
sizeof (GNCAccountSelClass),
|
||||
(GtkClassInitFunc) gnc_account_sel_class_init,
|
||||
(GtkObjectInitFunc) gnc_account_sel_init,
|
||||
NULL,
|
||||
NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
|
||||
account_sel_type = gtk_type_unique (GTK_TYPE_HBOX, &account_sel_info);
|
||||
}
|
||||
|
||||
return account_sel_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_account_sel_class_init (GNCAccountSelClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
GtkHBoxClass *hbox_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
hbox_class = (GtkHBoxClass*) class;
|
||||
|
||||
parent_class = gtk_type_class (gtk_entry_get_type ());
|
||||
|
||||
account_sel_signals [ACCOUNT_SEL_CHANGED] =
|
||||
gtk_signal_new ("account_sel_changed",
|
||||
GTK_RUN_FIRST, object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GNCAccountSelClass,
|
||||
account_sel_changed),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class,
|
||||
account_sel_signals,
|
||||
LAST_SIGNAL);
|
||||
|
||||
class->account_sel_changed = NULL;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GList **outList;
|
||||
char accountSep;
|
||||
} accounts_to_names_data;
|
||||
|
||||
static void
|
||||
gnc_account_sel_init (GNCAccountSel *gas)
|
||||
{
|
||||
gas->initDone = FALSE;
|
||||
gas->combo = GTK_COMBO(gtk_combo_new());
|
||||
gtk_container_add( GTK_CONTAINER(gas), GTK_WIDGET(gas->combo) );
|
||||
|
||||
gtk_editable_set_editable( GTK_EDITABLE(gas->combo->entry), FALSE );
|
||||
#if 0
|
||||
gtk_signal_connect( GTK_OBJECT(gas->combo->entry), "changed",
|
||||
GTK_SIGNAL_FUNC( gnc_account_sel_changed ),
|
||||
gas );
|
||||
#endif /* 0 */
|
||||
|
||||
/* Get the accounts, place into combo list and setup GCompletion */
|
||||
{
|
||||
accounts_to_names_data atnd;
|
||||
AccountGroup *ag;
|
||||
GList *accts, *nameList;
|
||||
|
||||
ag = gnc_book_get_group( gnc_get_current_book() );
|
||||
accts = (GList*)xaccGroupGetSubAccounts( ag );
|
||||
nameList = NULL;
|
||||
atnd.outList = &nameList;
|
||||
atnd.accountSep = gnc_get_account_separator();
|
||||
g_list_foreach( accts, gas_accounts_to_names,
|
||||
(gpointer)&atnd );
|
||||
g_list_free( accts );
|
||||
|
||||
gtk_combo_set_popdown_strings( gas->combo, nameList );
|
||||
|
||||
gas->completion = g_completion_new( NULL );
|
||||
g_completion_add_items( gas->completion, nameList );
|
||||
}
|
||||
gas->initDone = TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
gas_accounts_to_names( gpointer data, gpointer user_data )
|
||||
{
|
||||
accounts_to_names_data *atnd;
|
||||
Account *a;
|
||||
|
||||
atnd = (accounts_to_names_data*)user_data;
|
||||
a = (Account*)data;
|
||||
*atnd->outList =
|
||||
g_list_append( *atnd->outList,
|
||||
xaccAccountGetFullName(a, atnd->accountSep) );
|
||||
}
|
||||
|
||||
#if 0 /* fscking gtk... */
|
||||
/*
|
||||
* There is apparently no way -- in GTK 1.x -- to programatically select a
|
||||
* region in the way we would like... so we've disallowed manual editing of
|
||||
* the Account string.
|
||||
*/
|
||||
static
|
||||
void
|
||||
gnc_account_sel_changed( GtkEditable *entry, gpointer ud )
|
||||
{
|
||||
gchar *s, *prefix;
|
||||
GNCAccountSel *gas = (GNCAccountSel*)ud;
|
||||
|
||||
if ( !gas->initDone ) {
|
||||
return;
|
||||
}
|
||||
s = gtk_editable_get_chars( entry, 0, -1 );
|
||||
g_completion_complete( gas->completion, s, &prefix );
|
||||
if ( prefix && (strlen(prefix) > 0) ) {
|
||||
printf( "changed into \"%s\"; longest completion: \"%s\"\n", s, prefix );
|
||||
gtk_signal_handler_block_by_func( GTK_OBJECT(gas->combo->entry),
|
||||
GTK_SIGNAL_FUNC(gnc_account_sel_changed),
|
||||
ud );
|
||||
gtk_entry_set_text( GTK_ENTRY(gas->combo->entry), prefix );
|
||||
gtk_editable_select_region( GTK_EDITABLE(gas->combo->entry),
|
||||
strlen(s), -1 );
|
||||
{
|
||||
GdkEventKey k;
|
||||
gboolean ret;
|
||||
|
||||
k.type = GDK_KEY_RELEASE;
|
||||
k.send_event = TRUE;
|
||||
k.state = GDK_SHIFT_MASK;
|
||||
k.keyval = GDK_End;
|
||||
k.length = 0;
|
||||
k.string = "";
|
||||
printf( "foo [%d : \"%s\"]\n", k.length, k.string );
|
||||
//gtk_widget_event( GTK_WIDGET(gas->combo->entry), &e );
|
||||
gtk_signal_emit_by_name( GTK_OBJECT(gas->combo->entry),
|
||||
"key-press-event",
|
||||
gas->combo->entry, &k, NULL, &ret );
|
||||
printf( "bar\n" );
|
||||
}
|
||||
gtk_editable_set_position( GTK_EDITABLE(gas->combo->entry),
|
||||
strlen(s) );
|
||||
gtk_signal_handler_unblock_by_func( GTK_OBJECT(gas->combo->entry),
|
||||
GTK_SIGNAL_FUNC(gnc_account_sel_changed),
|
||||
ud );
|
||||
g_free( prefix );
|
||||
}
|
||||
g_free( s );
|
||||
}
|
||||
|
||||
static
|
||||
gint
|
||||
gnc_account_sel_key_press(GtkWidget *widget, GdkEventKey *event)
|
||||
{
|
||||
GNCAccountSel *gas = GNC_ACCOUNT_SEL(widget);
|
||||
gint result;
|
||||
|
||||
result = (* GTK_WIDGET_CLASS (parent_class)->key_press_event)(widget, event);
|
||||
|
||||
switch (event->keyval)
|
||||
{
|
||||
case GDK_Tab:
|
||||
/* FIXME: += equivalent. */
|
||||
break;
|
||||
#if 0
|
||||
case GDK_DOWN:
|
||||
/* dispaly combobox */
|
||||
break;
|
||||
#endif /* 0 */
|
||||
case GDK_Return:
|
||||
#if 0
|
||||
if (gae->evaluate_on_enter)
|
||||
break;
|
||||
#endif /* 0 */
|
||||
if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK))
|
||||
break;
|
||||
return result;
|
||||
case GDK_KP_Enter:
|
||||
break;
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
GtkWidget *
|
||||
gnc_account_sel_new (void)
|
||||
{
|
||||
GNCAccountSel *gas;
|
||||
|
||||
gas = gtk_type_new (gnc_account_sel_get_type ());
|
||||
|
||||
return GTK_WIDGET (gas);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gnc_account_sel_gtk_entry (GNCAccountSel *gas)
|
||||
{
|
||||
g_return_val_if_fail(gas != NULL, NULL);
|
||||
g_return_val_if_fail(GNC_IS_ACCOUNT_SEL(gas), NULL);
|
||||
|
||||
return (GtkWidget *)gas->combo->entry;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct )
|
||||
{
|
||||
gchar *acctStr;
|
||||
|
||||
if ( acct == NULL ) {
|
||||
gtk_list_select_item( GTK_LIST(gas->combo->list), 0 );
|
||||
return;
|
||||
}
|
||||
acctStr = xaccAccountGetFullName( acct,
|
||||
gnc_get_account_separator() );
|
||||
gtk_entry_set_text( GTK_EDITABLE(gas->combo->entry), acctStr );
|
||||
g_free( acctStr );
|
||||
}
|
||||
|
||||
Account*
|
||||
gnc_account_sel_get_account( GNCAccountSel *gas )
|
||||
{
|
||||
AccountGroup *ag;
|
||||
Account *ret;
|
||||
gchar *txt;
|
||||
|
||||
txt = gtk_editable_get_chars( GTK_EDITABLE(gas->combo->entry), 0, -1 );
|
||||
ag = gnc_book_get_group( gnc_get_current_book() );
|
||||
ret = xaccGetAccountFromFullName( ag, txt, gnc_get_account_separator() );
|
||||
g_free( txt );
|
||||
return ret;
|
||||
}
|
71
src/gnome-utils/gnc-account-sel.h
Normal file
71
src/gnome-utils/gnc-account-sel.h
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* gnc-account-sel.h -- combobox style account selection widget, with
|
||||
* auto-completion.
|
||||
*
|
||||
* Copyright (C) 2002 Joshua Sled <jsled@asynchronous.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* GnuCash is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Gnucash is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org
|
||||
**/
|
||||
|
||||
#ifndef GNC_ACCOUNT_SEL_H
|
||||
#define GNC_ACCOUNT_SEL_H
|
||||
|
||||
#include <gnome.h>
|
||||
#include "Account.h"
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
#define GNC_ACCOUNT_SEL(obj) GTK_CHECK_CAST (obj, gnc_account_sel_get_type(), GNCAccountSel)
|
||||
#define GNC_ACCOUNT_SEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gnc_account_sel_get_type(), GNCAccountSelClass)
|
||||
#define GNC_IS_ACCOUNT_SEL(obj) GTK_CHECK_TYPE (obj, gnc_account_sel_get_type ())
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkHBox hbox;
|
||||
gboolean initDone;
|
||||
GtkCombo *combo;
|
||||
GCompletion *completion;
|
||||
} GNCAccountSel;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
/* Signals for notification/filtering of changes */
|
||||
void (*account_sel_changed) (GNCAccountSel *gas);
|
||||
} GNCAccountSelClass;
|
||||
|
||||
guint gnc_account_sel_get_type(void);
|
||||
GtkWidget* gnc_account_sel_new(void);
|
||||
GtkWidget* gnc_account_sel_gtk_entry(GNCAccountSel *gas);
|
||||
/**
|
||||
* Sets the GAS to the given account. If the account doesn't exist in the
|
||||
* list, then it doesn't change the state of the GAS. If the account is
|
||||
* NULL, then the first list selection is made.
|
||||
**/
|
||||
void gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct );
|
||||
/**
|
||||
* Returns the currently-selected Account. If, for some reason the selection
|
||||
* is in a bad state, NULL will be returned.
|
||||
**/
|
||||
Account* gnc_account_sel_get_account( GNCAccountSel *gas );
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* !ndef GNC_ACCOUNT_SEL_H */
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include "druid-loan.h"
|
||||
|
||||
#include "gnc-amount-edit.h"
|
||||
#include "gnc-account-sel.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "Account.h"
|
||||
@ -50,8 +52,6 @@
|
||||
# define PARAM_TABLE "param_table"
|
||||
# define ORIG_PRINC_GNE "orig_princ_gne"
|
||||
# define ORIG_PRINC_ENTRY "orig_princ_ent"
|
||||
# define CUR_PRINC_GNE "cur_princ_gne"
|
||||
# define CUR_PRINC_ENTRY "cur_princ_ent"
|
||||
# define IRATE_SPIN "irate_spin"
|
||||
# define TYPE_OPT "type_opt"
|
||||
# define VAR_CONTAINER "type_freq_frame"
|
||||
@ -101,7 +101,7 @@ typedef struct RepayOptData_ {
|
||||
char *txnMemo;
|
||||
float amount;
|
||||
gboolean throughEscrowP;
|
||||
Account *to;
|
||||
//Account *to;
|
||||
Account *from; // If NULL { If throughEscrowP, then through escrowP;
|
||||
// else: undefined.
|
||||
FreqSpec *fs; // If NULL, part of repayment; otherwise: defined here.
|
||||
@ -154,8 +154,7 @@ typedef enum {
|
||||
**/
|
||||
typedef struct LoanData_ {
|
||||
Account *primaryAcct;
|
||||
float principal;
|
||||
float principalLeft;
|
||||
gnc_numeric principal;
|
||||
float interestRate;
|
||||
LoanType type;
|
||||
FreqSpec *loanFreq;
|
||||
@ -189,10 +188,8 @@ typedef struct LoanDruidData_ {
|
||||
/* widgets */
|
||||
/* prm = params */
|
||||
GtkTable *prmTable;
|
||||
GnomeNumberEntry *prmOrigPrincGNE;
|
||||
GtkEntry *prmOrigPrincEntry;
|
||||
GnomeNumberEntry *prmCurPrincGNE;
|
||||
GtkEntry *prmCurPrincEntry;
|
||||
GNCAccountSel *prmAccountGAS;
|
||||
GNCAmountEdit *prmOrigPrincGAE;
|
||||
GtkSpinButton *prmIrateSpin;
|
||||
GtkOptionMenu *prmType;
|
||||
GtkFrame *prmVarFrame;
|
||||
@ -204,13 +201,15 @@ typedef struct LoanDruidData_ {
|
||||
|
||||
/* opt = options */
|
||||
GtkVBox *optVBox;
|
||||
GtkCheckButton *optEscrowOpt;
|
||||
GtkHBox *optEscrowHBox;
|
||||
|
||||
/* rep = repayment */
|
||||
GtkEntry *repTxnName;
|
||||
GtkTable *repTable;
|
||||
GnomeNumberEntry *repAmtGNE;
|
||||
GNCAccountSel *repAssetsFromGAS;
|
||||
GNCAccountSel *repPrincToGAS;
|
||||
GNCAccountSel *repIntToGAS;
|
||||
GNCAccountSel *repEscrowToGAS;
|
||||
GtkEntry *repAmtEntry;
|
||||
GtkOptionMenu *repRemainderOpt;
|
||||
GtkFrame *repFreqFrame;
|
||||
@ -220,6 +219,7 @@ typedef struct LoanDruidData_ {
|
||||
GtkEntry *payTxnName;
|
||||
GnomeNumberEntry *payAmtGNE;
|
||||
GtkEntry *payAmtEntry;
|
||||
GNCAccountSel *payAccountGAS;
|
||||
GtkTable *payTable;
|
||||
GtkRadioButton *payTxnFreqPartRb;
|
||||
GtkRadioButton *payTxnFreqUniqRb;
|
||||
@ -235,6 +235,7 @@ static void ld_destroy( GtkObject *o, gpointer ud );
|
||||
|
||||
static void ld_cancel_check( GnomeDruid *gd, LoanDruidData *ldd );
|
||||
|
||||
static void ld_prm_type_change( GtkButton *b, gpointer ud );
|
||||
static void ld_opt_toggled( GtkToggleButton *tb, gpointer ud );
|
||||
static void ld_opt_consistency( GtkToggleButton *tb, gpointer ud );
|
||||
static void ld_escrow_tog( GtkToggleButton *tb, gpointer ud );
|
||||
@ -285,8 +286,58 @@ gnc_ui_sx_loan_druid_create()
|
||||
/* get pointers to the various widgets */
|
||||
gnc_loan_druid_get_widgets( ldd );
|
||||
|
||||
/* FIXME: non-gladeable widget setup */
|
||||
/* non-gladeable widget setup */
|
||||
{
|
||||
|
||||
{
|
||||
int i;
|
||||
GtkAlignment *a;
|
||||
struct gas_in_tables_data {
|
||||
GNCAccountSel **loc;
|
||||
GtkTable *table;
|
||||
int left, right, top, bottom;
|
||||
} gas_data[] = {
|
||||
{ &ldd->prmAccountGAS, ldd->prmTable, 1, 4, 0, 1 },
|
||||
{ &ldd->repAssetsFromGAS, ldd->repTable, 1, 2, 2, 3 },
|
||||
{ &ldd->repPrincToGAS, ldd->repTable, 1, 2, 3, 4 },
|
||||
{ &ldd->repIntToGAS, ldd->repTable, 1, 2, 4, 5 },
|
||||
{ &ldd->repEscrowToGAS, ldd->repTable, 1, 2, 5, 6 },
|
||||
{ &ldd->payAccountGAS, ldd->payTable, 1, 2, 2, 3 },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* left-aligned, 25%-width */
|
||||
a = GTK_ALIGNMENT(gtk_alignment_new( 0.0, 0.5, 0.25, 1.0 ));
|
||||
ldd->prmOrigPrincGAE = GNC_AMOUNT_EDIT(gnc_amount_edit_new());
|
||||
gtk_container_add( GTK_CONTAINER(a), GTK_WIDGET(ldd->prmOrigPrincGAE) );
|
||||
gtk_table_attach( ldd->prmTable, GTK_WIDGET(a),
|
||||
1, 4, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL,
|
||||
GTK_EXPAND | GTK_FILL, 2, 2 );
|
||||
|
||||
for ( i=0; gas_data[i].loc != NULL; i++ ) {
|
||||
GNCAccountSel *gas;
|
||||
|
||||
a = GTK_ALIGNMENT(gtk_alignment_new( 0.0, 0.5, 0.25, 1.0 ));
|
||||
gas = GNC_ACCOUNT_SEL(gnc_account_sel_new());
|
||||
gtk_container_add( GTK_CONTAINER(a),
|
||||
GTK_WIDGET(gas) );
|
||||
gtk_table_attach( gas_data[i].table,
|
||||
GTK_WIDGET(a),
|
||||
gas_data[i].left,
|
||||
gas_data[i].right,
|
||||
gas_data[i].top,
|
||||
gas_data[i].bottom,
|
||||
GTK_EXPAND | GTK_FILL,
|
||||
GTK_EXPAND | GTK_FILL, 2, 2 );
|
||||
*(gas_data[i].loc) = gas;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive( ldd->prmVarFrame, FALSE );
|
||||
gtk_signal_connect( GTK_OBJECT(ldd->prmType), "clicked",
|
||||
GTK_SIGNAL_FUNC(ld_prm_type_change), (gpointer)ldd );
|
||||
|
||||
{
|
||||
GtkAdjustment *a;
|
||||
|
||||
@ -314,22 +365,16 @@ gnc_ui_sx_loan_druid_create()
|
||||
gnc_option_menu_init( GTK_WIDGET(ldd->prmLengthType) );
|
||||
gnc_option_menu_init( GTK_WIDGET(ldd->repRemainderOpt) );
|
||||
|
||||
/* PARAM_TABLE(0,1) += account sel */
|
||||
/* OPT_ESCROW_CONTAINER += account sel */
|
||||
{
|
||||
}
|
||||
|
||||
/* OPT_CONTAINER += option options. */
|
||||
/* . Each RepayOpt gets an entry in the optContainer.
|
||||
* . Each "entry" is a 2-line vbox containing:
|
||||
* . The checkbox for the option itself
|
||||
* . an alignment-contained sub-checkbox for "through the
|
||||
* escrow account".
|
||||
* . Hook up each to bit-twiddling the appropriate line.
|
||||
*/
|
||||
|
||||
/* FIXME : too deep, factor out. */
|
||||
{
|
||||
/* . Each RepayOpt gets an entry in the optContainer.
|
||||
* . Each "entry" is a 2-line vbox containing:
|
||||
* . The checkbox for the option itself
|
||||
* . an alignment-contained sub-checkbox for "through the
|
||||
* escrow account".
|
||||
* . Hook up each to bit-twiddling the appropriate line.
|
||||
*/
|
||||
|
||||
RepayOptUIData *rouid;
|
||||
GtkVBox *vb;
|
||||
GtkAlignment *optAlign, *subOptAlign;
|
||||
@ -398,13 +443,13 @@ gnc_ui_sx_loan_druid_create()
|
||||
GNC_FREQUENCY(gnc_frequency_new( NULL, NULL ));
|
||||
gtk_container_add( GTK_CONTAINER(ldd->payFreqAlign),
|
||||
GTK_WIDGET(ldd->payGncFreq) );
|
||||
/* FIXME: Repayment/Payment[s] pages += account sel */
|
||||
}
|
||||
|
||||
gnc_register_gui_component( DIALOG_LOAN_DRUID_CM_CLASS,
|
||||
NULL, /* no refresh handler */
|
||||
ld_close_handler,
|
||||
(GNCComponentCloseHandler*)ld_close_handler,
|
||||
ldd );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(ldd->dialog), "destroy",
|
||||
GTK_SIGNAL_FUNC(ld_destroy),
|
||||
ldd );
|
||||
@ -465,6 +510,7 @@ gnc_loan_druid_data_init( LoanDruidData *ldd )
|
||||
|
||||
ldd->currentIdx = -1;
|
||||
|
||||
ldd->ld.principal = gnc_numeric_zero();
|
||||
ldd->ld.startDate = g_date_new();
|
||||
ldd->ld.varStartDate = g_date_new();
|
||||
g_date_set_time( ldd->ld.startDate, time(NULL) );
|
||||
@ -507,14 +553,6 @@ gnc_loan_druid_get_widgets( LoanDruidData *ldd )
|
||||
/* prm = params */
|
||||
ldd->prmTable =
|
||||
GET_CASTED_WIDGET( GTK_TABLE, PARAM_TABLE );
|
||||
ldd->prmOrigPrincGNE =
|
||||
GET_CASTED_WIDGET( GNOME_NUMBER_ENTRY, ORIG_PRINC_GNE );
|
||||
ldd->prmOrigPrincEntry =
|
||||
GET_CASTED_WIDGET( GTK_ENTRY, ORIG_PRINC_ENTRY );
|
||||
ldd->prmCurPrincGNE =
|
||||
GET_CASTED_WIDGET( GNOME_NUMBER_ENTRY, CUR_PRINC_GNE );
|
||||
ldd->prmCurPrincEntry =
|
||||
GET_CASTED_WIDGET( GTK_ENTRY, CUR_PRINC_ENTRY );
|
||||
ldd->prmIrateSpin =
|
||||
GET_CASTED_WIDGET( GTK_SPIN_BUTTON, IRATE_SPIN );
|
||||
ldd->prmType =
|
||||
@ -533,10 +571,6 @@ gnc_loan_druid_get_widgets( LoanDruidData *ldd )
|
||||
/* opt = options */
|
||||
ldd->optVBox =
|
||||
GET_CASTED_WIDGET( GTK_VBOX, OPT_CONTAINER );
|
||||
ldd->optEscrowOpt =
|
||||
GET_CASTED_WIDGET( GTK_CHECK_BUTTON, OPT_ESCROW );
|
||||
ldd->optEscrowHBox =
|
||||
GET_CASTED_WIDGET( GTK_HBOX, OPT_ESCROW_CONTAINER );
|
||||
|
||||
/* rep = repayment */
|
||||
ldd->repTxnName =
|
||||
@ -608,6 +642,17 @@ ld_cancel_check( GnomeDruid *gd, LoanDruidData *ldd )
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
ld_prm_type_change( GtkButton *b, gpointer ud )
|
||||
{
|
||||
LoanDruidData *ldd;
|
||||
|
||||
ldd = (LoanDruidData*)ud;
|
||||
gtk_widget_set_sensitive( ldd->prmVarFrame,
|
||||
gnc_option_menu_get_active( ldd->prmType ) );
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
ld_opt_toggled( GtkToggleButton *tb, gpointer ud )
|
||||
@ -648,13 +693,15 @@ static
|
||||
gboolean
|
||||
ld_info_save( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
|
||||
{
|
||||
LoanDruidData *ldd;
|
||||
float amt;
|
||||
gchar *txt;
|
||||
float amt;
|
||||
LoanDruidData *ldd;
|
||||
|
||||
ldd = (LoanDruidData*)ud;
|
||||
|
||||
/* FIXME: account */
|
||||
ldd->ld.principal = gnc_amount_edit_get_amount( ldd->prmOrigPrincGAE );
|
||||
#if 0
|
||||
txt = gtk_editable_get_chars( GTK_EDITABLE(ldd->prmOrigPrincEntry),
|
||||
0, -1 );
|
||||
amt = -1.0;
|
||||
@ -666,16 +713,7 @@ ld_info_save( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
|
||||
}
|
||||
ldd->ld.principal = amt;
|
||||
g_free( txt );
|
||||
txt = gtk_editable_get_chars( GTK_EDITABLE(ldd->prmCurPrincEntry),
|
||||
0, -1 );
|
||||
amt = -1.0;
|
||||
amt = (float)strtod( txt, NULL );
|
||||
if ( amt < 0 ) {
|
||||
gnc_error_dialog( _("The current principal must "
|
||||
"be a valid number.") );
|
||||
return TRUE;
|
||||
}
|
||||
ldd->ld.principalLeft = amt;
|
||||
#endif /* 0 */
|
||||
ldd->ld.interestRate =
|
||||
gtk_spin_button_get_value_as_float( ldd->prmIrateSpin );
|
||||
ldd->ld.type = gnc_option_menu_get_active( GTK_WIDGET(ldd->prmType) );
|
||||
@ -714,15 +752,19 @@ void
|
||||
ld_info_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
|
||||
{
|
||||
LoanDruidData *ldd;
|
||||
GString *str;
|
||||
|
||||
ldd = (LoanDruidData*)ud;
|
||||
str = g_string_sized_new( 16 );
|
||||
/* FIXME: account. */
|
||||
g_string_sprintf( str, "%0.2f", ldd->ld.principal );
|
||||
gnc_amount_edit_set_amount( ldd->prmOrigPrincGAE, ldd->ld.principal );
|
||||
#if 0
|
||||
{
|
||||
GString *str;
|
||||
str = g_string_sized_new( 16 );
|
||||
g_string_sprintf( str, "%0.2f", ldd->principal );
|
||||
gtk_entry_set_text( ldd->prmOrigPrincEntry, str->str );
|
||||
g_string_sprintf( str, "%0.2f", ldd->ld.principalLeft );
|
||||
gtk_entry_set_text( ldd->prmCurPrincEntry, str->str );
|
||||
g_string_free( str, TRUE );
|
||||
}
|
||||
#endif /* 0 */
|
||||
gtk_spin_button_set_value( ldd->prmIrateSpin, ldd->ld.interestRate );
|
||||
gtk_option_menu_set_history( ldd->prmType, ldd->ld.type );
|
||||
if ( ldd->ld.type != FIXED ) {
|
||||
@ -752,8 +794,6 @@ ld_info_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
|
||||
// prmRemainSpin
|
||||
gtk_spin_button_set_value( ldd->prmRemainSpin, ldd->ld.numPerRemain );
|
||||
}
|
||||
|
||||
g_string_free( str, TRUE );
|
||||
}
|
||||
|
||||
static
|
||||
@ -830,6 +870,9 @@ ld_pay_prep( GnomeDruidPage *gdp, gpointer arg1, gpointer ud )
|
||||
g_string_sprintf( str, "%0.2f", rod->amount );
|
||||
gtk_entry_set_text( ldd->payAmtEntry, str->str );
|
||||
|
||||
gnc_account_sel_set_account( ldd->payAccountGAS,
|
||||
rod->from );
|
||||
|
||||
uniq = (rod->fs != NULL);
|
||||
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ldd->payTxnFreqPartRb),
|
||||
!uniq );
|
||||
@ -869,6 +912,8 @@ ld_pay_save_current( LoanDruidData *ldd )
|
||||
rod->amount = (float)strtod( tmpStr, NULL );
|
||||
g_free( tmpStr );
|
||||
|
||||
rod->from = gnc_account_sel_get_account( ldd->payAccountGAS );
|
||||
|
||||
/* if ( rb toggled )
|
||||
* ensure freqspec/startdate setup
|
||||
* save
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user