* move QuickFill and dialog-transfer into gnome-utils

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7583 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2002-12-01 22:01:14 +00:00
parent 0b5f8465a6
commit ab59987d75
12 changed files with 160 additions and 55 deletions

View File

@@ -1,3 +1,7 @@
2002-12-01 Derek Atkins <derek@ihtfp.com>
* move QuickFill and dialog-transfer into gnome-utils
2002-12-01 Joshua Sled <jsled@asynchronous.org>
* src/app-utils/gnc-helpers.c (g_date_equals, g_date_hash): Added

View File

@@ -19,12 +19,14 @@ AM_CFLAGS = \
${G_WRAP_COMPILE_ARGS}
libgncmod_gnome_utils_la_SOURCES = \
QuickFill.c \
cursors.c \
argv-list-converters.c \
dialog-account.c \
dialog-account-pick.c \
dialog-commodity.c \
dialog-options.c \
dialog-transfer.c \
dialog-utils.c \
druid-utils.c \
gnc-account-sel.c \
@@ -51,10 +53,12 @@ libgncmod_gnome_utils_la_SOURCES = \
gncincludedir = ${GNC_INCLUDE_DIR}
gncinclude_HEADERS = \
QuickFill.h \
dialog-account.h \
dialog-account-pick.h \
dialog-commodity.h \
dialog-options.h \
dialog-transfer.h \
dialog-utils.h \
druid-utils.h \
gnc-account-sel.h \
@@ -117,7 +121,8 @@ gncscm_DATA = gnc-menu-extensions.scm
gladedir = $(GNC_GLADE_DIR)
glade_DATA = \
commodity.glade \
exchange-dialog.glade
exchange-dialog.glade \
transfer.glade
EXTRA_DIST = \
.cvsignore \

View File

@@ -33,7 +33,6 @@
#endif
#include "QuickFill.h"
#include "basiccell.h"
#include "dialog-utils.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"

View File

@@ -29,18 +29,21 @@
#include "gnc-numeric.h"
#include "date.h"
typedef struct _exchange_window ExchangeDialog;
void gnc_ui_exchange_dialog_destroy (ExchangeDialog * w);
/* Create a dialog to enter an exchange rate. Looks in the pricedb
* for entries; stores entries in the pricedb.
/* Create a dialog to enter/modify an Split's exchange rate. Look in
* the pricedb for potential entries if exchange_rate points to a
* 'zero' value; new/changed entries are stored in the pricedb
* (overwriting existing pricedb entries if they exist).
*
* If the run was successful (user hit 'ok'), fill in the (new)
* exchange rate, store it in the pricedb, and return TRUE. Otherwise
* return FALSE (and do not touch exchange_rate)
*/
ExchangeDialog *
gnc_ui_exchange_dialog_full (GNCPriceDB * pricedb,
gnc_numeric amount,
gnc_commodity * from,
gnc_commodity * to,
Timespec date);
gboolean
gnc_ui_exchange_dialog_new (GNCPriceDB * pricedb,
gnc_numeric amount,
gnc_commodity * from,
gnc_commodity * to,
Timespec date,
gnc_numeric * exchange_rate);
#endif /* GNC_DIALOG_EXCHANGE_H */

View File

@@ -37,10 +37,10 @@
#include "gnc-euro.h"
#include "gnc-exp-parser.h"
#include "gnc-gui-query.h"
#include "gnc-ledger-display.h"
#include "gnc-ui.h"
#include "messages.h"
#include "window-reconcile.h"
#include "Transaction.h"
#include "Account.h"
#define DIALOG_TRANSFER_CM_CLASS "dialog-transfer"
@@ -94,6 +94,11 @@ struct _xferDialog
GtkWidget * amount_radio;
GtkTooltips *tips;
/* Where to store the "to_amount" at exit (in lieu of
* creating a transaction)
*/
gnc_numeric * to_amount;
};
struct _acct_list_item
@@ -900,7 +905,8 @@ gnc_xfer_dialog_select_to_account(XferDialog *xferData, Account *account)
static void
gnc_xfer_dialog_lock_account_tree(XferDialog *xferData,
XferDirection direction)
XferDirection direction,
gboolean hide)
{
GNCAccountTree *tree;
GtkWidget *show_button;
@@ -924,6 +930,11 @@ gnc_xfer_dialog_lock_account_tree(XferDialog *xferData,
gtk_widget_set_sensitive( GTK_WIDGET(tree), FALSE );
gtk_widget_set_sensitive( GTK_WIDGET(show_button), FALSE );
if (hide) {
gtk_widget_hide( GTK_WIDGET(tree) );
gtk_widget_hide( GTK_WIDGET(show_button) );
}
}
@@ -937,7 +948,7 @@ gnc_xfer_dialog_lock_account_tree(XferDialog *xferData,
void
gnc_xfer_dialog_lock_from_account_tree(XferDialog *xferData)
{
gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_FROM);
gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_FROM, FALSE);
}
@@ -951,10 +962,61 @@ gnc_xfer_dialog_lock_from_account_tree(XferDialog *xferData)
void
gnc_xfer_dialog_lock_to_account_tree(XferDialog *xferData)
{
gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_TO);
gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_TO, FALSE);
}
/********************************************************************\
* gnc_xfer_dialog_hide_from_account_tree *
* prevent changes to the from account tree in an xfer dialog *
* *
* Args: xferData - xfer dialog structure *
* Return: none *
\********************************************************************/
void
gnc_xfer_dialog_hide_from_account_tree(XferDialog *xferData)
{
gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_FROM, TRUE);
}
/********************************************************************\
* gnc_xfer_dialog_hide_to_account_tree *
* prevent changes to the to account tree in an xfer dialog *
* *
* Args: xferData - xfer dialog structure *
* Return: none *
\********************************************************************/
void
gnc_xfer_dialog_hide_to_account_tree(XferDialog *xferData)
{
gnc_xfer_dialog_lock_account_tree(xferData, XFER_DIALOG_TO, TRUE);
}
/********************************************************************\
* gnc_xfer_dialog_is_exchange_dialog *
* set the dialog as an "exchange-dialog", which means that the *
* Transfer Information frame is read-only (and the dialog *
* will NOT create a transaction when it is closed) *
* *
* Args: xferData - xfer dialog structure *
* Return: none *
\********************************************************************/
void
gnc_xfer_dialog_is_exchange_dialog (XferDialog *xferData, gnc_numeric *to_amount)
{
if (!xferData) return;
gtk_widget_set_sensitive (xferData->amount_edit, FALSE);
gtk_widget_set_sensitive (xferData->date_entry, FALSE);
gtk_widget_set_sensitive (xferData->num_entry, FALSE);
gtk_widget_set_sensitive (xferData->description_entry, FALSE);
gtk_widget_set_sensitive (xferData->memo_entry, FALSE);
xferData->to_amount = to_amount;
}
/********************************************************************\
* gnc_xfer_dialog_set_amount *
* set the amount in the given xfer dialog *
@@ -1015,6 +1077,24 @@ gnc_xfer_dialog_set_memo(XferDialog *xferData, const char *memo)
/* gnc_quickfill_insert( xferData->qf, memo, QUICKFILL_LIFO ); */
}
/********************************************************************\
* gnc_xfer_dialog_set_num *
* set the num in the given xfer dialog *
* *
* Args: xferData - xfer dialog structure *
* num - the num to set *
* Return: none *
\********************************************************************/
void
gnc_xfer_dialog_set_num(XferDialog *xferData, const char *num)
{
if (xferData == NULL)
return;
gtk_entry_set_text(GTK_ENTRY(xferData->num_entry), num);
/* gnc_quickfill_insert( xferData->qf, num, QUICKFILL_LIFO ); */
}
/********************************************************************\
* gnc_xfer_dialog_set_date *
* set the date in the given xfer dialog *
@@ -1141,47 +1221,54 @@ gnc_xfer_dialog_ok_cb(GtkWidget * widget, gpointer data)
gnc_suspend_gui_refresh ();
/* Create the transaction */
trans = xaccMallocTransaction(gnc_get_current_book ());
if (xferData->to_amount)
{
*(xferData->to_amount) = to_amount;
}
else
{
/* Create the transaction */
trans = xaccMallocTransaction(gnc_get_current_book ());
xaccTransBeginEdit(trans);
xaccTransBeginEdit(trans);
xaccTransSetCurrency(trans, from_commodity);
xaccTransSetDateSecs(trans, time);
xaccTransSetCurrency(trans, from_commodity);
xaccTransSetDateSecs(trans, time);
string = gtk_entry_get_text(GTK_ENTRY(xferData->num_entry));
xaccTransSetNum(trans, string);
string = gtk_entry_get_text(GTK_ENTRY(xferData->num_entry));
xaccTransSetNum(trans, string);
string = gtk_entry_get_text(GTK_ENTRY(xferData->description_entry));
xaccTransSetDescription(trans, string);
string = gtk_entry_get_text(GTK_ENTRY(xferData->description_entry));
xaccTransSetDescription(trans, string);
/* create from split */
from_split = xaccMallocSplit(gnc_get_current_book ());
xaccTransAppendSplit(trans, from_split);
/* create from split */
from_split = xaccMallocSplit(gnc_get_current_book ());
xaccTransAppendSplit(trans, from_split);
/* create to split */
to_split = xaccMallocSplit(gnc_get_current_book ());
xaccTransAppendSplit(trans, to_split);
/* create to split */
to_split = xaccMallocSplit(gnc_get_current_book ());
xaccTransAppendSplit(trans, to_split);
xaccAccountBeginEdit(from_account);
xaccAccountInsertSplit(from_account, from_split);
xaccAccountBeginEdit(from_account);
xaccAccountInsertSplit(from_account, from_split);
xaccAccountBeginEdit(to_account);
xaccAccountInsertSplit(to_account, to_split);
xaccAccountBeginEdit(to_account);
xaccAccountInsertSplit(to_account, to_split);
xaccSplitSetBaseValue(from_split, gnc_numeric_neg (amount), from_commodity);
xaccSplitSetBaseValue(to_split, amount, from_commodity);
xaccSplitSetBaseValue(to_split, to_amount, to_commodity);
xaccSplitSetBaseValue(from_split, gnc_numeric_neg (amount), from_commodity);
xaccSplitSetBaseValue(to_split, amount, from_commodity);
xaccSplitSetBaseValue(to_split, to_amount, to_commodity);
/* Set the memo fields */
string = gtk_entry_get_text(GTK_ENTRY(xferData->memo_entry));
xaccSplitSetMemo(from_split, string);
xaccSplitSetMemo(to_split, string);
/* Set the memo fields */
string = gtk_entry_get_text(GTK_ENTRY(xferData->memo_entry));
xaccSplitSetMemo(from_split, string);
xaccSplitSetMemo(to_split, string);
/* finish transaction */
xaccTransCommitEdit(trans);
xaccAccountCommitEdit(from_account);
xaccAccountCommitEdit(to_account);
/* finish transaction */
xaccTransCommitEdit(trans);
xaccAccountCommitEdit(from_account);
xaccAccountCommitEdit(to_account);
}
/* XXX: Maybe save this exchange to the pricedb */

View File

@@ -69,11 +69,14 @@ void gnc_xfer_dialog_select_to_account(XferDialog *xferData,
/* prevent the user from changing an account tree */
void gnc_xfer_dialog_lock_from_account_tree(XferDialog *xferData );
void gnc_xfer_dialog_lock_to_account_tree(XferDialog *xferData );
void gnc_xfer_dialog_hide_from_account_tree(XferDialog *xferData );
void gnc_xfer_dialog_hide_to_account_tree(XferDialog *xferData );
void gnc_xfer_dialog_set_amount(XferDialog *xferData, gnc_numeric amount);
void gnc_xfer_dialog_set_description(XferDialog *xferData,
const char *description);
void gnc_xfer_dialog_set_memo(XferDialog *xferData, const char *memo);
void gnc_xfer_dialog_set_num(XferDialog *xferData, const char *num);
void gnc_xfer_dialog_set_date(XferDialog *xferData, time_t set_time);
/* Indicate whether the dialog should quickfill based on the "To" account,
@@ -82,4 +85,13 @@ void gnc_xfer_dialog_set_date(XferDialog *xferData, time_t set_time);
void gnc_xfer_dialog_quickfill_to_account(XferDialog *xferData,
gboolean qf_to_account );
/* Indicate that this is just trying to obtain the to_amount, so make
* the Transfer Information read-only and the dialog will NOT create a
* new transaction. Pass in the location to store the resulting
* to_amount when the dialog is complete. The caller should call the
* dialog 'run' function to make sure to_amount pointer remains valid.
*/
void gnc_xfer_dialog_is_exchange_dialog(XferDialog *xferData,
gnc_numeric * to_amount);
#endif

View File

@@ -15,7 +15,7 @@
<widget>
<class>GnomeDialog</class>
<name>Exchange Dialog</name>
<type>GTK_WINDOW_TOPLEVEL</type>
<type>GTK_WINDOW_POPUP</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>

View File

@@ -36,7 +36,6 @@ libgncgnome_la_SOURCES = \
dialog-sxsincelast.c \
dialog-tax-info.c \
dialog-totd.c \
dialog-transfer.c \
dialog-userpass.c \
dialog-scheduledxaction.c \
druid-hierarchy.c \
@@ -74,7 +73,6 @@ noinst_HEADERS = \
dialog-sx-from-trans.h \
dialog-sxsincelast.h \
dialog-totd.h \
dialog-transfer.h \
dialog-scheduledxaction.h \
druid-hierarchy.h \
druid-loan.h \

View File

@@ -11,7 +11,6 @@ glade_DATA = \
register.glade \
stocks.glade \
tax.glade \
transfer.glade \
userpass.glade \
sched-xact.glade

View File

@@ -12,7 +12,6 @@ libgncmod_register_core_la_LIBADD = \
libgncmod_register_core_la_SOURCES = \
gncmod-register-core.c \
QuickFill.c \
basiccell.c \
cell-factory.c \
cellblock.c \
@@ -31,7 +30,6 @@ libgncmod_register_core_la_SOURCES = \
gncincludedir = ${GNC_INCLUDE_DIR}
gncinclude_HEADERS = \
QuickFill.h \
basiccell.h \
cell-factory.h \
cellblock.h \